/** * @see Form::save() */ public function save() { global $game_config; AbstractForm::save(); $data = LWUtil::serialize(array('text' => $this->applicationText), 1); $this->alliance2->addInterrelation($this->allianceID, $this->interrelationType, 1, $data); if ($this->interrelationType == 3) { require_once WCF_DIR . 'lib/system/exception/NamedUserException.class.php'; throw new NamedUserException(WCF::getLanguage()->get('wot.alliance.diplomacy.newWar', array('boardURL' => $game_config['diplomacyBoardURL'], 'boardID' => $game_config['diplomacyBoardID']))); } header('Location: index.php?page=Alliance'); exit; }
/** * Updates the data of a logged fleet. * * @param LoggableFleet */ public static function update(LoggableFleet $fleet) { EventHandler::fireAction($fleet, 'logData'); // TODO: integrate this in wcf eventlistener logData@Fleet self::addRelevantData($fleet); $data = $fleet->getData(); if (isset(self::$invalidFleetIDs[$data['fleetID']])) { return; } $array = self::readArray($data['fleetID']); if ($array === false) { self::$invalidFleetIDs[$data['fleetID']] = true; return; } $array[] = array('data' => $data, 'fleet' => $fleet->getFleetArray(), 'stack' => self::getStacktrace(), 'time' => time()); $string = LWUtil::serialize(serialize($array), 1); $sql = "UPDATE ugml_archive_fleet\r\n\t\t\t\tSET data = '" . escapeString($string) . "'\r\n\t\t\t\tWHERE fleetID = " . $data['fleetID']; WCF::getDB()->sendQuery($sql); }
/** * Prepares the data for simulation */ protected function simulate() { // organize data foreach ($this->shipDataArray as $key => $value) { if (empty($value)) { continue; } $nfsSlotNo = intval(substr($key, 8, 2)); $front = strtolower(substr($key, 10, 8)); $isTech = strlen($key) > 21; $arrayName = $front . 'Fleets'; if ($isTech) { $techID = substr($key, -3); $this->{$arrayName}[$nfsSlotNo]['tech'][$techID] = intval($value); } else { $techID = substr($key, -3); $this->{$arrayName}[$nfsSlotNo]['fleet'][$techID] = intval($value); } } if (!count($this->attackerFleets) || !count($this->defenderFleets)) { return; } // create objs foreach ($this->attackerFleets as $nfsSlotNo => $fleetData) { $fleetStr = LWUtil::serialize($fleetData['fleet']); $array = array('fleet' => Spec::arrayToStr($fleetData['fleet']), 'galaxy' => 0, 'system' => 0, 'planet' => 0, 'ownerID' => 0, 'targetPlanetID' => 0, 'fleetID' => 0, 'weaponTech' => $fleetData['tech'][109], 'shieldTech' => $fleetData['tech'][110], 'hullPlatingTech' => $fleetData['tech'][111]); $this->attackerFleetObjs[$nfsSlotNo] = new PhantomFleet(null, $array); } $simulatingFleetArray = $array; foreach ($this->defenderFleets as $nfsSlotNo => $fleetData) { $fleetStr = LWUtil::serialize($fleetData['fleet']); $array = array('fleet' => Spec::arrayToStr($fleetData['fleet']), 'galaxy' => 0, 'system' => 0, 'planet' => 0, 'ownerID' => 0, 'targetPlanetID' => 0, 'fleetID' => 0, 'weaponTech' => $fleetData['tech'][109], 'shieldTech' => $fleetData['tech'][110], 'hullPlatingTech' => $fleetData['tech'][111]); $this->defenderFleetObjs[$nfsSlotNo] = new PhantomFleet(null, $array); } // simulate set_time_limit(60); for ($i = 0; $i < self::SIMULATIONS; ++$i) { try { ob_start(); $simulator = new CombatSimulator($this->attackerFleetObjs, $this->defenderFleetObjs, $simulatingFleetArray); $simulator->simulate(); ob_clean(); } catch (Exception $e) { message('Es ist ein fehler bei der Simulation aufgetreten!'); } $this->unitsAttackerArray[$i] = $simulator->units['attacker']; $this->unitsDefenderArray[$i] = $simulator->units['defender']; $this->debrisMetalArray[$i] = $simulator->debris['metal']; $this->debrisCrystalArray[$i] = $simulator->debris['crystal']; $this->bootyArray[$i] = $simulator->totalCapacity; $this->roundNoArray[$i] = $simulator->roundNo; $this->winnerArray[$i] = $simulator->winner; // check extrema if ($i == 0) { //var_dump($simulator); $this->minSimulator = $this->maxSimulator = $simulator; continue; } // real best case: difference in attacker units $byAttackerUnits = $simulator->units['attacker'] < $this->minSimulator->units['attacker']; // unreal best case: no difference in attacker units, but more defender units $byDefenderUnits = $simulator->units['attacker'] == $this->minSimulator->units['attacker'] && $simulator->units['defender'] > $this->minSimulator->units['defender']; if ($byAttackerUnits || $byDefenderUnits) { $this->minSimulator = $simulator; } // real worst case: difference in attacker units $byAttackerUnits = $simulator->units['attacker'] > $this->maxSimulator->units['attacker']; // unreal worst case: no difference in attacker units, but less defender units $byDefenderUnits = $simulator->units['attacker'] == $this->maxSimulator->units['attacker'] && $simulator->units['defender'] < $this->maxSimulator->units['defender']; if ($byAttackerUnits || $byDefenderUnits) { $this->maxSimulator = $simulator; } } $simulator->generateReport(); $report = CombatReport::create(time(), $simulator->report, false, array(WCF::getUser()->userID => WCF::getUser()->userID)); $this->reportID = $report->reportID; // sum up (avg) $this->units['attacker'] = array_sum($this->unitsAttackerArray) / self::SIMULATIONS; $this->units['defender'] = array_sum($this->unitsDefenderArray) / self::SIMULATIONS; $this->debris['metal'] = array_sum($this->debrisMetalArray) / self::SIMULATIONS; $this->debris['crystal'] = array_sum($this->debrisCrystalArray) / self::SIMULATIONS; $this->booty = array_sum($this->bootyArray) / self::SIMULATIONS; $this->roundNo = array_sum($this->roundNoArray) / self::SIMULATIONS; // sum up (min) $this->minUnits['attacker'] = $this->minSimulator->units['attacker']; $this->minUnits['defender'] = $this->minSimulator->units['defender']; $this->minDebris['metal'] = $this->minSimulator->debris['metal']; $this->minDebris['crystal'] = $this->minSimulator->debris['crystal']; $this->minBooty = $this->minSimulator->totalCapacity; // sum up (max) $this->maxUnits['attacker'] = $this->maxSimulator->units['attacker']; $this->maxUnits['defender'] = $this->maxSimulator->units['defender']; $this->maxDebris['metal'] = $this->maxSimulator->debris['metal']; $this->maxDebris['crystal'] = $this->maxSimulator->debris['crystal']; $this->maxBooty = $this->maxSimulator->totalCapacity; $this->winner = array_count_values($this->winnerArray); }
/* This file is part of WOT Game. WOT Game is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. WOT Game is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with WOT Game. If not, see <http://www.gnu.org/licenses/>. */ define('INSIDE', true); $ugamela_root_path = './'; include $ugamela_root_path . 'extension.inc'; include $ugamela_root_path . 'common.' . $phpEx; $userID = intval($_GET['u']); if ($userID != 0 && !isset($_COOKIE['dili_link_used' . $userID])) { // log $sql = "INSERT INTO ugml_dilizium_link\n\t\t\t(userID, registered, `time`,\n\t\t\t ipAddress, userAgent, cookieData)\n\t\t\tVALUES\n\t\t\t(" . $userID . ", 0, " . time() . ",\n\t\t\t INET_ATON('" . escapeString($_SERVER['REMOTE_ADDR']) . "'), '" . escapeString($_SERVER['HTTP_USER_AGENT']) . "', '" . escapeString(LWUtil::serialize($_COOKIE)) . "')"; WCF::getDB()->sendQuery($sql); $diliLinkID = WCF::getDB()->getInsertID(); setcookie('dili_link_used' . $userID, time(), time() + 60 * 60 * 24 * 365); setcookie('dili_link_clicked', $diliLinkID, time() + 60 * 60 * 24 * 365); } header("Location: index.htm");