function doWarDeclare(&$objSrcAlli, &$objTrgAlli) { global $orkTime; // M: Get game hours require_once 'inc/classes/clsGame.php'; $objGame = new clsGame(); $arrGameTime = $objGame->get_game_times(); $iGameHours = $arrGameTime['hour_counter']; // M: Get war table arrays $arrSrcWar = $objSrcAlli->get_wars(); $arrTrgWar = $objTrgAlli->get_wars(); // M: Get alliance sizes $iSrcLand = $objSrcAlli->get_rankings_alliance('land'); $iTrgLand = $objTrgAlli->get_rankings_alliance('land'); // M: Get alliance ids $iSrcAllianceid = $objSrcAlli->get_allianceid(); $iTrgAllianceid = $objTrgAlli->get_allianceid(); // M: Event handler $iEventid = mysql_query("SELECT event_counter FROM " . TBL_GAME_TIME); $iEventid = mysql_fetch_row($iEventid); // M: Create stored events for auto truce $iEventHour = $arrGameTime['hour_counter'] + WAR_LENGTH; $iEventid1 = $iEventid[0] + 1; $iEventid2 = $iEventid[0] + 2; $iEventid3 = $iEventid[0] + 3; $arrSQL[] = "UPDATE war SET target=0,truce=truce+1,last_target={$iTrgAllianceid},last_outgoing=\\'truce\\',last_end={$iEventHour},event_id=0 WHERE id={$iSrcAllianceid};"; $arrSQL[] = "UPDATE war SET target=0,truce=truce+1,last_target={$iSrcAllianceid},last_outgoing=\\'truce\\',last_end={$iEventHour},event_id=0 WHERE id={$iTrgAllianceid};"; $arrSQL[] = "INSERT INTO news SET time=NOW(), type=\\'global\\', kingdom_text=\\'<strong class=\"positive\">Alliance #{$iSrcAllianceid} and #{$iTrgAllianceid} have truced.</strong>\\';"; // M: Store events foreach ($arrSQL as $strSQL) { $iEventid[0]++; mysql_query("INSERT INTO auto_event SET event_id = {$iEventid['0']}, " . "query = '{$strSQL}', execution_hour = {$iEventHour};"); } // M: Update event counter $objGame->set_game_time('event_counter', $iEventid[0]); // M: Update source alli $arrNewSrcWar = array('target' => $iTrgAllianceid, 'start_land' => $iSrcLand, 'war_started' => $iGameHours, 'truce_offer' => 0, 'last_end' => 0, 'last_target' => 0, 'last_outgoing' => 0, 'land_needed' => round($iTrgLand * ($iSrcLand / $iTrgLand * 0.35)), 'event_id' => $iEventid1); $objSrcAlli->set_wars($arrNewSrcWar); // M: Update target alli $arrNewTrgWar = array('target' => $iSrcAllianceid, 'start_land' => $iTrgLand, 'war_started' => $iGameHours, 'truce_offer' => 0, 'last_end' => 0, 'last_target' => 0, 'last_outgoing' => 0, 'land_needed' => round($iSrcLand * ($iTrgLand / $iSrcLand * 0.35)), 'event_id' => $iEventid2); $objTrgAlli->set_wars($arrNewTrgWar); // M: News for winner, looser and global mysql_query("INSERT INTO news (id, time, ip, type, duser, ouser, result, text, kingdom_text, kingdoma, kingdomb) VALUES ('', '{$orkTime}', '---', 'War', '0', '0', '1', '', '<strong class=\"positive\">We have declared war on alliance #{$iTrgAllianceid}!</strong>', '{$iSrcAllianceid}', '')"); mysql_query("INSERT INTO news (id, time, ip, type, duser, ouser, result, text, kingdom_text, kingdoma, kingdomb) VALUES ('', '{$orkTime}', '---', 'War', '0', '0', '1', '', '<strong class=\"negative\">Alliance #{$iSrcAllianceid} has declared war on us!</strong>', '{$iTrgAllianceid}', '')"); mysql_query("INSERT INTO news (id, time, ip, type, duser, ouser, result, text, kingdom_text, kingdoma, kingdomb) VALUES ('', '{$orkTime}', '---', 'global', '0', '0', '1', '', '<strong class=\"positive\">Alliance #{$iSrcAllianceid} has declared war on #{$iTrgAllianceid}!</strong>', '0', '')"); }
function call_age_handler_text() { global $tool; include_once 'inc/functions/resort_tools.php'; if (!user_has_access($tool)) { echo "Sorry, this page is restricted to ORKFiA Staff"; include_game_down(); exit; } $objGame = new clsGame(); //========================================================================== // Take care of sent form data //========================================================================== if (isset($_POST['i_age_start']) && isset($_POST['i_age_end'])) { // Get post variables $iAgeStart = $_POST['i_age_start']; $iAgeEnd = $_POST['i_age_end']; // Get last age's id or 0 $iLastAge = 0; $iLastAge = mysql_result(mysql_query("SELECT age_number FROM ages ORDER BY age_number DESC LIMIT 0, 1"), 0); $iLastAge++; // Instantiate object and save to db $objNewAge = new clsAge($iLastAge, $iAgeStart, $iAgeEnd); $objNewAge->saveAge(); } elseif (isset($_POST['i_age_to_make_now'])) { $iAgeToMakeNow = $_POST['i_age_to_make_now']; $objGame->set_game_time(AGE_NUMBER, $iAgeToMakeNow); } elseif (isset($_POST['i_age_to_delete'])) { $iAgeToDelete = $_POST['i_age_to_delete']; $objNewAge = new clsAge($iAgeToDelete); $objNewAge->deleteAge(); } //========================================================================== // Show Task Links //========================================================================== echo 'Select Task:' . '<br /><br />' . ' | ' . '<a href="main.php?cat=game&page=resort_tools' . '&tool=' . $tool . '&show=create">Create Age</a>' . ' | ' . '<a href="main.php?cat=game&page=resort_tools' . '&tool=' . $tool . '&show=remove">Remove Age</a>' . ' | ' . '<a href="main.php?cat=game&page=resort_tools' . '&tool=' . $tool . '&show=current">Current Age</a>' . ' | ' . '<br /><br />'; //========================================================================== // Show table with existing ages //========================================================================== echo $strAgesTable = '<table class="small" cellspacing="0" cellpadding="0">' . '<tr class="header">' . '<th colspan="3">' . 'Ages' . '</th>' . '</tr>' . '<tr class="subheader">' . '<th>' . "Age #" . '</th>' . '<th class="right">' . "Start" . '</th>' . '<th class="right">' . "End" . '</th>' . '</tr>'; $resSQL = mysql_query("SELECT * FROM ages ORDER BY age_number ASC"); while ($arrRES = mysql_fetch_array($resSQL)) { echo $strAgesTable = '<tr class="data">' . '<th>' . $arrRES['age_number'] . '</th>' . '<td>' . $arrRES['year_start'] . ' OE</td>' . '<td>' . $arrRES['year_end'] . ' OE</td>' . '</tr>'; } echo $strAgesTable = '</table>' . '<br />'; //========================================================================== // Which option page to show //========================================================================== $strShow = ''; if (isset($_GET['show'])) { $strShow = strval($_GET['show']); } switch ($strShow) { case "create": echo $strForm = '<form method="post" action="main.php?cat=game&page=resort_tools&tool=' . $tool . '&show=create">' . '<label>First Year of new age: ' . '<input type="text" size="6" maxlength="4" name="i_age_start" />' . '</label>' . '<br /><br />' . '<label>Last Year of new age: ' . '<input type="text" size="6" maxlength="4" name="i_age_end" />' . '</label>' . '<br /><br />' . '<input type="submit" value="Create" />' . '<br /><br />' . '</form>'; break; case "remove": $iLastAge = @mysql_result(mysql_query("SELECT age_number FROM ages ORDER BY age_number DESC LIMIT 0, 1"), 0); echo $strForm = '<form method="post" action="main.php?cat=game&page=resort_tools&tool=' . $tool . '&show=remove">' . '<label>Age to Remove: ' . '<input type="text" size="6" maxlength="4" name="i_age_to_delete" value="' . $iLastAge . '" />' . '</label>' . '<br /><br />' . '<input type="submit" value="Remove" />' . '<br /><br />' . '</form>'; break; case "current": $iAgeNumber = $objGame->get_game_time(AGE_NUMBER); echo $strForm = '<form method="post" action="main.php?cat=game&page=resort_tools&tool=' . $tool . '&show=current">' . '<label>Current Age: ' . '<input type="text" size="6" maxlength="4" name="i_age_to_make_now" value="' . $iAgeNumber . '" />' . '</label>' . '<br /><br />' . '<input type="submit" value="Save New" />' . '<br /><br />' . '</form>'; break; } }