Example #1
0
File: gac.php Project: hdp/brass
function DoTask()
{
    global $Administrator, $GAME;
    if (!$Administrator) {
        $mypage = page::standard();
        $mypage->title_body('Not authorised');
        $mypage->leaf('p', 'You are not authorised to make use of this page. Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.');
        $mypage->finish();
    }
    if (!@$_POST['CheckD']) {
        $mypage = page::standard();
        $mypage->title_body('Tick box left unticked');
        $mypage->leaf('p', 'The tick box was left unticked. You need to make sure the box is ticked - this is to prevent accidental use of the administrator controls. Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.');
        $mypage->finish();
    }
    if ($GAME['GameStatus'] != 'In Progress' and $GAME['GameStatus'] != 'Recruiting Replacement') {
        $mypage = page::standard();
        $mypage->title_body('Cannot abort game');
        $mypage->leaf('p', 'This game cannot be aborted just now, perhaps because it has finished. Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.');
        $mypage->finish();
    }
    abortgame(1);
    dbformatgamedata();
    page::redirect(3, 'board.php?GameID=' . $GAME['GameID'], 'Successfully aborted game.');
}
Example #2
0
File: gan.php Project: hdp/brass
function DoTask()
{
    global $GAME;
    if ($GAME['GameStatus'] != 'In Progress' and $GAME['GameStatus'] != 'Recruiting Replacement') {
        $mypage = page::standard();
        $mypage->title_body('Cannot quit game');
        $mypage->leaf('p', 'You cannot presently quit this game, perhaps because it has finished. Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.');
        $mypage->finish();
    }
    if ($GAME['MyColour'] == 50) {
        $mypage = page::standard();
        $mypage->title_body('Not playing in this game');
        $mypage->leaf('p', 'You are not currently playing in this game. You might be seeing this message because you clicked the button twice. Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.');
        $mypage->finish();
    }
    if (!@$_POST['CheckA'] or !@$_POST['CheckB']) {
        $mypage = page::standard();
        $mypage->title_body('Tick boxes left unticked');
        $mypage->leaf('p', 'One or both tick boxes were left unticked. You need to make sure both boxes are ticked - this is to prevent accidental use of the "quit" function. Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.');
        $mypage->finish();
    }
    if ($GAME['PlayersMissing'] + 1 == $GAME['CurrentPlayers']) {
        abortgame(0);
        dbformatgamedata();
        $mypage = page::standard();
        $mypage->title_body('Game aborted instead');
        $mypage->leaf('p', 'Since you were the only player left in the game, the game has instead been aborted. Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.');
        $mypage->finish();
    }
    KickPlayer($GAME['MyColour'], 0);
    dbformatgamedata();
    page::redirect(3, 'board.php?GameID=' . $GAME['GameID'], 'Successfully quit game.');
}
Example #3
0
File: gae.php Project: hdp/brass
function DoTask()
{
    global $GAME, $unexpectederrormessage;
    if ($GAME['GameStatus'] != 'In Progress' and $GAME['GameStatus'] != 'Recruiting Replacement') {
        $mypage = page::standard();
        $mypage->title_body('Cannot abort this game');
        $mypage->leaf('p', 'This game cannot be aborted just now, perhaps because it has finished. Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.');
        $mypage->finish();
    }
    if ($GAME['MyColour'] == 50) {
        $mypage = page::standard();
        $mypage->title_body('Not playing in this game');
        $mypage->leaf('p', 'You are not currently playing in this game, so you cannot vote to abort it. Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.');
        $mypage->finish();
    }
    if ($GAME['AbortVoteActive']) {
        myerror($unexpectederrormessage, 'Unexpected vote page "gae.php" reached');
    }
    if ($GAME['CurrentPlayers'] - $GAME['PlayersMissing'] == 1) {
        abortgame(0);
        dbformatgamedata();
        page::redirect(3, 'board.php?GameID=' . $GAME['GameID'], 'Successfully voted and aborted game.');
    }
    $GAME['AbortVote'][$GAME['MyColour']] = 1;
    dbformatgamedata();
    for ($i = 0; $i < MAX_PLAYERS; $i++) {
        if ($GAME['PlayerExists'][$i] == 1 and !$GAME['PlayerMissing'][$i] and $i != $GAME['MyColour'] and $GAME['EmailPrompt'][$i] and $GAME['Email'][$i] != '') {
            $subject = 'There is a vote to abort game number ' . $GAME['GameID'];
            $body = '<p>This is an automated message. One of your fellow players in game number ' . $GAME['GameID'] . ' has initiated a vote to abort the game. In order for the game to be aborted, all of the players must agree; this means that a unanimous vote is required. Please visit the game\'s page and either vote in favour of aborting it, or shut the vote down by voting not to abort. Here is the URL of the game page:</p><p><a href="' . SITE_ADDRESS . 'board.php?GameID=' . $GAME['GameID'] . '">' . SITE_ADDRESS . 'board.php?GameID=' . $GAME['GameID'] . '</a></p>' . EMAIL_FOOTER;
            send_email($subject, $body, $GAME['Email'][$i], null);
        }
    }
    page::redirect(3, 'board.php?GameID=' . $GAME['GameID'], 'Successfully voted.');
}
Example #4
0
File: gaf.php Project: hdp/brass
function DoTask()
{
    global $GAME;
    if ($GAME['GameStatus'] != 'In Progress' and $GAME['GameStatus'] != 'Recruiting Replacement') {
        $mypage = page::standard();
        $mypage->title_body('Cannot abort this game');
        $mypage->leaf('p', 'This game cannot be aborted just now, perhaps because it has finished. Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.');
        $mypage->finish();
    }
    if ($GAME['MyColour'] == 50) {
        $mypage = page::standard();
        $mypage->title_body('Not playing in this game');
        $mypage->leaf('p', 'You are not currently playing in this game, so you cannot vote to abort it. Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.');
        $mypage->finish();
    }
    if (!$GAME['AbortVoteActive']) {
        $mypage = page::standard();
        $mypage->title_body('No vote is taking place');
        $mypage->leaf('p', 'At present, no vote on aborting the game is taking place. Perhaps somebody voted against aborting the game in the meantime. Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.');
        $mypage->finish();
    }
    if (@$_POST['votevalue']) {
        if ($GAME['PlayersVotingToAbort'] - $GAME['IHaveAbortVoted'] + 1 >= $GAME['CurrentPlayers']) {
            abortgame(0);
            dbformatgamedata();
            page::redirect(3, 'board.php?GameID=' . $GAME['GameID'], 'Successfully voted and aborted game.');
        }
        $GAME['AbortVote'][$GAME['MyColour']] = 1;
        dbformatgamedata();
        page::redirect(3, 'board.php?GameID=' . $GAME['GameID'], 'Successfully voted.');
    }
    $GAME['AbortVote'] = '00000';
    dbformatgamedata();
    for ($i = 0; $i < MAX_PLAYERS; $i++) {
        if ($GAME['PlayerExists'][$i] == 1 and !$GAME['PlayerMissing'][$i] and $i != $GAME['MyColour'] and $GAME['EmailPrompt'][$i] and $GAME['Email'][$i] != '') {
            $subject = 'The vote to abort game number ' . $GAME['GameID'] . ' has failed';
            $body = '<p>This is an automated message. One of your fellow players in game number ' . $GAME['GameID'] . ' has voted against aborting the game. In order for the game to be aborted, all of the players must agree; this means that a unanimous vote is required. So, the game will not be aborted at this time. Here is the URL of the game page:</p><p><a href="' . SITE_ADDRESS . 'board.php?GameID=' . $GAME['GameID'] . '">' . SITE_ADDRESS . 'board.php?GameID=' . $GAME['GameID'] . '</a></p>' . EMAIL_FOOTER;
            send_email($subject, $body, $GAME['Email'][$i], null);
        }
    }
    page::redirect(3, 'board.php?GameID=' . $GAME['GameID'], 'Successfully voted.');
}
Example #5
0
File: mt.php Project: hdp/brass
                     if (!KickPlayer($GAME['PlayerToMove'], 3)) {
                         abortgame(2);
                     }
                 } else {
                     abortgame(2);
                 }
             } else {
                 if ($GAME['DoWhatAtB'] == 'Kick current player; subsequently downsize') {
                     if ($GAME['GameStatus'] == 'Recruiting Replacement') {
                         downsizegame(true);
                     } else {
                         KickPlayer($GAME['PlayerToMove'], 3);
                     }
                 } else {
                     if ($GAME['GameStatus'] == 'Recruiting Replacement') {
                         abortgame(2);
                     } else {
                         KickPlayer($GAME['PlayerToMove'], 3);
                     }
                 }
             }
         }
     }
     $GAME['MoveMade'] = 1;
     $didsomething = 1;
     while ($didsomething) {
         $didsomething = gamecheck();
     }
     dbformatgamedata();
 }
 $OutputLines[] = 'Games timed out: ' . count($gamestimedout) . ', namely ' . implode(', ', $gamestimedout);
