示例#1
0
文件: gai.php 项目: hdp/brass
function DoTask()
{
    global $GAME, $PlayersVotingToKick;
    if ($GAME['GameStatus'] != 'Recruiting Replacement') {
        $mypage = page::standard();
        $mypage->title_body('Cannot vote to downsize this game');
        $mypage->leaf('p', 'This game is not currently seeking a replacement player, so you cannot vote to downsize it. (Perhaps something happened after you loaded the board 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 ($GAME['CurrentPlayers'] == 3) {
        $mypage = page::standard();
        $mypage->title_body('Cannot downsize a 3-player game');
        $mypage->leaf('p', 'At present, it is not permitted for a 3-player game to be downsized. 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['CurrentPlayers'] == $GAME['MinimumPlayersAllowed'] and $GAME['MinimumPlayersAllowed'] > 2) {
        $mypage = page::standard();
        $mypage->title_body('Cannot downsize from this number of players');
        $mypage->leaf('p', 'This game cannot be downsized, as the game board in use does not support fewer than ' . $GAME['MinimumPlayersAllowed'] . ' players. 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 downsize 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 (@$_POST['DSVote'] == 'Yes') {
        if ($GAME['PlayersVotingToKick'] - $GAME['IHaveKickVoted'] + 1 >= $GAME['CurrentPlayers']) {
            require HIDDEN_FILES_PATH . 'downsizeresource.php';
            downsizegame(false);
            $didsomething = 1;
            while ($didsomething) {
                $didsomething = gamecheck();
            }
            dbformatgamedata();
            page::redirect(3, 'board.php?GameID=' . $GAME['GameID'], 'Successfully voted and downsized game.');
        }
        $GAME['KickVote'][$GAME['MyColour']] = 1;
        dbformatgamedata();
        if (!$GAME['KickVoteActive']) {
            for ($i = 0; $i < MAX_PLAYERS; $i++) {
                if ($GAME['PlayerExists'][$i] == 1 and !$GAME['PlayerMissing'][$i] and !$GAME['PlayersVotingToKick'] and $i != $GAME['MyColour'] and $GAME['EmailPrompt'][$i] and $GAME['Email'][$i] != '') {
                    $subject = 'There is a vote to downsize 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 downsize the game instead of recruiting a replacement player. In order for the game to be downsized, all of the players must agree; this means that a unanimous vote is required. If you would like the game to be downsized, then please visit the game\'s page and vote in favour of downsizing. If you do not want the game to be downsized, then no action is required other than to accept a replacement if one asks to join. (You will be emailed if this happens. Bear in mind that if a replacement is not found before the Time Limit B for this game is exceeded, then the game will be downsized anyway.) 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.');
    }
    $GAME['KickVote'][$GAME['MyColour']] = 0;
    dbformatgamedata();
    page::redirect(3, 'board.php?GameID=' . $GAME['GameID'], 'Successfully voted.');
}
示例#2
0
文件: mt.php 项目: hdp/brass
 } else {
     if ($GAME['DoWhatAtB'] == 'Downsize') {
         downsizegame(true);
     } else {
         if ($GAME['DoWhatAtB'] == 'Abort') {
             if ($GAME['GameStatus'] == 'In Progress') {
                 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;
示例#3
0
文件: kraftwerk.php 项目: hdp/brass
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;
}