Exemple #1
0
/** This function removes all biddings of players who own MaxCaves
 *  Exits the script in case of an error.
 *
 */
function takeover_remove_maxed_players()
{
    global $db;
    // get players with maxcaves
    $sql = $db->prepare("SELECT t.playerID, p.name, p.takeover_max_caves\n                       FROM " . CAVE_TAKEOVER_TABLE . " t\n                         LEFT JOIN " . PLAYER_TABLE . " p ON t.playerID = p.playerID\n                         LEFT JOIN " . CAVE_TABLE . " c ON t.playerID = c.playerID\n                       GROUP BY t.playerID\n                       HAVING COUNT(c.caveID) >= p.takeover_max_caves");
    if (!$sql->execute()) {
        exit(1);
    }
    while ($row = $sql->fetch(PDO::FETCH_ASSOC)) {
        // remove the bidding
        takeover_remove_bidding_by_playerID($row['playerID']);
        // send a message
        takeover_send_max_caves($row['playerID'], $row['takeover_max_caves']);
    }
}
Exemple #2
0
/** This function removes all biddings of players who own MaxCaves
 *  Exits the script in case of an error.
 *
 */
function takeover_remove_maxed_players()
{
    global $db;
    // get players with maxcaves
    $query = "SELECT t.playerID, p.name, p.takeover_max_caves " . "FROM Cave_takeover t " . "LEFT JOIN Player p ON t.playerID = p.playerID " . "LEFT JOIN Cave c ON t.playerID = c.playerID " . "GROUP BY t.playerID " . "HAVING COUNT(c.caveID) >= p.takeover_max_caves";
    $db_max_caves = $db->query($query);
    if (!$db_max_caves) {
        echo "ERROR (check_max_caves): {$query} " . mysql_error();
        exit(1);
    }
    while ($row = $db_max_caves->nextrow()) {
        // remove the bidding
        takeover_remove_bidding_by_playerID($row['playerID']);
        // send a message
        takeover_send_max_caves($row['playerID'], $row['takeover_max_caves']);
    }
}