Fixed minor bugs
Updated redesign Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
This commit is contained in:
parent
fa9fa5d3a5
commit
4b2167c133
67 changed files with 323 additions and 1044 deletions
137
src/includes/functions/MissionCaseExploit.php
Normal file
137
src/includes/functions/MissionCaseExploit.php
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @deprecated
|
||||
* @param unknown_type $fleet
|
||||
*/
|
||||
function MissionCaseExploit($fleet)
|
||||
{
|
||||
global $lang;
|
||||
|
||||
$prices = Wootook_Empire_Helper_Config_Prices::getSingleton();
|
||||
$player = Wootook_Player_Model_Session::getSingleton()->getPlayer();
|
||||
$writeAdapter = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection('core_write');
|
||||
|
||||
$userId = $fleet['fleet_owner'];
|
||||
$MessSender = $lang['sys_mess_qg'];
|
||||
$MessTitle = $lang['sys_expe_report'];
|
||||
|
||||
if ($fleet['fleet_mess'] == 0) {
|
||||
if ($fleet['fleet_end_stay'] < time()) {
|
||||
$stayDuration = ($fleet['fleet_end_stay'] - $fleet['fleet_start_time']);
|
||||
|
||||
$shipList = array();
|
||||
$fleetCapacity = array();
|
||||
$storageShips = array(
|
||||
Legacies_Empire::ID_SHIP_ORE_MININER,
|
||||
Legacies_Empire::ID_SHIP_DEATH_STAR,
|
||||
Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT,
|
||||
Legacies_Empire::ID_SHIP_LARGE_TRANSPORT,
|
||||
Legacies_Empire::ID_SHIP_SUPERNOVA,
|
||||
);
|
||||
foreach (explode(";", $fleet['fleet_array']) as $shipData) {
|
||||
if ($shipData) {
|
||||
$shipData = explode(',', $shipData);
|
||||
if (count($shipData) != 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$shipList[$shipData[0]] = $shipData[1];
|
||||
|
||||
if (in_array($shipData[0], $storageShips) && isset($prices[$shipData[0]]) && isset($prices[$shipData[0]]['capacity'])) {
|
||||
$fleetCapacity += $prices[$shipData[0]]['capacity'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($shipList[Legacies_Empire::ID_SHIP_ORE_MININER])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$fleetSentResources = $fleet['fleet_resource_metal'] + $fleet['fleet_resource_crystal'] + $fleet['fleet_resource_deuterium'];
|
||||
$fleetAvailableCapacity = $fleetCapacity - $fleetSentResources;
|
||||
|
||||
$minerCount = $shipList[Legacies_Empire::ID_SHIP_ORE_MININER];
|
||||
|
||||
mt_srand();
|
||||
$miningAmount = Math::mul(Math::mul($minerCount, $stayDuration), Math::pow(1.2, $player->getElement(Legacies_Empire::ID_RESEARCH_ORE_MINING)));
|
||||
|
||||
$random = mt_rand(1, 10000);
|
||||
$metalOreAmount = Math::mul($miningAmount, Math::div($random, 10000));
|
||||
|
||||
$random = mt_rand(1, 10000);
|
||||
$cristalOreAmount = Math::mul($miningAmount, Math::div($random, 10000));
|
||||
|
||||
$totalOreAmount = Math::add($metalOreAmount, $cristalOreAmount);
|
||||
if (Math::comp($totalOreAmount, $fleetAvailableCapacity) > 0) {
|
||||
$ratio = Math::div($fleetAvailableCapacity, $totalOreAmount);
|
||||
|
||||
$metalOreAmount = Math::mul($metalOreAmount, $ratio);
|
||||
$cristalOreAmount = Math::mul($cristalOreAmount, $ratio);
|
||||
}
|
||||
|
||||
$statement = $writeAdapter->update()
|
||||
->into($writeAdapter->getTable('fleets'))
|
||||
->set('fleet_resource_metal', Math::add($fleet['fleet_resource_metal'], $metalOreAmount))
|
||||
->set('fleet_resource_crystal', Math::add($fleet['fleet_resource_crystal'], $cristalOreAmount))
|
||||
->prepare()
|
||||
;
|
||||
$statement->execute();
|
||||
}
|
||||
} else {
|
||||
// La Flotte est de retour a quai
|
||||
if ($fleet['fleet_end_time'] < time()) {
|
||||
$coords = array(
|
||||
'galaxy' => $fleet['fleet_start_galaxy'],
|
||||
'system' => $fleet['fleet_start_system'],
|
||||
'position' => $fleet['fleet_start_planet']
|
||||
);
|
||||
$planet = Wootook_Empire_Model_Planet::factoryFromCoords($coords, $fleet['fleet_start_type']);
|
||||
if (!$planet->getId() || $planet->getPlayerId() != $player->getId())
|
||||
foreach (explode(";", $fleet['fleet_array']) as $shipData) {
|
||||
if ($shipData) {
|
||||
$shipData = explode(',', $shipData);
|
||||
if (count($shipData) != 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$planet->setElement($shipData[0], Math::add($planet->getElement($shipData[0]), $shipData[1]));
|
||||
}
|
||||
}
|
||||
$planet->save();
|
||||
|
||||
SendSimpleMessage($userId, '', $fleet['fleet_end_time'], 15, $MessSender, $MessTitle, $lang['sys_expe_back_home']);
|
||||
|
||||
$writeAdapter->delete()->from($writeAdapter->getTable('fleets'))->where('fleet_id', $fleet['fleet_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue