function preliminaryUpdates($getPage_connection2) { $limit_allUnits = 0; if ($stmt = $getPage_connection2->prepare("SELECT COUNT(id) FROM unitsmap")) { $stmt->execute(); $stmt->bind_result($r_result); $stmt->fetch(); $limit_allUnits = $r_result; $stmt->close(); } else { $endTurnFailed = "failed"; } // else $limit_allTiles = 0; if ($stmt = $getPage_connection2->prepare("SELECT COUNT(id) FROM tilesmap")) { $stmt->execute(); $stmt->bind_result($r_result); $stmt->fetch(); $limit_allTiles = $r_result; $stmt->close(); } else { $endTurnFailed = "failed"; } // else $limit_allOffers = 0; if ($stmt = $getPage_connection2->prepare("SELECT COUNT(id) FROM offers")) { $stmt->execute(); $stmt->bind_result($r_result); $stmt->fetch(); $limit_allOffers = $r_result; $stmt->close(); } else { $endTurnFailed = "failed"; } // else // Illegal Conflicts and Table Cleanup // removed declined offers and empty or invalid offers and offers which have reached the turn limit if ($limit_allOffers >= 1) { if ($stmt = $getPage_connection2->prepare("SELECT id FROM offers ORDER BY id ASC")) { $stmt->execute(); $stmt->store_result(); $stmt->bind_result($r_result); while ($stmt->fetch()) { $next_offers = $r_result; $offerInfo1 = array("id" => 0, "fromNation" => 0, "toNation" => 0, "givingItems" => "", "receivingItems" => "", "turns" => 0, "counter" => 0, "status" => 0); if ($stmt10 = $getPage_connection2->prepare("SELECT id,fromNation,toNation,givingItems,receivingItems,turns,counter,status FROM offers WHERE id=? LIMIT 1")) { $stmt10->bind_param("i", $next_offers); $stmt10->execute(); $stmt10->bind_result($r_id, $r_fromNation, $r_toNation, $r_givingItems, $r_receivingItems, $r_turns, $r_counter, $r_status); $stmt10->fetch(); $offerInfo1["id"] = $r_id; $offerInfo1["fromNation"] = $r_fromNation; $offerInfo1["toNation"] = $r_toNation; if (stripos($r_givingItems, ",")) { $offerInfo1["givingItems"] = explode(",", $r_givingItems); } else { $offerInfo1["givingItems"] = array(0 => $r_givingItems); } // else if (stripos($r_receivingItems, ",")) { $offerInfo1["receivingItems"] = explode(",", $r_receivingItems); } else { $offerInfo1["receivingItems"] = array(0 => $r_receivingItems); } // else $offerInfo1["turns"] = $r_turns; $offerInfo1["counter"] = $r_counter; $offerInfo1["status"] = $r_status; $stmt10->close(); } else { } if ($offerInfo1["status"] == 2 || $offerInfo1["givingItems"][0] < 1 && $offerInfo1["receivingItems"][0] < 1 || $offerInfo1["toNation"] < 1 && $offerInfo1["fromNation"] < 1) { deleteOfferInfo($getPage_connection2, $next_offers); } // if if ($offerInfo1["counter"] == $offerInfo1["turns"]) { deleteOfferInfo($getPage_connection2, $next_offers); } // if } // while $stmt->close(); } else { } // else } // if // search through all units and look for illegally placed, dead, invalid level, or striking units remove them // also reset used movement if ($limit_allUnits >= 1) { if ($stmt = $getPage_connection2->prepare("SELECT id FROM unitsmap ORDER BY id ASC")) { $stmt->execute(); $stmt->store_result(); $stmt->bind_result($r_result); while ($stmt->fetch()) { $next_units = $r_result; $illegal = false; $unitInfoW = getUnitInfoByID($getPage_connection2, $next_units); $unitTypeInfoW = getUnitTypeInfo($getPage_connection2, $unitInfoW["type"]); $tileInfoW = getTileInfo($getPage_connection2, $unitInfoW["continent"], $unitInfoW["xpos"], $unitInfoW["ypos"]); $coastal = isItCoast($getPage_connection2, $tileInfoW); // reset used movement setUnitInfo($getPage_connection2, $unitInfoW["id"], $unitInfoW["continent"], $unitInfoW["xpos"], $unitInfoW["ypos"], $unitInfoW["health"], 0, $unitInfoW["name"], $unitInfoW["type"], $unitInfoW["owner"], $unitInfoW["level"], $unitInfoW["transport"], $unitInfoW["created"], 0.0); // land unit if ($unitTypeInfoW["water"] != 1 && $tileInfoW["terrain"] == 2) { $illegal = true; // water unit } else { if ($unitTypeInfoW["water"] == 1 && $tileInfoW["terrain"] != 2 && $coastal === false) { $illegal = true; } else { $illegal = false; } } // else if ($unitInfoW["health"] < 1 || $unitInfoW["level"] < 1) { $illegal = true; } else { $illegal = false; } // else $nationInfoA = getNationInfo($getPage_connection2, $unitInfoW["owner"]); if ($nationInfoA["strike"] > 1) { $new_strike = $nationInfoA["strike"] - 1; $illegal = true; } else { $new_strike = $nationInfoA["strike"]; } // else if ($illegal === true) { deleteUnitInfo($getPage_connection2, $next_units); setNationInfo($getPage_connection2, $nationInfoA["id"], $nationInfoA["name"], $nationInfoA["home"], $nationInfoA["formal"], $nationInfoA["flag"], $nationInfoA["production"], $nationInfoA["money"], $nationInfoA["debt"], $nationInfoA["happiness"], $nationInfoA["food"], $nationInfoA["authority"], $nationInfoA["authorityChanged"], $nationInfoA["economy"], $nationInfoA["economyChanged"], $nationInfoA["organizations"], $nationInfoA["invites"], $nationInfoA["goods"], $nationInfoA["resources"], $nationInfoA["population"], $new_strike); } // if } // while $stmt->close(); } else { } // else } // if if ($limit_allTiles >= 1) { // search through all tiles and look for illegally placed improvements or dead or invalid level improvements and remove them if ($stmt = $getPage_connection2->prepare("SELECT id FROM tilesmap ORDER BY id ASC")) { $stmt->execute(); $stmt->store_result(); $stmt->bind_result($r_result); while ($stmt->fetch()) { $next_tiles = $r_result; $tileInfoW = getTileInfoByID($getPage_connection2, $next_tiles); for ($w = 0; $w < count($tileInfoW["improvements"]); $w++) { $illegal = false; $improvementInfoW = getImprovementInfo($getPage_connection2, $tileInfoW["improvements"][$w]); $improvementTypeInfoW = getImprovementTypeInfo($getPage_connection2, $improvementInfoW["type"]); $resourceCheck = array(0 => true); // are any resources actually required if (count($improvementTypeInfoW["resourcesRequired"]) > 1) { if ($improvementTypeInfoW["resourcesRequired"][1] > 0) { $validResourcesRequired = true; } else { $validResourcesRequired = false; } // else } else { if ($improvementTypeInfoW["resourcesRequired"][0] > 0) { $validResourcesRequired = true; } else { $validResourcesRequired = false; } // else } // else if ($validResourcesRequired === true) { for ($a = 0; $a < count($improvementTypeInfoW["resourcesRequired"]); $a++) { for ($b = 0; $b < count($tileInfoW["resources"]); $b++) { $resourceCheck[$a] = false; $resourceInfoWW = getResourceInfo($getPage_connection2, $tileInfoW["resources"][$b]); if ($resourceInfoWW["type"] == $improvementTypeInfoW["resourcesRequired"][$a]) { $resourceCheck[$a] = true; break; } // if } // for } // for for ($a = 0; $a < count($improvementTypeInfoW["resourcesRequired"]); $a++) { if ($resourceCheck[$a] === false) { $illegal = true; break; } // if } // for } // if $terrainCheck = false; for ($a = 0; $a < count($improvementTypeInfoW["terrainTypeRequired"]); $a++) { if ($tileInfoW["terrain"] == $improvementTypeInfoW["terrainTypeRequired"][$a]) { $terrainCheck = true; break; } // if } // for if ($terrainCheck === false) { $illegal = true; } // if if ($improvementInfoW["level"] < 1) { $illegal = true; } // if if ($illegal === true) { deleteImprovementInfo($getPage_connection2, $improvementInfoW["id"], $improvementInfoW["continent"], $improvementInfoW["xpos"], $improvementInfoW["ypos"]); } // if } // for } // while $stmt->close(); } else { } // else // setup new claims and change control if needed if ($stmt = $getPage_connection2->prepare("SELECT id FROM tilesmap ORDER BY id ASC")) { $stmt->execute(); $stmt->store_result(); $stmt->bind_result($r_result); while ($stmt->fetch()) { $next_tiles1 = $r_result; $tileInfoW = getTileInfoByID($getPage_connection2, $next_tiles1); $unitInfoW = getUnitInfo($getPage_connection2, $tileInfoW["continent"], $tileInfoW["xpos"], $tileInfoW["ypos"]); $alreadyClaimed = false; if ($unitInfoW["id"] >= 1) { // remove improvement ownership from old player who lost tile control if ($unitInfoW["owner"] != $tileInfoW["owner"]) { for ($r = 0; $r < count($tileInfoW["improvements"]); $r++) { $improvementInfoW = getImprovementInfo($getPage_connection2, $tileInfoW["improvements"][$r]); if ($improvementInfoW["id"] >= 1) { $new_owners = array(0 => 0); $alreadyOwned = false; $counter = 0; for ($s = 0; $s < count($improvementInfoW["owners"]); $s++) { if ($improvementInfoW["owners"][$s] != $tileInfoW["owner"]) { $new_owners[$counter] = $improvementInfoW["owners"][$s]; $counter++; } // if if ($improvementInfoW["owners"][$s] == $unitInfoW["owner"]) { $alreadyOwned = true; } // if } // for if ($alreadyOwned === false) { $new_index = count($new_owners) + 1; $new_owners[$new_index] = $unitInfoW["owner"]; } // if setImprovementInfo($getPage_connection2, $improvementInfoW["id"], $improvementInfoW["continent"], $improvementInfoW["xpos"], $improvementInfoW["ypos"], $improvementInfoW["type"], $improvementInfoW["level"], $improvementInfoW["usingResources"], $new_owners, $improvementInfoW["name"]); } // if } // for } // if setTileInfo($getPage_connection2, $tileInfoW["id"], $tileInfoW["continent"], $tileInfoW["xpos"], $tileInfoW["ypos"], $tileInfoW["terrain"], $tileInfoW["resources"], $tileInfoW["improvements"], $unitInfoW["owner"], $tileInfoW["claims"], $tileInfoW["population"]); for ($v = 0; $v < count($tileInfoW["claims"]); $v++) { $claimsInfoW = getClaimInfo($getPage_connection2, $tileInfoW["claims"][$v]); if ($claimsInfoW["owner"] == $unitInfoW["owner"]) { $alreadyClaimed = true; break; } // if } // for if ($alreadyClaimed === false) { addClaimInfo($getPage_connection2, 10, $unitInfoW["owner"], $tileInfoW["id"]); } // if // Claims leaking for dominant bordering tiles // check for dominant claimed tiles $claimState1 = checkClaimsState($getPage_connection2, $tileInfoW, $tileInfoW["owner"]); // if dominant, bleed claim to neighbouring tiles if ($claimState1 == 1) { // add to left if ($tileInfoW["xpos"] > 1) { // West $tileInfoT = getTileInfo($getPage_connection2, $tileInfoW["continent"], $tileInfoW["xpos"] - 1, $tileInfoW["ypos"]); $claimStateT = checkClaimsState($getPage_connection2, $tileInfoT, $tileInfoW["owner"]); if ($claimStateT != 1 && $claimStateT > 1 && $tileInfoT["owner"] > 0) { $claimFound = false; for ($j = 0; $j < count($tileInfoT["claims"]); $j++) { $claimInfoT = getClaimInfo($getPage_connection2, $tileInfoT["claims"][$j]); if ($claimInfoT["owner"] == $tileInfoW["owner"]) { setClaimInfo($getPage_connection2, $claimInfoT["id"], $claimInfoT["strength"] + 3, $claimInfoT["owner"]); $claimFound = true; break; } // if } // for if ($claimFound === false) { addClaimInfo($getPage_connection2, 3, $tileInfoW["owner"], $tileInfoT["id"]); } // if } // if if ($tileInfoW["ypos"] > 1) { // Northwest $tileInfoT = getTileInfo($getPage_connection2, $tileInfoW["continent"], $tileInfoW["xpos"] - 1, $tileInfoW["ypos"] - 1); $claimStateT = checkClaimsState($getPage_connection2, $tileInfoT, $tileInfoW["owner"]); if ($claimStateT != 1 && $claimStateT > 1 && $tileInfoT["owner"] > 0) { $claimFound = false; for ($j = 0; $j < count($tileInfoT["claims"]); $j++) { $claimInfoT = getClaimInfo($getPage_connection2, $tileInfoT["claims"][$j]); if ($claimInfoT["owner"] == $tileInfoW["owner"]) { setClaimInfo($getPage_connection2, $claimInfoT["id"], $claimInfoT["strength"] + 3, $claimInfoT["owner"]); $claimFound = true; break; } // if } // for if ($claimFound === false) { addClaimInfo($getPage_connection2, 3, $tileInfoT["owner"], $tileInfoT["id"]); } // if } // if } // if if ($tileInfoW["ypos"] < 20) { // Southwest $tileInfoT = getTileInfo($getPage_connection2, $tileInfoW["continent"], $tileInfoW["xpos"] - 1, $tileInfoW["ypos"] + 1); $claimStateT = checkClaimsState($getPage_connection2, $tileInfoT, $tileInfoW["owner"]); if ($claimStateT != 1 && $claimStateT > 1 && $tileInfoT["owner"] > 0) { $claimFound = false; for ($j = 0; $j < count($tileInfoT["claims"]); $j++) { $claimInfoT = getClaimInfo($getPage_connection2, $tileInfoT["claims"][$j]); if ($claimInfoT["owner"] == $tileInfoW["owner"]) { setClaimInfo($getPage_connection2, $claimInfoT["id"], $claimInfoT["strength"] + 3, $claimInfoT["owner"]); $claimFound = true; break; } // if } // for if ($claimFound === false) { addClaimInfo($getPage_connection2, 3, $tileInfoT["owner"], $tileInfoT["id"]); } // if } // if } // if } // if // add to right if ($tileInfoW["xpos"] < 20) { // East $tileInfoT = getTileInfo($getPage_connection2, $tileInfoW["continent"], $tileInfoW["xpos"] + 1, $tileInfoW["ypos"]); $claimStateT = checkClaimsState($getPage_connection2, $tileInfoT, $tileInfoW["owner"]); if ($claimStateT != 1 && $claimStateT > 1 && $tileInfoT["owner"] > 0) { $claimFound = false; for ($j = 0; $j < count($tileInfoT["claims"]); $j++) { $claimInfoT = getClaimInfo($getPage_connection2, $tileInfoT["claims"][$j]); if ($claimInfoT["owner"] == $tileInfoW["owner"]) { setClaimInfo($getPage_connection2, $claimInfoT["id"], $claimInfoT["strength"] + 3, $claimInfoT["owner"]); $claimFound = true; break; } // if } // for if ($claimFound === false) { addClaimInfo($getPage_connection2, 3, $tileInfoW["owner"], $tileInfoT["id"]); } // if } // if if ($tileInfoW["ypos"] > 1) { // Northeast $tileInfoT = getTileInfo($getPage_connection2, $tileInfoW["continent"], $tileInfoW["xpos"] + 1, $tileInfoW["ypos"] - 1); $claimStateT = checkClaimsState($getPage_connection2, $tileInfoT, $tileInfoW["owner"]); if ($claimStateT != 1 && $claimStateT > 1 && $tileInfoT["owner"] > 0) { $claimFound = false; for ($j = 0; $j < count($tileInfoT["claims"]); $j++) { $claimInfoT = getClaimInfo($getPage_connection2, $tileInfoT["claims"][$j]); if ($claimInfoT["owner"] == $tileInfoW["owner"]) { setClaimInfo($getPage_connection2, $claimInfoT["id"], $claimInfoT["strength"] + 3, $claimInfoT["owner"]); $claimFound = true; break; } // if } // for if ($claimFound === false) { addClaimInfo($getPage_connection2, 3, $tileInfoW["owner"], $tileInfoT["id"]); } // if } // if } // if if ($tileInfoW["ypos"] < 20) { // Southeast $tileInfoT = getTileInfo($getPage_connection2, $tileInfoW["continent"], $tileInfoW["xpos"] + 1, $tileInfoW["ypos"] + 1); $claimStateT = checkClaimsState($getPage_connection2, $tileInfoT, $tileInfoW["owner"]); if ($claimStateT != 1 && $claimStateT > 1 && $tileInfoT["owner"] > 0) { $claimFound = false; for ($j = 0; $j < count($tileInfoT["claims"]); $j++) { $claimInfoT = getClaimInfo($getPage_connection2, $tileInfoT["claims"][$j]); if ($claimInfoT["owner"] == $tileInfoW["owner"]) { setClaimInfo($getPage_connection2, $claimInfoT["id"], $claimInfoT["strength"] + 3, $claimInfoT["owner"]); $claimFound = true; break; } // if } // for if ($claimFound === false) { addClaimInfo($getPage_connection2, 3, $tileInfoW["owner"], $tileInfoT["id"]); } // if } // if } // if } // if if ($tileInfoW["ypos"] > 1) { // North $tileInfoT = getTileInfo($getPage_connection2, $tileInfoW["continent"], $tileInfoW["xpos"], $tileInfoW["ypos"] - 1); $claimStateT = checkClaimsState($getPage_connection2, $tileInfoT, $tileInfoW["owner"]); if ($claimStateT != 1 && $claimStateT > 1 && $tileInfoT["owner"] > 0) { $claimFound = false; for ($j = 0; $j < count($tileInfoT["claims"]); $j++) { $claimInfoT = getClaimInfo($getPage_connection2, $tileInfoT["claims"][$j]); if ($claimInfoT["owner"] == $tileInfoW["owner"]) { setClaimInfo($getPage_connection2, $claimInfoT["id"], $claimInfoT["strength"] + 3, $claimInfoT["owner"]); $claimFound = true; break; } // if } // for if ($claimFound === false) { addClaimInfo($getPage_connection2, 3, $tileInfoW["owner"], $tileInfoT["id"]); } // if } // if } // if if ($tileInfoW["ypos"] < 20) { // South $tileInfoT = getTileInfo($getPage_connection2, $tileInfoW["continent"], $tileInfoW["xpos"], $tileInfoW["ypos"] + 1); $claimStateT = checkClaimsState($getPage_connection2, $tileInfoT, $tileInfoW["owner"]); if ($claimStateT != 1 && $claimStateT > 1 && $tileInfoT["owner"] > 0) { $claimFound = false; for ($j = 0; $j < count($tileInfoT["claims"]); $j++) { $claimInfoT = getClaimInfo($getPage_connection2, $tileInfoT["claims"][$j]); if ($claimInfoT["owner"] == $tileInfoW["owner"]) { setClaimInfo($getPage_connection2, $claimInfoT["id"], $claimInfoT["strength"] + 3, $claimInfoT["owner"]); $claimFound = true; break; } // if } // for if ($claimFound === false) { addClaimInfo($getPage_connection2, 3, $tileInfoW["owner"], $tileInfoT["id"]); } // if } // if } // if } // if } // if } // while $stmt->close(); } else { } // else } // if // Update claims strengths $limit_allClaims = 0; if ($stmt = $getPage_connection2->prepare("SELECT COUNT(id) FROM claims")) { $stmt->execute(); $stmt->bind_result($r_result); $stmt->fetch(); $limit_allClaims = $r_result; $stmt->close(); } else { $endTurnFailed = "failed"; } // else if ($limit_allClaims >= 1) { if ($stmt = $getPage_connection2->prepare("SELECT id FROM claims ORDER BY id ASC")) { $stmt->execute(); $stmt->store_result(); $stmt->bind_result($r_result); while ($stmt->fetch()) { $next_claims = $r_result; $claimInfoW = getClaimInfo($getPage_connection2, $next_claims); $nationInfoC = getNationInfo($getPage_connection2, $claimInfoW["owner"]); // start removing claim strength if the strike is still going on above 3 if ($nationInfoC["strike"] > 3) { if ($claimInfoW["strength"] - 10 >= 0) { $new_strength = $claimInfoW["strength"] - 10; } else { $new_strength = 0; } // else $new_strike = $nationInfoC["strike"] - 1; setNationInfo($getPage_connection2, $nationInfoC["id"], $nationInfoC["name"], $nationInfoC["home"], $nationInfoC["formal"], $nationInfoC["flag"], $nationInfoC["production"], $nationInfoC["money"], $nationInfoC["debt"], $nationInfoC["happiness"], $nationInfoC["food"], $nationInfoC["authority"], $nationInfoC["authorityChanged"], $nationInfoC["economy"], $nationInfoC["economyChanged"], $nationInfoC["organizations"], $nationInfoC["invites"], $nationInfoC["goods"], $nationInfoC["resources"], $nationInfoC["population"], $new_strike); } else { if ($claimInfoW["strength"] + 5 <= 1000) { $new_strength = $claimInfoW["strength"] + 5; } else { $new_strength = 1000; } // else } // else setClaimInfo($getPage_connection2, $next_claims, $new_strength, $claimInfoW["owner"]); } // while $stmt->close(); } else { } // else } // if }
function resetWorld($getPage_connection3) { if ($_SESSION["admin"] == 1) { if (strlen($_SESSION["action"]) >= 1) { if ($_SESSION["action"] == "reset_world") { if ($stmt = $getPage_connection3->prepare("TRUNCATE TABLE agreements")) { $stmt->execute(); $stmt->close(); } else { } // else if ($stmt = $getPage_connection3->prepare("TRUNCATE TABLE claims")) { $stmt->execute(); $stmt->close(); } else { } // else if ($stmt = $getPage_connection3->prepare("TRUNCATE TABLE combatlog")) { $stmt->execute(); $stmt->close(); } else { } // else if ($stmt = $getPage_connection3->prepare("TRUNCATE TABLE continents")) { $stmt->execute(); $stmt->close(); } else { } // else if ($stmt = $getPage_connection3->prepare("TRUNCATE TABLE improvementsmap")) { $stmt->execute(); $stmt->close(); } else { } // else if ($stmt = $getPage_connection3->prepare("TRUNCATE TABLE nations")) { $stmt->execute(); $stmt->close(); } else { } // else if ($stmt = $getPage_connection3->prepare("TRUNCATE TABLE offers")) { $stmt->execute(); $stmt->close(); } else { } // else if ($stmt = $getPage_connection3->prepare("TRUNCATE TABLE organizations")) { $stmt->execute(); $stmt->close(); } else { } // else if ($stmt = $getPage_connection3->prepare("TRUNCATE TABLE production")) { $stmt->execute(); $stmt->close(); } else { } // else if ($stmt = $getPage_connection3->prepare("TRUNCATE TABLE rankings")) { $stmt->execute(); $stmt->close(); } else { } // else if ($stmt = $getPage_connection3->prepare("TRUNCATE TABLE resourcesmap")) { $stmt->execute(); $stmt->close(); } else { } // else if ($stmt = $getPage_connection3->prepare("TRUNCATE TABLE tilesmap")) { $stmt->execute(); $stmt->close(); } else { } // else if ($stmt = $getPage_connection3->prepare("TRUNCATE TABLE trade")) { $stmt->execute(); $stmt->close(); } else { } // else if ($stmt = $getPage_connection3->prepare("TRUNCATE TABLE transport")) { $stmt->execute(); $stmt->close(); } else { } // else if ($stmt = $getPage_connection3->prepare("TRUNCATE TABLE unitsmap")) { $stmt->execute(); $stmt->close(); } else { } // else if ($stmt = $getPage_connection3->prepare("TRUNCATE TABLE users")) { $stmt->execute(); $stmt->close(); } else { } // else if ($stmt = $getPage_connection3->prepare("TRUNCATE TABLE mapmemory")) { $stmt->execute(); $stmt->close(); } else { } // else if ($stmt = $getPage_connection3->prepare("SELECT id FROM market ORDER BY id ASC")) { $stmt->execute(); $stmt->store_result(); $stmt->bind_result($r_id); while ($stmt->fetch()) { $next_markets = $r_id; $marketInfo1 = getMarketInfo($getPage_connection3, $next_markets); setMarketInfo($getPage_connection3, $next_markets, $marketInfo1["name"], 100); } // while $stmt->close(); } else { } // else resetSession(false); // Create Admin Account, starter continent $new_salt = ""; $new_username = "******"; $new_avatar = "images/users/avatar.png"; $allowed_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $chars_length = 63; for ($i = 0; $i < 51; $i++) { $new_salt .= $allowed_chars[mt_rand(0, $chars_length)]; } // for $new_date = date("Y-m-d H:i:s"); $new_token = mt_rand(1000, 9999); $new_thread = mt_rand(100, 999); $final_salt = '$2y$09$' . $new_salt . '$'; $created_password = crypt("qwertyuiop" . $new_salt, $final_salt); addUserInfo($getPage_connection3, $new_username, $new_avatar, $new_date, $new_date, $created_password, $new_salt, $new_token, $new_thread, 1); $new_userid = $getPage_connection3->insert_id; $new_name = "Administrator"; $new_formal = "Administrator"; addProductionInfo($getPage_connection3, $new_userid, 100, array(0 => 2, 1 => 2, 2 => 2, 3 => 2, 4 => 2, 5 => 2, 6 => 2, 7 => 2), array(0 => 2, 1 => 2, 2 => 2, 3 => 2, 4 => 2, 5 => 2, 6 => 2, 7 => 2)); addRankingInfo($getPage_connection3, $new_userid, 999, 999, 999, 999, 999); $new_routes = array(0 => 0); $new_worth = array(0 => 0); $new_offers = array(0 => 0); addTradeInfo($getPage_connection3, $new_userid, $new_routes, 0); $capitalBuilt = false; $availableTiles = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0); $finalTiles = array(0 => 0, 1 => 0); $availableContinent = 0; if ($stmt = $getPage_connection3->prepare("SELECT id FROM continents ORDER BY id ASC")) { $stmt->execute(); $stmt->store_result(); $stmt->bind_result($r_id); while ($stmt->fetch()) { $next_continents = $r_id; $availableTiles = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0); $next_tiles = 1; $counter1 = 0; if ($stmt2 = $getPage_connection3->prepare("SELECT id FROM tilesmap ORDER BY id ASC")) { $stmt2->execute(); $stmt2->store_result(); $stmt2->bind_result($r_id1); while ($stmt2->fetch()) { $next_tiles = $r_id1; $tileInfoD = getTileInfoByID($getPage_connection3, $next_tiles); if ($tileInfoD["continent"] == $next_continents && $tileInfoD["owner"] == 0 && $tileInfoD["terrain"] != 2) { $tileInfoDWest = getTileInfo($getPage_connection3, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"]); $tileInfoDNorthWest = getTileInfo($getPage_connection3, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"] - 1); $tileInfoDNorth = getTileInfo($getPage_connection3, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"] - 1); $tileInfoDNorthEast = getTileInfo($getPage_connection3, $tileInfoD["continent"], $tileInfoD["xpos"] + 1, $tileInfoD["ypos"] - 1); $tileInfoDEast = getTileInfo($getPage_connection3, $tileInfoD["continent"], $tileInfoD["xpos"] + 1, $tileInfoD["ypos"]); $tileInfoDSouthEast = getTileInfo($getPage_connection3, $tileInfoD["continent"], $tileInfoD["xpos"] + 1, $tileInfoD["ypos"] + 1); $tileInfoDSouth = getTileInfo($getPage_connection3, $tileInfoD["continent"], $tileInfoD["xpos"], $tileInfoD["ypos"] + 1); $tileInfoDSouthWest = getTileInfo($getPage_connection3, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"] + 1); if ($tileInfoDWest["continent"] == $next_continents && $tileInfoDWest["owner"] == 0 && $tileInfoDWest["terrain"] != 2 || $tileInfoDNorthWest["continent"] == $next_continents && $tileInfoDNorthWest["owner"] == 0 && $tileInfoDNorthWest["terrain"] != 2 || $tileInfoDNorth["continent"] == $next_continents && $tileInfoDNorth["owner"] == 0 && $tileInfoDNorth["terrain"] != 2 || $tileInfoDNorthEast["continent"] == $next_continents && $tileInfoDNorthEast["owner"] == 0 && $tileInfoDNorthEast["terrain"] != 2 || $tileInfoDEast["continent"] == $next_continents && $tileInfoDEast["owner"] == 0 && $tileInfoDEast["terrain"] != 2 || $tileInfoDSouthEast["continent"] == $next_continents && $tileInfoDSouthEast["owner"] == 0 && $tileInfoDSouthEast["terrain"] != 2 || $tileInfoDSouth["continent"] == $next_continents && $tileInfoDSouth["owner"] == 0 && $tileInfoDSouth["terrain"] != 2 || $tileInfoDSouthWest["continent"] == $next_continents && $tileInfoDSouthWest["owner"] == 0 && $tileInfoDSouthWest["terrain"] != 2) { $availableTiles[$counter1] = $tileInfoD["id"]; $counter1++; } // if } // if if ($counter1 == 4) { $availableContinent = $next_continents; } // if } // while $stmt2->close(); } else { } // else if ($counter1 == 4) { break; } // if } // while $stmt->close(); } else { $next_continents = 0; } // else // get available tiles from newly created continent if no continent is available if ($availableContinent < 1) { $continent1 = generateContinent($getPage_connection3); $next_continents = $continent1; $availableContinent = $next_continents; $availableTiles = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0); $counter1 = 0; if ($stmt = $getPage_connection3->prepare("SELECT id FROM tilesmap ORDER BY id ASC")) { $stmt->execute(); $stmt->store_result(); $stmt->bind_result($r_result); while ($stmt->fetch()) { $next_tiles = $r_result; $tileInfoD = getTileInfoByID($getPage_connection3, $next_tiles); if ($tileInfoD["continent"] == $next_continents && $tileInfoD["owner"] == 0 && ($tileInfoD["terrain"] != 2 && $tileInfoD["terrain"] != 3)) { $tileInfoDWest = getTileInfo($getPage_connection3, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"]); $tileInfoDNorthWest = getTileInfo($getPage_connection3, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"] - 1); $tileInfoDNorth = getTileInfo($getPage_connection3, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"] - 1); $tileInfoDNorthEast = getTileInfo($getPage_connection3, $tileInfoD["continent"], $tileInfoD["xpos"] + 1, $tileInfoD["ypos"] - 1); $tileInfoDEast = getTileInfo($getPage_connection3, $tileInfoD["continent"], $tileInfoD["xpos"] + 1, $tileInfoD["ypos"]); $tileInfoDSouthEast = getTileInfo($getPage_connection3, $tileInfoD["continent"], $tileInfoD["xpos"] + 1, $tileInfoD["ypos"] + 1); $tileInfoDSouth = getTileInfo($getPage_connection3, $tileInfoD["continent"], $tileInfoD["xpos"], $tileInfoD["ypos"] + 1); $tileInfoDSouthWest = getTileInfo($getPage_connection3, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"] + 1); if ($tileInfoDWest["continent"] == $next_continents && $tileInfoDWest["owner"] == 0 && ($tileInfoDWest["terrain"] != 2 && $tileInfoDWest["terrain"] != 3) || $tileInfoDNorthWest["continent"] == $next_continents && $tileInfoDNorthWest["owner"] == 0 && ($tileInfoDNorthWest["terrain"] != 2 && $tileInfoDNorthWest["terrain"] != 3) || $tileInfoDNorth["continent"] == $next_continents && $tileInfoDNorth["owner"] == 0 && ($tileInfoDNorth["terrain"] != 2 && $tileInfoDNorth["terrain"] != 3) || $tileInfoDNorthEast["continent"] == $next_continents && $tileInfoDNorthEast["owner"] == 0 && ($tileInfoDNorthEast["terrain"] != 2 && $tileInfoDNorthEast["terrain"] != 3) || $tileInfoDEast["continent"] == $next_continents && $tileInfoDEast["owner"] == 0 && ($tileInfoDEast["terrain"] != 2 && $tileInfoDEast["terrain"] != 3) || $tileInfoDSouthEast["continent"] == $next_continents && $tileInfoDSouthEast["owner"] == 0 && ($tileInfoDSouthEast["terrain"] != 2 && $tileInfoDSouthEast["terrain"] != 3) || $tileInfoDSouth["continent"] == $next_continents && $tileInfoDSouth["owner"] == 0 && ($tileInfoDSouth["terrain"] != 2 && $tileInfoDSouth["terrain"] != 3) || $tileInfoDSouthWest["continent"] == $next_continents && $tileInfoDSouthWest["owner"] == 0 && ($tileInfoDSouthWest["terrain"] != 2 && $tileInfoDSouthWest["terrain"] != 3)) { $availableTiles[$counter1] = $tileInfoD["id"]; $counter1++; } // if } // if } // while $stmt->close(); } else { } // else } // if $sameTile = true; $randTiles = array(0 => 0, 1 => 0); while ($sameTile === true) { $randTiles[0] = mt_rand(1, count($availableTiles) - 2); $randDirection = mt_rand(1, 2); if ($randDirection == 1) { $randTiles[1] = $randTiles[0] - 1; } else { if ($randDirection == 2) { $randTiles[1] = $randTiles[0] + 1; } } // else if if ($randTiles[0] == $randTiles[1]) { $sameTile = true; } else { $sameTile = false; } // else } // while $finalTiles[0] = $availableTiles[$randTiles[0]]; $finalTiles[1] = $availableTiles[$randTiles[1]]; $claims = array(0 => 0); for ($c = 0; $c < 3; $c++) { if (isset($finalTiles[$c])) { if ($finalTiles[$c] > 0) { addClaimInfo($getPage_connection3, 10, $new_userid, $finalTiles[$c]); } // if } // if } // for for ($j = 0; $j < 3; $j++) { if (isset($finalTiles[$j])) { if ($finalTiles[$j] > 0) { $tileInfo2 = getTileInfoByID($getPage_connection3, $finalTiles[$j]); setTileInfo($getPage_connection3, $tileInfo2["id"], $tileInfo2["continent"], $tileInfo2["xpos"], $tileInfo2["ypos"], $tileInfo2["terrain"], $tileInfo2["resources"], $tileInfo2["improvements"], $new_userid, $tileInfo2["claims"], $tileInfo2["population"]); if ($capitalBuilt === false) { addImprovementInfo($getPage_connection3, $tileInfo2["continent"], $tileInfo2["xpos"], $tileInfo2["ypos"], 1, 1, array(0 => 0), array(0 => $new_userid), "Capital City"); // add capital addImprovementInfo($getPage_connection3, $tileInfo2["continent"], $tileInfo2["xpos"], $tileInfo2["ypos"], 4, 1, array(0 => 0), array(0 => $new_userid), "First Farm"); // add farm $capitalBuilt = true; } // if } // if } // if } // for addNationInfo($getPage_connection3, $new_userid, $new_name, $availableContinent, $new_formal, "", 12, 5000, 0, 3, 2500, 5, 0, 5, 0, array(0 => 0), array(0 => 0), array(0 => 5, 1 => 0, 2 => 0, 3 => 5, 4 => 2, 5 => 5, 6 => 0, 7 => 5), array(0 => 5, 1 => 5, 2 => 5, 3 => 5), 2000, 0); // go through y positions for ($y = 1; $y < 21; $y++) { // go through x positions for ($x = 1; $x < 21; $x++) { $mapContentString = ""; $mapContentToken = 0; for ($qw = 0; $qw < 5; $qw++) { if ($qw == 0) { $_SESSION["overlay"] = "terrain"; } else { if ($qw == 1) { $_SESSION["overlay"] = "control"; } else { if ($qw == 2) { $_SESSION["overlay"] = "claims"; } else { if ($qw == 3) { $_SESSION["overlay"] = "units"; } else { if ($qw == 4) { $_SESSION["overlay"] = "nations"; } } } } } // else if $mapContent_generated = array("", 0); $mapContent_generated = generateMapTile($getPage_connection3, $availableContinent, $x, $y); $mapContentString = $mapContent_generated[0]; $mapContentToken = $mapContent_generated[1]; $_SESSION["terrainMapContentsTokens"] = array(0); $_SESSION["terrainMapContents"] = array(0); $_SESSION["controlMapContentsTokens"] = array(0); $_SESSION["controlMapContents"] = array(0); $_SESSION["claimsMapContentsTokens"] = array(0); $_SESSION["claimsMapContents"] = array(0); $_SESSION["unitsMapContentsTokens"] = array(0); $_SESSION["unitsMapContents"] = array(0); $_SESSION["nationsMapContentsTokens"] = array(0); $_SESSION["nationsMapContents"] = array(0); if ($_SESSION["overlay"] == "terrain") { $_SESSION["terrainMapContentsTokens"][$y][$x] = $mapContentToken; $_SESSION["terrainMapContents"][$y][$x] = $mapContentString; } else { if ($_SESSION["overlay"] == "control") { $_SESSION["controlMapContentsTokens"][$y][$x] = $mapContentToken; $_SESSION["controlMapContents"][$y][$x] = $mapContentString; } else { if ($_SESSION["overlay"] == "claims") { $_SESSION["claimsMapContentsTokens"][$y][$x] = $mapContentToken; $_SESSION["claimsMapContents"][$y][$x] = $mapContentString; } else { if ($_SESSION["overlay"] == "units") { $_SESSION["unitsMapContentsTokens"][$y][$x] = $mapContentToken; $_SESSION["unitsMapContents"][$y][$x] = $mapContentString; } else { if ($_SESSION["overlay"] == "nations") { $_SESSION["nationsMapContentsTokens"][$y][$x] = $mapContentToken; $_SESSION["nationsMapContents"][$y][$x] = $mapContentString; } else { $_SESSION["nationsMapContentsTokens"][$y][$x] = $mapContentToken; $_SESSION["nationsMapContents"][$y][$x] = $mapContentString; } } } } } // else } // for } // for } // for addMapMemoryInfo($getPage_connection3, $new_userid, $_SESSION["terrainMapContents"], $_SESSION["controlMapContents"], $_SESSION["claimsMapContents"], $_SESSION["unitsMapContents"], $_SESSION["nationsMapContents"], $_SESSION["terrainMapContentsTokens"], $_SESSION["controlMapContentsTokens"], $_SESSION["claimsMapContentsTokens"], $_SESSION["unitsMapContentsTokens"], $_SESSION["nationsMapContentsTokens"]); // $_SESSION["success_message"] = "World has been reset successfully!"; } else { $_SESSION["warning_message"] = "Cannot complete action: action is not valid."; } // else } else { $_SESSION["warning_message"] = "Cannot complete action: action is not valid."; } // else } else { $_SESSION["warning_message"] = "Cannot complete action: not valid admin."; } // else }
function registerUser($getPage_connection2) { if ($_SESSION["action"] == "register") { if (strlen($_SESSION["register_username"]) >= 5 && strlen($_SESSION["register_username"]) <= 35) { if (strlen($_SESSION["register_password"]) >= 8 && strlen($_SESSION["register_password"]) <= 35 && strlen($_SESSION["register_confirm_password"]) >= 8 && strlen($_SESSION["register_confirm_password"]) <= 35) { if ($_SESSION["register_confirm_password"] == $_SESSION["register_password"]) { $userInfoA = getUserInfoByName($getPage_connection2, $_SESSION["register_username"]); if ($userInfoA["id"] >= 1) { $_SESSION["warning_message"] = "Cannot complete action: Username is already in use."; } else { $new_salt = ""; $new_username = $_SESSION["register_username"]; $new_avatar = "images/users/avatar.png"; $allowed_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $chars_length = 63; for ($i = 0; $i < 51; $i++) { $new_salt .= $allowed_chars[mt_rand(0, $chars_length)]; } // for $new_date = date("Y-m-d H:i:s"); $new_token = mt_rand(1000, 9999); $new_thread = mt_rand(100, 999); $final_salt = '$2y$09$' . $new_salt . '$'; $created_password = crypt($_SESSION["register_password"] . $new_salt, $final_salt); addUserInfo($getPage_connection2, $new_username, $new_avatar, $new_date, $new_date, $created_password, $new_salt, $new_token, $new_thread, 0); $new_userid = $getPage_connection2->insert_id; $new_name = $_SESSION["register_nation"]; $new_formal = $_SESSION["register_formal"]; addProductionInfo($getPage_connection2, $new_userid, 100, array(0 => 2, 1 => 2, 2 => 2, 3 => 2, 4 => 2, 5 => 2, 6 => 2, 7 => 2), array(0 => 2, 1 => 2, 2 => 2, 3 => 2, 4 => 2, 5 => 2, 6 => 2, 7 => 2)); addRankingInfo($getPage_connection2, $new_userid, 999, 999, 999, 999, 999); $new_routes = array(0 => 0); $new_worth = array(0 => 0); $new_offers = array(0 => 0); addTradeInfo($getPage_connection2, $new_userid, $new_routes, 0); $capitalBuilt = false; $availableTiles = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0); $finalTiles = array(0 => 0, 1 => 0); $availableContinent = 0; if ($stmt = $getPage_connection2->prepare("SELECT id FROM continents ORDER BY id ASC")) { $stmt->execute(); $stmt->store_result(); $stmt->bind_result($r_id); while ($stmt->fetch()) { $next_continents = $r_id; $availableTiles = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0); $counter1 = 0; if ($stmt2 = $getPage_connection2->prepare("SELECT id FROM tilesmap ORDER BY id ASC")) { $stmt2->execute(); $stmt2->store_result(); $stmt2->bind_result($r_id1); while ($stmt2->fetch()) { $next_tiles = $r_id1; $tileInfoD = getTileInfoByID($getPage_connection2, $next_tiles); if ($tileInfoD["continent"] == $next_continents && $tileInfoD["owner"] == 0 && $tileInfoD["terrain"] != 2) { $tileInfoDWest = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"]); $tileInfoDNorthWest = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"] - 1); $tileInfoDNorth = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"] - 1); $tileInfoDNorthEast = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] + 1, $tileInfoD["ypos"] - 1); $tileInfoDEast = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] + 1, $tileInfoD["ypos"]); $tileInfoDSouthEast = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] + 1, $tileInfoD["ypos"] + 1); $tileInfoDSouth = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"], $tileInfoD["ypos"] + 1); $tileInfoDSouthWest = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"] + 1); if ($tileInfoDWest["continent"] == $next_continents && $tileInfoDWest["owner"] == 0 && $tileInfoDWest["terrain"] != 2 || $tileInfoDNorthWest["continent"] == $next_continents && $tileInfoDNorthWest["owner"] == 0 && $tileInfoDNorthWest["terrain"] != 2 || $tileInfoDNorth["continent"] == $next_continents && $tileInfoDNorth["owner"] == 0 && $tileInfoDNorth["terrain"] != 2 || $tileInfoDNorthEast["continent"] == $next_continents && $tileInfoDNorthEast["owner"] == 0 && $tileInfoDNorthEast["terrain"] != 2 || $tileInfoDEast["continent"] == $next_continents && $tileInfoDEast["owner"] == 0 && $tileInfoDEast["terrain"] != 2 || $tileInfoDSouthEast["continent"] == $next_continents && $tileInfoDSouthEast["owner"] == 0 && $tileInfoDSouthEast["terrain"] != 2 || $tileInfoDSouth["continent"] == $next_continents && $tileInfoDSouth["owner"] == 0 && $tileInfoDSouth["terrain"] != 2 || $tileInfoDSouthWest["continent"] == $next_continents && $tileInfoDSouthWest["owner"] == 0 && $tileInfoDSouthWest["terrain"] != 2) { $availableTiles[$counter1] = $tileInfoD["id"]; $counter1++; } // if } // if if ($counter1 == 4) { $availableContinent = $next_continents; } // if } // while $stmt2->close(); } else { } // else if ($counter1 == 4) { break; } // if } // while $stmt->close(); } else { } // else // get available tiles from newly created continent if no continent is available if ($availableContinent < 1) { $continent1 = generateContinent($getPage_connection2); $next_continents = $continent1; $availableContinent = $next_continents; $availableTiles = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0); $next_tiles = 1; $counter1 = 0; if ($stmt = $getPage_connection2->prepare("SELECT id FROM tilesmap ORDER BY id ASC")) { $stmt->execute(); $stmt->store_result(); $stmt->bind_result($r_id); while ($stmt->fetch()) { $next_tiles = $r_id; $tileInfoD = getTileInfoByID($getPage_connection2, $next_tiles); if ($tileInfoD["continent"] == $next_continents && $tileInfoD["owner"] == 0 && ($tileInfoD["terrain"] != 2 && $tileInfoD["terrain"] != 3)) { $tileInfoDWest = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"]); $tileInfoDNorthWest = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"] - 1); $tileInfoDNorth = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"] - 1); $tileInfoDNorthEast = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] + 1, $tileInfoD["ypos"] - 1); $tileInfoDEast = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] + 1, $tileInfoD["ypos"]); $tileInfoDSouthEast = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] + 1, $tileInfoD["ypos"] + 1); $tileInfoDSouth = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"], $tileInfoD["ypos"] + 1); $tileInfoDSouthWest = getTileInfo($getPage_connection2, $tileInfoD["continent"], $tileInfoD["xpos"] - 1, $tileInfoD["ypos"] + 1); if ($tileInfoDWest["continent"] == $next_continents && $tileInfoDWest["owner"] == 0 && ($tileInfoDWest["terrain"] != 2 && $tileInfoDWest["terrain"] != 3) || $tileInfoDNorthWest["continent"] == $next_continents && $tileInfoDNorthWest["owner"] == 0 && ($tileInfoDNorthWest["terrain"] != 2 && $tileInfoDNorthWest["terrain"] != 3) || $tileInfoDNorth["continent"] == $next_continents && $tileInfoDNorth["owner"] == 0 && ($tileInfoDNorth["terrain"] != 2 && $tileInfoDNorth["terrain"] != 3) || $tileInfoDNorthEast["continent"] == $next_continents && $tileInfoDNorthEast["owner"] == 0 && ($tileInfoDNorthEast["terrain"] != 2 && $tileInfoDNorthEast["terrain"] != 3) || $tileInfoDEast["continent"] == $next_continents && $tileInfoDEast["owner"] == 0 && ($tileInfoDEast["terrain"] != 2 && $tileInfoDEast["terrain"] != 3) || $tileInfoDSouthEast["continent"] == $next_continents && $tileInfoDSouthEast["owner"] == 0 && ($tileInfoDSouthEast["terrain"] != 2 && $tileInfoDSouthEast["terrain"] != 3) || $tileInfoDSouth["continent"] == $next_continents && $tileInfoDSouth["owner"] == 0 && ($tileInfoDSouth["terrain"] != 2 && $tileInfoDSouth["terrain"] != 3) || $tileInfoDSouthWest["continent"] == $next_continents && $tileInfoDSouthWest["owner"] == 0 && ($tileInfoDSouthWest["terrain"] != 2 && $tileInfoDSouthWest["terrain"] != 3)) { $availableTiles[$counter1] = $tileInfoD["id"]; $counter1++; } // if } // if } // while $stmt->close(); } else { } // else } // if $sameTile = true; $randTiles = array(0 => 0, 1 => 0); while ($sameTile === true) { $randTiles[0] = mt_rand(1, count($availableTiles) - 2); $randDirection = mt_rand(1, 2); if ($randDirection == 1) { $randTiles[1] = $randTiles[0] - 1; } else { if ($randDirection == 2) { $randTiles[1] = $randTiles[0] + 1; } } // else if if ($randTiles[0] == $randTiles[1]) { $sameTile = true; } else { $sameTile = false; } // else } // while $finalTiles[0] = $availableTiles[$randTiles[0]]; $finalTiles[1] = $availableTiles[$randTiles[1]]; $claims = array(0 => 0); for ($c = 0; $c < 3; $c++) { if (isset($finalTiles[$c])) { if ($finalTiles[$c] > 0) { addClaimInfo($getPage_connection2, 10, $new_userid, $finalTiles[$c]); } // if } // if } // for for ($j = 0; $j < 3; $j++) { if (isset($finalTiles[$j])) { if ($finalTiles[$j] > 0) { $tileInfo2 = getTileInfoByID($getPage_connection2, $finalTiles[$j]); setTileInfo($getPage_connection2, $tileInfo2["id"], $tileInfo2["continent"], $tileInfo2["xpos"], $tileInfo2["ypos"], $tileInfo2["terrain"], $tileInfo2["resources"], $tileInfo2["improvements"], $new_userid, $tileInfo2["claims"], $tileInfo2["population"]); if ($capitalBuilt === false) { addImprovementInfo($getPage_connection2, $tileInfo2["continent"], $tileInfo2["xpos"], $tileInfo2["ypos"], 1, 1, array(0 => 0), array(0 => $new_userid), "Capital City"); // add capital addImprovementInfo($getPage_connection2, $tileInfo2["continent"], $tileInfo2["xpos"], $tileInfo2["ypos"], 4, 1, array(0 => 0), array(0 => $new_userid), "First Farm"); // add farm $capitalBuilt = true; } // if } // if } // if } // for addNationInfo($getPage_connection2, $new_userid, $new_name, $availableContinent, $new_formal, "", 12, 5000, 0, 3, 2500, 5, 0, 5, 0, array(0 => 0), array(0 => 0), array(0 => 5, 1 => 0, 2 => 0, 3 => 5, 4 => 2, 5 => 5, 6 => 0, 7 => 5), array(0 => 5, 1 => 5, 2 => 5, 3 => 5), 2000, 0); // go through y positions for ($y = 1; $y < 21; $y++) { // go through x positions for ($x = 1; $x < 21; $x++) { $mapContentString = ""; $mapContentToken = 0; for ($qw = 0; $qw < 5; $qw++) { if ($qw == 0) { $_SESSION["overlay"] = "terrain"; } else { if ($qw == 1) { $_SESSION["overlay"] = "control"; } else { if ($qw == 2) { $_SESSION["overlay"] = "claims"; } else { if ($qw == 3) { $_SESSION["overlay"] = "units"; } else { if ($qw == 4) { $_SESSION["overlay"] = "nations"; } } } } } // else if $mapContent_generated = array("", 0); $mapContent_generated = generateMapTile($getPage_connection2, $availableContinent, $x, $y); $mapContentString = $mapContent_generated[0]; $mapContentToken = $mapContent_generated[1]; $_SESSION["terrainMapContentsTokens"] = array(0); $_SESSION["terrainMapContents"] = array(0); $_SESSION["controlMapContentsTokens"] = array(0); $_SESSION["controlMapContents"] = array(0); $_SESSION["claimsMapContentsTokens"] = array(0); $_SESSION["claimsMapContents"] = array(0); $_SESSION["unitsMapContentsTokens"] = array(0); $_SESSION["unitsMapContents"] = array(0); $_SESSION["nationsMapContentsTokens"] = array(0); $_SESSION["nationsMapContents"] = array(0); if ($_SESSION["overlay"] == "terrain") { $_SESSION["terrainMapContentsTokens"][$y][$x] = $mapContentToken; $_SESSION["terrainMapContents"][$y][$x] = $mapContentString; } else { if ($_SESSION["overlay"] == "control") { $_SESSION["controlMapContentsTokens"][$y][$x] = $mapContentToken; $_SESSION["controlMapContents"][$y][$x] = $mapContentString; } else { if ($_SESSION["overlay"] == "claims") { $_SESSION["claimsMapContentsTokens"][$y][$x] = $mapContentToken; $_SESSION["claimsMapContents"][$y][$x] = $mapContentString; } else { if ($_SESSION["overlay"] == "units") { $_SESSION["unitsMapContentsTokens"][$y][$x] = $mapContentToken; $_SESSION["unitsMapContents"][$y][$x] = $mapContentString; } else { if ($_SESSION["overlay"] == "nations") { $_SESSION["nationsMapContentsTokens"][$y][$x] = $mapContentToken; $_SESSION["nationsMapContents"][$y][$x] = $mapContentString; } else { $_SESSION["nationsMapContentsTokens"][$y][$x] = $mapContentToken; $_SESSION["nationsMapContents"][$y][$x] = $mapContentString; } } } } } // else } // for } // for } // for addMapMemoryInfo($getPage_connection2, $new_userid, $_SESSION["terrainMapContents"], $_SESSION["controlMapContents"], $_SESSION["claimsMapContents"], $_SESSION["unitsMapContents"], $_SESSION["nationsMapContents"], $_SESSION["terrainMapContentsTokens"], $_SESSION["controlMapContentsTokens"], $_SESSION["claimsMapContentsTokens"], $_SESSION["unitsMapContentsTokens"], $_SESSION["nationsMapContentsTokens"]); $_SESSION["success_message"] = "User has been registered successfully!"; } // else } else { $_SESSION["warning_message"] = "Cannot complete action: Passwords are not matching, double check your password fields."; } // else } else { $_SESSION["warning_message"] = "Cannot complete action: Password must be 8-35 characters."; } // else } else { $_SESSION["warning_message"] = "Cannot complete action: Username must be 8-35 characters."; } // else } else { $_SESSION["warning_message"] = "Cannot complete action: registration is invalid."; } // else }