예제 #1
0
파일: match.php 프로젝트: Utley/warden
function getMatchDetails($matchID)
{
    global $apiKey;
    $heroesArray = getHeroesArray();
    $itemsArray = getItemsArray();
    $match = getMatchObject($matchID);
    $players = $match->players;
    $matchString = getMatchString($match->game_mode);
    echo "<h1>{$matchID} ({$matchString})</h1>";
    echo "<h2>Began on " . date("l, F jS G:i:s", $match->start_time) . "</h2>";
    echo "<table class='table table-striped'>";
    echo "<tr>";
    echo "<th></th>";
    echo "<th>LH</th>";
    echo "<th>D</th>";
    echo "<th>XPM</th>";
    echo "<th>GPM</th>";
    echo "<th>HD</th>";
    echo "<th>TD</th>";
    echo "<th colspan=6>Items</th>";
    echo "</tr>";
    for ($i = 0; $i < count($players); $i++) {
        $player = $players[$i];
        if ($i < count($players) / 2) {
            echo "<tr class='success'>";
        } else {
            echo "<tr class='danger'>";
        }
        echo "<td>";
        if ($player->hero_id > 0) {
            $smallName = str_replace("npc_dota_hero_", "", $heroesArray[$player->hero_id]);
            echo "<a href='player.php?player={$player->account_id}'>";
            echo "<img src='http://cdn.dota2.com/apps/dota2/images/heroes/{$smallName}" . "_sb.png'/>";
            echo "</a>";
        } else {
            echo '<img src="unknown.png" />';
        }
        echo "</td>";
        echo "<td>{$player->last_hits}</td>";
        echo "<td>{$player->denies}</td>";
        echo "<td>{$player->xp_per_min}</td>";
        echo "<td>{$player->gold_per_min}</td>";
        echo "<td>{$player->hero_damage}</td>";
        echo "<td>{$player->tower_damage}</td>";
        $items = [$player->item_0, $player->item_1, $player->item_2, $player->item_3, $player->item_4, $player->item_5];
        for ($j = 0; $j < count($items); $j++) {
            $item = $itemsArray[$items[$j]];
            $shortName = str_replace("item_", "", $item);
            if (substr_count("item_", $shortName) > -1) {
                echo "<td><img class='item' src='http://cdn.dota2.com/apps/dota2/images/items/" . $shortName . "_lg.png'></td>";
            } else {
                echo "<td><img class='item' src='unknown_item.png' /></td>";
            }
        }
        echo "</tr>";
    }
    echo "</table>";
    echo "<!--" . $response . "-->";
}
예제 #2
0
파일: player.php 프로젝트: Utley/warden
    $ch = curl_init($getMatchesUrl);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
    $matchesResult = curl_exec($ch);
    curl_close($ch);
    $matchesObject = json_decode($matchesResult);
    $matchesObjectArray = $matchesObject->result->matches;
    return $matchesObjectArray;
}
echo "<h1>Player: " . $playerID . "<br>";
$matches = getPlayerHistory($playerID);
$heroObj = [];
foreach ($matches as $match) {
    $players = $match->players;
    foreach ($players as $player) {
        if ($player->account_id + 76561197960265728 == $playerID) {
            $heroObj[$player->hero_id] += 1;
        }
    }
    echo "<a href='match.php?match=" . "{$match->match_id}'>" . $match->match_id . "</a><br>";
}
$heroesArray = getHeroesArray();
foreach ($heroObj as $hero => $counts) {
    echo $heroesArray[$hero] . ": " . $counts;
    echo "<br>";
}
?>
</body>
</html>