function DoTask() { global $GAME; if ($GAME['GameStatus'] != 'In Progress' and $GAME['GameStatus'] != 'Recruiting Replacement' or !$GAME['PlayersMissingThatMatter']) { $mypage = page::standard(); $mypage->title_body('No replacements needed'); $mypage->leaf('p', 'No replacement players are needed for this game at the moment. (Perhaps something happened after you loaded the board page.) Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.'); $mypage->finish(); } $mycol = dbquery(DBQUERY_READ_SINGLEROW, 'SELECT "Colour" FROM "ReplacementOffer" WHERE "Game" = :game: AND "User" = :user:'******'game', $GAME['GameID'], 'user', $_SESSION['MyUserID']); if ($mycol === 'NONE') { $mypage = page::standard(); $mypage->title_body('Not currently a candidate replacement'); $mypage->leaf('p', 'You are not currently a candidate replacement. You might be seeing this message because you clicked the button twice. Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.'); $mypage->finish(); } dbquery(DBQUERY_WRITE, 'DELETE FROM "ReplacementOffer" WHERE "Game" = :game: AND "User" = :user:'******'game', $GAME['GameID'], 'user', $_SESSION['MyUserID']); if ($mycol['Colour'] == $GAME['PlayerToMove']) { $GAME['AltGameTicker'] .= '8F' . callmovetimediff() . letter_end_number($_SESSION['MyUserID']) . letter_end_number($_SESSION['MyGenderCode']); $GAME['GameTickerNames'] .= '|' . $_SESSION['MyUserName']; dbformatgamedata(); } else { dbquery(DBQUERY_COMMIT); } page::redirect(3, 'board.php?GameID=' . $GAME['GameID'], 'Successfully withdrew request.'); }
function DoTask() { global $Administrator, $GAME; if (!$Administrator) { $mypage = page::standard(); $mypage->title_body('Not authorised'); $mypage->leaf('p', 'You are not authorised to make use of this page. Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.'); $mypage->finish(); } $thenumber = sanitise_int(@$_POST['thenumber']); if ($thenumber < -9 or $thenumber > 99 or $thenumber == 0) { $mypage = page::standard(); $mypage->title_body('Invalid input'); $mypage->leaf('p', 'Expected a nonzero integer between -9 and 99 inclusive, but received ' . $thenumber . '. Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.'); $mypage->finish(); } $interval = sanitise_enum(@$_POST['theinterval'], array('MINUTE', 'HOUR', 'DAY')); if (@$_POST['whattime'] == 'now') { $whattime = 'UTC_TIMESTAMP()'; } else { $whattime = '"LastMove"'; } $time_expr = 'TIMESTAMPADD(' . $interval . ', :thenumber:, ' . $whattime . ')'; dbquery(DBQUERY_WRITE, 'UPDATE "Game" JOIN "GameInProgress" ON "Game"."GameID" = "GameInProgress"."Game" SET "Game"."LastMove" = ' . $time_expr . ', "GameInProgress"."GIPLastMove" = ' . $time_expr . ' "Game"."GameTicker" = CONCAT("Game"."GameTicker", :tickerconcat:), "Game"."GameTickerNames" = CONCAT("Game"."GameTickerNames", :namesconcat:) WHERE "GameID" = :game:', 'thenumber', $thenumber, 'tickerconcat', '3A' . callmovetimediff() . letter_end_number($_SESSION['MyUserID']) . letter_end_number($_SESSION['MyGenderCode']), 'namesconcat', '|' . $_SESSION['MyUserName'], 'game', $GAME['GameID']); dbquery(DBQUERY_COMMIT); page::redirect(3, 'board.php?GameID=' . $GAME['GameID'], 'Successfully altered clock.'); }
function DoTask() { global $Administrator, $GAME, $unexpectederrormessage; if ($GAME['GameStatus'] != 'Recruiting Replacement') { $mypage = page::standard(); $mypage->title_body('Current player is not missing'); $mypage->leaf('p', 'The current player is not missing. (Perhaps somebody accepted a replacement player after you had loaded the board page.) Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.'); $mypage->finish(); } if ($GAME['MyColour'] == 50) { $mypage = page::standard(); $mypage->title_body('Not playing in this game'); $mypage->leaf('p', 'You are not currently playing in this game, so you cannot choose replacement players. Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.'); $mypage->finish(); } $ReplacementValid = false; for ($i = 0; $i < count($GAME['ReplacementOffers']); $i++) { if ($GAME['ReplacementOffers'][$i][2] == $GAME['PlayerToMove'] and $GAME['ReplacementOffers'][$i][0] == @$_POST['whotoaccept']) { $ReplacementValid = $i; } } if ($ReplacementValid === false) { $mypage = page::standard(); $mypage->title_body('User ID not found among replacements'); $mypage->leaf('p', 'The submitted user ID was not found among the candidate replacements. (Perhaps the user withdrew his request after you had loaded the board page.) Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.'); $mypage->finish(); } $QR = dbquery(DBQUERY_READ_SINGLEROW, 'SELECT "Name", "Pronoun", "Email", "EmailPrompt" FROM "User" WHERE "UserID" = :user:'******'user', $GAME['ReplacementOffers'][$ReplacementValid][0]); if ($QR === 'NONE') { myerror($unexpectederrormessage, 'Candidate replacements list contains invalid user'); } switch ($QR['Pronoun']) { case 'He': $RepPronoun = 'A'; break; case 'She': $RepPronoun = 'B'; break; default: $RepPronoun = 'C'; break; } $GAME['AltGameTicker'] .= '8E' . callmovetimediff() . letter_end_number($GAME['ReplacementOffers'][$ReplacementValid][0]) . $RepPronoun . letter_end_number($GAME['MyColour']); $GAME['GameTickerNames'] .= '|' . $GAME['ReplacementOffers'][$ReplacementValid][1]; $GAME['PlayerName'][$GAME['PlayerToMove']] = $QR['Name']; $GAME['KickVote'] = '00000'; $GAME['GameStatus'] = 'In Progress'; $GAME['MoveMade'] = 1; dbquery(DBQUERY_WRITE, 'DELETE FROM "ReplacementOffer" WHERE "Game" = :game: AND "Colour" = :colour:', 'game', $GAME['GameID'], 'colour', $GAME['PlayerToMove']); dbquery(DBQUERY_WRITE, 'INSERT INTO "PlayerGameRcd" ("User", "Game", "GameResult", "Inherited", "GameCounts", "Colour", "NumLongTurns", "CurrentOccupant") VALUES (:user:, :game:, \'Playing\', 1, :counts:, :colour:, 0, 0)', 'user', $GAME['ReplacementOffers'][$ReplacementValid][0], 'game', $GAME['GameID'], 'counts', $GAME['ReplacementOffers'][$ReplacementValid][3], 'colour', $GAME['PlayerToMove']); dbformatgamedata(); if ($QR['EmailPrompt'] and $QR['Email'] != '') { $subject = 'Your request to join game number ' . $GAME['GameID'] . ' has been accepted'; $body = '<p>This is an automated message. One of the players in game number ' . $GAME['GameID'] . ' has accepted your request to join the game as a replacement player. This means that it is now your turn to move; please visit the game\'s page and take your turn. Here is the URL of the game page:</p><p><a href="' . SITE_ADDRESS . 'board.php?GameID=' . $GAME['GameID'] . '">' . SITE_ADDRESS . 'board.php?GameID=' . $GAME['GameID'] . '</a></p>' . EMAIL_FOOTER; send_email($subject, $body, $QR['Email'], null); } page::redirect(3, 'board.php?GameID=' . $GAME['GameID'], 'Successfully accepted replacement.'); }
function DoTask() { global $Administrator, $GAME, $unexpectederrormessage; if (!$Administrator) { $mypage = page::standard(); $mypage->title_body('Not authorised'); $mypage->leaf('p', 'You are not authorised to make use of this page. Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.'); $mypage->finish(); } $EscapedComment = sanitise_str(@$_POST['AdminComment'], STR_GPC | STR_STRIP_TAB_AND_NEWLINE); $EscapedComment = str_replace(array('|', '"'), array('', ''), $EscapedComment); $EscapedComment = htmlspecialchars($EscapedComment); if ($EscapedComment == '') { $mypage = page::standard(); $mypage->title_body('Comment is missing'); $mypage->leaf('p', 'The coment you entered is missing. Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.'); $mypage->finish(); } dbquery(DBQUERY_WRITE, 'UPDATE "Game" SET "GameTicker" = CONCAT("GameTicker", :tickerconcat:), "GameTickerNames" = CONCAT("GameTickerNames", :namesconcat:) WHERE "GameID" = :game:', 'tickerconcat', '3B' . callmovetimediff() . letter_end_number($_SESSION['MyUserID']) . letter_end_number($_SESSION['MyGenderCode']), 'namesconcat', '|' . $_SESSION['MyUserName'] . '|' . $EscapedComment, 'game', $GAME['GameID']); dbquery(DBQUERY_COMMIT); page::redirect(3, 'board.php?GameID=' . $GAME['GameID'], 'Successfully added comment.'); }
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 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 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 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); }
function DoTask() { global $Banned, $GAME; if (@$_POST['Counts']) { $ToCount = 1; } else { $ToCount = 0; } if ($GAME['RailPhase']) { $ToCount = 0; } $ChosenColour = sanitise_int(@$_POST['colourtoreplace'], SANITISE_NO_FLAGS, 0, MAX_PLAYERS - 1); $PostFailureTitle = false; do { if (!$GAME['PlayersMissing']) { $PostFailureTitle = 'No missing players'; $PostFailureMessage = 'There aren\'t any players missing from this game at the moment. (Perhaps something happened after you loaded the board page.) Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.'; break; } if ($GAME['GameStatus'] != 'In Progress' and $GAME['GameStatus'] != 'Recruiting Replacement' or !$GAME['PlayersMissingThatMatter']) { $PostFailureTitle = 'No replacements needed'; $PostFailureMessage = 'No replacement players are needed for this game at the moment. (Perhaps something happened after you loaded the board page.) Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.'; break; } if (!$GAME['PlayerMissingAndMatters'][$ChosenColour]) { $PostFailureTitle = 'Cannot join as selected colour'; $PostFailureMessage = 'You cannot join this game as the selected colour. (Perhaps something happened after you loaded the board page.) Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.'; break; } if ($GAME['MyColour'] != 50) { $PostFailureTitle = 'Already playing in this game'; $PostFailureMessage = 'You cannot join this game as a replacement, because you are already playing in it. Please click <a href="board.php?GameID=' . $GAME['GameID'] . '">here</a> to go to the board page, or <a href="index.php">here</a> to return to the Main Page.'; break; } if ($Banned) { $PostFailureTitle = 'Banned'; $PostFailureMessage = 'You cannot join this game as a replacement, because you are banned. Please click <a href="lobby.php?GameID=' . $GAME['GameID'] . '">here</a> to return to the lobby page, or <a href="index.php">here</a> to return to the Main Page.'; break; } if (in_array($_SESSION['MyUserID'], $GAME['ReplacementOffers_Users'])) { $PostFailureTitle = 'Request already received'; $PostFailureMessage = 'You have already made a request to join this game. You might be seeing this message because you clicked the button twice. Please click <a href="lobby.php?GameID=' . $GAME['GameID'] . '">here</a> to return to the lobby page, or <a href="index.php">here</a> to return to the Main Page.'; break; } if (dbquery(DBQUERY_READ_RESULTSET, 'SELECT "User" FROM "PlayerGameRcd" WHERE "User" = :user: AND "Game" = :game:', 'user', $_SESSION['MyUserID'], 'game', $GAME['GameID']) !== 'NONE') { $PostFailureTitle = 'You have previously played in this game'; $PostFailureMessage = 'You have previously played in this game. It is not possible to re-join the game. Please click <a href="lobby.php?GameID=' . $GAME['GameID'] . '">here</a> to return to the lobby page, or <a href="index.php">here</a> to return to the Main Page.'; break; } } while (false); if ($PostFailureTitle !== false) { $mypage = page::standard(); $mypage->title_body($PostFailureTitle); $mypage->leaf('p', $PostFailureMessage); $mypage->finish(); } dbquery(DBQUERY_WRITE, 'INSERT INTO "ReplacementOffer" ("Game", "User", "Colour", "ToCount") VALUES (:game:, :user:, :colour:, :tocount:)', 'game', $GAME['GameID'], 'user', $_SESSION['MyUserID'], 'colour', $ChosenColour, 'tocount', $ToCount); if ($ChosenColour == $GAME['PlayerToMove']) { $GAME['AltGameTicker'] .= '8A' . callmovetimediff() . letter_end_number($_SESSION['MyUserID']) . letter_end_number($_SESSION['MyGenderCode']); $GAME['GameTickerNames'] .= '|' . $_SESSION['MyUserName']; dbformatgamedata(); for ($i = 0; $i < MAX_PLAYERS; $i++) { if ($GAME['PlayerExists'][$i] == 1 and !$GAME['PlayerMissing'][$i] and $GAME['EmailPrompt'][$i] and $GAME['Email'][$i] != '') { $subject = $_SESSION['MyUserName'] . ' wants to join game number ' . $GAME['GameID'] . ' as a replacement'; $body = '<p>This is an automated message. ' . $_SESSION['MyUserName'] . ' has asked to join game number ' . $GAME['GameID'] . ' as a replacement. As you are playing in this game, you can choose to accept this request. Here is the URL of the game page:</p><p><a href="' . SITE_ADDRESS . 'board.php?GameID=' . $GAME['GameID'] . '">' . SITE_ADDRESS . 'board.php?GameID=' . $GAME['GameID'] . '</a></p>' . EMAIL_FOOTER; send_email($subject, $body, $GAME['Email'][$i], null); } } } else { dbformatgamedata(); } page::redirect(3, 'board.php?GameID=' . $GAME['GameID'], 'Successfully requested to join.'); }
function downsizegame($downsizetype) { global $GAME; $GAME['MoveMade'] = 1; $GAME['KickVote'] = '00000'; $GAME['SecondRailMode'] = 0; $GAME['SecondDevelopMode'] = 0; $GAME['ContinueSellingMode'] = 0; if ($GAME['GameStatus'] == 'In Progress') { if (KickPlayer($GAME['PlayerToMove'], 3)) { return; } // If KickPlayer aborts the game then it will return true. // We don't want any shenanigans going on after a game is aborted. } $GAME['PlayersMissing']--; $GAME['PlayerMissing'][$GAME['PlayerToMove']] = 0; $GAME['PlayersMissingThatMatter']--; $GAME['PlayerMissingAndMatters'][$GAME['PlayerToMove']] = 0; dbquery(DBQUERY_WRITE, 'DELETE FROM "ReplacementOffer" WHERE "Game" = :game: AND "Colour" = :colour:', 'game', $GAME['GameID'], 'colour', $GAME['PlayerToMove']); $GAME['GameStatus'] = 'In Progress'; if ($downsizetype) { $GAME['AltGameTicker'] .= '7A' . callmovetimediff(); } else { $GAME['AltGameTicker'] .= '7B' . callmovetimediff(); } $GAME['PlayerExists'][$GAME['PlayerToMove']] = 0; for ($i = 0; $i < $GAME['NumIndustrySpaces']; $i++) { if ($GAME['SpaceStatus'][$i] == $GAME['PlayerToMove']) { $GAME['SpaceStatus'][$i] = 8; } } for ($i = 0; $i < $GAME['RailPhase'] * $GAME['NumRailLinks'] + (1 - $GAME['RailPhase']) * $GAME['NumCanalLinks']; $i++) { if ($GAME['LinkStatus'][$i] == $GAME['PlayerToMove']) { $GAME['LinkStatus'][$i] = 8; } } switch ($GAME['CurrentPlayers']) { case 4: if ($GAME['Round'] < 3) { $GAME['NumRounds'] = 10; } else { if ($GAME['Round'] == 3) { $GAME['NumRounds'] = 9; } } if (!$GAME['RailPhase'] or $GAME['Round'] < 4) { $GAME['EffectiveNumPlayers'] = 3; } $GAME['ShuffledDeck'] = array_reverse($GAME['ShuffledDeck']); if (count($GAME['ShuffledDeck']) == 1 and $GAME['ShuffledDeck'][0] === '') { $GAME['ShuffledDeck'] = array(); } shuffle($GAME['Cards'][$GAME['PlayerToMove']]); for ($i = 0; $i < $GAME['HandSize'][$GAME['PlayerToMove']]; $i++) { $GAME['ShuffledDeck'][] = array_pop($GAME['Cards'][$GAME['PlayerToMove']]); } $GAME['ShuffledDeck'] = array_reverse($GAME['ShuffledDeck']); $GAME['AltGameTicker'] .= 'AAA9J'; break; case 3: // At present, it is not permitted for games to be downsized from 3 players to 2 players. // This function should not be called when CurrentPlayers is equal to 3; it will stop script execution with an error message. die('Programming error: Downsize function called when number of players is 3. Please contact Administrator and give details of how you obtained this error message.'); break; case 2: for ($i = 0; $i < MAX_PLAYERS; $i++) { if ($GAME['PlayerExists'][$i]) { $TheLastPlayer = $i; } } if ($GAME['RailPhase'] and $GAME['NumRounds'] - $GAME['Round'] < 2) { require_once HIDDEN_FILES_PATH . 'scoringresource.php'; endgamescoring(); } else { $GAME['GameStatus'] = 'Finished'; require_once HIDDEN_FILES_PATH . 'createpgr.php'; CreatePGR(0, 0, -1, 0, $TheLastPlayer); } $GAME['AltGameTicker'] .= 'AAA9J'; break; } $GAME['CurrentPlayers']--; if ($GAME['CurrentPlayers'] > 1) { for ($i = 0; $i < MAX_PLAYERS; $i++) { if ($GAME['TurnOrder'][$i] == $GAME['PlayerToMove']) { $WhereInTurnOrder = $i; } } for ($i = $WhereInTurnOrder; $i < MAX_PLAYERS - 1; $i++) { $GAME['TurnOrder'][$i] = $GAME['TurnOrder'][$i + 1]; } $GAME['TurnOrder'][MAX_PLAYERS - 1] = $GAME['PlayerToMove']; if ($GAME['DebtMode']) { $SomeoneInDebt = 9; for ($i = 0; $i < MAX_PLAYERS; $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]) { $SomeoneInDebt = $GAME['TurnOrder'][$i]; break 2; } } } } if ($SomeoneInDebt == 9) { $GAME['DebtMode'] = 0; $GAME['PlayerToMove'] = $GAME['TurnOrder'][0]; } else { $GAME['PlayerToMove'] = $SomeoneInDebt; } } else { $EndRound = true; for ($i = MAX_PLAYERS - 2; $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(); } } }
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; }