Example #6
0
function gamecheck()
{
    global $GAME, $PersonActing;
    if ($GAME['GameStatus'] == 'In Progress') {
        if ($GAME['PlayerMissing'][$GAME['PlayerToMove']]) {
            $GAME['GameStatus'] = 'Recruiting Replacement';
            if ($GAME['NumDepartures'] > PERMITTED_DEPARTURES) {
                if ($GAME['CurrentPlayers'] - $GAME['PlayersMissingThatMatter'] == $GAME['MinimumPlayersAllowed'] and $GAME['MinimumPlayersAllowed'] > 2 or $GAME['CurrentPlayers'] == 3) {
                    if ($GAME['DoWhatAtB'] == 'Downsize') {
                        $GAME['DoWhatAtB'] = 'Abort';
                    }
                    if ($GAME['DoWhatAtB'] == 'Kick current player; subsequently downsize') {
                        $GAME['DoWhatAtB'] = 'Kick current player; subsequently abort';
                    }
                }
                switch ($GAME['DoWhatAtB']) {
                    case 'Downsize':
                    case 'Kick current player; subsequently downsize':
                        require_once HIDDEN_FILES_PATH . 'downsizeresource.php';
                        downsizegame(true);
                        return true;
                        break;
                    default:
                        abortgame(2);
                }
            } else {
                if (in_array($GAME['PlayerToMove'], $GAME['ReplacementOffers_Colours'])) {
                    $QR = dbquery(DBQUERY_READ_RESULTSET, 'SELECT "User"."UserID", "User"."Name", "User"."Pronoun" FROM "ReplacementOffer" JOIN "User" ON "ReplacementOffer"."User" = "User"."UserID" WHERE "ReplacementOffer"."Game" = :game: AND "ReplacementOffer"."Colour" = :colour:', 'game', $GAME['GameID'], 'colour', $GAME['PlayerToMove']);
                    while ($row = db_fetch_assoc($QR)) {
                        switch ($row['Pronoun']) {
                            case 'He':
                                $RepPronoun = 'A';
                                break;
                            case 'She':
                                $RepPronoun = 'B';
                                break;
                            default:
                                $RepPronoun = 'C';
                                break;
                        }
                        $GAME['AltGameTicker'] .= '8A' . callmovetimediff() . letter_end_number($row['UserID']) . $RepPronoun;
                        $GAME['GameTickerNames'] .= '|' . $row['Name'];
                    }
                    for ($i = 0; $i < MAX_PLAYERS; $i++) {
                        if ($GAME['PlayerExists'][$i] and !$GAME['PlayerMissing'][$i] and $GAME['Email'][$i] != '' and $GAME['EmailPrompt'][$i]) {
                            $subject = 'Replacement players available';
                            $body = '<p>This is an automated message. One or more users have volunteered to step in as a replacement in game number ' . $GAME['GameID'] . '. Please visit the game page to review the volunteers, and to accept one if you are satisfied of his suitability. Here is the URL to the game page:</p><p><a href="' . SITE_ADDRESS . 'board.php?GameID=' . $GAME['GameID'] . '">' . SITE_ADDRESS . 'board.php?GameID=' . $GAME['GameID'] . '</a></p>' . EMAIL_FOOTER;
                            send_email($subject, $body, $GAME['Email'][$i], null);
                            dbquery(DBQUERY_WRITE, 'UPDATE "User" SET "HasBeenEmailed" = 1 WHERE "UserID" = :user:'******'user', $GAME['PlayerUserID'][$i]);
                        }
                    }
                }
            }
        } else {
            if ($GAME['PlayerExists'][$GAME['PlayerToMove']] and !$GAME['PlayerMissing'][$GAME['PlayerToMove']] and $GAME['Email'][$GAME['PlayerToMove']] != '' and $GAME['EmailPrompt'][$GAME['PlayerToMove']] and ($GAME['EmailPromptAgain'][$GAME['PlayerToMove']] or !$GAME['HasBeenEmailed'][$GAME['PlayerToMove']]) and $PersonActing != $GAME['PlayerUserID'][$GAME['PlayerToMove']]) {
                $subject = 'It\'s your turn to make a move';
                $body = '<p>This is an automated message. It\'s your turn to make a move in game number ' . $GAME['GameID'] . '. Here is the URL to the game page:</p><p><a href="' . SITE_ADDRESS . 'board.php?GameID=' . $GAME['GameID'] . '">' . SITE_ADDRESS . 'board.php?GameID=' . $GAME['GameID'] . '</a></p>' . EMAIL_FOOTER;
                send_email($subject, $body, $GAME['Email'][$GAME['PlayerToMove']], null);
                dbquery(DBQUERY_WRITE, 'UPDATE "User" SET "HasBeenEmailed" = 1 WHERE "UserID" = :user:'******'user', $GAME['PlayerUserID'][$GAME['PlayerToMove']]);
            }
        }
    }
    return false;
}