本文整理汇总了PHP中calculateAttack函数的典型用法代码示例。如果您正苦于以下问题:PHP calculateAttack函数的具体用法?PHP calculateAttack怎么用?PHP calculateAttack使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了calculateAttack函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: TargetEvent
//.........这里部分代码省略.........
$messageHTML = str_replace(array("\n", "\t", "\r"), "", $messageHTML);
$FindSize = mt_rand(0, 100);
$maxAttack = 0;
if (10 < $FindSize) {
$Message = $LNG['sys_expe_attack_' . $Which . '_1_' . $Rand[0]];
$maxAttack = 0.3 + $Add + mt_rand($Points[0], abs($Points[0])) * 0.01;
} elseif (0 < $FindSize && 10 >= $FindSize) {
$Message = $LNG['sys_expe_attack_' . $Which . '_2_' . $Rand[1]];
$maxAttack = 0.3 + $Add + mt_rand($Points[1], abs($Points[1])) * 0.01;
} elseif (0 == $FindSize) {
$Message = $LNG['sys_expe_attack_' . $Which . '_3_' . $Rand[2]];
$maxAttack = 0.3 + $Add + mt_rand($Points[2], abs($Points[2])) * 0.01;
}
foreach ($fleetArray as $ID => $count) {
$DefenderFleetArray .= $ID . "," . round($count * $maxAttack) . ";";
}
$AttackerTechno = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = " . $this->_fleet['fleet_owner'] . ";");
$DefenderTechno = array('id' => 0, 'username' => $Name, 'military_tech' => min($AttackerTechno['military_tech'] + $Def, 0), 'defence_tech' => min($AttackerTechno['defence_tech'] + $Def, 0), 'shield_tech' => min($AttackerTechno['shield_tech'] + $Def, 0), 'rpg_amiral' => 0, 'dm_defensive' => 0, 'dm_attack' => 0, 'academy_1101' => 0, 'academy_1102' => 0, 'academy_1301' => 0, 'academy_1302' => 0);
$fleetID = $this->_fleet['fleet_id'];
$fleetAttack[$fleetID]['fleetDetail'] = $this->_fleet;
$fleetAttack[$fleetID]['player'] = $AttackerTechno;
$fleetAttack[$fleetID]['player']['factor'] = getFactors($fleetAttack[$this->_fleet['fleet_id']]['player'], 'attack', $this->_fleet['fleet_start_time']);
$fleetAttack[$fleetID]['unit'] = array();
$temp = explode(';', $this->_fleet['fleet_array']);
foreach ($temp as $temp2) {
$temp2 = explode(',', $temp2);
if ($temp2[0] < 100) {
continue;
}
if (!isset($fleetAttack[$fleetID]['unit'][$temp2[0]])) {
$fleetAttack[$fleetID]['unit'][$temp2[0]] = 0;
}
$fleetAttack[$fleetID]['unit'][$temp2[0]] += $temp2[1];
}
$fleetDefend = array();
$defRowDef = explode(';', $DefenderFleetArray);
foreach ($defRowDef as $Element) {
$Element = explode(',', $Element);
if ($Element[0] < 100) {
continue;
}
if (!isset($fleetDefend[0]['unit'][$Element[0]])) {
$fleetDefend[0]['unit'][$Element[0]] = 0;
}
$fleetDefend[0]['unit'][$Element[0]] += $Element[1];
}
$fleetDefend[0]['fleetDetail'] = array('fleet_start_galaxy' => $this->_fleet['fleet_end_galaxy'], 'fleet_start_system' => $this->_fleet['fleet_end_system'], 'fleet_start_planet' => $this->_fleet['fleet_end_planet'], 'fleet_start_type' => 1, 'fleet_end_galaxy' => $this->_fleet['fleet_end_galaxy'], 'fleet_end_system' => $this->_fleet['fleet_end_system'], 'fleet_end_planet' => $this->_fleet['fleet_end_planet'], 'fleet_end_type' => 1, 'fleet_resource_metal' => 0, 'fleet_resource_crystal' => 0, 'fleet_resource_deuterium' => 0);
$fleetDefend[0]['player'] = $DefenderTechno;
$fleetDefend[0]['player']['factor'] = 0;
require_once 'calculateAttack.php';
$fleetIntoDebris = $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['Fleet_Cdr'];
$defIntoDebris = $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['Defs_Cdr'];
$combatResult = calculateAttack($fleetAttack, $fleetDefend, $fleetIntoDebris, $defIntoDebris);
$fleetArray = '';
$totalCount = 0;
$fleetAttack[$fleetID]['unit'] = array_filter($fleetAttack[$fleetID]['unit']);
foreach ($fleetAttack[$fleetID]['unit'] as $element => $amount) {
$fleetArray .= $element . ',' . $amount . ';';
$totalCount += $amount;
}
if ($totalCount <= 0) {
$this->KillFleet();
} else {
$this->UpdateFleet('fleet_array', substr($fleetArray, 0, -1));
$this->UpdateFleet('fleet_amount', $totalCount);
}
require_once 'GenerateReport.php';
$debrisRessource = array(901, 902);
foreach ($debrisRessource as $elementID) {
$debris[$elementID] = 0;
}
$stealResource = array(901 => 0, 902 => 0, 903 => 0);
$raportInfo = array('thisFleet' => $this->_fleet, 'debris' => $debris, 'stealResource' => $stealResource, 'moonChance' => 0, 'moonDestroy' => false, 'moonName' => null, 'moonDestroyChance' => null, 'moonDestroySuccess' => null, 'fleetDestroyChance' => null, 'fleetDestroySuccess' => null);
$raportData = GenerateReport($combatResult, $raportInfo);
$raportID = md5(uniqid('', true) . TIMESTAMP);
$sqlQuery = "INSERT INTO " . RW . " SET rid = '" . $raportID . "', raport = '" . serialize($raportData) . "', time = '" . $this->_fleet['fleet_start_time'] . "', attacker = '" . $this->_fleet['fleet_owner'] . "';";
$GLOBALS['DATABASE']->query($sqlQuery);
switch ($combatResult['won']) {
case "a":
$attackClass = 'style="color:green;"';
$defendClass = 'style="color:red;"';
break;
case "w":
$attackClass = 'raportDraw';
$defendClass = 'raportDraw';
break;
case "r":
$attackClass = 'style="color:red;"';
$defendClass = 'style="color:green;"';
break;
}
$message = sprintf($messageHTML, $raportID, $attackClass, $LNG['sys_mess_attack_report'], sprintf($LNG['sys_adress_planet'], $this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet']), $LNG['type_planet_short'][$this->_fleet['fleet_end_type']], $LNG['sys_lost'], $attackClass, $LNG['sys_attack_attacker_pos'], pretty_number($combatResult['unitLost']['attacker']), $defendClass, $LNG['sys_attack_defender_pos'], pretty_number($combatResult['unitLost']['defender']), $LNG['sys_gain'], $LNG['tech'][901], pretty_number($stealResource[901]), $LNG['tech'][902], pretty_number($stealResource[902]), $LNG['tech'][903], pretty_number($stealResource[903]), $LNG['sys_debris'], $LNG['tech'][901], pretty_number($debris[901]), $LNG['tech'][902], pretty_number($debris[902]));
if ($combatResult['won'] == 'a' && $this->_fleet['fleet_end_type'] == 4) {
$GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " set `id_owner` = '" . $this->_fleet['fleet_owner'] . "' where `id` = '" . $this->_fleet['fleet_end_id'] . "';");
}
SendSimpleMessage($this->_fleet['fleet_owner'], 0, $this->_fleet['fleet_end_stay'], 3, $LNG['sys_mess_tower'], $LNG['sys_mess_attack_report'], $message);
$this->setState(FLEET_RETURN);
$this->SaveFleet();
}
}
示例2: ShowBattleSimPage
function ShowBattleSimPage()
{
global $USER, $PLANET, $reslist, $pricelist, $LNG, $db, $ExtraDM, $LANG, $CONF;
$action = request_var('action', '');
$Slots = request_var('slots', 1);
if (isset($_REQUEST['im'])) {
$Array = $_REQUEST['im'];
foreach ($Array as $ID => $Count) {
$BattleArray[0][1][$ID] = floattostring($Count);
}
} elseif (isset($_REQUEST['battleinput'])) {
$BattleArray = $_REQUEST['battleinput'];
} else {
$BattleArray = array();
}
if ($action == 'send') {
$Counts = array(0, 0);
foreach ($BattleArray as $BattleSlotID => $BattleSlot) {
if (isset($BattleSlot[0]) && (array_sum($BattleSlot[0]) > 0 || $BattleSlotID == 0)) {
$Att = mt_rand(1, 1000);
$attack[$Att]['fleet'] = array('fleet_start_galaxy' => 1, 'fleet_start_system' => 33, 'fleet_start_planet' => 7, 'fleet_end_galaxy' => 1, 'fleet_end_system' => 33, 'fleet_end_planet' => 7, 'metal' => 0, 'crystal' => 0, 'deuterium' => 0);
$attack[$Att]['user'] = array('username' => $LNG['bs_atter'] . ' Nr.' . ($BattleSlotID + 1), 'military_tech' => $BattleSlot[0][109], 'defence_tech' => $BattleSlot[0][110], 'shield_tech' => $BattleSlot[0][111], 0, 'dm_defensive' => 0, 'dm_attack' => 0);
foreach ($BattleSlot[0] as $ID => $Count) {
if (!in_array($ID, $reslist['fleet']) || $BattleSlot[0][$ID] <= 0) {
unset($BattleSlot[0][$ID]);
}
}
if ($Counts[0] == 0 && $BattleSlotID != 0) {
exit('ERROR');
}
$Counts[0] = $Counts[0] + array_sum($BattleSlot[1]);
$attack[$Att]['detail'] = $BattleSlot[0];
}
if (isset($BattleSlot[1]) && (array_sum($BattleSlot[1]) > 0 || $BattleSlotID == 0)) {
$Def = mt_rand(1, 1000);
$defense[$Def]['fleet'] = array('fleet_start_galaxy' => 1, 'fleet_start_system' => 33, 'fleet_start_planet' => 7, 'fleet_end_galaxy' => 1, 'fleet_end_system' => 33, 'fleet_end_planet' => 7, 'metal' => 0, 'crystal' => 0, 'deuterium' => 0);
$defense[$Def]['user'] = array('username' => $LNG['bs_deffer'] . ' Nr.' . ($BattleSlotID + 1), 'military_tech' => $BattleSlot[1][109], 'defence_tech' => $BattleSlot[1][110], 'shield_tech' => $BattleSlot[1][111], 0, 'dm_defensive' => 0, 'dm_attack' => 0);
foreach ($BattleSlot[1] as $ID => $Count) {
if (!in_array($ID, $reslist['fleet']) && !in_array($ID, $reslist['defense'])) {
unset($BattleSlot[1][$ID]);
}
}
if ($Countd[1] == 0 && $BattleSlotID != 0) {
exit('ERROR');
}
$Countd[1] = $Countd[1] + array_sum($BattleSlot[1]);
$defense[$Def]['def'] = $BattleSlot[1];
}
}
$LANG->includeLang(array('FLEET'));
require_once ROOT_PATH . 'includes/classes/missions/calculateAttack.php';
require_once ROOT_PATH . 'includes/classes/missions/calculateSteal.php';
require_once ROOT_PATH . 'includes/classes/missions/GenerateReport.php';
$start = microtime(true);
$result = calculateAttack($attack, $defense, $CONF['Fleet_Cdr'], $CONF['Defs_Cdr']);
$totaltime = microtime(true) - $start;
$steal = $result['won'] == "a" ? calculateSteal($attack, array('metal' => $BattleArray[0][1][1], 'crystal' => $BattleArray[0][1][2], 'deuterium' => $BattleArray[0][1][3]), true) : array('metal' => 0, 'crystal' => 0, 'deuterium' => 0);
$FleetDebris = $result['debree']['att'][0] + $result['debree']['def'][0] + $result['debree']['att'][1] + $result['debree']['def'][1];
$StrAttackerUnits = sprintf($LNG['sys_attacker_lostunits'], $result['lost']['att']);
$StrDefenderUnits = sprintf($LNG['sys_defender_lostunits'], $result['lost']['def']);
$StrRuins = sprintf($LNG['sys_gcdrunits'], $result['debree']['def'][0] + $result['debree']['att'][0], $LNG['Metal'], $result['debree']['def'][1] + $result['debree']['att'][1], $LNG['Crystal']);
$DebrisField = $StrAttackerUnits . "<br>" . $StrDefenderUnits . "<br>" . $StrRuins;
$MoonChance = min(round($FleetDebris / 100000, 0), 20);
$AllSteal = array_sum($steal);
$RaportInfo = sprintf($LNG['bs_derbis_raport'], ceil($FleetDebris / $pricelist[219]['capacity']), $LNG['tech'][219], ceil($FleetDebris / $pricelist[209]['capacity']), $LNG['tech'][209]) . "<br>";
$RaportInfo .= sprintf($LNG['bs_steal_raport'], ceil($AllSteal / $pricelist[202]['capacity']), $LNG['tech'][202], ceil($AllSteal / $pricelist[203]['capacity']), $LNG['tech'][203], ceil($AllSteal / $pricelist[217]['capacity']), $LNG['tech'][217]) . "<br>";
$INFO['moon']['battlesim'] = $RaportInfo;
$INFO['steal'] = $steal;
$INFO['fleet_start_time'] = TIMESTAMP;
$INFO['moon']['des'] = 0;
$INFO['moon']['chance'] = $MoonChance;
$raport = GenerateReport($result, $INFO);
$rid = md5(microtime(true));
file_put_contents(ROOT_PATH . 'raports/raport_' . $rid . '.php', '<?php' . "\n" . '$raport = ' . $raport . ';' . "\n" . '?>');
$SQLQuery = "INSERT INTO " . RW . " SET ";
$SQLQuery .= "`time` = '" . TIMESTAMP . "', ";
$SQLQuery .= "`owners` = '" . $USER['id'] . ",0', ";
$SQLQuery .= "`rid` = '" . $rid . "';";
$db->query($SQLQuery);
echo $rid;
exit;
}
$PlanetRess = new ResourceUpdate();
$PlanetRess->CalcResource();
$PlanetRess->SavePlanetToDB();
foreach ($reslist['fleet'] as $ID) {
$GetFleet[$ID] = $LNG['tech'][$ID];
}
foreach ($reslist['defense'] as $ID) {
if ($ID >= 501) {
break;
}
$GetDef[$ID] = $LNG['tech'][$ID];
}
$template = new template();
$template->loadscript('battlesim.js');
$template->assign_vars(array('lm_battlesim' => $LNG['lm_battlesim'], 'bs_names' => $LNG['bs_names'], 'bs_atter' => $LNG['bs_atter'], 'bs_deffer' => $LNG['bs_deffer'], 'bs_steal' => $LNG['bs_steal'], 'bs_techno' => $LNG['bs_techno'], 'bs_send' => $LNG['bs_send'], 'bs_cancel' => $LNG['bs_cancel'], 'bs_wait' => $LNG['bs_wait'], 'Metal' => $LNG['Metal'], 'Crystal' => $LNG['Crystal'], 'Deuterium' => $LNG['Deuterium'], 'attack_tech' => $LNG['tech'][109], 'shield_tech' => $LNG['tech'][110], 'tank_tech' => $LNG['tech'][111], 'GetFleet' => $GetFleet, 'GetDef' => $GetDef, 'Slots' => $Slots, 'battleinput' => $BattleArray));
$template->show("battlesim.tpl");
}
示例3: EndStayEvent
//.........这里部分代码省略.........
$AttackerTechno = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = " . $this->_fleet['fleet_owner'] . ";");
$DefenderTechno = array('id' => 0, 'username' => $Name, 'military_tech' => min($AttackerTechno['military_tech'] + $Def, 0), 'defence_tech' => min($AttackerTechno['defence_tech'] + $Def, 0), 'shield_tech' => min($AttackerTechno['shield_tech'] + $Def, 0), 'laser_tech' => 0, 'ion_tech' => 0, 'plasma_tech' => 0, 'gravity_tech' => 0, 'rpg_amiral' => 0, 'dm_defensive' => 0, 'dm_attack' => 0, 'experience_combat_level' => min($AttackerTechno['experience_combat_level'], 0), 'academy_1101' => 0, 'academy_1102' => 0, 'academy_1301' => 0, 'academy_1302' => 0, 'academy_1103' => 0, 'academy_1108' => 0, 'academy_1109' => 0, 'academy_1110' => 0, 'academy_1111' => 0, 'academy_1303' => 0, 'academy_1311' => 0);
$fleetID = $this->_fleet['fleet_id'];
$fleetAttack[$fleetID]['fleetDetail'] = $this->_fleet;
$fleetAttack[$fleetID]['player'] = $AttackerTechno;
$fleetAttack[$fleetID]['player']['factor'] = getFactors($fleetAttack[$this->_fleet['fleet_id']]['player'], 'attack', $this->_fleet['fleet_start_time']);
$fleetAttack[$fleetID]['unit'] = array();
$temp = explode(';', $this->_fleet['fleet_array']);
foreach ($temp as $temp2) {
$temp2 = explode(',', $temp2);
if ($temp2[0] < 100) {
continue;
}
if (!isset($fleetAttack[$fleetID]['unit'][$temp2[0]])) {
$fleetAttack[$fleetID]['unit'][$temp2[0]] = 0;
}
$fleetAttack[$fleetID]['unit'][$temp2[0]] += $temp2[1];
}
$fleetDefend = array();
$defRowDef = explode(';', $DefenderFleetArray);
foreach ($defRowDef as $Element) {
$Element = explode(',', $Element);
if ($Element[0] < 100) {
continue;
}
if (!isset($fleetDefend[0]['unit'][$Element[0]])) {
$fleetDefend[0]['unit'][$Element[0]] = 0;
}
$fleetDefend[0]['unit'][$Element[0]] += $Element[1];
}
$fleetDefend[0]['fleetDetail'] = array('fleet_start_galaxy' => $this->_fleet['fleet_end_galaxy'], 'fleet_start_system' => $this->_fleet['fleet_end_system'], 'fleet_start_planet' => $this->_fleet['fleet_end_planet'], 'fleet_start_type' => 1, 'fleet_end_galaxy' => $this->_fleet['fleet_end_galaxy'], 'fleet_end_system' => $this->_fleet['fleet_end_system'], 'fleet_end_planet' => $this->_fleet['fleet_end_planet'], 'fleet_end_type' => 1, 'fleet_resource_metal' => 0, 'fleet_resource_crystal' => 0, 'fleet_resource_deuterium' => 0);
$fleetDefend[0]['player'] = $DefenderTechno;
$fleetDefend[0]['player']['factor'] = 0;
require_once 'calculateAttack.php';
$fleetIntoDebris = $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['Fleet_Cdr'];
$defIntoDebris = $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['Defs_Cdr'];
$combatResult = calculateAttack($fleetAttack, $fleetDefend, $fleetIntoDebris, $defIntoDebris);
$fleetArray = '';
$totalCount = 0;
$fleetAttack[$fleetID]['unit'] = array_filter($fleetAttack[$fleetID]['unit']);
foreach ($fleetAttack[$fleetID]['unit'] as $element => $amount) {
$fleetArray .= $element . ',' . $amount . ';';
$totalCount += $amount;
}
if ($totalCount <= 0) {
$this->KillFleet();
} else {
$this->UpdateFleet('fleet_array', substr($fleetArray, 0, -1));
$this->UpdateFleet('fleet_amount', $totalCount);
}
require_once 'GenerateReport.php';
$debrisRessource = array(901, 902);
foreach ($debrisRessource as $elementID) {
$debris[$elementID] = 0;
}
$stealResource = array(901 => 0, 902 => 0, 903 => 0);
$raportInfo = array('thisFleet' => $this->_fleet, 'debris' => $debris, 'stealResource' => $stealResource, 'moonChance' => 0, 'moonDestroy' => false, 'moonName' => null, 'moonDestroyChance' => null, 'moonDestroySuccess' => null, 'fleetDestroyChance' => null, 'fleetDestroySuccess' => null);
$raportData = GenerateReport($combatResult, $raportInfo);
$raportID = md5(uniqid('', true) . TIMESTAMP);
$sqlQuery = "INSERT INTO " . RW . " SET rid = '" . $raportID . "', raport = '" . serialize($raportData) . "', time = '" . $this->_fleet['fleet_start_time'] . "', attacker = '" . $this->_fleet['fleet_owner'] . "';";
$GLOBALS['DATABASE']->query($sqlQuery);
switch ($combatResult['won']) {
case "a":
$attackClass = 'style="color:green;"';
$defendClass = 'style="color:red;"';
break;
示例4: MissionCaseAttack
private function MissionCaseAttack($FleetRow)
{
global $pricelist, $lang, $resource, $CombatCaps, $game_config, $user;
if ($FleetRow['fleet_mess'] == 0 && $FleetRow['fleet_start_time'] <= time()) {
$targetPlanet = doquery("SELECT * FROM {{table}} WHERE `galaxy` = " . intval($FleetRow['fleet_end_galaxy']) . " AND `system` = " . intval($FleetRow['fleet_end_system']) . " AND `planet_type` = " . intval($FleetRow['fleet_end_type']) . " AND `planet` = " . intval($FleetRow['fleet_end_planet']) . ";", 'planets', true);
if ($FleetRow['fleet_group'] > 0) {
doquery("DELETE FROM {{table}} WHERE id =" . intval($FleetRow['fleet_group']), 'aks');
doquery("UPDATE {{table}} SET fleet_mess=1 WHERE fleet_group=" . $FleetRow['fleet_group'], 'fleets');
} else {
doquery("UPDATE {{table}} SET fleet_mess=1 WHERE fleet_id=" . intval($FleetRow['fleet_id']), 'fleets');
}
$targetGalaxy = doquery('SELECT * FROM {{table}} WHERE `galaxy` = ' . intval($FleetRow['fleet_end_galaxy']) . ' AND `system` = ' . intval($FleetRow['fleet_end_system']) . ' AND `planet` = ' . intval($FleetRow['fleet_end_planet']) . ';', 'galaxy', true);
$targetUser = doquery('SELECT * FROM {{table}} WHERE id=' . intval($targetPlanet['id_owner']), 'users', true);
PlanetResourceUpdate($targetUser, $targetPlanet, time());
$targetGalaxy = doquery('SELECT * FROM {{table}} WHERE `galaxy` = ' . intval($FleetRow['fleet_end_galaxy']) . ' AND `system` = ' . intval($FleetRow['fleet_end_system']) . ' AND `planet` = ' . intval($FleetRow['fleet_end_planet']) . ';', 'galaxy', true);
$targetUser = doquery('SELECT * FROM {{table}} WHERE id=' . intval($targetPlanet['id_owner']), 'users', true);
$TargetUserID = $targetUser['id'];
$attackFleets = array();
if ($FleetRow['fleet_group'] != 0) {
$fleets = doquery('SELECT * FROM {{table}} WHERE fleet_group=' . $FleetRow['fleet_group'], 'fleets');
while ($fleet = mysql_fetch_assoc($fleets)) {
$attackFleets[$fleet['fleet_id']]['fleet'] = $fleet;
$attackFleets[$fleet['fleet_id']]['user'] = doquery('SELECT * FROM {{table}} WHERE id =' . intval($fleet['fleet_owner']), 'users', true);
$attackFleets[$fleet['fleet_id']]['detail'] = array();
$temp = explode(';', $fleet['fleet_array']);
foreach ($temp as $temp2) {
$temp2 = explode(',', $temp2);
if ($temp2[0] < 100) {
continue;
}
if (!isset($attackFleets[$fleet['fleet_id']]['detail'][$temp2[0]])) {
$attackFleets[$fleet['fleet_id']]['detail'][$temp2[0]] = 0;
}
$attackFleets[$fleet['fleet_id']]['detail'][$temp2[0]] += $temp2[1];
}
}
} else {
$attackFleets[$FleetRow['fleet_id']]['fleet'] = $FleetRow;
$attackFleets[$FleetRow['fleet_id']]['user'] = doquery('SELECT * FROM {{table}} WHERE id=' . intval($FleetRow['fleet_owner']), 'users', true);
$attackFleets[$FleetRow['fleet_id']]['detail'] = array();
$temp = explode(';', $FleetRow['fleet_array']);
foreach ($temp as $temp2) {
$temp2 = explode(',', $temp2);
if ($temp2[0] < 100) {
continue;
}
if (!isset($attackFleets[$FleetRow['fleet_id']]['detail'][$temp2[0]])) {
$attackFleets[$FleetRow['fleet_id']]['detail'][$temp2[0]] = 0;
}
$attackFleets[$FleetRow['fleet_id']]['detail'][$temp2[0]] += $temp2[1];
}
}
$defense = array();
$def = doquery('SELECT * FROM {{table}} WHERE `fleet_end_galaxy` = ' . intval($FleetRow['fleet_end_galaxy']) . ' AND `fleet_end_system` = ' . intval($FleetRow['fleet_end_system']) . ' AND `fleet_end_type` = ' . intval($FleetRow['fleet_end_type']) . ' AND `fleet_end_planet` = ' . intval($FleetRow['fleet_end_planet']) . ' AND fleet_start_time<' . time() . ' AND fleet_end_stay>=' . time(), 'fleets');
while ($defRow = mysql_fetch_assoc($def)) {
$defRowDef = explode(';', $defRow['fleet_array']);
foreach ($defRowDef as $Element) {
$Element = explode(',', $Element);
if ($Element[0] < 100) {
continue;
}
if (!isset($defense[$defRow['fleet_id']]['def'][$Element[0]])) {
$defense[$defRow['fleet_id']][$Element[0]] = 0;
}
$defense[$defRow['fleet_id']]['def'][$Element[0]] += $Element[1];
$defense[$defRow['fleet_id']]['user'] = doquery('SELECT * FROM {{table}} WHERE id=' . intval($defRow['fleet_owner']), 'users', true);
}
}
$defense[0]['def'] = array();
$defense[0]['user'] = $targetUser;
for ($i = 200; $i < 500; $i++) {
if (isset($resource[$i]) && isset($targetPlanet[$resource[$i]])) {
$defense[0]['def'][$i] = $targetPlanet[$resource[$i]];
}
}
$start = microtime(true);
$result = calculateAttack($attackFleets, $defense);
$totaltime = microtime(true) - $start;
$QryUpdateGalaxy = "UPDATE {{table}} SET ";
$QryUpdateGalaxy .= "`metal` = `metal` +'" . ($result['debree']['att'][0] + $result['debree']['def'][0]) . "', ";
$QryUpdateGalaxy .= "`crystal` = `crystal` + '" . ($result['debree']['att'][1] + $result['debree']['def'][1]) . "' ";
$QryUpdateGalaxy .= "WHERE ";
$QryUpdateGalaxy .= "`galaxy` = '" . intval($FleetRow['fleet_end_galaxy']) . "' AND ";
$QryUpdateGalaxy .= "`system` = '" . intval($FleetRow['fleet_end_system']) . "' AND ";
$QryUpdateGalaxy .= "`planet` = '" . intval($FleetRow['fleet_end_planet']) . "' ";
$QryUpdateGalaxy .= "LIMIT 1;";
doquery($QryUpdateGalaxy, 'galaxy');
$totalDebree = $result['debree']['def'][0] + $result['debree']['def'][1] + $result['debree']['att'][0] + $result['debree']['att'][1];
$steal = array('metal' => 0, 'crystal' => 0, 'deuterium' => 0);
if ($result['won'] == "a") {
$steal = self::calculateAKSSteal($attackFleets, $targetPlanet);
}
foreach ($attackFleets as $fleetID => $attacker) {
$fleetArray = '';
$totalCount = 0;
foreach ($attacker['detail'] as $element => $amount) {
if ($amount) {
$fleetArray .= $element . ',' . $amount . ';';
}
$totalCount += $amount;
//.........这里部分代码省略.........
示例5: EndStayEvent
//.........这里部分代码省略.........
} elseif (0 == $FindSize) {
$Message = $LNG['sys_expe_attack_' . $Which . '_3_' . $Rand[2]];
$MaxAttackerPoints = 0.3 + $Add + mt_rand($Points[2], abs($Points[2])) * 0.01;
}
foreach ($FleetCount as $ID => $count) {
$DefenderFleetArray .= $ID . "," . round($count * $MaxAttackerPoints) . ";";
}
$AttackerTechno = $db->uniquequery('SELECT id,username,military_tech,defence_tech,shield_tech,rpg_amiral,dm_defensive,dm_attack FROM ' . USERS . ' WHERE id=' . $this->_fleet['fleet_owner'] . ";");
$DefenderTechno = array('id' => 0, 'username' => $Name, 'military_tech' => min($AttackerTechno['military_tech'] + $Def, 0), 'defence_tech' => min($AttackerTechno['defence_tech'] + $Def, 0), 'shield_tech' => min($AttackerTechno['shield_tech'] + $Def, 0), 'rpg_amiral' => 0, 'dm_defensive' => 0, 'dm_attack' => 0);
$attackFleets[$this->_fleet['fleet_id']]['fleet'] = $this->_fleet;
$attackFleets[$this->_fleet['fleet_id']]['user'] = $AttackerTechno;
$attackFleets[$this->_fleet['fleet_id']]['detail'] = array();
$temp = explode(';', $this->_fleet['fleet_array']);
foreach ($temp as $temp2) {
$temp2 = explode(',', $temp2);
if ($temp2[0] < 100) {
continue;
}
if (!isset($attackFleets[$this->_fleet['fleet_id']]['detail'][$temp2[0]])) {
$attackFleets[$this->_fleet['fleet_id']]['detail'][$temp2[0]] = 0;
}
$attackFleets[$this->_fleet['fleet_id']]['detail'][$temp2[0]] += $temp2[1];
}
$defense = array();
$defRowDef = explode(';', $DefenderFleetArray);
foreach ($defRowDef as $Element) {
$Element = explode(',', $Element);
if ($Element[0] < 100) {
continue;
}
if (!isset($defense[$defRow['fleet_id']]['def'][$Element[0]])) {
$defense[0][$Element[0]] = 0;
}
$defense[0]['def'][$Element[0]] += $Element[1];
}
$defense[0]['user'] = $DefenderTechno;
require_once 'calculateAttack.' . PHP_EXT;
$start = microtime(true);
$result = calculateAttack($attackFleets, $defense);
$totaltime = microtime(true) - $start;
foreach ($attackFleets as $fleetID => $attacker) {
$fleetArray = '';
$totalCount = 0;
foreach ($attacker['detail'] as $element => $amount) {
if ($amount) {
$fleetArray .= $element . ',' . $amount . ';';
}
$totalCount += $amount;
}
if ($totalCount <= 0) {
$this->KillFleet();
} else {
$this->UpdateFleet('fleet_array', substr($fleetArray, 0, -1));
$this->UpdateFleet('fleet_amount', $totalCount);
}
}
require_once 'GenerateReport.' . PHP_EXT;
$raport = GenerateReport($result, $INFO);
$rid = md5(microtime(true) . mt_rand(1, 100));
file_put_contents(ROOT_PATH . 'raports/raport_' . $rid . '.php', '<?php' . "\n" . '$raport = ' . $raport . ';' . "\n" . '?>');
$SQLQuery = "INSERT INTO " . RW . " SET `time` = '" . TIMESTAMP . "', `owners` = '" . $this->_fleet['fleet_owner'] . ",0', `rid` = '" . $rid . "', `raport` = '';";
$db->query($SQLQuery);
switch ($result['won']) {
case "r":
$ColorAtt = "red";
$ColorDef = "green";
break;
case "w":
$ColorAtt = "orange";
$ColorDef = "orange";
case "a":
$ColorAtt = "green";
$ColorDef = "red";
break;
}
$MessageAtt = sprintf('<a href="CombatReport.php?raport=%s" onclick="OpenPopup(\'CombatReport.php?raport=%s\', \'combat\', screen.width, screen.height);return false" target="combat"><center><font color="%s">%s %s</font></a><br><br><font color="%s">%s: %s</font> <font color="%s">%s: %s</font><br>%s %s:<font color="#adaead">%s</font> %s:<font color="#ef51ef">%s</font> %s:<font color="#f77542">%s</font><br>%s %s:<font color="#adaead">%s</font> %s:<font color="#ef51ef">%s</font><br></center>', $rid, $rid, $ColorAtt, $LNG['sys_mess_attack_report'], sprintf($LNG['sys_adress_planet'], $this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet']), $ColorAtt, $LNG['sys_perte_attaquant'], pretty_number($result['lost']['att']), $ColorDef, $LNG['sys_perte_defenseur'], pretty_number($result['lost']['def']), $LNG['sys_gain'], $LNG['Metal'], pretty_number($steal['metal']), $LNG['Crystal'], pretty_number($steal['crystal']), $LNG['Deuterium'], pretty_number($steal['deuterium']), $LNG['sys_debris'], $LNG['Metal'], pretty_number($result['debree']['att'][0] + $result['debree']['def'][0]), $LNG['Crystal'], pretty_number($result['debree']['att'][1] + $result['debree']['def'][1]));
SendSimpleMessage($this->_fleet['fleet_owner'], '', $this->_fleet['fleet_start_time'], 3, $LNG['sys_mess_tower'], $LNG['sys_mess_attack_report'], $MessageAtt);
break;
case 5:
$this->KillFleet();
$Message = $LNG['sys_expe_lost_fleet_' . mt_rand(1, 4)];
break;
case 6:
$MoreTime = mt_rand(0, 100);
if ($MoreTime < 75) {
$this->UpdateFleet('fleet_end_time', $this->_fleet['fleet_end_time'] - TIMESTAMP * mt_rand(1, 5) + TIMESTAMP);
$Message = $LNG['sys_expe_time_slow_' . mt_rand(1, 6)];
} else {
$this->UpdateFleet('fleet_end_time', round($this->_fleet['fleet_end_stay'] + ($this->_fleet['fleet_end_time'] - $this->_fleet['fleet_end_stay']) / 2));
$Message = $LNG['sys_expe_time_fast_' . mt_rand(1, 3)];
}
break;
default:
$Message = $LNG['sys_expe_nothing_' . mt_rand(1, 8)];
break;
}
SendSimpleMessage($this->_fleet['fleet_owner'], '', $this->_fleet['fleet_end_stay'], 15, $LNG['sys_mess_tower'], $LNG['sys_expe_report'], $Message);
$this->UpdateFleet('fleet_mess', 1);
$this->SaveFleet();
}
示例6: EndStayEvent
//.........这里部分代码省略.........
$attackFactor = 40 + mt_rand(-4, 4) / 100;
$targetFleetData[204] = 5;
} elseif (0 < $eventSize && 10 >= $eventSize) {
$Message = $LNG['sys_expe_attack_1_3_3'];
$attackFactor = 60 + mt_rand(-6, 6) / 100;
$targetFleetData[215] = 3;
} else {
$Message = $LNG['sys_expe_attack_1_3_2'];
$attackFactor = 90 + mt_rand(-9, 9) / 100;
$targetFleetData[213] = 2;
}
}
foreach ($fleetArray as $shipId => $shipAmount) {
if (isset($targetFleetData[$shipId])) {
$targetFleetData[$shipId] = 0;
}
$targetFleetData[$shipId] = $roundFunction($shipAmount * $attackFactor);
}
$targetFleetData = array_filter($targetFleetData);
$sql = 'SELECT * FROM %%USERS%% WHERE id = :userId;';
$senderData = Database::get()->selectSingle($sql, array(':userId' => $this->_fleet['fleet_owner']));
$targetData = array('id' => 0, 'username' => $targetName, 'military_tech' => min($senderData['military_tech'] + $techBonus, 0), 'defence_tech' => min($senderData['defence_tech'] + $techBonus, 0), 'shield_tech' => min($senderData['shield_tech'] + $techBonus, 0), 'rpg_amiral' => 0, 'dm_defensive' => 0, 'dm_attack' => 0);
$fleetID = $this->_fleet['fleet_id'];
$fleetAttack[$fleetID]['fleetDetail'] = $this->_fleet;
$fleetAttack[$fleetID]['player'] = $senderData;
$fleetAttack[$fleetID]['player']['factor'] = getFactors($fleetAttack[$this->_fleet['fleet_id']]['player'], 'attack', $this->_fleet['fleet_start_time']);
$fleetAttack[$fleetID]['unit'] = $fleetArray;
$fleetDefend = array();
$fleetDefend[0]['fleetDetail'] = array('fleet_start_galaxy' => $this->_fleet['fleet_end_galaxy'], 'fleet_start_system' => $this->_fleet['fleet_end_system'], 'fleet_start_planet' => $this->_fleet['fleet_end_planet'], 'fleet_start_type' => 1, 'fleet_end_galaxy' => $this->_fleet['fleet_end_galaxy'], 'fleet_end_system' => $this->_fleet['fleet_end_system'], 'fleet_end_planet' => $this->_fleet['fleet_end_planet'], 'fleet_end_type' => 1, 'fleet_resource_metal' => 0, 'fleet_resource_crystal' => 0, 'fleet_resource_deuterium' => 0);
$bonusList = BuildFunctions::getBonusList();
$fleetDefend[0]['player'] = $targetData;
$fleetDefend[0]['player']['factor'] = ArrayUtil::combineArrayWithSingleElement($bonusList, 0);
$fleetDefend[0]['unit'] = $targetFleetData;
require_once 'includes/classes/missions/functions/calculateAttack.php';
$combatResult = calculateAttack($fleetAttack, $fleetDefend, $config->Fleet_Cdr, $config->Defs_Cdr);
$fleetArray = '';
$totalCount = 0;
$fleetAttack[$fleetID]['unit'] = array_filter($fleetAttack[$fleetID]['unit']);
foreach ($fleetAttack[$fleetID]['unit'] as $element => $amount) {
$fleetArray .= $element . ',' . $amount . ';';
$totalCount += $amount;
}
if ($totalCount <= 0) {
$this->KillFleet();
} else {
$this->UpdateFleet('fleet_array', substr($fleetArray, 0, -1));
$this->UpdateFleet('fleet_amount', $totalCount);
}
require_once 'includes/classes/missions/functions/GenerateReport.php';
$debrisResource = array(901, 902);
$debris = array();
foreach ($debrisResource as $elementID) {
$debris[$elementID] = 0;
}
$stealResource = array(901 => 0, 902 => 0, 903 => 0);
$reportInfo = array('thisFleet' => $this->_fleet, 'debris' => $debris, 'stealResource' => $stealResource, 'moonChance' => 0, 'moonDestroy' => false, 'moonName' => NULL, 'moonDestroyChance' => NULL, 'moonDestroySuccess' => NULL, 'fleetDestroyChance' => NULL, 'fleetDestroySuccess' => NULL);
$reportData = GenerateReport($combatResult, $reportInfo);
$reportID = md5(uniqid('', true) . TIMESTAMP);
$sql = "INSERT INTO %%RW%% SET\n\t\t\t\trid\t\t\t= :reportId,\n\t\t\t\traport\t\t= :reportData,\n\t\t\t\ttime\t\t= :time,\n\t\t\t\tattacker\t= :attacker;";
Database::get()->insert($sql, array(':reportId' => $reportID, ':reportData' => serialize($reportData), ':time' => $this->_fleet['fleet_start_time'], ':attacker' => $this->_fleet['fleet_owner']));
switch ($combatResult['won']) {
case "a":
$attackClass = 'raportWin';
$defendClass = 'raportLose';
break;
case "r":
示例7: TargetEvent
//.........这里部分代码省略.........
$incomingFleets = array($this->_fleet['fleet_id'] => $this->_fleet);
}
foreach ($incomingFleets as $fleetID => $fleetDetail) {
$fleetAttack[$fleetID]['fleetDetail'] = $fleetDetail;
$fleetAttack[$fleetID]['player'] = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = '" . $fleetDetail['fleet_owner'] . "';");
$fleetAttack[$fleetID]['player']['factor'] = getFactors($fleetAttack[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']);
$fleetAttack[$fleetID]['unit'] = fleetAmountToArray($fleetDetail['fleet_array'] . ';306,' . $fleetDetail['fleet_population_306'] . ';307,' . $fleetDetail['fleet_population_307']);
$userAttack[$fleetAttack[$fleetID]['player']['id']] = $fleetAttack[$fleetID]['player']['username'];
}
$targetFleetsResult = $GLOBALS['DATABASE']->query("SELECT * FROM " . FLEETS . " WHERE fleet_mission = '5' AND fleet_end_id = '" . $this->_fleet['fleet_end_id'] . "' AND fleet_start_time <= '" . TIMESTAMP . "' AND fleet_end_stay >= '" . TIMESTAMP . "';");
while ($fleetDetail = $GLOBALS['DATABASE']->fetch_array($targetFleetsResult)) {
$fleetID = $fleetDetail['fleet_id'];
$fleetDefend[$fleetID]['fleetDetail'] = $fleetDetail;
$fleetDefend[$fleetID]['player'] = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = '" . $fleetDetail['fleet_owner'] . "';");
$fleetDefend[$fleetID]['player']['factor'] = getFactors($fleetDefend[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']);
$fleetDefend[$fleetID]['unit'] = fleetAmountToArray($fleetDetail['fleet_array']);
$userDefend[$fleetDefend[$fleetID]['player']['id']] = $fleetDefend[$fleetID]['player']['username'];
}
$GLOBALS['DATABASE']->free_result($targetFleetsResult);
$fleetDefend[0]['player'] = $targetUser;
$fleetDefend[0]['player']['factor'] = getFactors($fleetDefend[0]['player'], 'attack', $this->_fleet['fleet_start_time']);
$fleetDefend[0]['fleetDetail'] = array('fleet_start_galaxy' => $targetPlanet['galaxy'], 'fleet_start_system' => $targetPlanet['system'], 'fleet_start_planet' => $targetPlanet['planet'], 'fleet_start_type' => $targetPlanet['planet_type']);
$fleetDefend[0]['unit'] = array();
$avaible_fleets = array(202, 203, 209, 223, 219, 210, 204, 205, 206, 207, 211, 214, 215, 216);
$avaible_def = array(401, 402, 403, 404, 405, 406, 407, 408);
$avaible_pop = array(306, 307);
foreach (array_merge($avaible_fleets, $avaible_def, $avaible_pop) as $elementID) {
if (empty($targetPlanet[$resource[$elementID]])) {
continue;
}
$fleetDefend[0]['unit'][$elementID] = $targetPlanet[$resource[$elementID]];
}
$userDefend[$fleetDefend[0]['player']['id']] = $fleetDefend[0]['player']['username'];
require_once 'calculateAttack.php';
$fleetIntoDebris = $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['Fleet_Cdr'];
$defIntoDebris = $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['Defs_Cdr'];
$combatResult = calculateAttack($fleetAttack, $fleetDefend, $fleetIntoDebris, $defIntoDebris);
$sqlQuery = "";
foreach ($fleetAttack as $fleetID => $fleetDetail) {
$fleetArray = '';
$totalCount = 0;
$fleetDetail['unit'] = array_filter($fleetDetail['unit']);
foreach ($fleetDetail['unit'] as $elementID => $amount) {
$fleetArray .= $elementID . ',' . floattostring($amount) . ';';
$totalCount += $amount;
}
if ($totalCount == 0) {
if ($this->_fleet['fleet_id'] == $fleetID) {
$this->KillFleet();
} else {
$sqlQuery .= "DELETE FROM " . FLEETS . " WHERE fleet_id = " . $fleetID . ";";
$sqlQuery .= "DELETE FROM " . FLEETS_EVENT . " WHERE fleetID = " . $fleetID . ";";
}
$sqlQuery .= "UPDATE " . LOG_FLEETS . " SET fleet_state = 2 WHERE fleet_id = '" . $fleetID . "';";
} elseif ($totalCount > 0) {
$sqlQuery .= "UPDATE " . FLEETS . " SET fleet_array = '" . substr($fleetArray, 0, -1) . "', fleet_amount = '" . $totalCount . "' WHERE fleet_id = '" . $fleetID . "';";
$sqlQuery .= "UPDATE " . LOG_FLEETS . " SET fleet_array = '" . substr($fleetArray, 0, -1) . "', fleet_amount = '" . $totalCount . "', fleet_state = 1 WHERE fleet_id = '" . $fleetID . "';";
} else {
throw new Exception("Negative Fleet amount ....");
}
}
foreach ($fleetDefend as $fleetID => $fleetDetail) {
if ($fleetID != 0) {
$fleetArray = '';
$totalCount = 0;
$fleetDetail['unit'] = array_filter($fleetDetail['unit']);
示例8: MissionCaseDestruction
/**
* MissionCaseDestruction.php
* @Licence GNU (GPL)
* @version 2.2
* @copyright 2009
* @Team Space Beginner
*/
function MissionCaseDestruction($FleetRow)
{
global $phpEx, $xnova_root_path, $pricelist, $lang, $resource, $CombatCaps, $game_config, $user;
includeLang('system');
if ($FleetRow['fleet_mess'] == 0 && $FleetRow['fleet_start_time'] <= time()) {
if (!isset($CombatCaps[202]['sd'])) {
message('<font color=red>' . $lang['sys_no_vars'] . '</font><br />(Error: <font color=red>(!isset($pricelist[202][\'sd\']))</font>. Please report this to an admin.)', $lang['sys_error'], 'fleet.php', 15);
}
$targetPlanet = doquery("SELECT * FROM {{table}} WHERE `galaxy` = " . $FleetRow['fleet_end_galaxy'] . " AND `system` = " . $FleetRow['fleet_end_system'] . " AND `planet_type` = " . $FleetRow['fleet_end_type'] . " AND `planet` = " . $FleetRow['fleet_end_planet'] . ";", 'planets', true);
// if (!isset($targetPlanet['id'])) {
if ($FleetRow['fleet_group'] > 0) {
//MadnessRed Code
doquery("DELETE FROM {{table}} WHERE id =" . $FleetRow['fleet_group'], 'aks');
doquery("UPDATE {{table}} SET fleet_mess=1 WHERE fleet_group=" . $FleetRow['fleet_group'], 'fleets');
} else {
doquery("UPDATE {{table}} SET fleet_mess=1 WHERE fleet_id=" . $FleetRow['fleet_id'], 'fleets');
}
// return;
//}
// Mise à jour de la cible ...
// On recharge les infos qui viennent d'être mises à jour
$targetGalaxy = doquery('SELECT * FROM {{table}} WHERE `galaxy` = ' . $FleetRow['fleet_end_galaxy'] . ' AND `system` = ' . $FleetRow['fleet_end_system'] . ' AND `planet` = ' . $FleetRow['fleet_end_planet'] . ';', 'galaxy', true);
$targetUser = doquery('SELECT * FROM {{table}} WHERE id=' . $targetPlanet['id_owner'], 'users', true);
$TargetUserID = $targetUser['id'];
PlanetResourceUpdate($targetUser, $targetPlanet, time());
// AG : Mettre toutes les flottes dans un tableau
$attackFleets = array();
// De forme : attackFleets[id] = array('fleet' => $FleetRow, 'user' => $user);
if ($FleetRow['fleet_group'] != 0) {
$fleets = doquery('SELECT * FROM {{table}} WHERE fleet_group=' . $FleetRow['fleet_group'], 'fleets');
while ($fleet = mysql_fetch_assoc($fleets)) {
$attackFleets[$fleet['fleet_id']]['fleet'] = $fleet;
$attackFleets[$fleet['fleet_id']]['user'] = doquery('SELECT * FROM {{table}} WHERE id =' . $fleet['fleet_owner'], 'users', true);
$attackFleets[$fleet['fleet_id']]['detail'] = array();
$temp = explode(';', $fleet['fleet_array']);
foreach ($temp as $temp2) {
$temp2 = explode(',', $temp2);
if ($temp2[0] < 100) {
continue;
}
if (!isset($attackFleets[$fleet['fleet_id']]['detail'][$temp2[0]])) {
$attackFleets[$fleet['fleet_id']]['detail'][$temp2[0]] = 0;
}
$attackFleets[$fleet['fleet_id']]['detail'][$temp2[0]] += $temp2[1];
}
}
} else {
$attackFleets[$FleetRow['fleet_id']]['fleet'] = $FleetRow;
$attackFleets[$FleetRow['fleet_id']]['user'] = doquery('SELECT * FROM {{table}} WHERE id=' . $FleetRow['fleet_owner'], 'users', true);
$attackFleets[$FleetRow['fleet_id']]['detail'] = array();
$temp = explode(';', $FleetRow['fleet_array']);
foreach ($temp as $temp2) {
$temp2 = explode(',', $temp2);
if ($temp2[0] < 100) {
continue;
}
if (!isset($attackFleets[$FleetRow['fleet_id']]['detail'][$temp2[0]])) {
$attackFleets[$FleetRow['fleet_id']]['detail'][$temp2[0]] = 0;
}
$attackFleets[$FleetRow['fleet_id']]['detail'][$temp2[0]] += $temp2[1];
}
}
$defense = array();
$def = doquery('SELECT * FROM {{table}} WHERE `fleet_end_galaxy` = ' . $FleetRow['fleet_end_galaxy'] . ' AND `fleet_end_system` = ' . $FleetRow['fleet_end_system'] . ' AND `fleet_end_type` = ' . $FleetRow['fleet_end_type'] . ' AND `fleet_end_planet` = ' . $FleetRow['fleet_end_planet'] . ' AND fleet_start_time<' . time() . ' AND fleet_end_stay>=' . time(), 'fleets');
while ($defRow = mysql_fetch_assoc($def)) {
$defRowDef = explode(';', $defRow['fleet_array']);
foreach ($defRowDef as $Element) {
$Element = explode(',', $Element);
if ($Element[0] < 100) {
continue;
}
if (!isset($defense[$defRow['fleet_id']]['def'][$Element[0]])) {
$defense[$defRow['fleet_id']][$Element[0]] = 0;
}
$defense[$defRow['fleet_id']]['def'][$Element[0]] += $Element[1];
$defense[$defRow['fleet_id']]['user'] = doquery('SELECT * FROM {{table}} WHERE id=' . $defRow['fleet_owner'], 'users', true);
}
}
$defense[0]['def'] = array();
$defense[0]['user'] = $targetUser;
for ($i = 200; $i < 500; $i++) {
if (isset($resource[$i]) && isset($targetPlanet[$resource[$i]])) {
$defense[0]['def'][$i] = $targetPlanet[$resource[$i]];
}
}
$start = microtime(true);
$result = calculateAttack($attackFleets, $defense);
$totaltime = microtime(true) - $start;
// Mise a jour du champ de ruine devant la planete attaquée
$QryUpdateGalaxy = "UPDATE {{table}} SET ";
$QryUpdateGalaxy .= "`metal` = `metal` +'" . ($result['debree']['att'][0] + $result['debree']['def'][0]) . "', ";
$QryUpdateGalaxy .= "`crystal` = `crystal` + '" . ($result['debree']['att'][1] + $result['debree']['def'][1]) . "', ";
$QryUpdateGalaxy .= "`appolonium` = `appolonium` + '" . ($result['debree']['att'][2] + $result['debree']['def'][2]) . "' ";
//.........这里部分代码省略.........
示例9: send
function send()
{
global $USER, $PLANET, $reslist, $pricelist, $LNG, $CONF;
if (!isset($_REQUEST['battleinput'])) {
$this->sendJSON(0);
}
$pid = HTTP::_GP('pid', 0);
$targetUser = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = " . $pid . ";");
$BattleArray = $_REQUEST['battleinput'];
$elements = array(0, 0);
foreach ($BattleArray as $BattleSlotID => $BattleSlot) {
if (isset($BattleSlot[0]) && (array_sum($BattleSlot[0]) > 0 || $BattleSlotID == 0)) {
$attacker = array();
$attacker['fleetDetail'] = array('fleet_start_galaxy' => 1, 'fleet_start_system' => 33, 'fleet_start_planet' => 7, 'fleet_start_type' => 1, 'fleet_end_galaxy' => 1, 'fleet_end_system' => 33, 'fleet_end_planet' => 7, 'fleet_end_type' => 1, 'fleet_resource_metal' => 0, 'fleet_resource_crystal' => 0, 'fleet_resource_deuterium' => 0);
$attacker['player'] = array('id' => 1000 + $BattleSlotID + 1, 'username' => $LNG['bs_atter'] . ' Nr.' . ($BattleSlotID + 1), 'military_tech' => $BattleSlot[0][109], 'defence_tech' => $BattleSlot[0][110], 'shield_tech' => $BattleSlot[0][111], 'laser_tech' => $BattleSlot[0][120], 'ion_tech' => $BattleSlot[0][121], 'plasma_tech' => $BattleSlot[0][122], 'gravity_tech' => $BattleSlot[0][199], 'rpg_amiral' => $BattleSlot[0][602], 'academy_1101' => $USER['academy_1101'], 'academy_1102' => $USER['academy_1102'], 'academy_1301' => $USER['academy_1301'], 'academy_1302' => $USER['academy_1302'], 'academy_1103' => $BattleSlot[0][1103], 'academy_1108' => $BattleSlot[0][1108], 'academy_1109' => $BattleSlot[0][1109], 'academy_1110' => $BattleSlot[0][1110], 'academy_1111' => $BattleSlot[0][1111], 'academy_1303' => $BattleSlot[0][1303], 'academy_1311' => $BattleSlot[0][1311], 'experience_combat_level' => $USER['experience_combat_level']);
$attacker['player']['factor'] = getFactors($attacker['player'], 'attack');
foreach ($BattleSlot[0] as $ID => $Count) {
if (!in_array($ID, $reslist['fleet']) || $BattleSlot[0][$ID] <= 0) {
unset($BattleSlot[0][$ID]);
}
}
$attacker['unit'] = $BattleSlot[0];
$attackers[] = $attacker;
}
if (isset($BattleSlot[1]) && (array_sum($BattleSlot[1]) > 0 || $BattleSlotID == 0)) {
$defender = array();
$defender['fleetDetail'] = array('fleet_start_galaxy' => 1, 'fleet_start_system' => 33, 'fleet_start_planet' => 7, 'fleet_start_type' => 1, 'fleet_end_galaxy' => 1, 'fleet_end_system' => 33, 'fleet_end_planet' => 7, 'fleet_end_type' => 1, 'fleet_resource_metal' => 0, 'fleet_resource_crystal' => 0, 'fleet_resource_deuterium' => 0);
$defender['player'] = array('id' => 2000 + $BattleSlotID + 1, 'username' => $LNG['bs_deffer'] . ' Nr.' . ($BattleSlotID + 1), 'military_tech' => $BattleSlot[1][109], 'defence_tech' => $BattleSlot[1][110], 'shield_tech' => $BattleSlot[1][111], 'laser_tech' => $BattleSlot[1][120], 'ion_tech' => $BattleSlot[1][121], 'plasma_tech' => $BattleSlot[1][122], 'gravity_tech' => $BattleSlot[1][199], 'rpg_amiral' => $BattleSlot[1][602], 'academy_1101' => $targetUser['academy_1101'], 'academy_1102' => $targetUser['academy_1102'], 'academy_1301' => $targetUser['academy_1301'], 'academy_1302' => $targetUser['academy_1302'], 'academy_1103' => $BattleSlot[1][1103], 'academy_1108' => $BattleSlot[1][1108], 'academy_1109' => $BattleSlot[1][1109], 'academy_1110' => $BattleSlot[1][1110], 'academy_1111' => $BattleSlot[1][1111], 'academy_1303' => $BattleSlot[1][1303], 'academy_1311' => $BattleSlot[1][1311], 'experience_combat_level' => 0);
$defender['player']['factor'] = getFactors($defender['player'], 'attack');
foreach ($BattleSlot[1] as $ID => $Count) {
if (!in_array($ID, $reslist['fleet']) && !in_array($ID, $reslist['defense']) || $BattleSlot[1][$ID] <= 0) {
unset($BattleSlot[1][$ID]);
}
}
$defender['unit'] = $BattleSlot[1];
$defenders[] = $defender;
}
}
$LNG->includeData(array('FLEET'));
require_once 'includes/classes/missions/calculateAttack.php';
require_once 'includes/classes/missions/calculateSteal.php';
require_once 'includes/classes/missions/GenerateReport.php';
$combatResult = calculateAttack($attackers, $defenders, Config::get('Fleet_Cdr'), Config::get('Defs_Cdr'));
if ($combatResult['won'] == "a") {
$stealResource = calculateSteal($attackers, array('metal' => $BattleArray[0][1][1], 'crystal' => $BattleArray[0][1][2], 'deuterium' => $BattleArray[0][1][3]), true);
} else {
$stealResource = array(901 => 0, 902 => 0, 903 => 0);
}
$debris = array();
foreach (array(901, 902) as $elementID) {
$debris[$elementID] = $combatResult['debris']['attacker'][$elementID] + $combatResult['debris']['defender'][$elementID];
}
$debrisTotal = array_sum($debris);
$moonFactor = Config::get('moon_factor');
$maxMoonChance = Config::get('moon_chance');
$chanceCreateMoon = round($debrisTotal / 1000000 * $moonFactor);
$chanceCreateMoon = min($chanceCreateMoon, $maxMoonChance);
$raportInfo = array('thisFleet' => array('fleet_start_galaxy' => 1, 'fleet_start_system' => 33, 'fleet_start_planet' => 7, 'fleet_start_type' => 1, 'fleet_end_galaxy' => 1, 'fleet_end_system' => 33, 'fleet_end_planet' => 7, 'fleet_end_type' => 1, 'fleet_start_time' => TIMESTAMP), 'debris' => $debris, 'stealResource' => $stealResource, 'moonChance' => $chanceCreateMoon, 'moonDestroy' => false, 'moonName' => null, 'moonDestroyChance' => null, 'moonDestroySuccess' => null, 'fleetDestroyChance' => null, 'fleetDestroySuccess' => null);
$sumSteal = array_sum($stealResource);
$stealResourceInformations = sprintf($LNG['bs_derbis_raport'], pretty_number(ceil($debrisTotal / $pricelist[219]['capacity'])), $LNG['tech'][219], pretty_number(ceil($debrisTotal / $pricelist[209]['capacity'])), $LNG['tech'][209]);
$stealResourceInformations .= '<br>';
$stealResourceInformations .= sprintf($LNG['bs_steal_raport'], pretty_number(ceil($sumSteal / $pricelist[202]['capacity'])), $LNG['tech'][202], pretty_number(ceil($sumSteal / $pricelist[203]['capacity'])), $LNG['tech'][203], pretty_number(ceil($sumSteal / $pricelist[217]['capacity'])), $LNG['tech'][217]);
$raportInfo = array('thisFleet' => array('fleet_start_galaxy' => 1, 'fleet_start_system' => 33, 'fleet_start_planet' => 7, 'fleet_start_type' => 1, 'fleet_end_galaxy' => 1, 'fleet_end_system' => 33, 'fleet_end_planet' => 7, 'fleet_end_type' => 1, 'fleet_start_time' => TIMESTAMP), 'debris' => $debris, 'stealResource' => $stealResource, 'moonChance' => $chanceCreateMoon, 'moonDestroy' => false, 'moonName' => null, 'moonDestroyChance' => null, 'moonDestroySuccess' => null, 'fleetDestroyChance' => null, 'fleetDestroySuccess' => null, 'additionalInfo' => $stealResourceInformations);
$raportData = GenerateReport($combatResult, $raportInfo);
$raportID = md5(uniqid('', true) . TIMESTAMP);
$sqlQuery = "INSERT INTO " . RW . " SET rid = '" . $raportID . "', raport = '" . $GLOBALS['DATABASE']->sql_escape(serialize($raportData)) . "', time = " . TIMESTAMP . ";";
$GLOBALS['DATABASE']->query($sqlQuery);
$this->sendJSON($raportID);
}
示例10: TargetEvent
function TargetEvent()
{
global $pricelist, $resource, $reslist, $db, $LANG;
$targetPlanet = $db->uniquequery("SELECT * FROM " . PLANETS . " WHERE `id` = '" . $this->_fleet['fleet_end_id'] . "';");
$targetUser = $db->uniquequery("SELECT * FROM " . USERS . " WHERE id = '" . $targetPlanet['id_owner'] . "';");
require_once ROOT_PATH . 'includes/classes/class.PlanetRessUpdate.php';
$PlanetRess = new ResourceUpdate();
list($targetUser, $targetPlanet) = $PlanetRess->CalcResource($targetUser, $targetPlanet, true, $this->_fleet['fleet_start_time']);
$TargetUserID = $targetUser['id'];
$attackFleets = array();
$AttackerRow['id'] = array();
$AttackerRow['name'] = array();
$DefenderRow['id'] = array();
$DefenderRow['name'] = array();
if ($this->_fleet['fleet_group'] != 0) {
$db->query("DELETE FROM " . AKS . " WHERE `id` = '" . $this->_fleet['fleet_group'] . "';");
$fleets = $db->query("SELECT * FROM " . FLEETS . " WHERE fleet_group = '" . $this->_fleet['fleet_group'] . "';");
while ($fleet = $db->fetch_array($fleets)) {
$attackFleets[$fleet['fleet_id']]['fleet'] = $fleet;
$attackFleets[$fleet['fleet_id']]['user'] = $db->uniquequery("SELECT id,username,military_tech,defence_tech,shield_tech,rpg_amiral,dm_defensive,dm_attack FROM " . USERS . " WHERE `id` = '" . $fleet['fleet_owner'] . "';");
$attackFleets[$fleet['fleet_id']]['detail'] = array();
$temp = explode(';', $fleet['fleet_array']);
foreach ($temp as $temp2) {
$temp2 = explode(',', $temp2);
if ($temp2[0] < 100) {
continue;
}
if (!isset($attackFleets[$fleet['fleet_id']]['detail'][$temp2[0]])) {
$attackFleets[$fleet['fleet_id']]['detail'][$temp2[0]] = 0;
}
$attackFleets[$fleet['fleet_id']]['detail'][$temp2[0]] += $temp2[1];
}
$AttackerRow['id'][] = $attackFleets[$fleet['fleet_id']]['user']['id'];
$AttackerRow['name'][] = $attackFleets[$fleet['fleet_id']]['user']['username'];
}
} else {
$attackFleets[$this->_fleet['fleet_id']]['fleet'] = $this->_fleet;
$attackFleets[$this->_fleet['fleet_id']]['user'] = $db->uniquequery("SELECT id,username,military_tech,defence_tech,shield_tech,rpg_amiral,dm_defensive,dm_attack FROM " . USERS . " WHERE id = '" . $this->_fleet['fleet_owner'] . "';");
$attackFleets[$this->_fleet['fleet_id']]['detail'] = array();
$temp = explode(';', $this->_fleet['fleet_array']);
foreach ($temp as $temp2) {
$temp2 = explode(',', $temp2);
if ($temp2[0] < 100) {
continue;
}
if (!isset($attackFleets[$this->_fleet['fleet_id']]['detail'][$temp2[0]])) {
$attackFleets[$this->_fleet['fleet_id']]['detail'][$temp2[0]] = 0;
}
$attackFleets[$this->_fleet['fleet_id']]['detail'][$temp2[0]] += $temp2[1];
}
$AttackerRow['id'][] = $attackFleets[$this->_fleet['fleet_id']]['user']['id'];
$AttackerRow['name'][] = $attackFleets[$this->_fleet['fleet_id']]['user']['username'];
}
$defense = array();
$def = $db->query("SELECT * FROM " . FLEETS . " WHERE `fleet_mission` = '5' AND `fleet_end_id` = '" . $this->_fleet['fleet_end_id'] . "' AND fleet_start_time <= '" . TIMESTAMP . "' AND fleet_end_stay >= '" . TIMESTAMP . "';");
while ($defRow = $db->fetch_array($def)) {
$defense[$defRow['fleet_id']]['user'] = $db->uniquequery("SELECT id,username,military_tech,defence_tech,shield_tech,rpg_amiral,dm_defensive,dm_attack FROM " . USERS . " WHERE id = '" . $defRow['fleet_owner'] . "';");
$defRowDef = explode(';', $defRow['fleet_array']);
foreach ($defRowDef as $Element) {
$Element = explode(',', $Element);
if ($Element[0] < 100) {
continue;
}
if (!isset($defense[$defRow['fleet_id']]['def'][$Element[0]])) {
$defense[$defRow['fleet_id']][$Element[0]] = 0;
}
$defense[$defRow['fleet_id']]['def'][$Element[0]] += $Element[1];
}
$DefenderRow['id'][] = $defense[$defRow['fleet_id']]['user']['id'];
$DefenderRow['name'][] = $defense[$defRow['fleet_id']]['user']['username'];
}
$defense[0]['def'] = array();
$defense[0]['user'] = $targetUser;
$DefenderRow['id'][] = $defense[0]['user']['id'];
$DefenderRow['name'][] = $defense[0]['user']['username'];
foreach (array_merge($reslist['fleet'], $reslist['defense']) as $ID) {
if ($ID >= 500) {
continue;
}
$defense[0]['def'][$ID] = $targetPlanet[$resource[$ID]];
}
$Attacker['id'] = array_unique($AttackerRow['id']);
$Attacker['name'] = array_unique($AttackerRow['name']);
$Defender['id'] = array_unique($DefenderRow['id']);
$Defender['name'] = array_unique($DefenderRow['name']);
$CONF = $db->uniquequery("SELECT `Fleet_Cdr`, `Defs_Cdr` FROM `" . CONFIG . "` WHERE `uni` = '" . $this->_fleet['fleet_universe'] . "';");
require_once 'calculateAttack.php';
$result = calculateAttack($attackFleets, $defense, $CONF['Fleet_Cdr'], $CONF['Defs_Cdr']);
$SQL = "";
foreach ($attackFleets as $fleetID => $attacker) {
$fleetArray = '';
$totalCount = 0;
foreach ($attacker['detail'] as $element => $amount) {
if ($amount) {
$fleetArray .= $element . ',' . floattostring($amount) . ';';
}
$totalCount += $amount;
}
$SQL .= $totalCount <= 0 ? "DELETE FROM " . FLEETS . " WHERE `fleet_id`= '" . $fleetID . "';" : "UPDATE " . FLEETS . " SET `fleet_mess` = '1', `fleet_array` = '" . substr($fleetArray, 0, -1) . "', `fleet_amount` = '" . $totalCount . "' WHERE `fleet_id` = '" . $fleetID . "';";
}
//.........这里部分代码省略.........
示例11: TargetEvent
function TargetEvent()
{
global $resource, $reslist;
$fleetAttack = array();
$fleetDefend = array();
$userAttack = array();
$userDefend = array();
$stealResource = array(901 => 0, 902 => 0, 903 => 0);
$debris = array();
$planetDebris = array();
$raportInfo = array();
$debrisRessource = array(901, 902);
$messageHTML = <<<HTML
\t\t<div class="raportMessage">
\t<table>
\t\t<tr>
\t\t\t<td colspan="2"><a href="CombatReport.php?raport=%s" target="_blank"><span class="%s">%s %s (%s)</span></a></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span %s>%s: %s</span> <span %s>%s: %s</span></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span>%s: <span style="color:#a47d7a;">%s</span> </span><span>%s: <span style="color:#5ca6aa;">%s</span> </span><span>%s: <span style="color:#339966;">%s</span></span></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span>%s: <span style="color:#a47d7a;">%s</font> </span><span>%s: <span style="color:#5ca6aa;">%s</span></span></td>
\t\t</tr>
\t</table>
</div>
HTML;
//Minize HTML
$messageHTML = str_replace(array("\n", "\t", "\r"), "", $messageHTML);
$targetPlanet = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . PLANETS . " WHERE id = '" . $this->_fleet['fleet_end_id'] . "';");
$targetUser = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = '" . $targetPlanet['id_owner'] . "';");
$targetUser['factor'] = getFactors($targetUser, 'basic', $this->_fleet['fleet_start_time']);
$planetUpdater = new ResourceUpdate();
list($targetUser, $targetPlanet) = $planetUpdater->CalcResource($targetUser, $targetPlanet, true, $this->_fleet['fleet_start_time']);
if ($this->_fleet['fleet_group'] != 0) {
$GLOBALS['DATABASE']->query("DELETE FROM " . AKS . " WHERE id = '" . $this->_fleet['fleet_group'] . "';");
$incomingFleetsResult = $GLOBALS['DATABASE']->query("SELECT * FROM " . FLEETS . " WHERE fleet_group = '" . $this->_fleet['fleet_group'] . "';");
while ($incomingFleetsRow = $GLOBALS['DATABASE']->fetch_array($incomingFleetsResult)) {
$incomingFleets[$incomingFleetsRow['fleet_id']] = $incomingFleetsRow;
}
$GLOBALS['DATABASE']->free_result($incomingFleetsResult);
} else {
$incomingFleets = array($this->_fleet['fleet_id'] => $this->_fleet);
}
foreach ($incomingFleets as $fleetID => $fleetDetail) {
$fleetAttack[$fleetID]['fleetDetail'] = $fleetDetail;
$fleetAttack[$fleetID]['player'] = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = '" . $fleetDetail['fleet_owner'] . "';");
$fleetAttack[$fleetID]['player']['factor'] = getFactors($fleetAttack[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']);
$fleetAttack[$fleetID]['unit'] = fleetAmountToArray($fleetDetail['fleet_array']);
$userAttack[$fleetAttack[$fleetID]['player']['id']] = $fleetAttack[$fleetID]['player']['username'];
}
$targetFleetsResult = $GLOBALS['DATABASE']->query("SELECT * FROM " . FLEETS . " WHERE fleet_mission = '5' AND fleet_end_id = '" . $this->_fleet['fleet_end_id'] . "' AND fleet_start_time <= '" . TIMESTAMP . "' AND fleet_end_stay >= '" . TIMESTAMP . "';");
while ($fleetDetail = $GLOBALS['DATABASE']->fetch_array($targetFleetsResult)) {
$fleetID = $fleetDetail['fleet_id'];
$fleetDefend[$fleetID]['fleetDetail'] = $fleetDetail;
$fleetDefend[$fleetID]['player'] = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = '" . $fleetDetail['fleet_owner'] . "';");
$fleetDefend[$fleetID]['player']['factor'] = getFactors($fleetDefend[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']);
$fleetDefend[$fleetID]['unit'] = fleetAmountToArray($fleetDetail['fleet_array']);
$userDefend[$fleetDefend[$fleetID]['player']['id']] = $fleetDefend[$fleetID]['player']['username'];
}
$GLOBALS['DATABASE']->free_result($targetFleetsResult);
$fleetDefend[0]['player'] = $targetUser;
$fleetDefend[0]['player']['factor'] = getFactors($fleetDefend[0]['player'], 'attack', $this->_fleet['fleet_start_time']);
$fleetDefend[0]['fleetDetail'] = array('fleet_start_galaxy' => $targetPlanet['galaxy'], 'fleet_start_system' => $targetPlanet['system'], 'fleet_start_planet' => $targetPlanet['planet'], 'fleet_start_type' => $targetPlanet['planet_type']);
$fleetDefend[0]['unit'] = array();
foreach (array_merge($reslist['fleet'], $reslist['defense']) as $elementID) {
if (empty($targetPlanet[$resource[$elementID]])) {
continue;
}
$fleetDefend[0]['unit'][$elementID] = $targetPlanet[$resource[$elementID]];
}
$userDefend[$fleetDefend[0]['player']['id']] = $fleetDefend[0]['player']['username'];
require_once 'calculateAttack.php';
$fleetIntoDebris = $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['Fleet_Cdr'];
$defIntoDebris = $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['Defs_Cdr'];
$combatResult = calculateAttack($fleetAttack, $fleetDefend, $fleetIntoDebris, $defIntoDebris);
$sqlQuery = "";
foreach ($fleetAttack as $fleetID => $fleetDetail) {
$fleetArray = '';
$totalCount = 0;
$fleetDetail['unit'] = array_filter($fleetDetail['unit']);
foreach ($fleetDetail['unit'] as $elementID => $amount) {
$fleetArray .= $elementID . ',' . floattostring($amount) . ';';
$totalCount += $amount;
}
if ($totalCount == 0) {
if ($this->_fleet['fleet_id'] == $fleetID) {
$this->KillFleet();
} else {
$sqlQuery .= "DELETE FROM " . FLEETS . " WHERE fleet_id = " . $fleetID . ";";
$sqlQuery .= "DELETE FROM " . FLEETS_EVENT . " WHERE fleetID = " . $fleetID . ";";
}
$sqlQuery .= "UPDATE " . LOG_FLEETS . " SET fleet_state = 2 WHERE fleet_id = '" . $fleetID . "';";
} elseif ($totalCount > 0) {
$sqlQuery .= "UPDATE " . FLEETS . " SET fleet_array = '" . substr($fleetArray, 0, -1) . "', fleet_amount = '" . $totalCount . "' WHERE fleet_id = '" . $fleetID . "';";
$sqlQuery .= "UPDATE " . LOG_FLEETS . " SET fleet_array = '" . substr($fleetArray, 0, -1) . "', fleet_amount = '" . $totalCount . "', fleet_state = 1 WHERE fleet_id = '" . $fleetID . "';";
} else {
//.........这里部分代码省略.........
示例12: TargetEvent
function TargetEvent()
{
global $resource, $reslist;
$fleetAttack = array();
$fleetDefend = array();
$userAttack = array();
$userDefend = array();
$stealResource = array(901 => 0, 902 => 0, 903 => 0);
$debris = array();
$planetDebris = array();
$raportInfo = array();
$debrisRessource = array(901, 902);
$messageHTML = <<<HTML
\t\t<div class="raportMessage">
\t<table>
\t\t<tr>
\t\t\t<td colspan="2"><a href="CombatReport.php?raport=%s" onclick="starttraining20()" target="_blank"><span %s>%s %s (%s)</span></a></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span %s>%s: %s</span> <span %s>%s: %s</span></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span>%s: <span style="color:#a47d7a;">%s</span> </span><span>%s: <span style="color:#5ca6aa;">%s</span> </span><span>%s: <span style="color:#339966;">%s</span></span></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span>%s: <span style="color:#a47d7a;">%s</font> </span><span>%s: <span style="color:#5ca6aa;">%s</span></span></td>
\t\t</tr>
\t</table>
</div>
HTML;
//Minize HTML
$messageHTML = str_replace(array("\n", "\t", "\r"), "", $messageHTML);
$targetPlanet = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . PLANETS . " WHERE id = '" . $this->_fleet['fleet_end_id'] . "';");
$targetUser = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = '" . $targetPlanet['id_owner'] . "';");
$targetUser['factor'] = getFactors($targetUser, 'basic', $this->_fleet['fleet_start_time']);
$planetUpdater = new ResourceUpdate();
list($targetUser, $targetPlanet) = $planetUpdater->CalcResource($targetUser, $targetPlanet, true, $this->_fleet['fleet_start_time']);
if ($this->_fleet['fleet_group'] != 0) {
$GLOBALS['DATABASE']->query("DELETE FROM " . AKS . " WHERE id = '" . $this->_fleet['fleet_group'] . "';");
$incomingFleetsResult = $GLOBALS['DATABASE']->query("SELECT * FROM " . FLEETS . " WHERE fleet_group = '" . $this->_fleet['fleet_group'] . "';");
while ($incomingFleetsRow = $GLOBALS['DATABASE']->fetch_array($incomingFleetsResult)) {
$incomingFleets[$incomingFleetsRow['fleet_id']] = $incomingFleetsRow;
}
$GLOBALS['DATABASE']->free_result($incomingFleetsResult);
} else {
$incomingFleets = array($this->_fleet['fleet_id'] => $this->_fleet);
}
foreach ($incomingFleets as $fleetID => $fleetDetail) {
$fleetAttack[$fleetID]['fleetDetail'] = $fleetDetail;
$fleetAttack[$fleetID]['player'] = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = '" . $fleetDetail['fleet_owner'] . "';");
$fleetAttack[$fleetID]['player']['factor'] = getFactors($fleetAttack[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']);
$fleetAttack[$fleetID]['unit'] = fleetAmountToArray($fleetDetail['fleet_array']);
$userAttack[$fleetAttack[$fleetID]['player']['id']] = $fleetAttack[$fleetID]['player']['username'];
}
$targetFleetsResult = $GLOBALS['DATABASE']->query("SELECT * FROM " . FLEETS . " WHERE fleet_mission = '5' AND fleet_end_id = '" . $this->_fleet['fleet_end_id'] . "' AND fleet_start_time <= '" . TIMESTAMP . "' AND fleet_end_stay >= '" . TIMESTAMP . "';");
while ($fleetDetail = $GLOBALS['DATABASE']->fetch_array($targetFleetsResult)) {
$fleetID = $fleetDetail['fleet_id'];
$fleetDefend[$fleetID]['fleetDetail'] = $fleetDetail;
$fleetDefend[$fleetID]['player'] = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = '" . $fleetDetail['fleet_owner'] . "';");
$fleetDefend[$fleetID]['player']['factor'] = getFactors($fleetDefend[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']);
$fleetDefend[$fleetID]['unit'] = fleetAmountToArray($fleetDetail['fleet_array']);
$userDefend[$fleetDefend[$fleetID]['player']['id']] = $fleetDefend[$fleetID]['player']['username'];
}
$GLOBALS['DATABASE']->free_result($targetFleetsResult);
$fleetDefend[0]['player'] = $targetUser;
$fleetDefend[0]['player']['factor'] = getFactors($fleetDefend[0]['player'], 'attack', $this->_fleet['fleet_start_time']);
$fleetDefend[0]['fleetDetail'] = array('fleet_start_galaxy' => $targetPlanet['galaxy'], 'fleet_start_system' => $targetPlanet['system'], 'fleet_start_planet' => $targetPlanet['planet'], 'fleet_start_type' => $targetPlanet['planet_type']);
$fleetDefend[0]['unit'] = array();
foreach (array_merge($reslist['fleet'], $reslist['defense']) as $elementID) {
if (empty($targetPlanet[$resource[$elementID]])) {
continue;
}
$fleetDefend[0]['unit'][$elementID] = $targetPlanet[$resource[$elementID]];
}
$userDefend[$fleetDefend[0]['player']['id']] = $fleetDefend[0]['player']['username'];
require_once 'calculateAttack.php';
$fleetIntoDebris = $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['Fleet_Cdr'];
$defIntoDebris = $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['Defs_Cdr'];
$combatResult = calculateAttack($fleetAttack, $fleetDefend, $fleetIntoDebris, $defIntoDebris);
/*ob_start();
print_r($fleetAttack);
print_r($fleetDefend);
print_r($fleetIntoDebris);
print_r($defIntoDebris);
$content = ob_get_contents();
ob_end_clean();
$f = fopen("file.txt", "w");
fwrite($f, $content);
fclose($f);*/
$sqlQuery = "";
foreach ($fleetAttack as $fleetID => $fleetDetail) {
$fleetArray = '';
$totalCount = 0;
$fleetDetail['unit'] = array_filter($fleetDetail['unit']);
foreach ($fleetDetail['unit'] as $elementID => $amount) {
$fleetArray .= $elementID . ',' . floattostring($amount) . ';';
$totalCount += $amount;
}
//.........这里部分代码省略.........
示例13: TargetEvent
function TargetEvent()
{
global $pricelist, $resource, $reslist, $db;
$targetPlanet = $db->uniquequery("SELECT * FROM " . PLANETS . " WHERE `galaxy` = '" . $this->_fleet['fleet_end_galaxy'] . "' AND `system` = '" . $this->_fleet['fleet_end_system'] . "' AND `planet` = '" . $this->_fleet['fleet_end_planet'] . "' AND `planet_type` = '" . $this->_fleet['fleet_end_type'] . "' ;");
$targetUser = $db->uniquequery("SELECT * FROM " . USERS . " WHERE `id` = '" . $targetPlanet['id_owner'] . "';");
$TargetUserID = $targetUser['id'];
$attackFleets = array();
require_once ROOT_PATH . 'includes/classes/class.PlanetRessUpdate.' . PHP_EXT;
$PlanetRess = new ResourceUpdate();
list($TargetUser, $targetPlanet) = $PlanetRess->CalcResource($TargetUser, $targetPlanet, true, $this->_fleet['fleet_start_time']);
$attackFleets[$this->_fleet['fleet_id']]['fleet'] = $this->_fleet;
$attackFleets[$this->_fleet['fleet_id']]['user'] = $db->uniquequery("SELECT id,username,military_tech,defence_tech,shield_tech,rpg_amiral,dm_defensive,dm_attack FROM " . USERS . " WHERE id = '" . $this->_fleet['fleet_owner'] . "';");
$attackFleets[$this->_fleet['fleet_id']]['detail'] = array();
$temp = explode(';', $this->_fleet['fleet_array']);
foreach ($temp as $temp2) {
$temp2 = explode(',', $temp2);
if ($temp2[0] < 100) {
continue;
}
if (!isset($attackFleets[$this->_fleet['fleet_id']]['detail'][$temp2[0]])) {
$attackFleets[$this->_fleet['fleet_id']]['detail'][$temp2[0]] = 0;
}
$attackFleets[$this->_fleet['fleet_id']]['detail'][$temp2[0]] += $temp2[1];
$AttackerRow['id'][] = $attackFleets[$this->_fleet['fleet_id']]['user']['id'];
$AttackerRow['name'][] = $attackFleets[$this->_fleet['fleet_id']]['user']['username'];
}
$defense = array();
$def = $db->query('SELECT * FROM ' . FLEETS . ' WHERE `fleet_end_galaxy` = ' . $this->_fleet['fleet_end_galaxy'] . ' AND `fleet_end_system` = ' . $this->_fleet['fleet_end_system'] . ' AND `fleet_end_type` = ' . $this->_fleet['fleet_end_type'] . ' AND `fleet_end_planet` = ' . $this->_fleet['fleet_end_planet'] . ' AND fleet_start_time<' . TIMESTAMP . ' AND fleet_end_stay>=' . TIMESTAMP . ';');
while ($defRow = $db->fetch_array($def)) {
$defRowDef = explode(';', $defRow['fleet_array']);
foreach ($defRowDef as $Element) {
$Element = explode(',', $Element);
if ($Element[0] < 100) {
continue;
}
if (!isset($defense[$defRow['fleet_id']]['def'][$Element[0]])) {
$defense[$defRow['fleet_id']][$Element[0]] = 0;
}
$defense[$defRow['fleet_id']]['def'][$Element[0]] += $Element[1];
$defense[$defRow['fleet_id']]['user'] = $db->uniquequery("SELECT id,username,military_tech,defence_tech,shield_tech,rpg_amiral,dm_defensive,dm_attack FROM " . USERS . " WHERE id = '" . $defRow['fleet_owner'] . "';");
}
$DefenderRow['id'][] = $defense[$defRow['fleet_id']]['user']['id'];
$DefenderRow['name'][] = $defense[$defRow['fleet_id']]['user']['username'];
}
$defense[0]['def'] = array();
$defense[0]['user'] = $targetUser;
$DefenderRow['id'][] = $defense[0]['user']['id'];
$DefenderRow['name'][] = $defense[0]['user']['username'];
for ($i = 200; $i < 500; $i++) {
if (isset($resource[$i]) && isset($targetPlanet[$resource[$i]])) {
$defense[0]['def'][$i] = $targetPlanet[$resource[$i]];
}
}
$Attacker['id'] = array_unique($AttackerRow['id']);
$Attacker['name'] = array_unique($AttackerRow['name']);
$Defender['id'] = array_unique($DefenderRow['id']);
$Defender['name'] = array_unique($DefenderRow['name']);
require_once 'calculateAttack.' . PHP_EXT;
$result = calculateAttack($attackFleets, $defense);
$SQL = "";
foreach ($attackFleets as $fleetID => $attacker) {
$fleetArray = '';
$totalCount = 0;
foreach ($attacker['detail'] as $element => $amount) {
if ($amount) {
$fleetArray .= $element . ',' . floattostring($amount) . ';';
}
$totalCount += $amount;
}
if ($totalCount <= 0) {
$SQL .= "DELETE FROM " . FLEETS . " WHERE `fleet_id`= '" . $fleetID . "';";
} else {
$SQL .= "UPDATE " . FLEETS . " SET `fleet_mess` = '1', `fleet_array` = '" . substr($fleetArray, 0, -1) . "', `fleet_amount` = '" . floattostring($totalCount) . "' WHERE `fleet_id` = '" . $fleetID . "';";
}
}
$db->multi_query($SQL);
$SQL = "";
if ($result['won'] == "a") {
require_once 'calculateSteal.' . PHP_EXT;
$steal = calculateSteal($attackFleets, $targetPlanet);
}
foreach ($defense as $fleetID => $defender) {
if ($fleetID != 0) {
$fleetArray = '';
$totalCount = 0;
foreach ($defender['def'] as $element => $amount) {
if ($amount) {
$fleetArray .= $element . ',' . floattostring($amount) . ';';
}
$totalCount += $amount;
}
if ($totalCount <= 0) {
$SQL .= "DELETE FROM " . FLEETS . " WHERE `fleet_id`= '" . $fleetID . "';";
} else {
$SQL .= "UPDATE " . FLEETS . " SET `fleet_array` = '" . substr($fleetArray, 0, -1) . "', `fleet_amount` = '" . floattostring($totalCount) . "' WHERE `fleet_id` = '" . $fleetID . "';";
}
} else {
$fleetArray = '';
$totalCount = 0;
foreach ($defender['def'] as $element => $amount) {
//.........这里部分代码省略.........
示例14: send
function send()
{
global $reslist, $pricelist, $LNG;
if (!isset($_REQUEST['battleinput'])) {
$this->sendJSON(0);
}
$BattleArray = $_REQUEST['battleinput'];
$elements = array(0, 0);
foreach ($BattleArray as $BattleSlotID => $BattleSlot) {
if (isset($BattleSlot[0]) && (array_sum($BattleSlot[0]) > 0 || $BattleSlotID == 0)) {
$attacker = array();
$attacker['fleetDetail'] = array('fleet_start_galaxy' => 1, 'fleet_start_system' => 33, 'fleet_start_planet' => 7, 'fleet_start_type' => 1, 'fleet_end_galaxy' => 1, 'fleet_end_system' => 33, 'fleet_end_planet' => 7, 'fleet_end_type' => 1, 'fleet_resource_metal' => 0, 'fleet_resource_crystal' => 0, 'fleet_resource_deuterium' => 0);
$attacker['player'] = array('id' => 1000 + $BattleSlotID + 1, 'username' => $LNG['bs_atter'] . ' Nr.' . ($BattleSlotID + 1), 'military_tech' => $BattleSlot[0][109], 'defence_tech' => $BattleSlot[0][110], 'shield_tech' => $BattleSlot[0][111], 'dm_defensive' => 0, 'dm_attack' => 0);
$attacker['player']['factor'] = getFactors($attacker['player'], 'attack');
foreach ($BattleSlot[0] as $ID => $Count) {
if (!in_array($ID, $reslist['fleet']) || $BattleSlot[0][$ID] <= 0) {
unset($BattleSlot[0][$ID]);
}
}
$attacker['unit'] = $BattleSlot[0];
$attackers[] = $attacker;
}
if (isset($BattleSlot[1]) && (array_sum($BattleSlot[1]) > 0 || $BattleSlotID == 0)) {
$defender = array();
$defender['fleetDetail'] = array('fleet_start_galaxy' => 1, 'fleet_start_system' => 33, 'fleet_start_planet' => 7, 'fleet_start_type' => 1, 'fleet_end_galaxy' => 1, 'fleet_end_system' => 33, 'fleet_end_planet' => 7, 'fleet_end_type' => 1, 'fleet_resource_metal' => 0, 'fleet_resource_crystal' => 0, 'fleet_resource_deuterium' => 0);
$defender['player'] = array('id' => 2000 + $BattleSlotID + 1, 'username' => $LNG['bs_deffer'] . ' Nr.' . ($BattleSlotID + 1), 'military_tech' => $BattleSlot[1][109], 'defence_tech' => $BattleSlot[1][110], 'shield_tech' => $BattleSlot[1][111], 'dm_attack' => 0, 'dm_defensive' => 0);
$defender['player']['factor'] = getFactors($defender['player'], 'attack');
foreach ($BattleSlot[1] as $ID => $Count) {
if (!in_array($ID, $reslist['fleet']) && !in_array($ID, $reslist['defense']) || $BattleSlot[1][$ID] <= 0) {
unset($BattleSlot[1][$ID]);
}
}
$defender['unit'] = $BattleSlot[1];
$defenders[] = $defender;
}
}
$LNG->includeData(array('FLEET'));
require_once 'includes/classes/missions/functions/calculateAttack.php';
require_once 'includes/classes/missions/functions/calculateSteal.php';
require_once 'includes/classes/missions/functions/GenerateReport.php';
$combatResult = calculateAttack($attackers, $defenders, Config::get()->Fleet_Cdr, Config::get()->Defs_Cdr);
if ($combatResult['won'] == "a") {
$stealResource = calculateSteal($attackers, array('metal' => $BattleArray[0][1][1], 'crystal' => $BattleArray[0][1][2], 'deuterium' => $BattleArray[0][1][3]), true);
} else {
$stealResource = array(901 => 0, 902 => 0, 903 => 0);
}
$debris = array();
foreach (array(901, 902) as $elementID) {
$debris[$elementID] = $combatResult['debris']['attacker'][$elementID] + $combatResult['debris']['defender'][$elementID];
}
$debrisTotal = array_sum($debris);
$moonFactor = Config::get()->moon_factor;
$maxMoonChance = Config::get()->moon_chance;
$chanceCreateMoon = round($debrisTotal / 100000 * $moonFactor);
$chanceCreateMoon = min($chanceCreateMoon, $maxMoonChance);
$sumSteal = array_sum($stealResource);
$stealResourceInformation = sprintf($LNG['bs_derbis_raport'], pretty_number(ceil($debrisTotal / $pricelist[219]['capacity'])), $LNG['tech'][219], pretty_number(ceil($debrisTotal / $pricelist[209]['capacity'])), $LNG['tech'][209]);
$stealResourceInformation .= '<br>';
$stealResourceInformation .= sprintf($LNG['bs_steal_raport'], pretty_number(ceil($sumSteal / $pricelist[202]['capacity'])), $LNG['tech'][202], pretty_number(ceil($sumSteal / $pricelist[203]['capacity'])), $LNG['tech'][203], pretty_number(ceil($sumSteal / $pricelist[217]['capacity'])), $LNG['tech'][217]);
$reportInfo = array('thisFleet' => array('fleet_start_galaxy' => 1, 'fleet_start_system' => 33, 'fleet_start_planet' => 7, 'fleet_start_type' => 1, 'fleet_end_galaxy' => 1, 'fleet_end_system' => 33, 'fleet_end_planet' => 7, 'fleet_end_type' => 1, 'fleet_start_time' => TIMESTAMP), 'debris' => $debris, 'stealResource' => $stealResource, 'moonChance' => $chanceCreateMoon, 'moonDestroy' => false, 'moonName' => NULL, 'moonDestroyChance' => NULL, 'moonDestroySuccess' => NULL, 'fleetDestroyChance' => NULL, 'fleetDestroySuccess' => NULL, 'additionalInfo' => $stealResourceInformation);
$reportData = GenerateReport($combatResult, $reportInfo);
$reportID = md5(uniqid('', true) . TIMESTAMP);
$db = Database::get();
$sql = "INSERT INTO %%RW%% SET rid = :reportID, raport = :reportData, time = :time;";
$db->insert($sql, array(':reportID' => $reportID, ':reportData' => serialize($reportData), ':time' => TIMESTAMP));
$this->sendJSON($reportID);
}
示例15: TargetEvent
function TargetEvent()
{
global $resource, $reslist;
$db = Database::get();
$fleetAttack = array();
$fleetDefend = array();
$userAttack = array();
$userDefend = array();
$incomingFleets = array();
$stealResource = array(901 => 0, 902 => 0, 903 => 0);
$debris = array();
$planetDebris = array();
$debrisResource = array(901, 902);
$messageHTML = <<<HTML
<div class="raportMessage">
\t<table>
\t\t<tr>
\t\t\t<td colspan="2"><a href="game.php?page=raport&raport=%s" target="_blank"><span class="%s">%s %s (%s)</span></a></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span class="%s">%s: %s</span> <span class="%s">%s: %s</span></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span>%s: <span class="reportSteal element901">%s</span> </span><span>%s: <span class="reportSteal element902">%s</span> </span><span>%s: <span class="reportSteal element903">%s</span></span></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span>%s: <span class="reportDebris element901">%s</span> </span><span>%s: <span class="reportDebris element902">%s</span></span></td>
\t\t</tr>
\t</table>
</div>
HTML;
//Minize HTML
$messageHTML = str_replace(array("\n", "\t", "\r"), "", $messageHTML);
$sql = "SELECT * FROM %%PLANETS%% WHERE id = :planetId;";
$targetPlanet = $db->selectSingle($sql, array(':planetId' => $this->_fleet['fleet_end_id']));
$sql = "SELECT * FROM %%USERS%% WHERE id = :userId;";
$targetUser = $db->selectSingle($sql, array(':userId' => $targetPlanet['id_owner']));
$targetUser['factor'] = getFactors($targetUser, 'basic', $this->_fleet['fleet_start_time']);
$planetUpdater = new ResourceUpdate();
list($targetUser, $targetPlanet) = $planetUpdater->CalcResource($targetUser, $targetPlanet, true, $this->_fleet['fleet_start_time']);
if ($this->_fleet['fleet_group'] != 0) {
$sql = "DELETE FROM %%AKS%% WHERE id = :acsId;";
$db->delete($sql, array(':acsId' => $this->_fleet['fleet_group']));
$sql = "SELECT * FROM %%FLEETS%% WHERE fleet_group = :acsId;";
$incomingFleetsResult = $db->select($sql, array(':acsId' => $this->_fleet['fleet_group']));
foreach ($incomingFleetsResult as $incomingFleetRow) {
$incomingFleets[$incomingFleetRow['fleet_id']] = $incomingFleetRow;
}
unset($incomingFleetsResult);
} else {
$incomingFleets = array($this->_fleet['fleet_id'] => $this->_fleet);
}
foreach ($incomingFleets as $fleetID => $fleetDetail) {
$sql = "SELECT * FROM %%USERS%% WHERE id = :userId;";
$fleetAttack[$fleetID]['player'] = $db->selectSingle($sql, array(':userId' => $fleetDetail['fleet_owner']));
$fleetAttack[$fleetID]['player']['factor'] = getFactors($fleetAttack[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']);
$fleetAttack[$fleetID]['fleetDetail'] = $fleetDetail;
$fleetAttack[$fleetID]['unit'] = FleetFunctions::unserialize($fleetDetail['fleet_array']);
$userAttack[$fleetAttack[$fleetID]['player']['id']] = $fleetAttack[$fleetID]['player']['username'];
}
$sql = "SELECT * FROM %%FLEETS%%\n\t\tWHERE fleet_mission\t\t= :mission\n\t\tAND fleet_end_id\t\t= :fleetEndId\n\t\tAND fleet_start_time \t<= :timeStamp\n\t\tAND fleet_end_stay \t\t>= :timeStamp;";
$targetFleetsResult = $db->select($sql, array(':mission' => 5, ':fleetEndId' => $this->_fleet['fleet_end_id'], ':timeStamp' => TIMESTAMP));
foreach ($targetFleetsResult as $fleetDetail) {
$fleetID = $fleetDetail['fleet_id'];
$sql = "SELECT * FROM %%USERS%% WHERE id = :userId;";
$fleetDefend[$fleetID]['player'] = $db->selectSingle($sql, array(':userId' => $fleetDetail['fleet_owner']));
$fleetDefend[$fleetID]['player']['factor'] = getFactors($fleetDefend[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']);
$fleetDefend[$fleetID]['fleetDetail'] = $fleetDetail;
$fleetDefend[$fleetID]['unit'] = FleetFunctions::unserialize($fleetDetail['fleet_array']);
$userDefend[$fleetDefend[$fleetID]['player']['id']] = $fleetDefend[$fleetID]['player']['username'];
}
unset($targetFleetsResult);
$fleetDefend[0]['player'] = $targetUser;
$fleetDefend[0]['player']['factor'] = getFactors($fleetDefend[0]['player'], 'attack', $this->_fleet['fleet_start_time']);
$fleetDefend[0]['fleetDetail'] = array('fleet_start_galaxy' => $targetPlanet['galaxy'], 'fleet_start_system' => $targetPlanet['system'], 'fleet_start_planet' => $targetPlanet['planet'], 'fleet_start_type' => $targetPlanet['planet_type']);
$fleetDefend[0]['unit'] = array();
foreach (array_merge($reslist['fleet'], $reslist['defense']) as $elementID) {
if (empty($targetPlanet[$resource[$elementID]])) {
continue;
}
$fleetDefend[0]['unit'][$elementID] = $targetPlanet[$resource[$elementID]];
}
$userDefend[$fleetDefend[0]['player']['id']] = $fleetDefend[0]['player']['username'];
require_once 'includes/classes/missions/functions/calculateAttack.php';
$fleetIntoDebris = Config::get($this->_fleet['fleet_universe'])->Fleet_Cdr;
$defIntoDebris = Config::get($this->_fleet['fleet_universe'])->Defs_Cdr;
$combatResult = calculateAttack($fleetAttack, $fleetDefend, $fleetIntoDebris, $defIntoDebris);
foreach ($fleetAttack as $fleetID => $fleetDetail) {
$fleetArray = '';
$totalCount = 0;
$fleetDetail['unit'] = array_filter($fleetDetail['unit']);
foreach ($fleetDetail['unit'] as $elementID => $amount) {
$fleetArray .= $elementID . ',' . floattostring($amount) . ';';
$totalCount += $amount;
}
if ($totalCount == 0) {
if ($this->_fleet['fleet_id'] == $fleetID) {
$this->KillFleet();
} else {
$sql = 'DELETE %%FLEETS%%, %%FLEETS_EVENT%%
//.........这里部分代码省略.........