function DoTask() { global $Administrator, $Banned, $GAME, $Rating; if ($GAME['GameStatus'] == 'Cancelled' and !$Administrator) { $mypage = page::standard(); $mypage->title_body('Cannot find game'); $mypage->leaf('p', 'Cannot find a game with that game ID number. Please click <a href="index.php">here</a> to return to the Main Page.'); $mypage->finish(); } if ($GAME['GameStatus'] == 'Cancelled') { $GAME['GameName_Page'] .= ' <span style="font-size: 150%; color: #FF0000;">[CANCELLED]</span>'; } $CreationTimeText = date('Y-m-d H:i:s', strtotime($GAME['CreationTime'])); if ($GAME['SpecialRules'] & 1) { $ReverseVCText = 'Yes'; } else { $ReverseVCText = 'No'; } if ($GAME['SpecialRules'] & 2) { $ForbidSCText = 'Yes'; } else { $ForbidSCText = 'No'; } if ($GAME['SpecialRules'] & 4) { $ORAWText = 'Yes'; } else { $ORAWText = 'No'; } if ($GAME['AnyPlayerStarts']) { $APSText = 'Yes'; } else { $APSText = 'No'; } if ($GAME['Friendly']) { $FriendText = 'Friendly'; } else { $FriendText = 'Competitive'; } if ($GAME['AutoStart']) { $AutoStartText = 'Yes'; } else { $AutoStartText = 'No'; } if ($GAME['GPrivate']) { $PrivateText = ' checked'; } else { $PrivateText = ''; } if ($GAME['TimeLimitA_Minutes'] <= 30) { $x = 5; $TimeLimitAAlert = 'class="bigalert"'; } else { if ($GAME['TimeLimitA_Minutes'] <= 90) { $x = 4; $TimeLimitAAlert = 'class="bigalert"'; } else { if ($GAME['TimeLimitA_Minutes'] <= 720) { $x = 3; $TimeLimitAAlert = 'class="alert"'; } else { if ($GAME['TimeLimitA_Minutes'] <= 1080) { $x = 2; $TimeLimitAAlert = 'class="alert"'; } else { if ($GAME['TimeLimitA_Minutes'] <= 1800) { $x = 1; $TimeLimitAAlert = 'style="font-weight: bold;"'; } else { $x = 0; $TimeLimitAAlert = null; } } } } } if ($GAME['TimeLimitB_Minutes'] <= 60) { $y = 5; $TimeLimitBAlert = 'class="bigalert"'; } else { if ($GAME['TimeLimitB_Minutes'] <= 180) { $y = 4; $TimeLimitBAlert = 'class="bigalert"'; } } if ($GAME['TimeLimitB_Minutes'] <= 1440) { $y = 3; $TimeLimitBAlert = 'class="alert"'; } else { if ($GAME['TimeLimitB_Minutes'] <= 2160) { $y = 2; $TimeLimitBAlert = 'class="alert"'; } else { if ($GAME['TimeLimitB_Minutes'] <= 3600) { $y = 1; $TimeLimitBAlert = 'style="font-weight: bold;"'; } else { $y = 0; $TimeLimitBAlert = null; } } } $cbmessageID = max($x, $y); $ShowTimeLimitWarning = true; switch ($cbmessageID) { case 5: $TimeLimitsWarning = 'These time limits indicate that the game\'s creator probably wants to play the game in near-real time. You should only join if you have a good stretch of time to spare and are prepared to play the game in a sitting. Failure to play rapidly when it is your turn may result in your being kicked from the game.'; $TimeLimitsWarningAttributes = 'class="bigalert"'; break; case 4: $TimeLimitsWarning = 'These time limits indicate that the game\'s creator probably wants to play through the game in the space of a day or less. You should only join if you will be able to check back frequently to make your moves until the game is over. Failure to play rapidly when it is your turn may result in your being kicked from the game.'; $TimeLimitsWarningAttributes = 'class="bigalert"'; break; case 3: $TimeLimitsWarning = 'These time limits indicate that the game\'s creator probably wants players to check the game several times a day to make their moves. You should only join if you can make this commitment. Delaying for too long when it is your turn may result in your being kicked from the game.'; $TimeLimitsWarningAttributes = 'class="alert"'; break; case 2: $TimeLimitsWarning = 'These time limits indicate that the game\'s creator probably wants players to check the game at least a couple of times a day to make their moves. You should only join if you can make this commitment. Delaying for too long when it is your turn may result in your being kicked from the game.'; $TimeLimitsWarningAttributes = 'class="alert"'; break; case 1: $TimeLimitsWarning = 'These time limits indicate that the game\'s creator probably wants players to check the game at least once a day to make their moves. You should only join if you can make this commitment. Delaying for too long when it is your turn may result in your being kicked from the game.'; $TimeLimitsWarningAttributes = 'style="font-weight: bold;"'; break; default: $ShowTimeLimitWarning = false; } $mypage = page::standard(); $mypage->script('lobby.js'); $mypage->title_body('Brass - #' . $GAME['GameID'] . ' ' . $GAME['GameName_Title']); $mypage->loginbox(array('Location' => 6, 'GameID' => $GAME['GameID'])); $FormOpen = false; if ($GAME['GameStatus'] != 'Cancelled' and @$_SESSION['LoggedIn'] and !$Banned) { $FormOpen = true; } $mypage->leaf('h3', $GAME['GameName_Page']); if ($FormOpen) { $mypage->opennode('form', 'action="lobby.php" method="POST"'); } $mypage->leaf('p', 'Game details:'); $mypage->opennode('table', 'class="table_no_borders table_extra_horizontal_padding" style="text-align: left;"'); $mypage->opennode('tr'); $mypage->leaf('td', 'Created by:', 'align=right style="min-width: 350px;"'); if ($_SESSION['LoggedIn']) { $mypage->leaf('td', '<a href="userdetails.php?UserID=' . $GAME['GameCreator'] . '">' . $GAME['GameCreatorName'] . '</a>'); } else { $mypage->leaf('td', $GAME['GameCreatorName']); } $mypage->next(); $mypage->leaf('td', 'Creation time:', 'align=right'); $mypage->leaf('td', $CreationTimeText); $mypage->next(); $mypage->leaf('td', 'Friendly or Competitive?', 'align=right'); $mypage->leaf('td', $FriendText); $mypage->next(); $mypage->leaf('td', 'Game version:', 'align=right'); $mypage->leaf('td', $GAME['VersionName'] . ' (' . $GAME['Creators'] . ')'); $mypage->next(); $mypage->leaf('td', 'Can be started by any player?', 'align=right'); $mypage->leaf('td', $APSText); $mypage->next(); $mypage->leaf('td', 'Starts automatically on reaching capacity?', 'align=right'); $mypage->leaf('td', $AutoStartText); $mypage->next(); $mypage->leaf('td', 'Minimum number of players:', 'align=right'); $mypage->leaf('td', $GAME['MinimumPlayers']); $mypage->next(); $mypage->leaf('td', 'Maximum number of players:', 'align=right'); $mypage->leaf('td', $GAME['MaximumPlayers']); $mypage->next(); $mypage->leaf('td', 'Reverse Virtual Connection?', 'align=right'); $mypage->leaf('td', $ReverseVCText); $mypage->next(); $mypage->leaf('td', 'Forbid the Canal Link to Scotland?', 'align=right'); $mypage->leaf('td', $ForbidSCText); $mypage->next(); $mypage->leaf('td', 'Modified Coal Overbuild Rules?', 'align=right'); $mypage->leaf('td', $ORAWText); $mypage->next(); $mypage->leaf('td', 'Initial Turn Order:', 'align=right'); $mypage->leaf('td', $GAME['InitialTurnOrder']); $mypage->next(); $mypage->leaf('td', 'Talk Rules:', 'align=right'); $mypage->leaf('td', $GAME['TalkRules']); $mypage->next(); $mypage->leaf('td', 'Time Limit A:', 'align=right'); $mypage->leaf('td', $GAME['TimeLimitA'] . ' ' . $GAME['TimeLimitAunit'], $TimeLimitAAlert); $mypage->next(); $mypage->leaf('td', 'Time Limit B:', 'align=right'); $mypage->leaf('td', $GAME['TimeLimitB'] . ' ' . $GAME['TimeLimitBunit'], $TimeLimitBAlert); if ($ShowTimeLimitWarning) { $mypage->next(); $mypage->leaf('td', ''); $mypage->leaf('td', $TimeLimitsWarning, $TimeLimitsWarningAttributes); } $mypage->next(); $mypage->leaf('td', 'Behaviour at Time Limit B:', 'align=right'); $mypage->leaf('td', $GAME['DoWhatAtB']); $mypage->next(); $mypage->leaf('td', 'Minimum Player Rating:', 'align=right'); $mypage->leaf('td', $GAME['MinimumRating'] ? $GAME['MinimumRating'] : 'None'); $mypage->next(); $mypage->leaf('td', 'Maximum Player Rating:', 'align=right'); $mypage->leaf('td', is_null($GAME['MaximumRating']) ? 'None' : $GAME['MinimumRating']); if ($_SESSION['LoggedIn'] and ($GAME['MinimumRating'] or !is_null($GAME['MaximumRating']))) { $mypage->next(); $mypage->leaf('td', ''); $mypage->leaf('td', '(Your player rating is ' . $Rating . ')'); } $mypage->next('style="height: 10px;"'); $mypage->leaf('td', ''); $mypage->leaf('td', ' '); if ($GAME['GameCreator'] == @$_SESSION['MyUserID']) { $IAmTheCreator = true; } else { $IAmTheCreator = false; } $EnglishColourNames = array('Red', 'Yellow', 'Green', 'Purple', 'Grey'); $TranslatedColourNames = array(transtext('_colourRed'), transtext('_colourYellow'), transtext('_colourGreen'), transtext('_colourPurple'), transtext('_colourGrey')); $PlayerColours = array('FFC18A', 'FFFFAF', '9FFF9F', 'FFC6FF', 'C4C4C4'); $SlotAvailable = false; for ($i = 0; $i < MAX_PLAYERS; $i++) { $mypage->next(); $mypage->leaf('td', $TranslatedColourNames[$i] . ':', 'align=right style="background-color: #' . $PlayerColours[$i] . ';"'); echo '<td>'; if (!$GAME['PlayerExists'][$i]) { echo ' —'; if ($FormOpen and @$_SESSION['LoggedIn'] and !$Banned and $GAME['MyColour'] == 50 and $GAME['CurrentPlayers'] < $GAME['MaximumPlayers'] and $Rating >= $GAME['MinimumRating'] and (is_null($GAME['MaximumRating']) or $Rating <= $GAME['MaximumRating'])) { $SlotAvailable = true; echo ' <input type="submit" name="FormSubmit" value="Join Game as ' . $EnglishColourNames[$i] . '" onClick="'; if ($ShowTimeLimitWarning) { echo 'ConfirmTimeLimit('; } else { echo 'ChangeActionID('; } echo 20 + $i . ')">'; } } else { if ($GAME['MyColour'] == $i) { echo ' <b>You</b>'; if ($FormOpen and $GAME['CurrentPlayers'] > 1 and !$IAmTheCreator) { echo ' <input type="submit" name="FormSubmit" value="Leave this game" onClick="ChangeActionID(31)">'; } } else { if (@$_SESSION['LoggedIn']) { echo ' <a href="userdetails.php?UserID=' . $GAME['PlayerUserID'][$i] . '">' . $GAME['PlayerName'][$i] . '</a>'; if ($FormOpen and ($Administrator or $IAmTheCreator) and $GAME['CurrentPlayers'] > 1 and $GAME['PlayerUserID'][$i] != $GAME['GameCreator']) { echo ' <input type="submit" name="FormSubmit" value="Remove ' . $EnglishColourNames[$i] . ' from the game" onClick="ChangeActionID(' . (10 + $i) . ')">'; } } else { echo ' ' . $GAME['PlayerName'][$i]; } } } echo '</td>'; } $mypage->closenode(2); // tr, table if ($FormOpen and $SlotAvailable) { $mypage->leaf('p', '<input type="submit" name="FormSubmit" value="Join as Any" onClick="' . ($ShowTimeLimitWarning ? 'ConfirmTimeLimit' : 'ChangeActionID') . '(28);">'); if ($GAME['GPrivate']) { $mypage->opennode('p'); $mypage->text('This game is private. In order to join it, you must first enter the password here (the game password, <i>not</i> your user password):'); $mypage->emptyleaf('input', 'type="text" name="Password" size=20 maxlength=20'); $mypage->closenode(); // p } } if ($FormOpen and $IAmTheCreator) { $mypage->opennode('p'); $mypage->text('As the creator of the game, you may change whether the game is private or not.'); $mypage->text('<br>Game is private?'); $mypage->emptyleaf('input', 'type="checkbox" name="GPrivateBox" value=1' . $PrivateText); $mypage->text('Password:'******'input', 'type="text" name="PasswordB" size=20 maxlength=20 value="' . $GAME['Password'] . '"'); $mypage->emptyleaf('input', 'type="submit" name="FormSubmit" value="Amend" onClick="ChangeActionID(32);"'); $mypage->text('<br>(The "Password" field is ignored if the game is not private. If used, the password should be between 3 and 20 characters. Please note that game passwords are stored merely as plain text, and not in encrypted form like user passwords; they are intended only as a simple barrier to joining the game for people to whom you have not given the password.)'); $mypage->closenode(); // p } if ($FormOpen and ($GAME['CurrentPlayers'] >= $GAME['MinimumPlayersAllowed'] and $Administrator or $GAME['CurrentPlayers'] >= $GAME['MinimumPlayers'] and ($IAmTheCreator or $GAME['AnyPlayerStarts'] and $GAME['MyColour'] != 50))) { $mypage->opennode('p'); $mypage->leaf('a', 'Start the game', 'href="startgame.php?GameID=' . $GAME['GameID'] . '&NumPlayers=' . $GAME['CurrentPlayers'] . '"'); if ($GAME['CurrentPlayers'] < $GAME['MinimumPlayers']) { $mypage->text('<br>(note: it does not have its "minimum number" of players yet)'); } if (!$GAME['AnyPlayerStarts'] and !$IAmTheCreator) { $mypage->text('<br>(note: the game creator does not intend others to start it)'); } $mypage->closenode(); // p } if ($FormOpen and ($Administrator or $IAmTheCreator)) { $mypage->leaf('p', '<input type="submit" name="FormSubmit" value="Cancel this game" onClick="ChangeActionID(30);">'); } if ($FormOpen and $Administrator) { if ($GAME['GTitleDeletedByAdmin']) { $mypage->leaf('p', '<input type="submit" name="FormSubmit" value="Unclear title" onClick="ChangeActionID(34);">'); } else { $mypage->leaf('p', '<input type="submit" name="FormSubmit" value="Clear title" onClick="ChangeActionID(33);">'); } } if ($FormOpen) { $mypage->emptyleaf('input', 'type="hidden" name="GameID" value="' . $GAME['GameID'] . '"'); $mypage->emptyleaf('input', 'type="hidden" name="FormActionID" id="FormActionIDid" value=0'); $mypage->closenode(); // form } require HIDDEN_FILES_PATH . 'displaythread.php'; if ($Administrator) { if ($GAME['Closed'] == 'Forced Closed') { $StringFC = ' selected'; } else { $StringFC = ''; } if ($GAME['Closed'] == 'Closed') { $StringC = ' selected'; } else { $StringC = ''; } if ($GAME['Closed'] == 'Forced Open') { $StringFO = ' selected'; } else { $StringFO = ''; } if ($GAME['Closed'] == 'Open') { $StringO = ' selected'; } else { $StringO = ''; } echo '<form action="threadview.php" method="POST"><p>Thread is <select name="Closedness"><option value="FC"' . $StringFC . '>Forced Closed<option value="C"' . $StringC . '>Closed<option value="FO"' . $StringFO . '>Forced Open<option value="O"' . $StringO . '>Open</select><input type="hidden" name="ThreadSticky" value="0"> --- <input type="submit" name="FormSubmitA" value="Execute"></p><input type="hidden" name="WhichThread" value=' . $GAME['Thread'] . '></form>'; } else { if ($GAME['Closed'] == 'Closed' or $GAME['Closed'] == 'Forced Closed') { $mypage->leaf('h3', 'This game\'s discussion thread has been closed by an Administrator.'); } } displaythread($GAME['Thread'], $GAME['Closed'], 1, $Administrator, $Banned); $mypage->leaf('p', 'Click <a href="index.php">here</a> to return to the Main Page.'); $mypage->finish(); }
function buildtile($wheretobuild, $whattobuild, $coalsource, $ironsource, $card, $doublebuild, $thecardA, $thecardB) { global $GAME, $SystemActing; $errorlist = ''; $TheTechLevel = $GAME['TechLevelArray'][$whattobuild][$GAME['RemainingTiles'][$whattobuild][$GAME['PlayerToMove']]]; $carddetail = $GAME['carddetailarray'][$GAME['Cards'][$GAME['PlayerToMove']][$card]]; if ($coalsource == 50) { $altcoalsource = 99; } else { $altcoalsource = $coalsource; } if ($ironsource == 50) { $altironsource = 99; } else { $altironsource = $ironsource; } if ($TheTechLevel == 9) { $errorlist = transtext('memOutOfTiles') . '<br>'; // "You have run out of industry tiles of the chosen type." } else { if ($GAME['HasBuilt'][$GAME['PlayerToMove']] and !$doublebuild and $GAME['Cards'][$GAME['PlayerToMove']][$card] > $GAME['TopLocationCard'] and !$GAME['HasBuiltInTown'][$GAME['PlayerToMove']][$GAME['spacetowns'][$wheretobuild]] and !$GAME['HasLinkedToTown'][$GAME['PlayerToMove']][$GAME['spacetowns'][$wheretobuild]]) { $CannotBuildHere = true; for ($i = 0; $i < count($GAME['GeneralisedVCs']); $i++) { if ($GAME['spacetowns'][$wheretobuild] == $GAME['GeneralisedVCs'][$i][0] and ($GAME['HasBuiltInTown'][$GAME['PlayerToMove']][$GAME['GeneralisedVCs'][$i][1]] or $GAME['HasLinkedToTown'][$GAME['PlayerToMove']][$GAME['GeneralisedVCs'][$i][1]]) or ($GAME['SpecialRules'] & 1 and $GAME['GeneralisedVCs'][$i][2] or $GAME['GeneralisedVCs'][$i][2] == 2) and $GAME['spacetowns'][$wheretobuild] == $GAME['GeneralisedVCs'][$i][1] and ($GAME['HasBuiltInTown'][$GAME['PlayerToMove']][$GAME['GeneralisedVCs'][$i][0]] or $GAME['HasLinkedToTown'][$GAME['PlayerToMove']][$GAME['GeneralisedVCs'][$i][0]])) { $CannotBuildHere = false; } } if ($CannotBuildHere) { if ($GAME['RailPhase']) { $errorlist .= transtext('memIndyCardBadR') . '<br>'; // "You cannot use an industry card to build in that location, // as you have neither connected to the location nor built a tile there." } else { $errorlist .= transtext('memIndyCardBadC') . '<br>'; // "You cannot use an industry card to build in that location, // as you have not connected to the location." } } } if (!$GAME['SpaceAlwaysExists'][$wheretobuild] and ($GAME['ModularBoardParts'] & $GAME['SpaceExistenceArray'][$wheretobuild]) != $GAME['SpaceExistenceArray'][$wheretobuild]) { $errorlist .= transtext('memSpaceNotThere') . '<br>'; // "That industry space does not exist (or it no longer exists) in this game." } if ($GAME['tileindustries'][$wheretobuild] != $whattobuild and ($whattobuild > 1 or $GAME['tileindustries'][$wheretobuild] != 5) and ($whattobuild and $whattobuild != 3 or $GAME['tileindustries'][$wheretobuild] != 6) and ($whattobuild != 2 and $whattobuild != 3 or $GAME['tileindustries'][$wheretobuild] != 7)) { $errorlist .= transtext('memWrongTileType') . '<br>'; // "The tile that you attempted to build cannot be built in the chosen industry space." } if (!$GAME['RailPhase'] and $GAME['HasBuiltInTown'][$GAME['PlayerToMove']][$GAME['spacetowns'][$wheretobuild]] and $GAME['SpaceStatus'][$wheretobuild] != $GAME['PlayerToMove']) { $errorlist .= transtext('memAlreadyInTown') . '<br>'; // "You have already built an industry tile in that location." } $StrategicBlockAttempt = false; for ($i = 0; $i < count($GAME['GeneralisedNoStratBlock']); $i++) { if ($whattobuild == $GAME['GeneralisedNoStratBlock'][$i][0] and $GAME['SpaceStatus'][$GAME['GeneralisedNoStratBlock'][$i][1]] == 9 and $wheretobuild == $GAME['GeneralisedNoStratBlock'][$i][2]) { $StrategicBlockAttempt = true; } } if ($StrategicBlockAttempt) { $errorlist .= transtext('memTacticalBlock') . '<br>'; } if ($GAME['SpaceStatus'][$wheretobuild] != 9 and $GAME['SpaceTile'][$wheretobuild] != $whattobuild) { $errorlist .= transtext('memOvrSameType') . '<br>'; } if ($GAME['SpaceStatus'][$wheretobuild] != 9 and $GAME['TechLevels'][$wheretobuild] >= $TheTechLevel) { $errorlist .= transtext('memOvrTechLevel') . '<br>'; } if ($GAME['SpaceStatus'][$wheretobuild] == 8 and !$GAME['SpaceTile'][$wheretobuild]) { $errorlist .= transtext('memOvrCM') . '<br>'; // "You can never build over an opponent's Cotton Mill." // (Prevents building over an orphan Cotton Mill.) } if ($GAME['SpaceStatus'][$wheretobuild] != 9 and $GAME['SpaceStatus'][$wheretobuild] != 8 and $GAME['SpaceStatus'][$wheretobuild] != $GAME['PlayerToMove']) { switch ($GAME['SpaceTile'][$wheretobuild]) { case 0: $errorlist .= transtext('memOvrCM') . '<br>'; // "You can never build over an opponent's Cotton Mill." break; case 1: if ($GAME['CurrentPlayers'] > 2 and $GAME['CoalDemand'] < 8 or $GAME['CurrentPlayers'] == 2 and $GAME['CoalDemand'] < 6 or $GAME['CoalInLancs']) { $errorlist .= transtext('memOvrCoalCubes') . '<br>'; // "You cannot currently build over an opponent's Coal Mine: // the cube scarcity condition is not satisfied." } if ($GAME['SpecialRules'] & 4) { for ($i = 0; $i < $GAME['NumIndustrySpaces']; $i++) { if ($GAME['spacetowns'][$i] == $GAME['spacetowns'][$wheretobuild] and ($GAME['tileindustries'][$i] == 1 or $GAME['tileindustries'][$i] == 5) and $GAME['SpaceStatus'][$i] == 9) { $errorlist .= transtext('memOvrCoalMCOR') . '<br>'; // There is a free space in the same location for a Coal Mine. // You cannot build over your opponent's Coal Mine here. break; } } } break; case 2: if ($GAME['CurrentPlayers'] > 2 and $GAME['IronDemand'] < 8 or $GAME['CurrentPlayers'] == 2 and $GAME['IronDemand'] < 6 or $GAME['IronInLancs']) { $errorlist .= transtext('memOvrIronCubes') . '<br>'; // "You cannot currently build over an opponent's Iron Works: // the cube scarcity condition is not satisfied." } break; case 3: $errorlist .= transtext('memOvrPort') . '<br>'; // "You can never build over an opponent's Port." break; default: $errorlist .= transtext('memOvrShipyard') . '<br>'; // "You can never build over an opponent's Shipyard." } } if (!$doublebuild and $GAME['Cards'][$GAME['PlayerToMove']][$card] <= $GAME['TopLocationCard'] and $carddetail != $GAME['spacetowns'][$wheretobuild]) { $errorlist .= transtext('memLocnCardBad') . '<br>'; // "The space where you attempted to build is not in // the location named on the card that you tried to use." } if ($doublebuild and !$GAME['RailPhase'] and $GAME['Round'] == 1) { $errorlist .= transtext('memFirstTurnDbl') . '<br>'; // "You cannot use two cards to build on the first turn of the game." } if ($doublebuild and $GAME['HandSize'][$GAME['PlayerToMove']] % 2 == 1) { $errorlist .= transtext('mem2ndActionDbl') . '<br>'; // "You cannot use two cards to build for your second action of the turn." } if (!$doublebuild and $GAME['Cards'][$GAME['PlayerToMove']][$card] > $GAME['TopLocationCard'] and $carddetail != $whattobuild) { $errorlist .= transtext('memIndyCardType') . '<br>'; // "The tile that you attempted to build does not match // the industry type of the card that you tried to use." } if (!$GAME['RailPhase'] and $whattobuild == 4 and $TheTechLevel == 2) { $errorlist .= transtext('memTech2Shipyard') . '<br>'; // "You cannot build a Tech Level 2 Shipyard during the Canal Phase." } if ($whattobuild == 4 and $TheTechLevel == 0) { $errorlist .= transtext('memTech0Shipyard') . '<br>'; // "You cannot build a Tech Level 0 Shipyard at any time. // These tiles must be developed away before you can build Shipyards." } if ($GAME['RailPhase'] and $TheTechLevel == 1) { $errorlist .= transtext('memTech1Rails') . '<br>'; // You cannot build a Tech Level 1 industry tile during the Rail Phase. } if ($GAME['Money'][$GAME['PlayerToMove']] < $GAME['TileCosts'][$whattobuild][$TheTechLevel - 1]) { $errorlist .= 'You cannot afford to build that industry tile.<br>'; } else { if ($GAME['TileRequireCoal'][$whattobuild][$TheTechLevel - 1] and $coalsource == 50 and $GAME['Money'][$GAME['PlayerToMove']] < $GAME['TileCosts'][$whattobuild][$TheTechLevel - 1] + $GAME['cubeprice'][$GAME['CoalDemand']] or $GAME['TileRequireIron'][$whattobuild][$TheTechLevel - 1] and $ironsource == 50 and $GAME['Money'][$GAME['PlayerToMove']] < $GAME['TileCosts'][$whattobuild][$TheTechLevel - 1] + $GAME['cubeprice'][$GAME['IronDemand']] or $GAME['TileRequireCoal'][$whattobuild][$TheTechLevel - 1] and $GAME['TileRequireIron'][$whattobuild][$TheTechLevel - 1] and $coalsource == 50 and $ironsource == 50 and $GAME['Money'][$GAME['PlayerToMove']] < $GAME['TileCosts'][$whattobuild][$TheTechLevel - 1] + $GAME['cubeprice'][$GAME['CoalDemand']] + $GAME['cubeprice'][$GAME['IronDemand']]) { $errorlist .= transtext('memTilePoorCubes') . '<br>'; // Although you can afford to build the chosen industry tile, // you cannot afford to buy from the Demand Track(s) the cube(s) needed to build it. } } if ($GAME['TileRequireCoal'][$whattobuild][$TheTechLevel - 1]) { switch ($coalsource) { case 90: $errorlist .= transtext('memCoalNotValid') . '<br>'; break; // "The selected source of coal is not valid." // "The selected source of coal is not valid." case 91: $errorlist .= transtext('memCoalOnBoard') . '<br>'; break; // "You cannot buy coal from the Demand Track, // as there is coal available on the board for you to use." // "You cannot buy coal from the Demand Track, // as there is coal available on the board for you to use." case 92: $errorlist .= transtext('memCoalNearer') . '<br>'; break; case 93: $errorlist .= 'The selected source of coal is not connected to the location where you are trying to build.<br>'; break; case 95: $errorlist .= transtext('memCoalNoPorts') . '<br>'; break; // "You cannot buy coal from the Demand Track, // as the location where you want to build is not connected to a Port." } } if ($GAME['TileRequireIron'][$whattobuild][$TheTechLevel - 1]) { switch ($ironsource) { case 90: $errorlist .= transtext('memIronNotValid') . '<br>'; break; // "The selected source of iron is not valid." // "The selected source of iron is not valid." case 91: $errorlist .= transtext('memIronOnBoard') . '<br>'; break; // "You cannot buy iron from the Demand Track, // as there is iron available on the board for you to use." } } } if ($errorlist == '') { if ($GAME['SpaceStatus'][$wheretobuild] != 9) { destroytile($wheretobuild, 0, 1); } $GAME['HasBuilt'][$GAME['PlayerToMove']] = 1; $GAME['HasBuiltInTown'][$GAME['PlayerToMove']][$GAME['spacetowns'][$wheretobuild]] = 1; $GAME['SpaceStatus'][$wheretobuild] = $GAME['PlayerToMove']; $GAME['SpaceTile'][$wheretobuild] = $whattobuild; $GAME['TechLevels'][$wheretobuild] = $TheTechLevel; $GAME['Money'][$GAME['PlayerToMove']] -= $GAME['TileCosts'][$whattobuild][$TheTechLevel - 1]; $GAME['AmountSpent'][$GAME['PlayerToMove']] += $GAME['TileCosts'][$whattobuild][$TheTechLevel - 1]; $GAME['RemainingTiles'][$whattobuild][$GAME['PlayerToMove']]--; if ($GAME['TileRequireCoal'][$whattobuild][$TheTechLevel - 1]) { if ($coalsource == 50) { $GAME['Money'][$GAME['PlayerToMove']] -= $GAME['cubeprice'][$GAME['CoalDemand']]; $GAME['AmountSpent'][$GAME['PlayerToMove']] += $GAME['cubeprice'][$GAME['CoalDemand']]; if ($GAME['CurrentPlayers'] == 2 and $GAME['CoalDemand'] < 6 or $GAME['CurrentPlayers'] > 2 and $GAME['CoalDemand'] < 8) { $GAME['CoalDemand']++; } } else { $GAME['CoalInLancs']--; $GAME['SpaceCubes'][$coalsource] = $GAME['SpaceCubes'][$coalsource] - 1; // This is written in this way because SpaceCubes is a string consisting of digits // (it is not legal to use increment/decrement operators on string offsets). if (!$GAME['SpaceCubes'][$coalsource]) { fliptile($coalsource); } } } else { $altcoalsource = 98; } if ($GAME['TileRequireIron'][$whattobuild][$TheTechLevel - 1]) { if ($ironsource == 50) { $GAME['Money'][$GAME['PlayerToMove']] -= $GAME['cubeprice'][$GAME['IronDemand']]; $GAME['AmountSpent'][$GAME['PlayerToMove']] += $GAME['cubeprice'][$GAME['IronDemand']]; if ($GAME['CurrentPlayers'] == 2 and $GAME['IronDemand'] < 6 or $GAME['CurrentPlayers'] > 2 and $GAME['IronDemand'] < 8) { $GAME['IronDemand']++; } } else { $GAME['IronInLancs']--; $GAME['SpaceCubes'][$ironsource] = $GAME['SpaceCubes'][$ironsource] - 1; // This is written in this way because SpaceCubes is a string consisting of digits // (it is not legal to use increment/decrement operators on string offsets). if (!$GAME['SpaceCubes'][$ironsource]) { fliptile($ironsource); } } } else { $altironsource = 98; } switch ($whattobuild) { case 0: $GAME['SpaceCubes'][$wheretobuild] = 1; break; case 1: $GAME['SpaceCubes'][$wheretobuild] = $GAME['TileInitialCubes'][0][$TheTechLevel - 1]; $GAME['CoalInLancs'] += $GAME['SpaceCubes'][$wheretobuild]; if ($GAME['HasPort'][$GAME['spacetowns'][$wheretobuild]]) { if ($GAME['CoalDemand'] >= $GAME['SpaceCubes'][$wheretobuild]) { $GAME['CoalInLancs'] -= $GAME['SpaceCubes'][$wheretobuild]; $CoalIncome = 0; for ($i = 0; $i < $GAME['SpaceCubes'][$wheretobuild]; $i++) { $GAME['CoalDemand']--; $CoalIncome += $GAME['cubeprice'][$GAME['CoalDemand']]; } $GAME['SpaceCubes'][$wheretobuild] = 0; fliptile($wheretobuild); } else { $GAME['CoalInLancs'] -= $GAME['CoalDemand']; $GAME['SpaceCubes'][$wheretobuild] = $GAME['TileInitialCubes'][0][$TheTechLevel - 1] - $GAME['CoalDemand']; $oldcoaldemand = $GAME['CoalDemand']; $CoalIncome = 0; for ($i = 0; $i < $oldcoaldemand; $i++) { $GAME['CoalDemand']--; $CoalIncome += $GAME['cubeprice'][$GAME['CoalDemand']]; } } if ($CoalIncome) { $GAME['Money'][$GAME['PlayerToMove']] += $CoalIncome; $altcoalsource = 97; } } break; case 2: $GAME['SpaceCubes'][$wheretobuild] = $GAME['TileInitialCubes'][1][$TheTechLevel - 1]; $GAME['IronInLancs'] += $GAME['SpaceCubes'][$wheretobuild]; if ($GAME['IronDemand'] >= $GAME['SpaceCubes'][$wheretobuild]) { $GAME['IronInLancs'] -= $GAME['SpaceCubes'][$wheretobuild]; $IronIncome = 0; for ($i = 0; $i < $GAME['SpaceCubes'][$wheretobuild]; $i++) { $GAME['IronDemand']--; $IronIncome += $GAME['cubeprice'][$GAME['IronDemand']]; } $GAME['SpaceCubes'][$wheretobuild] = 0; fliptile($wheretobuild); } else { $GAME['IronInLancs'] -= $GAME['IronDemand']; $GAME['SpaceCubes'][$wheretobuild] = $GAME['TileInitialCubes'][1][$TheTechLevel - 1] - $GAME['IronDemand']; $oldirondemand = $GAME['IronDemand']; $IronIncome = 0; for ($i = 0; $i < $oldirondemand; $i++) { $GAME['IronDemand']--; $IronIncome += $GAME['cubeprice'][$GAME['IronDemand']]; } } if ($IronIncome) { $GAME['Money'][$GAME['PlayerToMove']] += $IronIncome; $altironsource = 97; } break; case 3: for ($i = 0; $i < $GAME['NumTowns']; $i++) { if ($GAME['CoalNet'][$i] == $GAME['CoalNet'][$GAME['spacetowns'][$wheretobuild]]) { $GAME['HasPort'][$i] = 1; } } $GAME['SpaceCubes'][$wheretobuild] = 1; break; case 4: fliptile($wheretobuild); } if ($SystemActing) { $AdminTakingMove = 0; } else { if ($GAME['PlayerUserID'][$GAME['PlayerToMove']] == $_SESSION['MyUserID']) { $AdminTakingMove = 0; } else { $AdminTakingMove = 1; } } if ($doublebuild) { $dbcard = letter_end_number($thecardB); $actionnuma = '1H'; $actionnumb = 'C'; } else { $dbcard = ''; $actionnuma = '1G'; $actionnumb = 'B'; } if ($AdminTakingMove) { $altgoodoutput = $actionnuma . callmovetimediff() . letter_end_number($_SESSION['MyUserID']) . letter_end_number($_SESSION['MyGenderCode']) . letter_end_number($thecardA) . $dbcard . letter_end_number($whattobuild) . letter_end_number($wheretobuild) . letter_end_number($altcoalsource) . letter_end_number($altironsource); $altgoodoutputName = '|' . $_SESSION['MyUserName']; } else { $altgoodoutput = $actionnumb . callmovetimediff() . letter_end_number($thecardA) . $dbcard . letter_end_number($whattobuild) . letter_end_number($wheretobuild) . letter_end_number($altcoalsource) . letter_end_number($altironsource); $altgoodoutputName = ''; } } else { $altgoodoutput = ''; $altgoodoutputName = ''; } return array($errorlist, '', $altgoodoutput, $altgoodoutputName); }
function gamelistdisplayuf(tagtree &$tt, $ThePlayerID, $PlayerName, $PlayerPronoun, $DisplayNotification, $StartPoint, $MaxResults, $Pagenum) { if ($DisplayNotification) { $MaxResults++; } $QueryResult = dbquery(DBQUERY_READ_RESULTSET, 'SELECT "PlayerGameRcd"."Colour" AS "UsersColour", "PlayerGameRcd"."Inherited", "PlayerGameRcd"."GameCounts", "PlayerGameRcd"."GameResult", "PlayerGameRcd"."NumLongTurns", "Game"."GameID", "Game"."Friendly", "Game"."GameName", "Game"."GTitleDeletedByAdmin", "Game"."LastMove", "Game"."GameCreator", "Game"."OriginalPlayers", "Game"."CurrentPlayers", "Game"."GameStatus", "GameVersion"."ShortVersionName", "GameVersionGroup"."VersionName", "GameVersion"."VersionNameSuffix", "GameVersion"."Creators", "User"."Name" AS "GameCreatorName", "GameInProgress"."PlayerToMove", "GameInProgress"."AbortVote", "GameInProgress"."KickVote", ROUND("PGRScore"."Score"/100, 2) AS "Score", "ParticipantRcd"."CurrentOccupant" FROM "PlayerGameRcd" JOIN "Game" ON "PlayerGameRcd"."Game" = "Game"."GameID" JOIN "GameVersion" ON "Game"."GVersion" = "GameVersion"."VersionID" JOIN "GameVersionGroup" ON "GameVersion"."VersionGroup" = "GameVersionGroup"."VersionGroupID" JOIN "User" ON "Game"."GameCreator" = "User"."UserID" LEFT JOIN "GameInProgress" ON "Game"."GameID" = "GameInProgress"."Game" LEFT JOIN "PGRScore" ON "PlayerGameRcd"."Game" = "PGRScore"."Game" AND "PlayerGameRcd"."User" = "PGRScore"."User" LEFT JOIN "PlayerGameRcd" AS "ParticipantRcd" ON "ParticipantRcd"."User" = :me: AND "Game"."GameID" = "ParticipantRcd"."Game" WHERE "PlayerGameRcd"."User" = :user: AND "PlayerGameRcd"."GameResult" NOT IN (\'Playing\', \'Hide\') ORDER BY "Game"."LastMove" DESC LIMIT :startpoint:, :maxresults:', 'user', $ThePlayerID, 'me', $_SESSION['MyUserID'], 'startpoint', $StartPoint, 'maxresults', $MaxResults); if ($DisplayNotification) { $MaxResults--; if ($QueryResult === 'NONE') { $tt->leaf('p', 'None'); return; } $fb = fragment::blank(); $PaginationBar = array($fb, $fb); } else { require_once HIDDEN_FILES_PATH . 'paginate.php'; $CountQueryResult = dbquery(DBQUERY_READ_INTEGER, 'CALL "CountUsersGamesFinished"(:user:)', 'user', $ThePlayerID); if (!$CountQueryResult) { return false; } $PaginationBar = paginationbar('game', 'games', SITE_ADDRESS . 'oldgames.php', array('UserID' => $ThePlayerID), 100, $Pagenum, $CountQueryResult); if ($QueryResult === 'NONE') { $tt->append($PaginationBar[0]); return; } } $PlayerColours = array('FFC18A', 'FFFFAF', '9FFF9F', 'FFC6FF', 'C4C4C4'); $ColourNames = array(transtext('_colourRed'), transtext('_colourYellow'), transtext('_colourGreen'), transtext('_colourPurple'), transtext('_colourGrey')); $TranslatedResults = array('Finished 1st' => transtext('_ugResult1st'), 'Finished 2nd' => transtext('_ugResult2nd'), 'Finished 3rd' => transtext('_ugResult3rd'), 'Finished 4th' => transtext('_ugResult4th'), 'Finished 5th' => transtext('_ugResult5th'), 'Game Aborted' => transtext('_ugResultAborted'), 'Quit' => transtext('_ugResultQuit'), 'Kicked by Admin' => transtext('_ugResultKickA'), 'Kicked by System' => transtext('_ugResultKickS'), 'Kicked by Vote' => transtext('_ugResultKickV')); $frag = fragment::blank(); $OldGameID = 0; $i = 0; while ($row = db_fetch_assoc($QueryResult)) { if ($row['GameID'] != $OldGameID) { $i++; if ($i > $MaxResults) { // "This table shows only X's last 20 games" etc $tt->leaf('p', str_replace(array('\\username', '\\pronoun', '\\userid'), array($PlayerName, $PlayerPronoun, $ThePlayerID), transtext('_ugFinishedNote'))); break; } $OldGameID = $row['GameID']; if ($row['GTitleDeletedByAdmin']) { $row['GameName'] = 'The title of this game has been cleared by an Administrator'; } if (is_null($row['CurrentOccupant']) or $row['CurrentOccupant'] > 0 and !$row['GameIsFinished']) { $RowTagAttributes = null; } else { if ($row['GameStatus'] == 'In Progress' and $row['PlayerToMoveID'] == $_SESSION['MyUserID'] or $row['GameStatus'] == 'Recruiting Replacement' and !is_null($row['Colour'])) { $RowTagAttributes = 'class="mymove"'; } else { if (($row['GameStatus'] == 'In Progress' or $row['GameStatus'] == 'Recruiting Replacement') and ($row['AbortVote'] != '00000' or $row['KickVote'] != '00000')) { $RowTagAttributes = 'class="myattn"'; } else { $RowTagAttributes = 'class="mygame"'; } } } $frag->opennode('tr', $RowTagAttributes); $version_name = vname($row['VersionName'], $row['VersionNameSuffix']); $frag->leaf('td', '<img src="gfx/icon-' . strtolower($row['ShortVersionName']) . '.png" alt="' . $version_name . '" title="' . $version_name . ' (' . $row['Creators'] . ')">', 'width=23 style="border-right: none;"'); $frag->leaf('td', '<a href="board.php?GameID=' . $row['GameID'] . '">' . $row['GameName'] . '</a>', 'style="border-left: none; padding-left: 0px; text-align: left;"'); $frag->leaf('td', '<a href="userdetails.php?UserID=' . $row['GameCreator'] . '">' . $row['GameCreatorName'] . '</a>'); if ($row['Friendly']) { $frag->leaf('td', transtext('^Yes'), 'bgcolor="#9FFF9F"'); } else { $frag->leaf('td', transtext('^No'), 'bgcolor="#FFC18A"'); } $frag->leaf('td', $row['CurrentPlayers'] . ($row['CurrentPlayers'] == $row['OriginalPlayers'] ? '' : ' / ' . $row['OriginalPlayers'])); $frag->leaf('td', $row['GameStatus']); $lmtime = strtotime($row['LastMove']); $frag->opennode('td'); $frag->leaf('span', date('Y', $lmtime), 'style="font-size: 50%;"'); $frag->text(date('M-d', $lmtime)); $frag->closenode(); $frag->leaf('td', $ColourNames[$row['UsersColour']], 'bgcolor="#' . $PlayerColours[$row['UsersColour']] . '"'); $frag->leaf('td', $TranslatedResults[$row['GameResult']]); $frag->leaf('td', $row['NumLongTurns']); $frag->leaf('td', is_null($row['Score']) ? 'n/a' : $row['Score']); $frag->leaf('td', $row['GameCounts'] ? transtext('^Yes') : transtext('^No')); $frag->leaf('td', $row['Inherited'] ? transtext('^Yes') : transtext('^No')); $frag->closenode(); } } $tt->append($PaginationBar[0]); $tt->opennode('table', 'class="table_extra_horizontal_padding"'); $tt->opennode('thead'); $tt->opennode('tr'); $tt->leaf('th', 'Name', 'colspan=2 style="width: 175px;"'); $tt->leaf('th', 'Creator'); $tt->leaf('th', 'Frdly', 'title="Whether the game was a "friendly" game."'); $tt->leaf('th', 'P', 'title="The number of players the game had when it finished (or currently has, if it hasn\'t finished) / the number of players it had when it started."'); $tt->leaf('th', 'Status'); $tt->leaf('th', 'Last Move', 'style="min-width: 75px;"'); $tt->leaf('th', transtext('_ugColColour'), 'title="The colour ' . $PlayerName . ' played as in this game."'); $tt->leaf('th', transtext('_ugColResult'), 'style="min-width: 90px;" title="The result ' . $PlayerName . ' achieved in this game. Usually this will be a rank achieved at the final scoring."'); $tt->leaf('th', transtext('_ugColLT'), 'title=""Long Turns": The number of times in this game ' . $PlayerName . ' took longer than Time Limit A to make a decision."'); $tt->leaf('th', transtext('_ugColScore'), 'title="The score ' . $PlayerName . ' achieved in this game. The decimal part gives the player\'s position on the income track."'); $tt->leaf('th', 'Counts', 'title="Whether the game counts towards ' . $PlayerName . '\'s statistics. Sometimes if you join a game in the middle, it does not contibute (either negatively or positively) toward your personal statistics."'); $tt->leaf('th', 'Inhrtd', 'title="Whether ' . $PlayerName . ' inherited this game, that is, took over from another player who had left the game."'); $tt->closenode(2); // tr, thead $tt->opennode('tbody'); $tt->append($frag); $tt->closenode(2); // tbody, table $tt->append($PaginationBar[1]); }
$mypage->leaf('p', 'It looks like you have been sent to the wrong page. Please click <a href="index.php">here</a> to return to the Main Page.'); $mypage->finish(); } $QR = dbquery(DBQUERY_READ_SINGLEROW, 'CALL "GameGetData_CardDistribution"(:game:)', 'game', (int) $_GET['GameID']); if ($QR === 'NONE') { $mypage->title_body('Game not found'); $mypage->leaf('p', 'Could not find a game with that ID number.'); $mypage->finish(); } extract($QR); if ($GameStatus != 'In Progress' and $GameStatus != 'Recruiting Replacement') { $mypage->title_body('Game has finished'); $mypage->leaf('p', 'This game has finished.'); $mypage->finish(); } $industrynames = array(transtext('_indCotnMill'), transtext('_indCoalMine'), transtext('_indIronWorks'), transtext('_indPort'), transtext('_indShipyard')); $CardDetailArray = explode('|', $CardDetailArray); $LocationNames = explode('|', $LocationNames); $playablecards = array(); $allcards = array(); if ($DiscardPile != '') { $allcards = explode('|', $DiscardPile); } if ($ShuffledDeck != '') { $ShuffledDeck = explode('|', $ShuffledDeck); while (count($ShuffledDeck)) { $newcard = array_pop($ShuffledDeck); $allcards[] = $newcard; $playablecards[] = $newcard; } }
function buildlink($linktobuild, $coalsource, $buildnum, $thecard) { global $GAME, $SystemActing; $errorlist = ''; if ($GAME['LinkStatus'][$linktobuild] != 9) { if ($GAME['RailPhase']) { $errorlist .= transtext('memRailBuilt') . '<br>'; } else { $errorlist .= transtext('memCanalBuilt') . '<br>'; } // "The chosen rail/canal link has already been built." } if ($GAME['RailPhase']) { if (!$GAME['RailAlwaysExists'][$linktobuild] and ($GAME['ModularBoardParts'] & $GAME['RailExistenceArray'][$linktobuild]) != $GAME['RailExistenceArray'][$linktobuild]) { $errorlist .= transtext('memRailNotThere') . '<br>'; // "That rail link does not exist (or it no longer exists) in this game." } if (!$GAME['HasBuiltInTown'][$GAME['PlayerToMove']][$GAME['RailStarts'][$linktobuild]] and !$GAME['HasBuiltInTown'][$GAME['PlayerToMove']][$GAME['RailEnds'][$linktobuild]] and !$GAME['HasLinkedToTown'][$GAME['PlayerToMove']][$GAME['RailStarts'][$linktobuild]] and !$GAME['HasLinkedToTown'][$GAME['PlayerToMove']][$GAME['RailEnds'][$linktobuild]]) { $errorlist .= transtext('memRailNotConn') . '<br>'; // "You cannot build that rail link, as you have neither connected to nor built in either location." } switch ($coalsource) { case 90: $errorlist .= transtext('memCoalNotValid') . '<br>'; break; // "The selected source of coal is not valid." // "The selected source of coal is not valid." case 91: $errorlist .= transtext('memCoalOnBoard') . '<br>'; break; // "You cannot buy coal from the Demand Track, // as there is coal available on the board for you to use." // "You cannot buy coal from the Demand Track, // as there is coal available on the board for you to use." case 92: $errorlist .= transtext('memCoalNearer') . '<br>'; break; case 93: $errorlist .= 'The selected source of coal is not connected to the location where you are trying to build.<br>'; break; case 95: $errorlist .= transtext('memCoalNoPorts') . '<br>'; break; // "You cannot buy coal from the Demand Track, // as the location where you want to build is not connected to a Port." } } else { if (!$GAME['CanalAlwaysExists'][$linktobuild] and ($GAME['ModularBoardParts'] & $GAME['CanalExistenceArray'][$linktobuild]) != $GAME['CanalExistenceArray'][$linktobuild]) { $errorlist .= transtext('memCanalNotThere') . '<br>'; // That canal link does not exist (or it no longer exists) in this game. } if (!$GAME['HasBuiltInTown'][$GAME['PlayerToMove']][$GAME['CanalStarts'][$linktobuild]] and !$GAME['HasBuiltInTown'][$GAME['PlayerToMove']][$GAME['CanalEnds'][$linktobuild]] and !$GAME['HasLinkedToTown'][$GAME['PlayerToMove']][$GAME['CanalStarts'][$linktobuild]] and !$GAME['HasLinkedToTown'][$GAME['PlayerToMove']][$GAME['CanalEnds'][$linktobuild]]) { $errorlist .= transtext('memCanalNotConn') . '<br>'; // "You cannot build that canal link, as you have neither connected to nor built in either location." } } $MoneyWarning = true; if (!$GAME['RailPhase'] and $GAME['Money'][$GAME['PlayerToMove']] < 3) { $errorlist .= transtext('memCanalPoor') . '<br>'; // "You cannot afford to build a canal link." } if ($GAME['RailPhase'] and $GAME['Money'][$GAME['PlayerToMove']] < 5) { $MoneyWarning = false; $errorlist .= transtext('memRailPoor') . '<br>'; // "You cannot afford to build a rail link." } if ($GAME['RailPhase'] and $MoneyWarning and $coalsource == 50 and $GAME['Money'][$GAME['PlayerToMove']] < 5 * $buildnum + $GAME['cubeprice'][$GAME['CoalDemand']]) { $errorlist .= transtext('memRailPoorCoal') . '<br>'; // "Although you can afford to build a rail link, you cannot afford // to buy from the Demand Track the coal cube needed to build it." } if (!$GAME['RemainingTiles'][5][$GAME['PlayerToMove']]) { if ($GAME['RailPhase']) { $errorlist .= transtext('memOutOfRails') . '<br>'; } else { $errorlist .= transtext('memOutOfCanals') . '<br>'; } // "You do not have any rail/canal markers left." } if ($coalsource == 50) { $altcoalsource = 99; } else { $altcoalsource = $coalsource; } if ($errorlist == '') { if ($SystemActing) { $AdminTakingMove = 0; } else { if ($GAME['PlayerUserID'][$GAME['PlayerToMove']] == $_SESSION['MyUserID']) { $AdminTakingMove = 0; } else { $AdminTakingMove = 1; } } $GAME['RemainingTiles'][5][$GAME['PlayerToMove']]--; $GAME['LinkStatus'][$linktobuild] = $GAME['PlayerToMove']; $GAME['Money'][$GAME['PlayerToMove']] -= (3 + 2 * $GAME['RailPhase']) * $buildnum; $GAME['AmountSpent'][$GAME['PlayerToMove']] += (3 + 2 * $GAME['RailPhase']) * $buildnum; if ($GAME['RailPhase']) { if ($GAME['CoalNet'][$GAME['RailStarts'][$linktobuild]] < $GAME['CoalNet'][$GAME['RailEnds'][$linktobuild]]) { $LowCoalNet = $GAME['CoalNet'][$GAME['RailStarts'][$linktobuild]]; $HighCoalNet = $GAME['CoalNet'][$GAME['RailEnds'][$linktobuild]]; } else { $LowCoalNet = $GAME['CoalNet'][$GAME['RailEnds'][$linktobuild]]; $HighCoalNet = $GAME['CoalNet'][$GAME['RailStarts'][$linktobuild]]; } if ($GAME['HasPort'][$GAME['RailStarts'][$linktobuild]] or $GAME['HasPort'][$GAME['RailEnds'][$linktobuild]]) { $AssignHasPort = 1; } else { $AssignHasPort = 0; } for ($i = 0; $i < $GAME['NumTowns']; $i++) { if ($GAME['CoalNet'][$i] == $HighCoalNet) { $GAME['CoalNet'][$i] = $LowCoalNet; } if ($GAME['CoalNet'][$i] == $LowCoalNet) { $GAME['HasPort'][$i] = $AssignHasPort; } } if ($coalsource == 50) { $GAME['Money'][$GAME['PlayerToMove']] -= $GAME['cubeprice'][$GAME['CoalDemand']]; $GAME['AmountSpent'][$GAME['PlayerToMove']] += $GAME['cubeprice'][$GAME['CoalDemand']]; if ($GAME['CurrentPlayers'] == 2 and $GAME['CoalDemand'] < 6 or $GAME['CurrentPlayers'] > 2 and $GAME['CoalDemand'] < 8) { $GAME['CoalDemand']++; } } else { $GAME['CoalInLancs']--; $GAME['SpaceCubes'][$coalsource] = $GAME['SpaceCubes'][$coalsource] - 1; // This is written in this way because SpaceCubes is a string consisting of digits // (it is not legal to use increment/decrement operators on string offsets). if (!$GAME['SpaceCubes'][$coalsource]) { fliptile($coalsource); } } $GAME['HasLinkedToTown'][$GAME['PlayerToMove']][$GAME['RailStarts'][$linktobuild]] = 1; $GAME['HasLinkedToTown'][$GAME['PlayerToMove']][$GAME['RailEnds'][$linktobuild]] = 1; if ($buildnum == 2) { if ($AdminTakingMove) { $altgoodoutput = '2D' . callmovetimediff() . letter_end_number($_SESSION['MyUserID']) . letter_end_number($_SESSION['MyGenderCode']) . letter_end_number($linktobuild) . letter_end_number($altcoalsource); $altgoodoutputName = '|' . $_SESSION['MyUserName']; } else { $altgoodoutput = 'I' . callmovetimediff() . letter_end_number($linktobuild) . letter_end_number($altcoalsource); $altgoodoutputName = ''; } $GAME['SecondRailMode'] = 0; } else { if ($AdminTakingMove) { $altgoodoutput = '1I' . callmovetimediff() . letter_end_number($_SESSION['MyUserID']) . letter_end_number($_SESSION['MyGenderCode']) . letter_end_number($thecard) . letter_end_number($linktobuild) . letter_end_number($altcoalsource); $altgoodoutputName = '|' . $_SESSION['MyUserName']; } else { $altgoodoutput = 'D' . callmovetimediff() . letter_end_number($thecard) . letter_end_number($linktobuild) . letter_end_number($altcoalsource); $altgoodoutputName = ''; } if (!$GAME['RemainingTiles'][5][$GAME['PlayerToMove']]) { $altgoodoutput .= '9IB'; } else { if ($GAME['Money'][$GAME['PlayerToMove']] < 10) { $altgoodoutput .= '9IC'; } else { if ($GAME['CoalInLancs'] or $GAME['Money'][$GAME['PlayerToMove']] > 9 + $GAME['cubeprice'][$GAME['CoalDemand']]) { for ($i = 0; $i < $GAME['NumRailLinks']; $i++) { if (($GAME['HasPort'][$GAME['RailEnds'][$i]] or $GAME['HasPort'][$GAME['RailStarts'][$i]]) and $GAME['Money'][$GAME['PlayerToMove']] > 9 + $GAME['cubeprice'][$GAME['CoalDemand']] and $GAME['LinkStatus'][$i] == 9 and ($GAME['HasBuiltInTown'][$GAME['PlayerToMove']][$GAME['RailStarts'][$i]] or $GAME['HasBuiltInTown'][$GAME['PlayerToMove']][$GAME['RailEnds'][$i]] or $GAME['HasLinkedToTown'][$GAME['PlayerToMove']][$GAME['RailStarts'][$i]] or $GAME['HasLinkedToTown'][$GAME['PlayerToMove']][$GAME['RailEnds'][$i]])) { $GAME['SecondRailMode'] = 1; break; } for ($j = 0; $j < $GAME['NumIndustrySpaces']; $j++) { if ($GAME['SpaceStatus'][$j] != 9 and $GAME['SpaceTile'][$j] == 1 and $GAME['SpaceCubes'][$j] and ($GAME['CoalNet'][$GAME['spacetowns'][$j]] == $GAME['CoalNet'][$GAME['RailStarts'][$i]] or $GAME['CoalNet'][$GAME['spacetowns'][$j]] == $GAME['CoalNet'][$GAME['RailEnds'][$i]]) and ($GAME['HasBuiltInTown'][$GAME['PlayerToMove']][$GAME['RailStarts'][$i]] or $GAME['HasBuiltInTown'][$GAME['PlayerToMove']][$GAME['RailEnds'][$i]] or $GAME['HasLinkedToTown'][$GAME['PlayerToMove']][$GAME['RailStarts'][$i]] or $GAME['HasLinkedToTown'][$GAME['PlayerToMove']][$GAME['RailEnds'][$i]]) and $GAME['LinkStatus'][$i] == 9 and ($GAME['RailAlwaysExists'][$i] or $GAME['ModularBoardParts'] & $GAME['RailExistenceArray'][$i])) { $GAME['SecondRailMode'] = 1; break 2; } } } } if (!$GAME['SecondRailMode']) { $altgoodoutput .= '9IA'; } } } } } else { if ($GAME['CoalNet'][$GAME['CanalStarts'][$linktobuild]] < $GAME['CoalNet'][$GAME['CanalEnds'][$linktobuild]]) { $LowCoalNet = $GAME['CoalNet'][$GAME['CanalStarts'][$linktobuild]]; $HighCoalNet = $GAME['CoalNet'][$GAME['CanalEnds'][$linktobuild]]; } else { $LowCoalNet = $GAME['CoalNet'][$GAME['CanalEnds'][$linktobuild]]; $HighCoalNet = $GAME['CoalNet'][$GAME['CanalStarts'][$linktobuild]]; } if ($GAME['HasPort'][$GAME['CanalStarts'][$linktobuild]] or $GAME['HasPort'][$GAME['CanalEnds'][$linktobuild]]) { $AssignHasPort = 1; } else { $AssignHasPort = 0; } for ($i = 0; $i < $GAME['NumTowns']; $i++) { if ($GAME['CoalNet'][$i] == $HighCoalNet) { $GAME['CoalNet'][$i] = $LowCoalNet; } if ($GAME['CoalNet'][$i] == $LowCoalNet) { $GAME['HasPort'][$i] = $AssignHasPort; } } $GAME['HasLinkedToTown'][$GAME['PlayerToMove']][$GAME['CanalStarts'][$linktobuild]] = 1; $GAME['HasLinkedToTown'][$GAME['PlayerToMove']][$GAME['CanalEnds'][$linktobuild]] = 1; if ($AdminTakingMove) { $altgoodoutput = '1I' . callmovetimediff() . letter_end_number($_SESSION['MyUserID']) . letter_end_number($_SESSION['MyGenderCode']) . letter_end_number($thecard) . letter_end_number($linktobuild); $altgoodoutputName = '|' . $_SESSION['MyUserName']; } else { $altgoodoutput = 'D' . callmovetimediff() . letter_end_number($thecard) . letter_end_number($linktobuild); $altgoodoutputName = ''; } } } else { $altgoodoutput = ''; $altgoodoutputName = ''; } return array($errorlist, '', $altgoodoutput, $altgoodoutputName); }
function gamelistdisplayf(tagtree &$tt, $StartPoint, $Pagenum) { if ($_SESSION['LoggedIn']) { $Query = 'SELECT "Game"."GameID", "Game"."Friendly", "Game"."GameName", "Game"."GTitleDeletedByAdmin", "Game"."LastMove", "Game"."GameCreator", "Game"."OriginalPlayers", "Game"."CurrentPlayers", "Game"."RailPhase", "Game"."Round", "Game"."NumRounds", "Game"."GameStatus", "GameVersion"."ShortVersionName", "GameVersionGroup"."VersionName", "GameVersion"."VersionNameSuffix", "GameVersion"."Creators", "User"."Name" AS "GameCreatorName", "PlayerGameRcd"."User" FROM "Game" JOIN "GameVersion" ON "Game"."GVersion" = "GameVersion"."VersionID" JOIN "GameVersionGroup" ON "GameVersion"."VersionGroup" = "GameVersionGroup"."VersionGroupID" JOIN "User" ON "Game"."GameCreator" = "User"."UserID" LEFT JOIN "PlayerGameRcd" ON "PlayerGameRcd"."User" = :me: AND "Game"."GameID" = "PlayerGameRcd"."Game" WHERE "Game"."GameIsFinished" = 1 ORDER BY "Game"."LastMove" DESC LIMIT :startpoint:, 100'; $me = $_SESSION['MyUserID']; } else { $Query = 'SELECT "Game"."GameID", "Game"."Friendly", "Game"."GameName", "Game"."GTitleDeletedByAdmin", "Game"."LastMove", "Game"."GameCreator", "Game"."OriginalPlayers", "Game"."CurrentPlayers", "Game"."RailPhase", "Game"."Round", "Game"."NumRounds", "Game"."GameStatus", "GameVersion"."ShortVersionName", "GameVersionGroup"."VersionName", "GameVersion"."VersionNameSuffix", "GameVersion"."Creators", "User"."Name" AS "GameCreatorName" FROM "Game" JOIN "GameVersion" ON "Game"."GVersion" = "GameVersion"."VersionID" JOIN "GameVersionGroup" ON "GameVersion"."VersionGroup" = "GameVersionGroup"."VersionGroupID" JOIN "User" ON "Game"."GameCreator" = "User"."UserID" WHERE "Game"."GameIsFinished" = 1 ORDER BY "Game"."LastMove" DESC LIMIT :startpoint:, 100'; $me = 0; } $QueryResult = dbquery(DBQUERY_READ_RESULTSET, $Query, 'me', $me, 'startpoint', $StartPoint); $CountQueryResult = dbquery(DBQUERY_READ_INTEGER_TOLERANT_ZERO, 'SELECT "MetadatumValue" FROM "Metadatum" WHERE "MetadatumName" = \'Games-Finished\''); if (!$CountQueryResult) { return false; } require_once HIDDEN_FILES_PATH . 'paginate.php'; $PaginationBar = paginationbar('game', 'games', SITE_ADDRESS . 'oldgames.php', null, 100, $Pagenum, $CountQueryResult); $tt->append($PaginationBar[0]); if ($QueryResult === 'NONE') { return; } $tt->opennode('table', 'class="table_extra_horizontal_padding"'); $tt->opennode('thead'); $tt->opennode('tr'); $tt->leaf('th', 'Name', 'colspan=2 style="width: 270px;"'); $tt->leaf('th', 'Creator'); $tt->leaf('th', 'Friendly?'); $tt->leaf('th', 'Original', 'title="The number of players the game had when it started."'); $tt->leaf('th', 'Final', 'title="The number of players the game had when it finished."'); $tt->leaf('th', 'Status'); $tt->leaf('th', 'Round'); $tt->leaf('th', 'Last Move <span style="font-weight: normal;">(GMT)</span>'); $tt->closenode(2); // tr, thead $tt->opennode('tbody'); $RoundColumnStyles = array('gamelist_roundcol_c', 'gamelist_roundcol_r'); while ($row = db_fetch_assoc($QueryResult)) { if ($row['GTitleDeletedByAdmin']) { $row['GameName'] = 'The title of this game has been cleared by an Administrator'; } $RowTagAttributes = null; if ($_SESSION['LoggedIn']) { $GameCreatorColumn = '<a href="userdetails.php?UserID=' . $row['GameCreator'] . '">' . $row['GameCreatorName'] . '</a>'; if (!is_null($row['User'])) { $RowTagAttributes = 'class="mygame"'; } } else { $GameCreatorColumn = $row['GameCreatorName']; } $tt->opennode('tr', $RowTagAttributes); $version_name = vname($row['VersionName'], $row['VersionNameSuffix']); $tt->leaf('td', '<img src="gfx/icon-' . strtolower($row['ShortVersionName']) . '.png" alt="' . $version_name . '" title="' . $version_name . ' (' . $row['Creators'] . ')">', 'width=23 style="border-right: none;"'); $tt->leaf('td', '<a href="board.php?GameID=' . $row['GameID'] . '">' . $row['GameName'] . '</a>', 'style="border-left: none; padding-left: 0px; text-align: left;"'); $tt->leaf('td', $GameCreatorColumn); if ($row['Friendly']) { $tt->leaf('td', transtext('^Yes'), 'bgcolor="#9FFF9F"'); } else { $tt->leaf('td', transtext('^No'), 'bgcolor="#FFC18A"'); } $tt->leaf('td', $row['OriginalPlayers']); $tt->leaf('td', $row['CurrentPlayers']); $tt->leaf('td', $row['GameStatus']); $tt->leaf('td', ($row['Round'] >= 10 ? '' : ' ') . $row['Round'] . ' / ' . $row['NumRounds'], 'class="' . $RoundColumnStyles[$row['RailPhase']] . '"'); $lmtime = strtotime($row['LastMove']); $tt->opennode('td'); $tt->leaf('span', date('Y', $lmtime), 'style="font-size: 50%;"'); $tt->text(date('M-d H:i:s', $lmtime)); $tt->closenode(2); // td, tr } $tt->closenode(2); // tbody, table $tt->append($PaginationBar[1]); }
function gamegetdata_board_see($GameID) { $GAME = dbquery(DBQUERY_READ_SINGLEROW, 'CALL "GameGetData_Game_Display"(:gameid:)', 'gameid', $GameID); $QRP = dbquery(DBQUERY_READ_RESULTSET, 'CALL "GameGetData_User_Display"(:gameid:)', 'gameid', $GameID); if ($GAME === 'NONE') { return false; } if ($GAME['GameStatus'] == 'Cancelled' and !$Administrator) { return false; } if ($GAME['GameStatus'] == 'Recruiting' or $GAME['GameStatus'] == 'Cancelled') { return 'WRONG PAGE'; } $colournames = array(transtext('_colourRed'), transtext('_colourYellow'), transtext('_colourGreen'), transtext('_colourPurple'), transtext('_colourGrey')); $pronounmap_BasicUppercase = array('He' => transtext('^pronounHeCap'), 'She' => transtext('^pronounSheCap'), 'It' => transtext('^pronounItCap')); $pronounmap_BasicLowercase = array('He' => transtext('^pronounHe'), 'She' => transtext('^pronounShe'), 'It' => transtext('^pronounIt')); // $pronounmap_PossessiveUppercase = array( 'He' => transtext('^pronounHisPoCap'), // 'She' => transtext('^pronounHerPoCap'), // 'It' => transtext('^pronounItsPoCap') // ); // Not currently needed $pronounmap_PossessiveLowercase = array('He' => transtext('^pronounHisPo'), 'She' => transtext('^pronounHerPo'), 'It' => transtext('^pronounItsPo')); $pronounmap_IndirectObjectLowercase = array('He' => transtext('^pronounHimIO'), 'She' => transtext('^pronounHerIO'), 'It' => transtext('^pronounItIO')); $GAME['VersionName'] = vname($GAME['VersionName'], $GAME['VersionNameSuffix']); if ($GAME['GTitleDeletedByAdmin']) { $GAME['GameName_Title'] = transtext('_GameTitleHidden'); if ($Administrator) { $GAME['GameName_Page'] = '<b>' . $GAME['GameName'] . '</b> (Title hidden to non-Administrators)'; } else { $GAME['GameName_Page'] = '<b>' . transtext('_GameTitleHidden') . '</b>'; } } else { $GAME['GameName_Title'] = $GAME['GameName']; $GAME['GameName_Page'] = '<b>' . $GAME['GameName'] . '</b>'; } $GAME['locationnames'] = explode('|', $GAME['LocationNames']); $GAME['spacetowns'] = explode('|', $GAME['SpaceTowns']); $GAME['tileindustries'] = explode('|', $GAME['TileIndustries']); $GAME['CanalStarts'] = explode('|', $GAME['CanalStarts']); $GAME['CanalEnds'] = explode('|', $GAME['CanalEnds']); $GAME['RailStarts'] = explode('|', $GAME['RailStarts']); $GAME['RailEnds'] = explode('|', $GAME['RailEnds']); $GAME['CanalAlwaysExists'] = explode('|', $GAME['CanalAlwaysExists']); $GAME['CanalExistenceArray'] = explode('|', $GAME['CanalExistenceArray']); $GAME['RailAlwaysExists'] = explode('|', $GAME['RailAlwaysExists']); $GAME['RailExistenceArray'] = explode('|', $GAME['RailExistenceArray']); $GAME['SpaceAlwaysExists'] = explode('|', $GAME['SpaceAlwaysExists']); $GAME['SpaceExistenceArray'] = explode('|', $GAME['SpaceExistenceArray']); $GAME['carddetailarray'] = explode('|', $GAME['CardDetailArray']); $GAME['carddetailarrayb'] = explode('|', $GAME['CardDetailArrayB']); $GAME['SpaceNumbersNotOrdinal'] = explode('|', $GAME['SpaceNumbers']); $GAME['spacenumbers'] = explode('|', $GAME['SpaceOrdinals']); $GAME['LocationAutoValue'] = explode('|', $GAME['LocationAutoValue']); $GAME['CanalExistenceArray'] = array_map('intval', $GAME['CanalExistenceArray']); $GAME['RailExistenceArray'] = array_map('intval', $GAME['RailExistenceArray']); $GAME['SpaceExistenceArray'] = array_map('intval', $GAME['SpaceExistenceArray']); $GAME['ModularBoardParts'] = (int) $GAME['ModularBoardParts']; $GAME['SpecialRules'] = (int) $GAME['SpecialRules']; if (is_null($GAME['TileXPositionsPretty'])) { $GAME['TileXPositions'] = array(null, explode('|', $GAME['TileXPositionsCompact'])); $GAME['TileYPositions'] = array(null, explode('|', $GAME['TileYPositionsCompact'])); } else { $GAME['TileXPositions'] = array(explode('|', $GAME['TileXPositionsPretty']), explode('|', $GAME['TileXPositionsCompact'])); $GAME['TileYPositions'] = array(explode('|', $GAME['TileYPositionsPretty']), explode('|', $GAME['TileYPositionsCompact'])); } if ($GAME['RailPhase']) { if (is_null($GAME['RailXPositionsPretty'])) { $GAME['LinkDotXPositions'] = array(null, explode('|', $GAME['RailXPositionsCompact'])); $GAME['LinkDotYPositions'] = array(null, explode('|', $GAME['RailYPositionsCompact'])); } else { $GAME['LinkDotXPositions'] = array(explode('|', $GAME['RailXPositionsPretty']), explode('|', $GAME['RailXPositionsCompact'])); $GAME['LinkDotYPositions'] = array(explode('|', $GAME['RailYPositionsPretty']), explode('|', $GAME['RailYPositionsCompact'])); } } else { if (is_null($GAME['CanalXPositionsPretty'])) { $GAME['LinkDotXPositions'] = array(null, explode('|', $GAME['CanalXPositionsCompact'])); $GAME['LinkDotYPositions'] = array(null, explode('|', $GAME['CanalYPositionsCompact'])); } else { $GAME['LinkDotXPositions'] = array(explode('|', $GAME['CanalXPositionsPretty']), explode('|', $GAME['CanalXPositionsCompact'])); $GAME['LinkDotYPositions'] = array(explode('|', $GAME['CanalYPositionsPretty']), explode('|', $GAME['CanalYPositionsCompact'])); } } $GAME['NumTowns'] = count($GAME['locationnames']); $GAME['NumIndustrySpaces'] = count($GAME['spacetowns']); $GAME['NumCanalLinks'] = count($GAME['CanalStarts']); $GAME['NumRailLinks'] = count($GAME['RailEnds']); $NumLinks = $GAME['RailPhase'] ? $GAME['NumRailLinks'] : $GAME['NumCanalLinks']; if ($NumLinks % 2) { $GAME['LinkStatus'] = substr($GAME['LinkStatus'], 0, -1); } if ($GAME['NumIndustrySpaces'] % 2) { $GAME['SpaceStatus'] = substr($GAME['SpaceStatus'], 0, -1); $GAME['SpaceTile'] = substr($GAME['SpaceTile'], 0, -1); $GAME['TechLevels'] = substr($GAME['TechLevels'], 0, -1); $GAME['SpaceCubes'] = substr($GAME['SpaceCubes'], 0, -1); } $GAME['CoalInLancs'] = 0; $GAME['IronInLancs'] = 0; for ($i = 0; $i < $GAME['NumIndustrySpaces']; $i++) { if ($GAME['SpaceStatus'][$i] != 9 and $GAME['SpaceTile'][$i] == 1) { $GAME['CoalInLancs'] += $GAME['SpaceCubes'][$i]; } if ($GAME['SpaceStatus'][$i] != 9 and $GAME['SpaceTile'][$i] == 2) { $GAME['IronInLancs'] += $GAME['SpaceCubes'][$i]; } } $GAME['Money'] = explode('|', $GAME['Money']); $GAME['AmountSpent'] = explode('|', $GAME['AmountSpent']); $GAME['VictoryPoints'] = explode('|', $GAME['VictoryPoints']); $GAME['IncomeSpace'] = explode('|', $GAME['IncomeSpace']); $GAME['RemainingTiles'] = str_split($GAME['RemainingTiles'], MAX_PLAYERS); for ($i = 0; $i < 6; $i++) { $GAME['RemainingTiles'][$i] = array_map('hexdec', str_split($GAME['RemainingTiles'][$i])); } if (is_null($GAME['Cards']) or $GAME['Cards'] == '') { $GAME['Cards'] = array(array(), array(), array(), array(), array()); $GAME['HandSize'] = array(0, 0, 0, 0, 0); } else { $GAME['Cards'] = explode(':', $GAME['Cards']); for ($i = 0; $i < MAX_PLAYERS; $i++) { $GAME['Cards'][$i] = explode('|', $GAME['Cards'][$i]); $GAME['HandSize'][$i] = count($GAME['Cards'][$i]); if ($GAME['HandSize'][$i] == 1 and $GAME['Cards'][$i][0] == '') { $GAME['Cards'][$i] = array(); $GAME['HandSize'][$i] = 0; } } } $GAME['CanTakeLoans'] = 1; if ($GAME['GameIsFinished'] or $GAME['IncomeSpace'][$GAME['PlayerToMove']] == 0 or $GAME['RailPhase'] and $GAME['NumRounds'] - $GAME['Round'] < 4) { $GAME['CanTakeLoans'] = 0; } if ($GAME['TilesDrawn'] == 'None') { $GAME['NumberOfTilesDrawn'] = 0; } else { $GAME['NumberOfTilesDrawn'] = strlen($GAME['TilesDrawn']); } if ($GAME['GameStatus'] == 'In Progress' and time() - strtotime($GAME['LastMove']) > 60 * $GAME['TimeLimitA'] and !MAINTENANCE_DISABLED) { $GAME['CanKickVote'] = 1; } else { $GAME['CanKickVote'] = 0; } if ($GAME['TimeLimitA'] % 1440 == 0) { $GAME['TimeLimitA'] /= 1440; if ($GAME['TimeLimitA'] == 1) { $GAME['TimeLimitAunit'] = transtext('_timeDay'); } else { $GAME['TimeLimitAunit'] = transtext('_timeDayPl'); } } else { if ($GAME['TimeLimitA'] % 60 == 0) { $GAME['TimeLimitA'] /= 60; if ($GAME['TimeLimitA'] == 1) { $GAME['TimeLimitAunit'] = transtext('_timeHour'); } else { $GAME['TimeLimitAunit'] = transtext('_timeHourPl'); } } else { $GAME['TimeLimitAunit'] = transtext('_timeMinutePl'); } } if ($GAME['TimeLimitB'] % 1440 == 0) { $GAME['TimeLimitB'] /= 1440; if ($GAME['TimeLimitB'] == 1) { $GAME['TimeLimitBunit'] = transtext('_timeDay'); } else { $GAME['TimeLimitBunit'] = transtext('_timeDayPl'); } } else { if ($GAME['TimeLimitB'] % 60 == 0) { $GAME['TimeLimitB'] /= 60; if ($GAME['TimeLimitB'] == 1) { $GAME['TimeLimitBunit'] = transtext('_timeHour'); } else { $GAME['TimeLimitBunit'] = transtext('_timeHourPl'); } } else { $GAME['TimeLimitBunit'] = transtext('_timeMinutePl'); } } switch ($GAME['SpecialModes']) { case 1: $GAME['DebtMode'] = 1; $GAME['ContinueSellingMode'] = 0; $GAME['SecondRailMode'] = 0; $GAME['SecondDevelopMode'] = 0; break; case 2: $GAME['DebtMode'] = 0; $GAME['ContinueSellingMode'] = 1; $GAME['SecondRailMode'] = 0; $GAME['SecondDevelopMode'] = 0; break; case 3: $GAME['DebtMode'] = 0; $GAME['ContinueSellingMode'] = 0; $GAME['SecondRailMode'] = 1; $GAME['SecondDevelopMode'] = 0; break; case 4: $GAME['DebtMode'] = 0; $GAME['ContinueSellingMode'] = 0; $GAME['SecondRailMode'] = 0; $GAME['SecondDevelopMode'] = 1; break; default: $GAME['DebtMode'] = 0; $GAME['ContinueSellingMode'] = 0; $GAME['SecondRailMode'] = 0; $GAME['SecondDevelopMode'] = 0; } $GAME['HasBuilt'] = array(0, 0, 0, 0, 0); for ($i = 0; $i < MAX_PLAYERS; $i++) { if (strpos($GAME['SpaceStatus'], $i) !== false or strpos($GAME['LinkStatus'], $i) !== false) { $GAME['HasBuilt'][$i] = 1; } } if ($GAME['GVersion'] == 2) { $GAME['NarrativeTicker'] = 2; } else { if (is_null($GAME['GameTicker'])) { $GAME['NarrativeTicker'] = 1; } else { $GAME['NarrativeTicker'] = 0; } } for ($i = 0; $i < MAX_PLAYERS; $i++) { $GAME['PlayerName'][$i] = transtext('_PlayerBoxAbsent'); $GAME['PlayerFullName'][$i] = $colournames[$i] . ' (' . $GAME['PlayerName'][$i] . ')'; } $GAME['MyColour'] = 50; $GAME['PlayersMissing'] = (int) $GAME['CurrentPlayers']; $GAME['PlayerMissing'] = $GAME['PlayerExists']; if (is_null($GAME['AbortVote']) or $GAME['AbortVote'] == '') { $GAME['AbortVote'] = '00000'; } if (is_null($GAME['KickVote']) or $GAME['KickVote'] == '') { $GAME['KickVote'] = '00000'; } if ($GAME['GameStatus'] == 'In Progress' and strpos($GAME['KickVote'], '1') !== false) { $GAME['CanKickVote'] = 1; } while ($row = db_fetch_assoc($QRP)) { $GAME['PlayersMissing']--; $GAME['PlayerMissing'][$row['Colour']] = 0; $GAME['PlayerUserID'][$row['Colour']] = $row['UserID']; $GAME['PlayerName'][$row['Colour']] = $row['Name']; $GAME['PlayerFullName'][$row['Colour']] = $colournames[$row['Colour']] . ' (' . $row['Name'] . ')'; $GAME['Pronoun'][$row['Colour']] = $pronounmap_BasicUppercase[$row['Pronoun']]; $GAME['PronounLC'][$row['Colour']] = $pronounmap_BasicLowercase[$row['Pronoun']]; $GAME['PossessivePronounLC'][$row['Colour']] = $pronounmap_PossessiveLowercase[$row['Pronoun']]; $GAME['OtherPronounLC'][$row['Colour']] = $pronounmap_IndirectObjectLowercase[$row['Pronoun']]; $GAME['Notes'][$row['Colour']] = $row['Notes']; if ($_SESSION['LoggedIn'] and $_SESSION['MyUserID'] == $row['UserID']) { $GAME['MyColour'] = $row['Colour']; if ($GAME['AbortVote'][$row['Colour']]) { $GAME['IHaveAbortVoted'] = 1; } else { $GAME['IHaveAbortVoted'] = 0; } if ($GAME['KickVote'][$row['Colour']]) { $GAME['IHaveKickVoted'] = 1; } else { $GAME['IHaveKickVoted'] = 0; } } } $GAME['PlayerMissingAndMatters'] = $GAME['PlayerMissing']; $GAME['PlayersMissingThatMatter'] = $GAME['PlayersMissing']; for ($i = 0; $i < MAX_PLAYERS; $i++) { if ($GAME['PlayerMissing'][$i] and $GAME['RailPhase'] and $GAME['PlayerToMove'] != $i and !$GAME['HandSize'][$i]) { $GAME['PlayersMissingThatMatter']--; $GAME['PlayerMissingAndMatters'][$i] = 0; } } $GAME['PlayersVotingToAbort'] = 0; $GAME['PlayersVotingToKick'] = 0; $GAME['AbortVoteActive'] = false; $GAME['KickVoteActive'] = false; for ($i = 0; $i < MAX_PLAYERS; $i++) { if ($GAME['PlayerMissing'][$i] or $GAME['AbortVote'][$i]) { $GAME['PlayersVotingToAbort']++; } if ($GAME['PlayerMissing'][$i] or $GAME['KickVote'][$i]) { $GAME['PlayersVotingToKick']++; } if ($GAME['AbortVote'][$i]) { $GAME['AbortVoteActive'] = true; } if ($GAME['KickVote'][$i]) { $GAME['KickVoteActive'] = true; } } if ($GAME['PlayersMissingThatMatter']) { $GAME['ReplacementOffers'] = array(); $GAME['ReplacementOffers_Users'] = array(); $GAME['ReplacementOffers_Colours'] = array(); $QRR = dbquery(DBQUERY_READ_RESULTSET, 'CALL "GameGetData_GetReplacements"(:game:)', 'game', $GameID); if ($QRR === 'NONE') { $GAME['NumReplacementOffers'] = 0; } else { $GAME['NumReplacementOffers'] = mysqli_num_rows($QRR); while ($row = db_fetch_assoc($QRR)) { $GAME['ReplacementOffers'][] = array($row['User'], $row['Name'], $row['Colour'], $row['Rating'], $row['ToCount']); $GAME['ReplacementOffers_Users'][] = $row['User']; $GAME['ReplacementOffers_Colours'][] = $row['Colour']; } } } return $GAME; }
function sellcotton($milllocation, $portlocation, $continuing, $thecard) { global $GAME, $SystemActing; $errorlistA = ''; $errorlistB = ''; $ExclamationMark = 0; if ($GAME['SpaceTile'][$milllocation] or $GAME['SpaceStatus'][$milllocation] == 9) { $errorlistA .= transtext('memIsNotCM') . '<br>'; // "The industry space that you specified as the location // of the Cotton Mill is not occupied by a Cotton Mill." } else { if ($GAME['SpaceStatus'][$milllocation] != $GAME['PlayerToMove']) { $errorlistA .= transtext('memCMNotYours') . '<br>'; } else { if (!$GAME['SpaceCubes'][$milllocation]) { $errorlistA .= transtext('memCMFlipped') . '<br>'; // "The Cotton Mill that you specified is already flipped." } } } if ($errorlistA == '') { if ($portlocation < $GAME['NumIndustrySpaces']) { if ($GAME['SpaceTile'][$portlocation] != 3) { $errorlistB .= transtext('memIsNotPort') . '<br>'; // "The industry space that you specified as the location // of the Port is not occupied by a Port." } else { if ($GAME['CoalNet'][$GAME['spacetowns'][$milllocation]] != $GAME['CoalNet'][$GAME['spacetowns'][$portlocation]]) { $errorlistB .= transtext('memPortNotConn') . '<br>'; // "The Port location that you specified is not connected to the Cotton Mill that you specified." } else { if (!$GAME['SpaceCubes'][$portlocation]) { $errorlistB .= transtext('memPortFlipped') . '<br>'; // "The Port in the location that you specified is already flipped." } } } } else { if (!$GAME['HasPort'][$GAME['spacetowns'][$milllocation]]) { $errorlistB .= transtext('memCMNoPorts') . '<br>'; // "The specified Cotton Mill cannot sell to the Distant Market, as it is not connected to any Ports." } else { if ($GAME['CottonDemand'] == 8) { $errorlistB .= transtext('memNoMoreDemand') . '<br>'; } } } } $errorlist = $errorlistA . $errorlistB; if ($errorlist == '') { if ($SystemActing) { $AdminTakingMove = 0; } else { if ($GAME['PlayerUserID'][$GAME['PlayerToMove']] == $_SESSION['MyUserID']) { $AdminTakingMove = 0; } else { $AdminTakingMove = 1; } } $append_action_end_note = true; if ($portlocation < $GAME['NumIndustrySpaces']) { fliptile($portlocation); fliptile($milllocation); if ($continuing) { if ($AdminTakingMove) { $altgoodoutput = '2D' . callmovetimediff() . letter_end_number($_SESSION['MyUserID']) . letter_end_number($_SESSION['MyGenderCode']) . letter_end_number($milllocation) . letter_end_number($portlocation); $altgoodoutputName = '|' . $_SESSION['MyUserName']; } else { $altgoodoutput = 'I' . callmovetimediff() . letter_end_number($milllocation) . letter_end_number($portlocation); $altgoodoutputName = ''; } } else { if ($AdminTakingMove) { $altgoodoutput = '2B' . callmovetimediff() . letter_end_number($_SESSION['MyUserID']) . letter_end_number($_SESSION['MyGenderCode']) . letter_end_number($thecard) . letter_end_number($milllocation) . letter_end_number($portlocation); $altgoodoutputName = '|' . $_SESSION['MyUserName']; } else { $altgoodoutput = 'G' . callmovetimediff() . letter_end_number($thecard) . letter_end_number($milllocation) . letter_end_number($portlocation); $altgoodoutputName = ''; } } $CheckCtu = true; } else { drawDMtile(); if ($continuing) { if ($AdminTakingMove) { $altgoodoutput = '2D' . callmovetimediff() . letter_end_number($_SESSION['MyUserID']) . letter_end_number($_SESSION['MyGenderCode']) . letter_end_number($milllocation) . '9J'; $altgoodoutputName = '|' . $_SESSION['MyUserName']; } else { $altgoodoutput = 'I' . callmovetimediff() . letter_end_number($milllocation) . '9J'; $altgoodoutputName = ''; } } else { if ($AdminTakingMove) { $altgoodoutput = '2B' . callmovetimediff() . letter_end_number($_SESSION['MyUserID']) . letter_end_number($_SESSION['MyGenderCode']) . letter_end_number($thecard) . letter_end_number($milllocation) . '9J'; $altgoodoutputName = '|' . $_SESSION['MyUserName']; } else { $altgoodoutput = 'G' . callmovetimediff() . letter_end_number($thecard) . letter_end_number($milllocation) . '9J'; $altgoodoutputName = ''; } } if ($GAME['CottonDemand'] < 8) { $CheckCtu = true; $Boost = array(3, 3, 2, 2, 1, 1, 0, 0); $Boost = $Boost[$GAME['CottonDemand']]; $GAME['IncomeSpace'][$GAME['PlayerToMove']] += $Boost; // If IncomeSpace[...] ends up above 99, // it's taken care of by the call to fliptile() fliptile($milllocation); if (!DMSaleSuccessProbability()) { $GAME['CottonDemand'] = 8; $altgoodoutput .= '9J'; } } else { $CheckCtu = false; $append_action_end_note = false; } } $GAME['ContinueSellingMode'] = 0; if ($CheckCtu) { $MillsArray = array(); $PortsArray = array(); for ($i = 0; $i < $GAME['NumIndustrySpaces']; $i++) { if ($GAME['SpaceStatus'][$i] == $GAME['PlayerToMove'] and !$GAME['SpaceTile'][$i] and $GAME['SpaceCubes'][$i]) { $MillsArray[] = $i; } if ($GAME['SpaceStatus'][$i] != 9 and $GAME['SpaceTile'][$i] == 3 and $GAME['SpaceCubes'][$i]) { $PortsArray[] = $i; } } for ($i = 0; $i < count($MillsArray); $i++) { if ($GAME['HasPort'][$GAME['spacetowns'][$MillsArray[$i]]] and $GAME['CottonDemand'] < 8) { $GAME['ContinueSellingMode'] = 1; break; } for ($j = 0; $j < count($PortsArray); $j++) { if ($GAME['CoalNet'][$GAME['spacetowns'][$MillsArray[$i]]] == $GAME['CoalNet'][$GAME['spacetowns'][$PortsArray[$j]]]) { $GAME['ContinueSellingMode'] = 1; break 2; } } } } if (!$GAME['ContinueSellingMode'] and $append_action_end_note) { $altgoodoutput .= '9I'; } } else { $altgoodoutput = ''; $altgoodoutputName = ''; } return array($errorlist, '', $altgoodoutput, $altgoodoutputName); }
} else { $RowTagAttributes = 'class="mygame"'; } } $mypage->opennode('tr', $RowTagAttributes); $mypage->leaf('td', '<b>' . ($StartPoint + $j) . '</b>'); $mypage->leaf('td', '<a href="board.php?GameID=' . $row['GameID'] . '">' . $row['AdaptedScore']); if (!$EscapedUserID) { $mypage->leaf('td', '<a href="userdetails.php?UserID=' . $row['Owner'] . '">' . $row['Name']); } if ($resultcolumn) { $mypage->leaf('td', $TranslatedResults[$row['GameResult']]); } if ($friendlycolumn) { if ($row['Friendly']) { $mypage->leaf('td', transtext('^Yes'), 'align=center bgcolor="#9FFF9F"'); } else { $mypage->leaf('td', transtext('^No'), 'align=center bgcolor="#FFC18A"'); } } $mypage->leaf('td', '<a href="board.php?GameID=' . $row['GameID'] . '">' . $row['GameName'] . '</a>'); $mypage->leaf('td', '<a href="userdetails.php?UserID=' . $row['GameCreator'] . '">' . $row['GameCreatorName'] . '</a>'); $mypage->leaf('td', date('Y-M-d H:i:s', strtotime($row['LastMove']))); $mypage->closenode(); } $mypage->closenode(2); // tbody, table $mypage->append($PaginationBar[1]); $mypage->leaf('p', 'Click <a href="index.php">here</a> to return to the Main Page, or <a href="statistics.php">here</a> to return to the main Statistics page.'); } $mypage->finish();
function DoTask() { global $Administrator, $GAME, $PersonActing, $SystemActing, $unexpectederrormessage; if ($GAME['GameStatus'] != 'In Progress') { echo '<html><head><title>' . transtext('memCannotMoveT') . '</title><body>' . str_replace('\\gameid', $GAME['GameID'], transtext('memCannotMoveM')) . '</body></html>'; die; } if ($GAME['PlayerToMove'] == $GAME['MyColour'] or $Administrator and @$_POST['AdminMoveYes']) { if ($_POST['ProgressDigit'] != $GAME['NumMovesMade']) { echo '<html><head><title>' . transtext('memCheckIntegerT') . '</title></head><body>' . str_replace('\\gameid', $GAME['GameID'], transtext('memCheckIntegerM')) . '</body></html>'; exit; } if (!isset($_POST['LinkToBuild'])) { $formdetails['LinkToBuild'] = 50; } else { if ($_POST['LinkToBuild'] == 'StopBuilding') { $formdetails['LinkToBuild'] = 50; } else { $formdetails['LinkToBuild'] = (int) $_POST['LinkToBuild']; if ($formdetails['LinkToBuild'] < 0 or $GAME['RailPhase'] and $formdetails['LinkToBuild'] >= $GAME['NumRailLinks'] or !$GAME['RailPhase'] and ($formdetails['LinkToBuild'] >= $GAME['NumCanalLinks'] or ($GAME['ModularBoardParts'] & 8) == 0 and $formdetails['LinkToBuild'] == 12 and $GAME['GVersion'] == 1)) { die(transtext('memBadMoveData')); } } } if (!isset($_POST['FirstCard'])) { $formdetails['CardA'] = 9; } else { if ($_POST['FirstCard'] == 'NoCardSelected') { $formdetails['CardA'] = 9; } else { $formdetails['CardA'] = (int) $_POST['FirstCard']; if ($formdetails['CardA'] < 0 or $formdetails['CardA'] > 7) { die(transtext('memBadMoveData')); } } } if (!isset($_POST['SecondCard'])) { $formdetails['CardB'] = 9; } else { if ($_POST['SecondCard'] == 'NoCardSelected') { $formdetails['CardB'] = 9; } else { $formdetails['CardB'] = (int) $_POST['SecondCard']; if ($formdetails['CardB'] < 0 or $formdetails['CardB'] > 7) { die(transtext('memBadMoveData')); } } } if (!isset($_POST['MoveType'])) { $formdetails['MoveType'] = 0; } else { if ($_POST['MoveType'] == 9) { echo '<html><head><title>' . transtext('memNoMoveTypeT') . '</title></head><body>' . str_replace('\\gameid', $GAME['GameID'], transtext('memNoMoveTypeM')) . '</body></html>'; die; } else { $formdetails['MoveType'] = (int) $_POST['MoveType']; if ($formdetails['MoveType'] < 0 or $formdetails['MoveType'] > 6) { die(transtext('memBadMoveData')); } if ($GAME['HandSize'][$GAME['PlayerToMove']] == 2 and ($formdetails['MoveType'] == 1 or $formdetails['MoveType'] == 6)) { $formdetails['CardA'] = 0; $formdetails['CardB'] = 1; } } } if ($formdetails['MoveType'] == 6 and !$_POST['PassSure']) { echo '<html><head><title>' . transtext('memBoxUntickedT') . '</title><body>' . str_replace('\\gameid', $GAME['GameID'], transtext('memBoxUntickedM')) . '</body></html>'; die; } if (!isset($_POST['TileType0'])) { $TileT[0] = 9; } else { $TileT[0] = (int) $_POST['TileType0']; } if (!isset($_POST['TileType1'])) { $TileT[1] = 9; } else { $TileT[1] = (int) $_POST['TileType1']; } if (!isset($_POST['TileType2'])) { $TileT[2] = 9; } else { $TileT[2] = (int) $_POST['TileType2']; } if (!isset($_POST['TileType3'])) { $TileT[3] = 9; } else { $TileT[3] = (int) $_POST['TileType3']; } if (!isset($_POST['TileType4'])) { $TileT[4] = 9; } else { $TileT[4] = (int) $_POST['TileType4']; } if (!isset($_POST['TileType5'])) { $TileT[5] = 9; } else { $TileT[5] = (int) $_POST['TileType5']; } if (!isset($_POST['TileType6'])) { $TileT[6] = 9; } else { $TileT[6] = (int) $_POST['TileType6']; } if (!isset($_POST['TileType7'])) { $TileT[7] = 9; } else { $TileT[7] = (int) $_POST['TileType7']; } if (!isset($_POST['TileTypeY'])) { $TileTY = 9; } else { $TileTY = (int) $_POST['TileTypeY']; } if (!isset($_POST['TileType'])) { $TileTX = 9; } else { if ($_POST['TileType'] == 'StopDeveloping') { $TileTX = 9; } else { $TileTX = (int) $_POST['TileType']; if ($TileTX < 0 or $TileTX > 4) { die(transtext('memBadMoveData')); } } } if ($GAME['SecondDevelopMode']) { $formdetails['TileType'] = $TileTX; } else { if ($formdetails['MoveType'] == 3) { $formdetails['TileType'] = $TileTX; } else { if ($formdetails['MoveType'] == 1) { $formdetails['TileType'] = $TileTY; if ($formdetails['TileType'] < 0 or $formdetails['TileType'] > 4) { die(transtext('memBadMoveData')); } } else { if (!$GAME['ContinueSellingMode'] and !$GAME['SecondRailMode'] and !$GAME['DebtMode']) { if ($formdetails['CardA'] != 9) { $formdetails['TileType'] = $TileT[$formdetails['CardA']]; if ($formdetails['TileType'] < 0 or $formdetails['TileType'] > 4) { die(transtext('memBadMoveData')); } } } } } } if (!isset($_POST['IndustrySpace0'])) { $IndSp[0] = 50; } else { $IndSp[0] = (int) $_POST['IndustrySpace0']; } if (!isset($_POST['IndustrySpace1'])) { $IndSp[1] = 50; } else { $IndSp[1] = (int) $_POST['IndustrySpace1']; } if (!isset($_POST['IndustrySpace2'])) { $IndSp[2] = 50; } else { $IndSp[2] = (int) $_POST['IndustrySpace2']; } if (!isset($_POST['IndustrySpace3'])) { $IndSp[3] = 50; } else { $IndSp[3] = (int) $_POST['IndustrySpace3']; } if (!isset($_POST['IndustrySpace4'])) { $IndSp[4] = 50; } else { $IndSp[4] = (int) $_POST['IndustrySpace4']; } if (!isset($_POST['IndustrySpace5'])) { $IndSp[5] = 50; } else { $IndSp[5] = (int) $_POST['IndustrySpace5']; } if (!isset($_POST['IndustrySpace6'])) { $IndSp[6] = 50; } else { $IndSp[6] = (int) $_POST['IndustrySpace6']; } if (!isset($_POST['IndustrySpace7'])) { $IndSp[7] = 50; } else { $IndSp[7] = (int) $_POST['IndustrySpace7']; } if (!isset($_POST['IndustrySpaceY'])) { $IndSpY = 50; } else { $IndSpY = (int) $_POST['IndustrySpaceY']; } if (!isset($_POST['IndustrySpace'])) { $IndSpX = 50; if ($GAME['DebtMode']) { die(transtext('memBadMoveData')); } } else { if ($_POST['IndustrySpace'] == 'StopSelling') { $IndSpX = 50; if ($GAME['DebtMode']) { die(transtext('memBadMoveData')); } } else { $IndSpX = (int) $_POST['IndustrySpace']; if ($IndSpX < 0 or $IndSpX >= $GAME['NumIndustrySpaces']) { die(transtext('memBadMoveData')); } } } if ($GAME['DebtMode'] or $GAME['ContinueSellingMode']) { $formdetails['IndustrySpace'] = $IndSpX; } else { if ($formdetails['MoveType'] == 5) { $formdetails['IndustrySpace'] = $IndSpX; } else { if ($formdetails['MoveType'] == 1) { $formdetails['IndustrySpace'] = $IndSpY; if ($formdetails['IndustrySpace'] < 0 or $formdetails['IndustrySpace'] >= $GAME['NumIndustrySpaces']) { die(transtext('memBadMoveData')); } } else { if (!$GAME['SecondDevelopMode'] and !$GAME['SecondRailMode']) { $formdetails['IndustrySpace'] = $IndSp[$formdetails['CardA']]; if ($formdetails['IndustrySpace'] < 0 or $formdetails['IndustrySpace'] >= $GAME['NumIndustrySpaces']) { die(transtext('memBadMoveData')); } } } } } if (!isset($_POST['CoalSource'])) { $formdetails['CoalSource'] = 50; } else { if ($_POST['CoalSource'] == 'DemandTrack') { $formdetails['CoalSource'] = 50; } else { $formdetails['CoalSource'] = (int) $_POST['CoalSource']; if ($formdetails['CoalSource'] < 0 or $formdetails['CoalSource'] >= $GAME['NumIndustrySpaces']) { die(transtext('memBadMoveData')); } } } if (!isset($_POST['IronSource'])) { $formdetails['IronSource'] = 50; } else { if ($_POST['IronSource'] == 'DemandTrack') { $formdetails['IronSource'] = 50; } else { $formdetails['IronSource'] = (int) $_POST['IronSource']; if ($formdetails['IronSource'] < 0 or $formdetails['IronSource'] >= $GAME['NumIndustrySpaces']) { die(transtext('memBadMoveData')); } } } if (!isset($_POST['PortSpace'])) { $formdetails['PortSpace'] = 50; } else { if ($_POST['PortSpace'] == 'DistantMarket') { $formdetails['PortSpace'] = 50; } else { $formdetails['PortSpace'] = (int) $_POST['PortSpace']; if ($formdetails['PortSpace'] < 0 or $formdetails['PortSpace'] >= $GAME['NumIndustrySpaces']) { die(transtext('memBadMoveData')); } } } if (!isset($_POST['LoanAmount'])) { $formdetails['LoanAmount'] = 3; } else { $formdetails['LoanAmount'] = (int) $_POST['LoanAmount']; if ($formdetails['LoanAmount'] < 1 or $formdetails['LoanAmount'] > 3) { die(transtext('memBadMoveData')); } } $SystemActing = false; $PersonActing = $_SESSION['MyUserID']; $ColourMoving = $GAME['PlayerToMove']; $errorlist = moveexecute($formdetails); $SystemActing = true; if ($errorlist == '') { $didsomething = 1; while ($didsomething) { $didsomething = gamecheck(); } dbformatgamedata(); echo "<html><head><title>Move Executed</title><script type=\"text/javascript\"><!--\nfunction delayer(){\nwindow.location =\"board.php?GameID={$GAME['GameID']}\"\n}\n//-->\n</script>\n</head><body onLoad=\"setTimeout('delayer()', 2000)\">" . str_replace('\\gameid', $GAME['GameID'], transtext('moveSuccess')); if ($GAME['GameStatus'] != 'In Progress' or $GAME['PlayerToMove'] != $ColourMoving) { echo ' ' . str_replace('\\userid', $_SESSION['MyUserID'], transtext('moveAlternateLk')); // "Alternatively, click _here_" etc } echo ')<p><font color="#'; if ($GAME['GameStatus'] == 'In Progress' and $GAME['PlayerToMove'] == $ColourMoving) { echo 'FF0000"><b>' . transtext('moveStillYou'); } else { echo '00BB00"><b>'; if ($GAME['RailPhase'] and $GAME['Round'] == $GAME['NumRounds'] and !$GAME['DebtMode'] and $GAME['GameStatus'] != 'Finished') { $ReferenceTurnOrder = array_flip(str_split($GAME['TurnOrder'], 1)); if ($ReferenceTurnOrder[$ColourMoving] > $ReferenceTurnOrder[$GAME['PlayerToMove']]) { echo transtext('moveNoLongerYou'); } else { echo transtext('moveYouAreDone'); } } else { if ($GAME['GameStatus'] != 'Finished') { echo transtext('moveNoLongerYou'); } else { // This last "else" is redundant, I think, but I'll leave it as I can't be bothered to make sure of that echo transtext('moveYouAreDone'); } } } echo '</b></font></body></html>'; } else { echo '<html><head><title>' . transtext('memProblemsT') . '</title><body>' . str_replace(array('\\errorlist', '\\gameid'), array($errorlist, $GAME['GameID']), transtext('memProblemsM')) . '</body></html>'; } } else { if ($Administrator) { echo '<html><head><title>You did not select the tick box</title><body>You did not select the tick box to indicate that you want to intervene in the current player\'s turn. Click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to return to the game.</body></html>'; } else { if ($GAME['MyColour'] != 50) { die($unexpectederrormessage); } else { echo '<html><head><title>' . transtext('memNotYourGameT') . '</title><body>' . str_replace('\\gameid', $GAME['GameID'], transtext('memNotYourGameM')) . '</body></html>'; } } } }
$mypage->leaf('option', transtext('optBlinkVVSlow'), 'value=3' . $BRText[3]); $mypage->closenode(2); $mypage->next(); $mypage->leaf('td', '<input type="checkbox" name="ReverseTicker" value=1' . $CReverseTicker . '>', 'align=right'); $mypage->leaf('td', transtext('optReverseTicker')); $mypage->next(); $mypage->leaf('td', '<input type="checkbox" name="AlwaysHideMsgs" value=1' . $CAlwaysHideMsgs . '>', 'align=right'); $mypage->leaf('td', transtext('optAutoHideThrd')); $mypage->next(); $mypage->leaf('td', ''); $mypage->leaf('td', '<input type="submit" name="FormSubmit" value="Make Changes">'); ///////////////////////////////////////////////////// ///////////////////////////////////////////////////// ///////////////////////////////////////////////////// // "Miscellaneous settings" $mypage->next('style="height: 40px; vertical-align: middle;"'); $mypage->leaf('td', transtext('optShMisc'), 'colspan=2 style="font-weight: bold;"'); $mypage->next(); $mypage->leaf('td', '<input type="checkbox" name="AutoSort" value=1' . $CAutoSort . '>', 'align=right'); $mypage->leaf('td', transtext('optAutoSortCards')); $mypage->next(); $mypage->leaf('td', '<input type="checkbox" name="ReverseMessages" value=1' . $CReverseMessages . '>', 'align=right'); $mypage->leaf('td', transtext('optReverseMsgs')); $mypage->next(); $mypage->leaf('td', ''); $mypage->leaf('td', '<input type="submit" name="FormSubmit" value="Make Changes">'); $mypage->closenode(2); // tr, table $mypage->emptyleaf('input', 'type="hidden" name="TheUserID" value="' . $EscapedUserID . '"'); $mypage->closenode(); // form
function moveexecute($formdetails) { global $GAME, $SystemActing; $errorlist = ''; $MoveOn = true; if ($GAME['DebtMode']) { if ($GAME['SpaceStatus'][$formdetails['IndustrySpace']] == 9) { $errorlist .= transtext('memNoTileInSpace') . '<br>'; } else { if ($GAME['SpaceStatus'][$formdetails['IndustrySpace']] != $GAME['PlayerToMove']) { $errorlist .= transtext('memTileNotYours') . '<br>'; } else { destroytile($formdetails['IndustrySpace'], 1, 1); $GAME['MoveMade'] = 1; $GAME['MoveMadeByPlayer'][$GAME['PlayerToMove']] = 1; } } if ($GAME['Money'][$GAME['PlayerToMove']] >= 0) { for ($i = 0; $i < MAX_PLAYERS; $i++) { if ($GAME['TurnOrder'][$i] == $GAME['PlayerToMove']) { $WhereInTurnOrder = $i; } } $GAME['DebtMode'] = 0; for ($i = MAX_PLAYERS - 1; $i > $WhereInTurnOrder; $i--) { if ($GAME['PlayerExists'][$GAME['TurnOrder'][$i]] and $GAME['Money'][$GAME['TurnOrder'][$i]] < 0) { for ($j = 0; $j < $GAME['NumIndustrySpaces']; $j++) { if ($GAME['SpaceStatus'][$j] == $GAME['TurnOrder'][$i]) { $GAME['PlayerToMove'] = $GAME['TurnOrder'][$i]; $GAME['DebtMode'] = 1; break; } } } } if (!$GAME['DebtMode']) { $GAME['PlayerToMove'] = $GAME['TurnOrder'][0]; $MoveOn = false; } } } else { if ($GAME['SecondRailMode']) { if ($formdetails['LinkToBuild'] == 50) { if ($SystemActing) { $AdminTakingMove = 0; } else { if ($GAME['PlayerUserID'][$GAME['PlayerToMove']] == $_SESSION['MyUserID']) { $AdminTakingMove = 0; } else { $AdminTakingMove = 1; } } if ($AdminTakingMove) { $ResultArray = array('', '', '2E' . callmovetimediff() . letter_end_number($_SESSION['MyUserID']) . letter_end_number($_SESSION['MyGenderCode']), '|' . $_SESSION['MyUserName']); } else { $ResultArray = array('', '', 'J' . callmovetimediff(), ''); } $GAME['SecondRailMode'] = 0; } else { require_once HIDDEN_FILES_PATH . 'coalresource.php'; require_once HIDDEN_FILES_PATH . 'linkresource.php'; $AssuredCoalSource = ClosestCoal($GAME['RailStarts'][$formdetails['LinkToBuild']], $GAME['RailEnds'][$formdetails['LinkToBuild']], $formdetails['CoalSource']); $ResultArray = buildlink($formdetails['LinkToBuild'], $AssuredCoalSource, 2, 50); } if ($ResultArray[0] == '') { $GAME['AltGameTicker'] .= $ResultArray[2]; $GAME['GameTickerNames'] .= $ResultArray[3]; } else { $errorlist .= $ResultArray[0]; } } else { if ($GAME['SecondDevelopMode']) { if ($formdetails['TileType'] == 9) { if ($SystemActing) { $AdminTakingMove = 0; } else { if ($GAME['PlayerUserID'][$GAME['PlayerToMove']] == $_SESSION['MyUserID']) { $AdminTakingMove = 0; } else { $AdminTakingMove = 1; } } if ($AdminTakingMove) { $ResultArray = array('', '', '2E' . callmovetimediff() . letter_end_number($_SESSION['MyUserID']) . letter_end_number($_SESSION['MyGenderCode']), '|' . $_SESSION['MyUserName']); } else { $ResultArray = array('', '', 'J' . callmovetimediff(), ''); } $GAME['SecondDevelopMode'] = 0; } else { require_once HIDDEN_FILES_PATH . 'developresource.php'; $AssuredIronSource = GetIron($formdetails['IronSource']); $ResultArray = develop($formdetails['TileType'], $AssuredIronSource, 1, 50); } if ($ResultArray[0] == '') { $GAME['AltGameTicker'] .= $ResultArray[2]; $GAME['GameTickerNames'] .= $ResultArray[3]; } else { $errorlist .= $ResultArray[0]; } } else { if ($GAME['ContinueSellingMode']) { if ($formdetails['IndustrySpace'] == 50) { if ($SystemActing) { $AdminTakingMove = 0; } else { if ($GAME['PlayerUserID'][$GAME['PlayerToMove']] == $_SESSION['MyUserID']) { $AdminTakingMove = 0; } else { $AdminTakingMove = 1; } } if ($AdminTakingMove) { $ResultArray = array('', '', '2E' . callmovetimediff() . letter_end_number($_SESSION['MyUserID']) . letter_end_number($_SESSION['MyGenderCode']), '|' . $_SESSION['MyUserName']); } else { $ResultArray = array('', '', 'J' . callmovetimediff(), ''); } $GAME['ContinueSellingMode'] = 0; } else { require_once HIDDEN_FILES_PATH . 'cottonresource.php'; $ResultArray = sellcotton($formdetails['IndustrySpace'], $formdetails['PortSpace'], 1, 50); } if ($ResultArray[0] == '') { $GAME['AltGameTicker'] .= $ResultArray[2]; $GAME['GameTickerNames'] .= $ResultArray[3]; } else { $errorlist .= $ResultArray[0]; } } else { if ($formdetails['CardA'] == 9) { $errorlist .= 'No card selected.<br>'; } else { $CardDetailsA = $GAME['carddetailarrayb'][$GAME['Cards'][$GAME['PlayerToMove']][$formdetails['CardA']]]; if ($formdetails['CardB'] == 9) { $CardDetailsB = 50; $passcb = ''; } else { $CardDetailsB = $GAME['carddetailarrayb'][$GAME['Cards'][$GAME['PlayerToMove']][$formdetails['CardB']]]; if ($GAME['Round'] == 1 and !$GAME['RailPhase'] or $GAME['HandSize'][$GAME['PlayerToMove']] % 2) { $passcb = ''; } else { $passcb = letter_end_number($CardDetailsB); } } switch ($formdetails['MoveType']) { case 0: case 1: if ($formdetails['MoveType'] and $formdetails['CardB'] == 9) { $ResultArray = array(transtext('memNo2ndCard') . '<br>', '', ''); } else { if ($formdetails['MoveType'] and $formdetails['CardB'] == $formdetails['CardA']) { $ResultArray = array(transtext('memDuplicCard') . '<br>', '', ''); // "You have selected the same card twice. Please select two different cards." } else { if ($formdetails['IndustrySpace'] == 50 or $formdetails['TileType'] == 9) { $ResultArray = array(transtext('memBadMoveData') . '<br>', '', ''); } else { require_once HIDDEN_FILES_PATH . 'coalresource.php'; require_once HIDDEN_FILES_PATH . 'tileresource.php'; $AssuredCoalSource = ClosestCoal($formdetails['IndustrySpace'], 50, $formdetails['CoalSource']); $AssuredIronSource = GetIron($formdetails['IronSource']); $ResultArray = buildtile($formdetails['IndustrySpace'], $formdetails['TileType'], $AssuredCoalSource, $AssuredIronSource, $formdetails['CardA'], $formdetails['MoveType'], $CardDetailsA, $CardDetailsB); } } } $TwoCards = $formdetails['MoveType']; break; case 2: require_once HIDDEN_FILES_PATH . 'linkresource.php'; if ($formdetails['LinkToBuild'] == 50) { $ResultArray = array(transtext('memBadMoveData') . '<br>', '', ''); } else { if ($GAME['RailPhase']) { require_once HIDDEN_FILES_PATH . 'coalresource.php'; $AssuredCoalSource = ClosestCoal($GAME['RailStarts'][$formdetails['LinkToBuild']], $GAME['RailEnds'][$formdetails['LinkToBuild']], $formdetails['CoalSource']); $ResultArray = buildlink($formdetails['LinkToBuild'], $AssuredCoalSource, 1, $CardDetailsA); } else { $ResultArray = buildlink($formdetails['LinkToBuild'], 50, 1, $CardDetailsA); } } $TwoCards = 0; break; case 3: if ($formdetails['TileType'] == 9) { $ResultArray = array(transtext('memBadMoveData') . '<br>', '', ''); } else { require_once HIDDEN_FILES_PATH . 'developresource.php'; $AssuredIronSource = GetIron($formdetails['IronSource']); $ResultArray = develop($formdetails['TileType'], $AssuredIronSource, 0, $CardDetailsA); } $TwoCards = 0; break; case 4: $ResultArray = array('', '', ''); if ($formdetails['LoanAmount'] > 3 or $GAME['IncomeSpace'][$GAME['PlayerToMove']] - $formdetails['LoanAmount'] < 0) { $ResultArray[0] .= transtext('memLoanTooBig') . '<br>'; } if ($GAME['RailPhase'] and $GAME['NumRounds'] - $GAME['Round'] < 4) { $ResultArray[0] .= transtext('memLoanTooLate') . '<br>'; } if ($ResultArray[0] == '') { $amount = 10 * $formdetails['LoanAmount']; $GAME['Money'][$GAME['PlayerToMove']] += $amount; $reducearray = array(0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 28, 28, 30, 30, 30, 33, 33, 33, 36, 36, 36, 39, 39, 39, 42, 42, 42, 45, 45, 45, 48, 48, 48, 51, 51, 51, 54, 54, 54, 57, 57, 57, 60, 60, 60, 60, 64, 64, 64, 64, 68, 68, 68, 68, 72, 72, 72, 72, 76, 76, 76, 76, 80, 80, 80, 80, 84, 84, 84, 84, 88, 88, 88, 88, 92, 92, 92, 92, 96, 96, 96); for ($i = 0; $i < $formdetails['LoanAmount']; $i++) { $GAME['IncomeSpace'][$GAME['PlayerToMove']] = $reducearray[$GAME['IncomeSpace'][$GAME['PlayerToMove']]]; } if ($SystemActing) { $AdminTakingMove = 0; } else { if ($GAME['PlayerUserID'][$GAME['PlayerToMove']] == $_SESSION['MyUserID']) { $AdminTakingMove = 0; } else { $AdminTakingMove = 1; } } if ($AdminTakingMove) { $ResultArray[2] = '2A' . callmovetimediff() . letter_end_number($_SESSION['MyUserID']) . letter_end_number($_SESSION['MyGenderCode']) . letter_end_number($CardDetailsA) . letter_end_number($formdetails['LoanAmount']); $ResultArray[3] = '|' . $_SESSION['MyUserName']; } else { $ResultArray[2] = 'F' . callmovetimediff() . letter_end_number($CardDetailsA) . letter_end_number($formdetails['LoanAmount']); $ResultArray[3] = ''; } } $TwoCards = 0; break; case 5: if ($formdetails['IndustrySpace'] == 50) { $ResultArray = array(transtext('memBadMoveData') . '<br>', '', ''); } else { require_once HIDDEN_FILES_PATH . 'cottonresource.php'; $ResultArray = sellcotton($formdetails['IndustrySpace'], $formdetails['PortSpace'], 0, $CardDetailsA); } $TwoCards = 0; break; case 6: $ResultArray[0] = ''; if ($GAME['HandSize'][$GAME['PlayerToMove']] % 2) { $TwoCards = 0; } else { if (!$GAME['RailPhase'] and $GAME['Round'] == 1) { $TwoCards = 0; } else { $TwoCards = 1; if ($CardDetailsB == 50) { $ResultArray[0] = transtext('memNo2ndCard') . '<br>'; // No second card selected. } if ($formdetails[CardB] == $formdetails[CardA]) { $ResultArray[0] = transtext('memDuplicCard') . '<br>'; // "You have selected the same card twice. Please select two different cards." } } } if ($SystemActing) { $AdminTakingMove = 0; } else { if ($GAME['PlayerUserID'][$GAME['PlayerToMove']] == $_SESSION['MyUserID']) { $AdminTakingMove = 0; } else { $AdminTakingMove = 1; } } if ($AdminTakingMove) { $ResultArray[2] = '2C' . callmovetimediff() . letter_end_number($_SESSION['MyUserID']) . letter_end_number($_SESSION['MyGenderCode']) . letter_end_number($CardDetailsA) . $passcb; $ResultArray[3] = '|' . $_SESSION['MyUserName']; } else { $ResultArray[2] = 'H' . callmovetimediff() . letter_end_number($CardDetailsA) . $passcb; $ResultArray[3] = ''; } } if ($ResultArray[0] == '') { $GAME['AltGameTicker'] .= $ResultArray[2]; $GAME['GameTickerNames'] .= $ResultArray[3]; if ($TwoCards) { if ($formdetails['CardA'] < $formdetails['CardB']) { $formdetails['CardB']--; } } $y = $GAME['Cards'][$GAME['PlayerToMove']][$formdetails['CardA']]; for ($i = $formdetails['CardA']; $i < $GAME['HandSize'][$GAME['PlayerToMove']] - 1; $i++) { $GAME['Cards'][$GAME['PlayerToMove']][$i] = $GAME['Cards'][$GAME['PlayerToMove']][$i + 1]; } $GAME['Cards'][$GAME['PlayerToMove']][$GAME['HandSize'][$GAME['PlayerToMove']] - 1] = $y; $GAME['DiscardPile'][] = array_pop($GAME['Cards'][$GAME['PlayerToMove']]); $GAME['HandSize'][$GAME['PlayerToMove']]--; if ($TwoCards) { $y = $GAME['Cards'][$GAME['PlayerToMove']][$formdetails['CardB']]; for ($i = $formdetails['CardB']; $i < $GAME['HandSize'][$GAME['PlayerToMove']] - 1; $i++) { $GAME['Cards'][$GAME['PlayerToMove']][$i] = $GAME['Cards'][$GAME['PlayerToMove']][$i + 1]; } $GAME['Cards'][$GAME['PlayerToMove']][$GAME['HandSize'][$GAME['PlayerToMove']] - 1] = $y; $GAME['DiscardPile'][] = array_pop($GAME['Cards'][$GAME['PlayerToMove']]); $GAME['HandSize'][$GAME['PlayerToMove']]--; } } else { $errorlist .= $ResultArray[0]; } } } } } } if ($errorlist == '') { $GAME['MoveMade'] = 1; if (!$SystemActing) { if ($GAME['PlayerUserID'][$GAME['PlayerToMove']] == $_SESSION['MyUserID']) { $GAME['MoveMadeByPlayer'][$GAME['PlayerToMove']] = 1; } } else { $GAME['MoveMadeByPlayer'][$GAME['PlayerToMove']] = 1; } } if ($MoveOn and !$GAME['DebtMode'] and !$GAME['SecondRailMode'] and !$GAME['SecondDevelopMode'] and !$GAME['ContinueSellingMode'] and $errorlist == '') { if ($GAME['RailPhase'] and $GAME['HandSize'][$GAME['PlayerToMove']] == 1) { require_once HIDDEN_FILES_PATH . 'nomovesresource.php'; if (CheckNoMoves($GAME['Cards'][$GAME['PlayerToMove']][0])) { $GAME['AltGameTicker'] .= '9H' . letter_end_number($GAME['carddetailarrayb'][$GAME['Cards'][$GAME['PlayerToMove']][0]]); $GAME['DiscardPile'][] = array_pop($GAME['Cards'][$GAME['PlayerToMove']]); $GAME['HandSize'][$GAME['PlayerToMove']] = 0; } } $EvenTest = $GAME['HandSize'][$GAME['PlayerToMove']] % 2; if (!$EvenTest or !$GAME['RailPhase'] and $GAME['Round'] == 1) { if ($GAME['NumRounds'] - $GAME['Round'] > 3) { if ($GAME['RailPhase'] or $GAME['Round'] != 1) { $GAME['Cards'][$GAME['PlayerToMove']][6] = array_pop($GAME['ShuffledDeck']); $GAME['HandSize'][$GAME['PlayerToMove']]++; } $GAME['Cards'][$GAME['PlayerToMove']][7] = array_pop($GAME['ShuffledDeck']); $GAME['HandSize'][$GAME['PlayerToMove']]++; if ($GAME['AutoSort'][$GAME['PlayerToMove']]) { sort($GAME['Cards'][$GAME['PlayerToMove']]); } } for ($i = 0; $i < MAX_PLAYERS; $i++) { if ($GAME['TurnOrder'][$i] == $GAME['PlayerToMove']) { $WhereInTurnOrder = $i; } } $EndRound = true; for ($i = MAX_PLAYERS - 1; $i > $WhereInTurnOrder; $i--) { if ($GAME['PlayerExists'][$GAME['TurnOrder'][$i]]) { $GAME['PlayerToMove'] = $GAME['TurnOrder'][$i]; $EndRound = false; } } if ($EndRound) { if ($GAME['Round'] == $GAME['NumRounds']) { if ($GAME['RailPhase']) { require_once HIDDEN_FILES_PATH . 'scoringresource.php'; endgamescoring(); } else { require_once HIDDEN_FILES_PATH . 'scoringresource.php'; require_once HIDDEN_FILES_PATH . 'turnorderresource.php'; canalphasescoring(); DoTurnOrder(1); } } else { require_once HIDDEN_FILES_PATH . 'turnorderresource.php'; DoTurnOrder(1); } } if ($GAME['RailPhase'] and $GAME['Round'] == $GAME['NumRounds'] and $GAME['GameStatus'] != 'Finished') { require_once HIDDEN_FILES_PATH . 'nomovesresource.php'; CheckNoMovesShell(); } } } return $errorlist; }
function gamegetdata_lobby($GameID, $DoingWork) { global $Administrator; $GAME = dbquery(DBQUERY_READ_SINGLEROW, 'CALL "GameGetData_Lobby_DisplayOrModify"(:gameid:)', 'gameid', $GameID); $QRP = dbquery(DBQUERY_READ_RESULTSET, 'CALL "GameGetData_User_Modify"(:gameid:)', 'gameid', $GameID); if ($GAME === 'NONE') { return false; } if ($GAME['GameStatus'] == 'Cancelled' and !$Administrator) { return false; } if ($GAME['GameStatus'] != 'Recruiting' and $GAME['GameStatus'] != 'Cancelled') { return 'WRONG PAGE'; } $colournames = array(transtext('_colourRed'), transtext('_colourYellow'), transtext('_colourGreen'), transtext('_colourPurple'), transtext('_colourGrey')); $pronounmap_BasicUppercase = array('He' => transtext('^pronounHeCap'), 'She' => transtext('^pronounSheCap'), 'It' => transtext('^pronounItCap')); $pronounmap_BasicLowercase = array('He' => transtext('^pronounHe'), 'She' => transtext('^pronounShe'), 'It' => transtext('^pronounIt')); // $pronounmap_PossessiveUppercase = array( 'He' => transtext('^pronounHisPoCap'), // 'She' => transtext('^pronounHerPoCap'), // 'It' => transtext('^pronounItsPoCap') // ); // Not currently needed $pronounmap_PossessiveLowercase = array('He' => transtext('^pronounHisPo'), 'She' => transtext('^pronounHerPo'), 'It' => transtext('^pronounItsPo')); $pronounmap_IndirectObjectLowercase = array('He' => transtext('^pronounHimIO'), 'She' => transtext('^pronounHerIO'), 'It' => transtext('^pronounItIO')); $GAME['GameID'] = $GameID; $GAME['SpecialRules'] = (int) $GAME['SpecialRules']; for ($i = 0; $i < MAX_PLAYERS; $i++) { $GAME['PlayerName'][$i] = ''; $GAME['PlayerFullName'][$i] = ''; } $GAME['MyColour'] = 50; while ($row = db_fetch_assoc($QRP)) { $GAME['PlayerUserID'][$row['Colour']] = $row['UserID']; $GAME['PlayerName'][$row['Colour']] = $row['Name']; $GAME['PlayerFullName'][$row['Colour']] = $colournames[$row['Colour']] . ' (' . $row['Name'] . ')'; $GAME['Pronoun_Eng'][$row['Colour']] = $row['Pronoun']; $GAME['PlayerRating'][$row['Colour']] = $row['Rating']; $GAME['Pronoun'][$row['Colour']] = $pronounmap_BasicUppercase[$row['Pronoun']]; $GAME['PronounLC'][$row['Colour']] = $pronounmap_BasicLowercase[$row['Pronoun']]; $GAME['PossessivePronounLC'][$row['Colour']] = $pronounmap_PossessiveLowercase[$row['Pronoun']]; $GAME['OtherPronounLC'][$row['Colour']] = $pronounmap_IndirectObjectLowercase[$row['Pronoun']]; $GAME['Email'][$row['Colour']] = $row['Email']; $GAME['EmailPrompt'][$row['Colour']] = $row['EmailPrompt']; $GAME['EmailPromptAgain'][$row['Colour']] = $row['EmailPromptAgain']; $GAME['HasBeenEmailed'][$row['Colour']] = $row['HasBeenEmailed']; if ($_SESSION['LoggedIn'] and $_SESSION['MyUserID'] == $row['UserID']) { $GAME['MyColour'] = $row['Colour']; } } $GAME['TimeLimitA_Minutes'] = $GAME['TimeLimitA']; $GAME['TimeLimitB_Minutes'] = $GAME['TimeLimitB']; if ($DoingWork) { if (is_null($GAME['CardsToRemove'])) { $GAME['CardsToRemove'] = array(); } else { $GAME['CardsToRemove'] = explode('|', $GAME['CardsToRemove']); } $GAME['SpaceAlwaysExists'] = explode('|', $GAME['SpaceAlwaysExists']); $GAME['CanalAlwaysExists'] = explode('|', $GAME['CanalAlwaysExists']); $GAME['carddetailarrayb'] = explode('|', $GAME['CardDetailArrayB']); $GAME['ExternalLocations'] = explode('|', $GAME['ExternalLocations']); $GAME['NumTowns'] = count($GAME['ExternalLocations']); $GAME['NumIndustrySpaces'] = count($GAME['SpaceAlwaysExists']); $GAME['NumCanalLinks'] = count($GAME['CanalAlwaysExists']); dbquery(DBQUERY_START_TRANSACTION); } else { $GAME['VersionName'] = vname($GAME['VersionName'], $GAME['VersionNameSuffix']); if ($GAME['GTitleDeletedByAdmin']) { $GAME['GameName_Title'] = transtext('_GameTitleHidden'); if ($Administrator) { $GAME['GameName_Page'] = '<b>' . $GAME['GameName'] . '</b> (Title hidden to non-Administrators)'; } else { $GAME['GameName_Page'] = '<b>' . transtext('_GameTitleHidden') . '</b>'; } } else { $GAME['GameName_Title'] = $GAME['GameName']; $GAME['GameName_Page'] = '<b>' . $GAME['GameName'] . '</b>'; } if ($GAME['TimeLimitA'] % 1440 == 0) { $GAME['TimeLimitA'] /= 1440; if ($GAME['TimeLimitA'] == 1) { $GAME['TimeLimitAunit'] = transtext('_timeDay'); } else { $GAME['TimeLimitAunit'] = transtext('_timeDayPl'); } } else { if ($GAME['TimeLimitA'] % 60 == 0) { $GAME['TimeLimitA'] /= 60; if ($GAME['TimeLimitA'] == 1) { $GAME['TimeLimitAunit'] = transtext('_timeHour'); } else { $GAME['TimeLimitAunit'] = transtext('_timeHourPl'); } } else { $GAME['TimeLimitAunit'] = transtext('_timeMinutePl'); } } if ($GAME['TimeLimitB'] % 1440 == 0) { $GAME['TimeLimitB'] /= 1440; if ($GAME['TimeLimitB'] == 1) { $GAME['TimeLimitBunit'] = transtext('_timeDay'); } else { $GAME['TimeLimitBunit'] = transtext('_timeDayPl'); } } else { if ($GAME['TimeLimitB'] % 60 == 0) { $GAME['TimeLimitB'] /= 60; if ($GAME['TimeLimitB'] == 1) { $GAME['TimeLimitBunit'] = transtext('_timeHour'); } else { $GAME['TimeLimitBunit'] = transtext('_timeHourPl'); } } else { $GAME['TimeLimitBunit'] = transtext('_timeMinutePl'); } } } return $GAME; }
function pricelegend($x, $y) { return '<div style="position: absolute; top: ' . $y . 'px; left: ' . $x . 'px; width: 160px; border: 1px solid black"><center><table cellpadding=0 cellspacing=0 border=0><tr><td align=right><font size=2>Canal: </font></td><td><font size=2>' . moneyformat(3) . '</font></td></tr><tr><td align=right><font size=2>Rail: </font></td><td><font size=2>' . moneyformat(5) . ' + ' . transtext('Coal') . '</font></td></tr><tr><td align=right><font size=2>2 × Rail: </font></td><td><font size=2>' . moneyformat(15) . ' + 2 × ' . transtext('Coal') . '</font></td></tr></table></center></div>'; }
function loginbox($redirect_vars = null, $AlwaysShowMessage = false) { // If specified, $redirect_vars should be null or an array of redirect // variables to be included as hidden fields in the login form. (The // names of the fields will be the keys of the array, prefixed by // 'red_'.) Passing a non-array gives the same results as passing an // empty array. No sanitisation whatsoever is performed by this // function; sanitisation is the responsibility of the script calling // the function. global $Administrator, $Translator; $this->opennode('noscript'); $this->leaf('p', 'PLEASE ENABLE JAVASCRIPT', 'style="font-family: Helvetica,Tahoma,Verdana,Arial,sans-serif; font-size: 130%; font-weight: bold; text-align: center;"'); $this->closenode(); // noscript if ($_SESSION['LoggedIn']) { $this->opennode('div', 'id="loginbox" class="modularbox font_sans_serif mygame"'); $this->leaf('div', 'Generated ' . date('M-d H:i:s') . ' GMT', 'style="float: right; border: none; margin: 5px 0px; text-align: right; font-size: 75%;"'); $this->leaf('p', TEST_ENVIRONMENT_NOTICE . str_replace('\\username', $_SESSION['MyUserName'], transtext('^LoggedInAs'))); $this->opennode('ul', 'class="navlinks"'); $this->leaf('li', '<a href="usersgames.php?UserID=' . $_SESSION['MyUserID'] . '">' . transtext('^LkYourGames') . '</a>'); $this->leaf('li', '<a href="userdetails.php?UserID=' . $_SESSION['MyUserID'] . '">' . transtext('^LkUserDetails') . '</a>'); $this->leaf('li', '<a href="emails.php">Emails</a>'); if ($Administrator or $Translator) { $this->leaf('li', '<a href="translatea.php">Translation interface</a>'); } $this->leaf('li', '<a href="logout.php">' . transtext('^LkLogOut') . '</a>'); $this->leaf('li', '<a href="index.php">' . transtext('^LkMainPage') . '</a>'); $this->closenode(); } else { $this->opennode('div', 'id="loginbox" class="modularbox font_sans_serif myattn"'); $this->leaf('div', 'Generated ' . date('M-d H:i:s') . ' GMT', 'style="float: right; border: none; margin: 5px 0px; text-align: right; font-size: 75%;"'); $NotLoggedInStatement = TEST_ENVIRONMENT_NOTICE . transtext('^NotLoggedIn'); if (LOGIN_DISABLED) { $NotLoggedInStatement .= ' <b>(Login is currently disabled except for Administrators.)</b>'; } $this->leaf('p', $NotLoggedInStatement); $this->opennode('form', 'action="login.php" method="POST"'); $this->opennode('p'); $this->text('Name:'); $this->emptyleaf('input', 'type="text" name="Name" size=28 maxlength=20'); $this->text('Password:'******'input', 'type="password" name="Password" size=28 maxlength=20'); $this->emptyleaf('input', 'type="submit" value="Log in"'); $this->closenode(); // p if (is_array($redirect_vars)) { foreach ($redirect_vars as $key => $value) { $this->emptyleaf('input', 'type="hidden" name="red_' . $key . '" value="' . $value . '"'); } } $this->closenode(); // form $this->opennode('ul', 'class="navlinks"'); $this->leaf('li', '<a href="recoveraccount.php">Recover Account (Forgotten Password)</a>'); if (LOGIN_DISABLED or REGISTRATION_DISABLED) { $this->leaf('li', '<del>Register new user</del>'); $this->leaf('li', '<del>Re-send validation email</del>'); } else { $this->leaf('li', '<a href="newuser_language.php">Register new user</a>'); $this->leaf('li', '<a href="resendvalemail.php">Re-send validation email</a>'); } $this->leaf('li', '<a href="index.php">' . transtext('^LkMainPage') . '</a>'); $this->closenode(); } if (MAINTENANCE_DISABLED) { $this->leaf('p', transtext('^MaintenanceOff'), 'style="color: #FF0000; font-weight: bold;"'); } if (DISPLAY_SYSTEM_MESSAGE == 2) { $this->leaf('p', '<span style="color: #FF0000; font-weight: bold;">' . transtext('^ImportantMsg') . '</span> ' . SYSTEM_MESSAGE); } else { if (DISPLAY_SYSTEM_MESSAGE and $AlwaysShowMessage) { $this->leaf('p', '<span style="color: #FF0000; font-weight: bold;">' . transtext('^SystemMessage') . '</span> ' . SYSTEM_MESSAGE); } } $this->closenode(); }
function gamegetdata_board_do($GameID) { global $unexpectederrormessage; $GAME = dbquery(DBQUERY_READ_SINGLEROW, 'CALL "GameGetData_Game_Modify"(:gameid:)', 'gameid', $GameID); $QRP = dbquery(DBQUERY_READ_RESULTSET, 'CALL "GameGetData_User_Modify"(:gameid:)', 'gameid', $GameID); if ($GAME === 'NONE') { return false; } if ($GAME['GameStatus'] == 'Cancelled' and !$Administrator) { return false; } if ($GAME['GameStatus'] == 'Recruiting' or $GAME['GameStatus'] == 'Cancelled') { return 'WRONG PAGE'; } if ($GAME['GameIsFinished']) { return 'FINISHED'; } $colournames = array(transtext('_colourRed'), transtext('_colourYellow'), transtext('_colourGreen'), transtext('_colourPurple'), transtext('_colourGrey')); $englishcolournames = array('Red', 'Yellow', 'Green', 'Purple', 'Grey'); $pronounmap_PossessiveLowercase_Eng = array('He' => 'his', 'She' => 'her', 'It' => 'its'); $GAME['LastEventSQL'] = ''; $GAME['MoveMadeByPlayer'] = array(0, 0, 0, 0, 0); $GAME['MoveMade'] = 0; $GAME['movetimediff'] = time() - strtotime($GAME['LastEvent']); $GAME['locationnames'] = explode('|', $GAME['LocationNames']); $GAME['spacetowns'] = explode('|', $GAME['SpaceTowns']); $GAME['tileindustries'] = explode('|', $GAME['TileIndustries']); $GAME['CanalStarts'] = explode('|', $GAME['CanalStarts']); $GAME['CanalEnds'] = explode('|', $GAME['CanalEnds']); $GAME['RailStarts'] = explode('|', $GAME['RailStarts']); $GAME['RailEnds'] = explode('|', $GAME['RailEnds']); $GAME['CanalAlwaysExists'] = explode('|', $GAME['CanalAlwaysExists']); $GAME['CanalExistenceArray'] = explode('|', $GAME['CanalExistenceArray']); $GAME['RailAlwaysExists'] = explode('|', $GAME['RailAlwaysExists']); $GAME['RailExistenceArray'] = explode('|', $GAME['RailExistenceArray']); $GAME['SpaceAlwaysExists'] = explode('|', $GAME['SpaceAlwaysExists']); $GAME['SpaceExistenceArray'] = explode('|', $GAME['SpaceExistenceArray']); $GAME['carddetailarray'] = explode('|', $GAME['CardDetailArray']); $GAME['carddetailarrayb'] = explode('|', $GAME['CardDetailArrayB']); $GAME['ShuffledDeck'] = explode('|', $GAME['ShuffledDeck']); $GAME['spacenumbers'] = explode('|', $GAME['SpaceOrdinals']); $GAME['ExternalLocations'] = explode('|', $GAME['ExternalLocations']); $GAME['LocationAutoValue'] = explode('|', $GAME['LocationAutoValue']); $GAME['CoalNet'] = explode('|', $GAME['CoalNet']); $GAME['CanalExistenceArray'] = array_map('intval', $GAME['CanalExistenceArray']); $GAME['RailExistenceArray'] = array_map('intval', $GAME['RailExistenceArray']); $GAME['SpaceExistenceArray'] = array_map('intval', $GAME['SpaceExistenceArray']); $GAME['ModularBoardParts'] = (int) $GAME['ModularBoardParts']; $GAME['SpecialRules'] = (int) $GAME['SpecialRules']; $GAME['DiscardPile'] = explode('|', $GAME['DiscardPile']); if ($GAME['DiscardPile'][0] == '') { $GAME['DiscardPile'] = array(); } $GAME['NumTowns'] = count($GAME['locationnames']); $GAME['NumIndustrySpaces'] = count($GAME['spacetowns']); $GAME['NumCanalLinks'] = count($GAME['CanalStarts']); $GAME['NumRailLinks'] = count($GAME['RailStarts']); if (is_null($GAME['CardsToRemove'])) { $GAME['CardsToRemove'] = array(); } else { $GAME['CardsToRemove'] = explode('|', $GAME['CardsToRemove']); } if (is_null($GAME['VirtualConnections'])) { $GAME['GeneralisedVCs'] = array(); } else { $GAME['GeneralisedVCs'] = explode(':', $GAME['VirtualConnections']); for ($i = 0; $i < count($GAME['GeneralisedVCs']); $i++) { $GAME['GeneralisedVCs'][$i] = explode('|', $GAME['GeneralisedVCs'][$i]); } } if (is_null($GAME['TileDenyStrategicBlock'])) { $GAME['GeneralisedNoStratBlock'] = array(); } else { $GAME['GeneralisedNoStratBlock'] = explode(':', $GAME['TileDenyStrategicBlock']); for ($i = 0; $i < count($GAME['GeneralisedNoStratBlock']); $i++) { $GAME['GeneralisedNoStratBlock'][$i] = explode('|', $GAME['GeneralisedNoStratBlock'][$i]); } } if ($GAME['RailPhase']) { $LinkStarts = $GAME['RailStarts']; $LinkEnds = $GAME['RailEnds']; $NumLinks = $GAME['NumRailLinks']; } else { $LinkStarts = $GAME['CanalStarts']; $LinkEnds = $GAME['CanalEnds']; $NumLinks = $GAME['NumCanalLinks']; } if ($NumLinks % 2) { $GAME['LinkStatus'] = substr($GAME['LinkStatus'], 0, -1); } if ($GAME['NumIndustrySpaces'] % 2) { $GAME['SpaceStatus'] = substr($GAME['SpaceStatus'], 0, -1); $GAME['SpaceTile'] = substr($GAME['SpaceTile'], 0, -1); $GAME['TechLevels'] = substr($GAME['TechLevels'], 0, -1); $GAME['SpaceCubes'] = substr($GAME['SpaceCubes'], 0, -1); } $GAME['CoalInLancs'] = 0; $GAME['IronInLancs'] = 0; for ($i = 0; $i < $GAME['NumIndustrySpaces']; $i++) { if ($GAME['SpaceStatus'][$i] != 9 and $GAME['SpaceTile'][$i] == 1) { $GAME['CoalInLancs'] += $GAME['SpaceCubes'][$i]; } if ($GAME['SpaceStatus'][$i] != 9 and $GAME['SpaceTile'][$i] == 2) { $GAME['IronInLancs'] += $GAME['SpaceCubes'][$i]; } } if ($GAME['CurrentPlayers'] == 2) { $GAME['cubeprice'] = array(2, 2, 3, 3, 4, 4, 5); } else { $GAME['cubeprice'] = array(1, 1, 2, 2, 3, 3, 4, 4, 5); } $GAME['Money'] = explode('|', $GAME['Money']); $GAME['AmountSpent'] = explode('|', $GAME['AmountSpent']); $GAME['VictoryPoints'] = explode('|', $GAME['VictoryPoints']); $GAME['IncomeSpace'] = explode('|', $GAME['IncomeSpace']); $GAME['Cards'] = explode(':', $GAME['Cards']); $GAME['RemainingTiles'] = str_split($GAME['RemainingTiles'], MAX_PLAYERS); for ($i = 0; $i < 6; $i++) { $GAME['RemainingTiles'][$i] = array_map('hexdec', str_split($GAME['RemainingTiles'][$i])); } for ($i = 0; $i < MAX_PLAYERS; $i++) { $GAME['Cards'][$i] = explode('|', $GAME['Cards'][$i]); $GAME['HandSize'][$i] = count($GAME['Cards'][$i]); if ($GAME['HandSize'][$i] == 1 and $GAME['Cards'][$i][0] == '') { $GAME['Cards'][$i] = array(); $GAME['HandSize'][$i] = 0; } } if ($GAME['GameStatus'] == 'In Progress' and time() - strtotime($GAME['LastMove']) > 60 * $GAME['TimeLimitA'] and !MAINTENANCE_DISABLED) { $GAME['CanKickVote'] = 1; } else { $GAME['CanKickVote'] = 0; } switch ($GAME['SpecialModes']) { case 1: $GAME['DebtMode'] = 1; $GAME['ContinueSellingMode'] = 0; $GAME['SecondRailMode'] = 0; $GAME['SecondDevelopMode'] = 0; break; case 2: $GAME['DebtMode'] = 0; $GAME['ContinueSellingMode'] = 1; $GAME['SecondRailMode'] = 0; $GAME['SecondDevelopMode'] = 0; break; case 3: $GAME['DebtMode'] = 0; $GAME['ContinueSellingMode'] = 0; $GAME['SecondRailMode'] = 1; $GAME['SecondDevelopMode'] = 0; break; case 4: $GAME['DebtMode'] = 0; $GAME['ContinueSellingMode'] = 0; $GAME['SecondRailMode'] = 0; $GAME['SecondDevelopMode'] = 1; break; default: $GAME['DebtMode'] = 0; $GAME['ContinueSellingMode'] = 0; $GAME['SecondRailMode'] = 0; $GAME['SecondDevelopMode'] = 0; } $HasLinkedComponents = ''; for ($i = 0; $i < $GAME['NumTowns']; $i++) { $HasLinkedComponents .= '0'; } $GAME['HasBuilt'] = array(0, 0, 0, 0, 0); $GAME['HasBuiltInTown'] = array($HasLinkedComponents, $HasLinkedComponents, $HasLinkedComponents, $HasLinkedComponents, $HasLinkedComponents); $GAME['HasLinkedToTown'] = array($HasLinkedComponents, $HasLinkedComponents, $HasLinkedComponents, $HasLinkedComponents, $HasLinkedComponents); for ($i = 0; $i < $GAME['NumIndustrySpaces']; $i++) { if ($GAME['SpaceStatus'][$i] < MAX_PLAYERS) { $GAME['HasBuiltInTown'][$GAME['SpaceStatus'][$i]][$GAME['spacetowns'][$i]] = 1; $GAME['HasBuilt'][$GAME['SpaceStatus'][$i]] = 1; } } for ($i = 0; $i < $NumLinks; $i++) { if ($GAME['LinkStatus'][$i] < MAX_PLAYERS) { $GAME['HasLinkedToTown'][$GAME['LinkStatus'][$i]][$LinkStarts[$i]] = 1; $GAME['HasLinkedToTown'][$GAME['LinkStatus'][$i]][$LinkEnds[$i]] = 1; $GAME['HasBuilt'][$GAME['LinkStatus'][$i]] = 1; } } if (is_null($GAME['GameTicker']) or is_null($GAME['GameTickerNames'])) { $GAME['NarrativeTicker'] = true; } else { $GAME['NarrativeTicker'] = false; } $GAME['AltGameTicker'] = ''; $GAME['GameTickerNames'] = ''; for ($i = 0; $i < MAX_PLAYERS; $i++) { $GAME['PlayerName'][$i] = transtext('_PlayerBoxAbsent'); $GAME['PlayerFullName'][$i] = $colournames[$i] . ' (' . $GAME['PlayerName'][$i] . ')'; $GAME['PlayerName_Eng'][$i] = 'Missing'; $GAME['PlayerFullName_Eng'][$i] = $englishcolournames[$i] . ' (Missing)'; $GAME['PossessivePronounLC_Eng'][$i] = 'its'; } $GAME['MyColour'] = 50; $GAME['PlayersMissing'] = (int) $GAME['CurrentPlayers']; $GAME['PlayerMissing'] = $GAME['PlayerExists']; if ($GAME['GameStatus'] == 'In Progress' and strpos($GAME['KickVote'], '1') !== false) { $GAME['CanKickVote'] = 1; } while ($row = db_fetch_assoc($QRP)) { $GAME['PlayersMissing']--; $GAME['PlayerMissing'][$row['Colour']] = 0; $GAME['PlayerUserID'][$row['Colour']] = $row['UserID']; $GAME['PlayerName'][$row['Colour']] = $row['Name']; $GAME['PlayerFullName'][$row['Colour']] = $colournames[$row['Colour']] . ' (' . $row['Name'] . ')'; $GAME['PlayerName_Eng'][$row['Colour']] = $row['Name']; $GAME['PlayerFullName_Eng'][$row['Colour']] = $englishcolournames[$row['Colour']] . ' (' . $row['Name'] . ')'; $GAME['PossessivePronounLC_Eng'][$row['Colour']] = $pronounmap_PossessiveLowercase_Eng[$row['Pronoun']]; $GAME['Email'][$row['Colour']] = $row['Email']; $GAME['EmailPrompt'][$row['Colour']] = $row['EmailPrompt']; $GAME['EmailPromptAgain'][$row['Colour']] = $row['EmailPromptAgain']; $GAME['EmailAtEnd'][$row['Colour']] = $row['EmailAtEnd']; $GAME['HasBeenEmailed'][$row['Colour']] = $row['HasBeenEmailed']; $GAME['AutoSort'][$row['Colour']] = $row['AutoSort']; if (isset($_SESSION) and $_SESSION['LoggedIn'] and $_SESSION['MyUserID'] == $row['UserID']) { $GAME['MyColour'] = $row['Colour']; if ($GAME['AbortVote'][$row['Colour']]) { $GAME['IHaveAbortVoted'] = 1; } else { $GAME['IHaveAbortVoted'] = 0; } if ($GAME['KickVote'][$row['Colour']]) { $GAME['IHaveKickVoted'] = 1; } else { $GAME['IHaveKickVoted'] = 0; } } } $GAME['PlayerMissingAndMatters'] = $GAME['PlayerMissing']; $GAME['PlayersMissingThatMatter'] = $GAME['PlayersMissing']; for ($i = 0; $i < MAX_PLAYERS; $i++) { if ($GAME['PlayerMissing'][$i] and $GAME['RailPhase'] and $GAME['PlayerToMove'] != $i and !$GAME['HandSize'][$i]) { $GAME['PlayersMissingThatMatter']--; $GAME['PlayerMissingAndMatters'][$i] = 0; } } $GAME['PlayersVotingToAbort'] = 0; $GAME['PlayersVotingToKick'] = 0; $GAME['AbortVoteActive'] = false; $GAME['KickVoteActive'] = false; for ($i = 0; $i < MAX_PLAYERS; $i++) { if ($GAME['PlayerMissing'][$i] or $GAME['AbortVote'][$i]) { $GAME['PlayersVotingToAbort']++; } if ($GAME['PlayerMissing'][$i] or $GAME['KickVote'][$i]) { $GAME['PlayersVotingToKick']++; } if ($GAME['AbortVote'][$i]) { $GAME['AbortVoteActive'] = true; } if ($GAME['KickVote'][$i]) { $GAME['KickVoteActive'] = true; } } $GAME['ReplacementOffers'] = array(); $GAME['ReplacementOffers_Users'] = array(); $GAME['ReplacementOffers_Colours'] = array(); if ($GAME['PlayersMissingThatMatter']) { $QRR = dbquery(DBQUERY_READ_RESULTSET, 'CALL "GameGetData_GetReplacements"(:game:)', 'game', $GameID); if ($QRR === 'NONE') { $GAME['NumReplacementOffers'] = 0; } else { $GAME['NumReplacementOffers'] = mysqli_num_rows($QRR); while ($row = db_fetch_assoc($QRR)) { $GAME['ReplacementOffers'][] = array($row['User'], $row['Name'], $row['Colour'], $row['ToCount']); $GAME['ReplacementOffers_Users'][] = $row['User']; $GAME['ReplacementOffers_Colours'][] = $row['Colour']; } } } if ($GAME['CanKickVote']) { $GAME['PlayerToMoveForLongTurns'] = $GAME['PlayerUserID'][$GAME['PlayerToMove']]; } else { $GAME['PlayerToMoveForLongTurns'] = 0; } $GAME['TechLevelArray'] = array(array(9, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1), array(9, 4, 4, 3, 3, 2, 2, 1), array(9, 4, 3, 2, 1), array(9, 4, 4, 3, 3, 2, 2, 1, 1), array(9, 2, 2, 1, 1, 0, 0)); $GAME['incomeamounts'] = array(-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 25, 25, 25, 25, 26, 26, 26, 26, 27, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30); $GAME['TileVPValue'] = array(array(3, 5, 9, 12), array(1, 2, 3, 4), array(3, 5, 7, 9), array(2, 4, 6, 9), array(10, 18)); $GAME['TileIncomeValue'] = array(array(5, 4, 3, 2), array(4, 7, 6, 5), array(3, 3, 2, 1), array(3, 3, 4, 4), array(2, 1)); $GAME['TileInitialCubes'] = array(array(2, 3, 4, 5), array(4, 4, 5, 6)); $GAME['TileCosts'] = array(array(12, 14, 16, 18), array(5, 7, 8, 10), array(5, 7, 9, 12), array(6, 7, 8, 9), array(16, 25)); $GAME['TileRequireCoal'] = array(array(0, 1, 1, 1), array(0, 0, 0, 0), array(1, 1, 1, 1), array(0, 0, 0, 0), array(1, 1)); $GAME['TileRequireIron'] = array(array(0, 0, 1, 1), array(0, 0, 1, 1), array(0, 0, 0, 0), array(0, 0, 0, 0), array(1, 1)); dbquery(DBQUERY_START_TRANSACTION); return $GAME; }
function develop($tiletype, $ironsource, $continuing, $thecard) { global $GAME, $SystemActing; $errorlist = ''; if (!$GAME['RemainingTiles'][$tiletype][$GAME['PlayerToMove']]) { $errorlist = transtext('memOutOfTiles') . '<br>'; // "You have run out of industry tiles of the chosen type." } if ($ironsource == 50 and $GAME['Money'][$GAME['PlayerToMove']] < $GAME['cubeprice'][$GAME['IronDemand']]) { $errorlist = transtext('memDevPoor') . '<br>'; // "You cannot develop, as you cannot afford the iron cube." } switch ($ironsource) { case 90: $errorlist .= transtext('memIronNotValid') . '<br>'; break; // "The selected source of iron is not valid." // "The selected source of iron is not valid." case 91: $errorlist .= transtext('memIronOnBoard') . '<br>'; break; // "You cannot buy iron from the Demand Track, // as there is iron available on the board for you to use." } if ($ironsource == 50) { $altironsource = 99; } else { $altironsource = $ironsource; } if ($errorlist == '') { $GAME['RemainingTiles'][$tiletype][$GAME['PlayerToMove']]--; if ($ironsource == 50) { $GAME['Money'][$GAME['PlayerToMove']] -= $GAME['cubeprice'][$GAME['IronDemand']]; $GAME['AmountSpent'][$GAME['PlayerToMove']] += $GAME['cubeprice'][$GAME['IronDemand']]; if ($GAME['CurrentPlayers'] == 2 and $GAME['IronDemand'] < 6 or $GAME['CurrentPlayers'] > 2 and $GAME['IronDemand'] < 8) { $GAME['IronDemand']++; } } else { $GAME['IronInLancs']--; $GAME['SpaceCubes'][$ironsource] = $GAME['SpaceCubes'][$ironsource] - 1; // This is written in this way because SpaceCubes is a string consisting of digits // (it is not legal to use increment/decrement operators on string offsets). if (!$GAME['SpaceCubes'][$ironsource]) { fliptile($ironsource); } } if ($SystemActing) { $AdminTakingMove = 0; } else { if ($GAME['PlayerUserID'][$GAME['PlayerToMove']] == $_SESSION['MyUserID']) { $AdminTakingMove = 0; } else { $AdminTakingMove = 1; } } if ($continuing) { if ($AdminTakingMove) { $altgoodoutput = '2D' . callmovetimediff() . letter_end_number($_SESSION['MyUserID']) . letter_end_number($_SESSION['MyGenderCode']) . letter_end_number($tiletype) . letter_end_number($altironsource); $altgoodoutputName = '|' . $_SESSION['MyUserName']; } else { $altgoodoutput = 'I' . callmovetimediff() . letter_end_number($tiletype) . letter_end_number($altironsource); $altgoodoutputName = ''; } $GAME['SecondDevelopMode'] = 0; } else { if ($AdminTakingMove) { $altgoodoutput = '1J' . callmovetimediff() . letter_end_number($_SESSION['MyUserID']) . letter_end_number($_SESSION['MyGenderCode']) . letter_end_number($thecard) . letter_end_number($tiletype) . letter_end_number($altironsource); $altgoodoutputName = '|' . $_SESSION['MyUserName']; } else { $altgoodoutput = 'E' . callmovetimediff() . letter_end_number($thecard) . letter_end_number($tiletype) . letter_end_number($altironsource); $altgoodoutputName = ''; } if ($GAME['RemainingTiles'][0][$GAME['PlayerToMove']] or $GAME['RemainingTiles'][1][$GAME['PlayerToMove']] or $GAME['RemainingTiles'][2][$GAME['PlayerToMove']] or $GAME['RemainingTiles'][3][$GAME['PlayerToMove']] or $GAME['RemainingTiles'][4][$GAME['PlayerToMove']]) { $CanGetIronFree = false; for ($i = 0; $i < $GAME['NumIndustrySpaces']; $i++) { if ($GAME['SpaceStatus'] != 9 and $GAME['SpaceTile'][$i] == 2 and $GAME['SpaceCubes'][$i]) { $CanGetIronFree = true; } } if (!$CanGetIronFree and $GAME['Money'][$GAME['PlayerToMove']] < $GAME['cubeprice'][$GAME['IronDemand']]) { $altgoodoutput .= '9IA'; } else { $GAME['SecondDevelopMode'] = 1; } } else { $altgoodoutput .= '9IB'; } } } else { $altgoodoutput = ''; $altgoodoutputName = ''; } return array($errorlist, '', $altgoodoutput, $altgoodoutputName); }
function gamelistdisplayx(tagtree &$tt) { if ($_SESSION['LoggedIn']) { $Query = 'CALL "ListGamesNeedingReplacements_LoggedIn"(:me:)'; $me = $_SESSION['MyUserID']; } else { $Query = 'CALL "ListGamesNeedingReplacements_LoggedOut"()'; $me = 0; } $QueryResult = dbquery(DBQUERY_READ_RESULTSET, $Query, 'me', $me); if ($QueryResult === 'NONE') { $tt->leaf('p', 'None'); return; } $tt->opennode('table', 'class="table_extra_horizontal_padding"'); $tt->opennode('thead'); $tt->opennode('tr'); $tt->leaf('th', 'Name', 'colspan=2 style="width: 270px;"'); $tt->leaf('th', 'Creator'); $tt->leaf('th', 'Friendly?'); $tt->leaf('th', 'Found?', 'title="Has at least one candidate replacement been found for the seat that is unfilled?"'); $tt->leaf('th', 'Original', 'title="The number of players the game had when it started."'); $tt->leaf('th', 'Current', 'title="The number of players (as in seats, whether filled or unfilled) the game has at present."'); $tt->leaf('th', '<a href="http://orderofthehammer.com/credits.htm#acronyms">TLA</a>', 'style="min-width: 36px;" title=""Time Limit A" - click the link for more information."'); $tt->leaf('th', '<a href="http://orderofthehammer.com/credits.htm#acronyms">TLB</a>', 'style="min-width: 36px;" title=""Time Limit B" - click the link for more information."'); $tt->leaf('th', 'Round', 'style="width: 46px;"'); $tt->leaf('th', 'Talk Rules', 'style="min-width: 100px;"'); $tt->closenode(2); // tr, thead $tt->opennode('tbody'); $RoundColumnStyles = array('gamelist_roundcol_c', 'gamelist_roundcol_r'); $OldGameID = 0; while ($row = db_fetch_assoc($QueryResult)) { if ($row['GameID'] != $OldGameID) { $OldGameID = $row['GameID']; if ($row['GTitleDeletedByAdmin']) { $row['GameName'] = 'The title of this game has been cleared by an Administrator'; } $RowTagAttributes = null; if ($_SESSION['LoggedIn']) { $GameCreatorColumn = '<a href="userdetails.php?UserID=' . $row['GameCreator'] . '">' . $row['GameCreatorName'] . '</a>'; if (!is_null($row['User'])) { if (!is_null($row['Colour'])) { $RowTagAttributes = 'class="mymove"'; } else { if ($row['AbortVote'] == '00000' and $row['KickVote'] == '00000') { $RowTagAttributes = 'class="mygame"'; } else { $RowTagAttributes = 'class="myattn"'; } } } } else { $GameCreatorColumn = $row['GameCreatorName']; } if ($row['TimeLimitA'] <= 1080) { $TLACellAttributes = 'class="alert"'; } else { if ($row['TimeLimitA'] <= 1800) { $TLACellAttributes = 'style="font-weight: bold;"'; } else { $TLACellAttributes = null; } } if ($row['TimeLimitB'] <= 2160) { $TLBCellAttributes = 'class="alert"'; } else { if ($row['TimeLimitB'] <= 3600) { $TLBCellAttributes = 'style="font-weight: bold;"'; } else { $TLBCellAttributes = null; } } $tt->opennode('tr', $RowTagAttributes); $version_name = vname($row['VersionName'], $row['VersionNameSuffix']); $tt->leaf('td', '<img src="gfx/icon-' . strtolower($row['ShortVersionName']) . '.png" alt="' . $version_name . '" title="' . $version_name . ' (' . $row['Creators'] . ')">', 'width=23 style="border-right: none;"'); $tt->leaf('td', '<a href="board.php?GameID=' . $row['GameID'] . '">' . $row['GameName'] . '</a>', 'style="border-left: none; padding-left: 0px; text-align: left;"'); $tt->leaf('td', $GameCreatorColumn); if ($row['Friendly']) { $tt->leaf('td', transtext('^Yes'), 'bgcolor="#9FFF9F"'); } else { $tt->leaf('td', transtext('^No'), 'bgcolor="#FFC18A"'); } if (is_null($row['Colour'])) { $tt->leaf('td', transtext('^No'), 'bgcolor="#FFC18A"'); } else { $tt->leaf('td', transtext('^Yes'), 'bgcolor="#9FFF9F"'); } $tt->leaf('td', $row['OriginalPlayers']); $tt->leaf('td', $row['CurrentPlayers']); $tt->leaf('td', minutes_mhd($row['TimeLimitA']), $TLACellAttributes); $tt->leaf('td', minutes_mhd($row['TimeLimitB']), $TLBCellAttributes); $tt->leaf('td', ($row['Round'] >= 10 ? '' : ' ') . $row['Round'] . ' / ' . $row['NumRounds'], 'class="' . $RoundColumnStyles[$row['RailPhase']] . '"'); $tt->leaf('td', $row['TalkRules']); $tt->closenode(); } } $tt->closenode(2); // tbody, table }
} $mypage->closenode(); } else { $mypage->leaf('h3', $PStatementHeader); $mypage->leaf('div', '(Personal statement is in an unexpected format!)', 'class="modularbox font_sans_serif" style="background-color: #FFCF9F; text-align: center;"'); } } ///////////////////////////////////////////////////// ///////////////////////////////////////////////////// ///////////////////////////////////////////////////// $mypage->leaf('h3', transtext('_ugInProgress')); gamelistdisplayup($mypage, $EscapedUserID, $therow['Name']); if ($therow['PublicWatch'] or $Administrator or $_SESSION['MyUserID'] == $EscapedUserID) { $WatchedGamesHeader = transtext('_ugWatching'); if (!$therow['PublicWatch']) { $WatchedGamesHeader .= $_SESSION['MyUserID'] == $EscapedUserID ? ' <span style="font-weight: normal;">' . transtext('_ugPrivWatchlist') . '</span>' : ' <span style="font-weight: normal;">(This list has been made invisible to non-admins)</span>'; } $mypage->leaf('h3', $WatchedGamesHeader); gamelistdisplayuw($mypage, $EscapedUserID, 1); } $mypage->leaf('h3', transtext('_ugRR')); gamelistdisplayux($mypage, $EscapedUserID, $therow['Name']); $mypage->leaf('h3', transtext('_ugRecruiting')); gamelistdisplayur($mypage, $EscapedUserID, $therow['Name']); $mypage->leaf('h3', transtext('_ugFinished')); gamelistdisplayuf($mypage, $EscapedUserID, $therow['Name'], $lowercasepronoun, true, 0, 20, null); if ($_SESSION['MyUserID'] == $EscapedUserID) { require HIDDEN_FILES_PATH . 'udform.php'; } $mypage->leaf('p', 'Click <a href="index.php">here</a> to return to the Main Page.'); $mypage->finish();
} if ($SpaceStatus[$i] == $TilesToShow) { $ArrowInclusion[$i] = '<div id="Pointer' . $NumUnflipped . '" style="background: transparent url(gfx/arrows' . $BlinkRate . '.gif) ' . $colouroffset . 'px 0px no-repeat; position: absolute; top: ' . $YLocn . 'px; left: ' . $XLocn . 'px; z-index: 7; width: 38px; height: 42px; display: none"></div>'; $NumUnflipped++; } else { $ArrowInclusion[$i] = '<div id="PointerX' . $NumUnflippedX . '" style="background: transparent url(gfx/arrows' . $BlinkRate . '.gif) ' . $colouroffset . 'px 0px no-repeat; position: absolute; top: ' . $YLocn . 'px; left: ' . $XLocn . 'px; z-index: 7; width: 38px; height: 42px; display: none"></div>'; $NumUnflippedX++; } } } if ($NumUnflipped and !$NumUnflippedX) { $HTBox = '<p><input type="checkbox" name="HighlightTiles" onClick="ToggleShowTiles();"> ' . $BoxText . ' <i>(' . $UnluckyText . ')</i>'; $HTScript = 'var DisplayTiles = 0; function ToggleShowTiles() { DisplayTiles = 1 - DisplayTiles; if ( DisplayTiles ) { for (i=0;i<' . $NumUnflipped . ';i++) { document.getElementById(\'Pointer\'+i).style.display = \'block\'; } } else { for (i=0;i<' . $NumUnflipped . ';i++) { document.getElementById(\'Pointer\'+i).style.display = \'none\'; } } }'; } else { if ($NumUnflipped) { $HTBox = '<p><input type="checkbox" id="HighlightTiles" name="HighlightTiles" value="1" onClick="DisplayTiles = 1 - DisplayTiles; ToggleShowTiles();"> ' . $BoxText . ' <input type="checkbox" id="HighlightAllTiles" name="HighlightAllTiles" value="1" onClick="DisplayAllTiles = 1 - DisplayAllTiles; ToggleShowTiles();"> ' . transtext('bpArrowsAll'); $HTScript = 'var DisplayTiles = 0; var DisplayAllTiles = 0; function ToggleShowTiles() { if ( DisplayTiles || DisplayAllTiles ) { for (i=0;i<' . $NumUnflipped . ';i++) { document.getElementById(\'Pointer\'+i).style.display = \'block\'; } } else { for (i=0;i<' . $NumUnflipped . ';i++) { document.getElementById(\'Pointer\'+i).style.display = \'none\'; } } if ( DisplayAllTiles ) { for (i=0;i<' . $NumUnflippedX . ';i++) { document.getElementById(\'PointerX\'+i).style.display = \'block\'; } } else { for (i=0;i<' . $NumUnflippedX . ';i++) { document.getElementById(\'PointerX\'+i).style.display = \'none\'; } } }'; } else { if ($NumUnflippedX) { $HTBox = '<p><input type="checkbox" name="HighlightAllTiles" onClick="ToggleShowTiles();"> ' . transtext('bpArrowsAll') . ' <i>(' . $LuckyText . ')</i>'; $HTScript = 'var DisplayTiles = 0; function ToggleShowTiles() { DisplayTiles = 1 - DisplayTiles; if ( DisplayTiles ) { for (i=0;i<' . $NumUnflippedX . ';i++) { document.getElementById(\'PointerX\'+i).style.display = \'block\'; } } else { for (i=0;i<' . $NumUnflippedX . ';i++) { document.getElementById(\'PointerX\'+i).style.display = \'none\'; } } }'; } else { $HTBox = ''; $HTScript = ''; } } } } else { $HTBox = ''; $HTScript = ''; }