Example #1
0
 function getRecordEvent($eventname)
 {
     $entry = new Entry($eventname, $this->name);
     return $entry->recordString();
 }
Example #2
0
function print_ratingsHistory($format)
{
    global $player;
    $db = Database::getConnection();
    $stmt = $db->prepare("SELECT e.name, r.rating, n.medal, n.deck AS id\n    FROM events e, entries n, ratings r\n    WHERE r.format= ? AND r.player = ?\n    AND e.start=r.updated AND n.player=r.player AND n.event=e.name\n    ORDER BY e.start DESC");
    $stmt->bind_param("ss", $format, $player->name);
    $stmt->execute();
    $stmt->bind_result($eventname, $rating, $medal, $deckid);
    $stmt->store_result();
    echo "<table style=\"border-width: 0px;\" align=\"center\">\n";
    echo "<tr><td align=\"center\"><b>Pre-Event</td>\n";
    echo "<td><b>Event</td>\n";
    echo "<td><b>Deck</td>\n";
    echo "<td align=\"center\"><b>Record</td>\n";
    echo "<td align=\"center\"><b>Medal</td>\n";
    echo "<td align=\"center\"><b>Post-Event</td></tr>\n";
    if ($stmt->num_rows > 0) {
        $stmt->fetch();
        $preveventname = $eventname;
        $prevrating = $rating;
        while ($stmt->fetch()) {
            $entry = new Entry($preveventname, $player->name);
            $wl = $entry->recordString();
            $img = medalImgStr($entry->medal);
            echo "<tr><td align=\"center\">{$rating}</td>\n";
            echo "<td>{$preveventname}</td>\n";
            echo "<td>" . $entry->deck->linkTo() . "</td>\n";
            echo "<td align=\"center\">{$wl}</td>\n";
            echo "<td align=\"center\">{$img}</td>";
            echo "<td align=\"center\">{$prevrating}</td></tr>";
            $prevrating = $rating;
            $preveventname = $eventname;
        }
        $entry = new Entry($preveventname, $player->name);
        $wl = $entry->recordString();
        $img = medalImgStr($entry->medal);
        echo "<tr><td align=\"center\">1600</td>\n";
        echo "<td>{$preveventname}</td>\n";
        echo "<td>" . $entry->deck->linkTo() . "</td>\n";
        echo "<td align=\"center\">{$wl}</td>\n";
        echo "<td align=\"center\">{$img}</td>";
        echo "<td align=\"center\">{$prevrating}</td></tr>";
    } else {
        echo "<tr><td colspan=6 align=\"center\"><i>";
        echo "You have not played any {$format} events.</td></tr>\n";
    }
    echo "</table>\n";
}
Example #3
0
function fullmetagame($event)
{
    $decks = $event->getDecks();
    $players = array();
    foreach ($decks as $deck) {
        $info = array("player" => $deck->playername, "deckname" => $deck->name, "archetype" => $deck->archetype, "medal" => $deck->medal, "id" => $deck->id);
        $arr = deckInfo($deck);
        $info["colors"] = $arr[1];
        if ($info['medal'] == "dot") {
            $info['medal'] = "z";
        }
        $players[] = $info;
    }
    $db = Database::getConnection();
    $succ = $db->query("CREATE TEMPORARY TABLE meta(\n    player VARCHAR(40), deckname VARCHAR(40), archetype VARCHAR(20),\n    colors VARCHAR(10), medal VARCHAR(10), id BIGINT UNSIGNED,\n    srtordr TINYINT UNSIGNED DEFAULT 0)");
    $succ or die($db->error);
    $stmt = $db->prepare("INSERT INTO meta(player, deckname, archetype,  colors, medal, id)\n    VALUES(?, ?, ?, ?, ?, ?)");
    foreach ($players as $player) {
        $stmt->bind_param("sssssd", $player['player'], $player['deckname'], $player['archetype'], $player['colors'], $player['medal'], $player['id']);
        $stmt->execute() or die($stmt->error);
    }
    $stmt->close();
    $result = $db->query("SELECT colors, COUNT(player) AS cnt FROM meta GROUP BY(colors)");
    $stmt = $db->prepare("UPDATE meta SET srtordr = ? WHERE colors = ?");
    while ($row = $result->fetch_assoc()) {
        $stmt->bind_param("ds", $row['cnt'], $row['colors']);
        $stmt->execute() or die($stmt->error);
    }
    $stmt->close();
    $result->close();
    $result = $db->query("SELECT player, deckname, archetype, colors, medal, id, srtordr\n    FROM meta ORDER BY srtordr DESC, colors, medal, player");
    $color = "orange";
    echo "<table style=\"border-width: 0px;\" align=\"center\">";
    echo "<tr>";
    echo "<td colspan=5 align=\"center\"><b>Metagame Breakdown</td></tr>\n";
    while ($row = $result->fetch_assoc()) {
        if ($row['colors'] != $color) {
            $color = $row['colors'];
            echo "<tr><td>";
            echo image_tag("colors/{$color}.png") . "&nbsp;</td>\n";
            echo "<td colspan=4 align=\"left\"><i>{$row['srtordr']} Players ";
            echo "</td></tr>\n";
        }
        echo "<tr><td></td>\n";
        echo "<td align=\"left\">";
        echo "</td>\n<td align=\"left\">";
        if ($event->finalized == '0') {
            echo "Player is anonymous for deck privacy until event is finalized.";
        } else {
            // puts medal next to name of person who won it
            if ($row['medal'] != "z") {
                echo medalImgStr($row['medal']) . "&nbsp;";
            }
            $play = new Player($row['player']);
            $entry = new Entry($event->name, $play->name);
            echo $play->linkTo() . "</td>\n";
            echo "<td align=\\left\">{$entry->recordString()}</td>";
            echo "<td align=\"left\">";
            echo "<a href=\"deck.php?mode=view&id={$row['id']}\">";
            echo "{$row['deckname']}</a></td>\n";
            echo "<td align=\"right\">{$row['archetype']}</td></tr>\n";
        }
    }
    $result->close();
    echo "</table>\n";
}