include_once 'inc/classes/clsUser.php'; include_once 'inc/classes/clsAlliance.php'; //============================================================================== // Time stamps (Used here and/or globally elsewhere) //============================================================================== $timestamp = date(TIMESTAMP_FORMAT); $orkTime = $timestamp; $timeNow = $timestamp; $arrDate = getdate(); //============================================================================== // Frost: Global time counter for the game. // Functionality: Game hours only update if someone logs on once each hour. //============================================================================== include_once 'inc/classes/clsGame.php'; $objGame = new clsGame(); $arrGameTime = $objGame->get_game_times(); if ($arrGameTime[CURRENT_HOUR] != $arrDate['hours']) { if ($objGame->get_game_switch(GLOBAL_PAUSE) != ON) { $arrGameTime[HOUR_COUNTER]++; mysql_query('UPDATE admin_global_time SET hour_counter = ' . $arrGameTime[HOUR_COUNTER]); } mysql_query("UPDATE admin_global_time SET current_hour = {$arrDate['hours']}"); //========================================================================== // Frost: auto event handler //========================================================================== $arrEvents = mysql_query('SELECT * FROM auto_event WHERE execution_hour ' . '<= ' . $arrGameTime[HOUR_COUNTER]); $iEvents = count($arrEvents) + 1; for ($i = 0; $i < $iEvents; $i++) { $arrEvent = mysql_fetch_array($arrEvents); // Run Event mysql_query($arrEvent['query']);
function doWarSurrender(&$objSuxAlli, &$objWinAlli) { global $orkTime; $winner = $objWinAlli->get_allianceid(); $looser = $objSuxAlli->get_allianceid(); // Clear events $iEventid1 = $objWinAlli->get_war('event_id'); $iEventid2 = $objSuxAlli->get_war('event_id'); clearEvents($iEventid1, $iEventid2); // Get game hours require_once 'inc/classes/clsGame.php'; $objGame = new clsGame(); $arrGameTime = $objGame->get_game_times(); // M: Update winner alli $arrWinWar = $objWinAlli->get_wars(); $arrNewWinWar = array('target' => 0, 'last_target' => $looser, 'last_outgoing' => 'victory', 'last_end' => $arrGameTime['hour_counter'], 'victory' => $arrWinWar['victory'] + 1, 'event_id' => ''); $objWinAlli->set_wars($arrNewWinWar); // M: Update looser alli $arrSuxWar = $objSuxAlli->get_wars(); $arrNewSuxWar = array('target' => 0, 'last_target' => $winner, 'last_outgoing' => 'surrender', 'last_end' => $arrGameTime['hour_counter'], 'surrender' => $arrSuxWar['surrender'] + 1, 'event_id' => ''); $objSuxAlli->set_wars($arrNewSuxWar); // M: Update winner alli fame $objTmpUser = new clsUser(0); $arrUserId = $objWinAlli->get_userids(); foreach ($arrUserId as $iUserid) { $objTmpUser->set_userid($iUserid); $iNewFame = $objTmpUser->get_stat('fame') + WAR_SURRENDER_FAME; $objTmpUser->set_stat('fame', $iNewFame); } // M: Update looser alli fame $arrUserId = $objSuxAlli->get_userids(); foreach ($arrUserId as $iUserid) { $objTmpUser->set_userid($iUserid); $iNewFame = max(0, $objTmpUser->get_stat('fame') - WAR_SURRENDER_FAME); $objTmpUser->set_stat('fame', $iNewFame); } // M: Transfer research $arrResearch = moveResearch($objSuxAlli, $objWinAlli, WAR_SURRENDER_LOSSES); // M: Transfer market goods (Atm this is the same % as regular victory) $arrMarket = moveMarketGoods($objSuxAlli, $objWinAlli, WAR_VICTORY_GOODS); // 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-end', '0', '0', '1', '', '<strong class=\"positive\">We were victorious in the war with alliance #{$looser}!</strong>', '{$winner}', '')"); mysql_query("INSERT INTO news (id, time, ip, type, duser, ouser, result, text, kingdom_text, kingdoma, kingdomb) VALUES ('', '{$orkTime}', '---', 'war-end', '0', '0', '1', '', '<strong class=\"negative\">We have surrendered in the war with #{$winner}!</strong>', '{$looser}', '')"); 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 #{$looser} have surrendered! #{$winner} wins!</strong>', '0', '')"); return array($arrResearch, $arrMarket); }