Kommunauty
Connexion
Inscription

0 ressource pillée !


pyrosephiroth Messages : 62

Salut à toi chère Kommunauté.

Je me présente à toi avec un nouveau K (hop-là, petit jeu de mot passé ! ).

Les faits sont très simples : tandis que l'on peut transporter des ressources sans aucun soucis entre planètes (d'un même joueur ou de joueurs différents), lorsque l'on attaque ou que l'on pille, on ne ramène aucune ressource ! En effet, quoique vainqueur du combat, le RC rapporte que l'on gagne 0 de chaque ressource. Ensuite, lorsque la flotte revient à quai, le message de retour indique également 0 de ressource.

Perdu dans un monde de mensonge et de variables, je me permets de vous mettre ici le code des deux fichiers desquels je pense que le soucis peut provenir.

Je suis actuellement sous Xnova Revolution 5.9. J'ai déjà essayé de résoudre le soucis par moi-même (ayant cru voir une multiplication par 0 des ressources pillées) mais ça n'avait pas fonctionné ... Les fichiers présentés ci-dessous sont d'origine ...

Calculateattack.php

function calculateAttack(&$attackers, &$defenders, $FleetTF, $DefTF)
{
global $pricelist, $CombatCaps, $resource;

$TRES = array('attacker' => 0, 'defender' => 0);
$ARES = $DRES = array('metal' => 0, 'crystal' => 0);
$ROUND = array();
$RF = array();

foreach ($attackers as $fleetID => $attacker)
{
foreach ($attacker['detail'] as $element => $amount)
{
$ARES['metal'] += $pricelist[$element]['metal'] * $amount;
$ARES['crystal'] += $pricelist[$element]['crystal'] * $amount;
}
}

foreach($CombatCaps as $e => $arr) {
foreach($arr['sd'] as $t => $sd) {
if($sd == 0) continue;
$RF[$t][$e] = $sd;
}
}

$TRES['attacker'] = $ARES['metal'] + $ARES['crystal'] ;

foreach ($defenders as $fleetID => $defender)
{
foreach ($defender['def'] as $element => $amount)
{
if ($element < 300) {
$DRES['metal'] += $pricelist[$element]['metal'] * $amount;
$DRES['crystal'] += $pricelist[$element]['crystal'] * $amount ;

$TRES['defender'] += $pricelist[$element]['metal'] * $amount;
$TRES['defender'] += $pricelist[$element]['crystal'] * $amount;
} else {
if (!isset($STARTDEF[$element]))
$STARTDEF[$element] = 0;

$STARTDEF[$element] += $amount;

$TRES['defender'] += $pricelist[$element]['metal'] * $amount;
$TRES['defender'] += $pricelist[$element]['crystal'] * $amount;
}
}
}

for ($ROUNDC = 0; $ROUNDC <= MAX_ATTACK_ROUNDS; $ROUNDC++)
{
$attackDamage  = array('total' => 0);
$attackShield  = array('total' => 0);
$attackAmount  = array('total' => 0);
$defenseDamage = array('total' => 0);
$defenseShield = array('total' => 0);
$defenseAmount = array('total' => 0);
$attArray = array();
$defArray = array();

foreach ($attackers as $fleetID => $attacker) {
$attackDamage[$fleetID] = 0;
$attackShield[$fleetID] = 0;
$attackAmount[$fleetID] = 0;

$attTech = (1 + (0.1 * $attacker['user']['military_tech']) + $attacker['user']['factor']['attack']);
$defTech = (1 + (0.1 * $attacker['user']['defence_tech']) + $attacker['user']['factor']['defensive']);
$shieldTech = (1 + (0.1 * $attacker['user']['shield_tech']) + $attacker['user']['factor']['shield']);
$attackers[$fleetID]['techs'] = array($attTech, $defTech, $shieldTech);

foreach ($attacker['detail'] as $element => $amount) {
$thisAtt = $amount * ($CombatCaps[$element]['attack']) * $attTech * (rand(80, 120) / 100); //attaque
$thisDef = $amount * ($CombatCaps[$element]['shield']) * $defTech ; //bouclier
$thisShield = $amount * ($pricelist[$element]['metal'] + $pricelist[$element]['crystal'] + $pricelist[$element]['norio']) / 10 * $shieldTech; //coque

$attArray[$fleetID][$element] = array('def' => $thisDef, 'shield' => $thisShield, 'att' => $thisAtt);

$attackDamage[$fleetID] += $thisAtt;
$attackDamage['total'] += $thisAtt;
$attackShield[$fleetID] += $thisDef;
$attackShield['total'] += $thisDef;
$attackAmount[$fleetID] += $amount;
$attackAmount['total'] += $amount;
}
$temp1 = $attacker['detail'];
}

foreach ($defenders as $fleetID => $defender) {
$defenseDamage[$fleetID] = 0;
$defenseShield[$fleetID] = 0;
$defenseAmount[$fleetID] = 0;

$attTech = (1 + (0.1 * $defender['user']['military_tech']) + $defender['user']['factor']['attack']);
$defTech = (1 + (0.1 * $defender['user']['defence_tech']) + $defender['user']['factor']['defensive']);
$shieldTech = (1 + (0.1 * $defender['user']['shield_tech']) + $defender['user']['factor']['shield']);
$defenders[$fleetID]['techs'] = array($attTech, $defTech, $shieldTech);

foreach ($defender['def'] as $element => $amount) {
$thisAtt = $amount * ($CombatCaps[$element]['attack']) * $attTech * (rand(80, 120) / 100); //attaque
$thisDef = $amount * ($CombatCaps[$element]['shield']) * $defTech ; //bouclier
$thisShield = $amount * ($pricelist[$element]['metal'] + $pricelist[$element]['crystal'] + $pricelist[$element]['norio']) / 10 * $shieldTech; //coque

if ($element == 407 || $element == 408 || $element == 409) $thisAtt = 0;

$defArray[$fleetID][$element] = array('def' => $thisDef, 'shield' => $thisShield, 'att' => $thisAtt);

$defenseDamage[$fleetID] += $thisAtt;
$defenseDamage['total'] += $thisAtt;
$defenseShield[$fleetID] += $thisDef;
$defenseShield['total'] += $thisDef;
$defenseAmount[$fleetID] += $amount;
$defenseAmount['total'] += $amount;
}
$temp2 = $defender['def'];
}

$ROUND[$ROUNDC] = array('attackers' => $attackers, 'defenders' => $defenders, 'attackA' => $attackAmount, 'defenseA' => $defenseAmount, 'infoA' => $attArray, 'infoD' => $defArray);

if ($ROUNDC >= MAX_ATTACK_ROUNDS || $defenseAmount['total'] <= 0 || $attackAmount['total'] <= 0) {
break;
}

// Calculate hit percentages (ACS only but ok)
$attackPct = array();
foreach ($attackAmount as $fleetID => $amount) {
if (!is_numeric($fleetID)) continue;
$attackPct[$fleetID] = $amount / $attackAmount['total'];
}

$defensePct = array();
foreach ($defenseAmount as $fleetID => $amount) {
if (!is_numeric($fleetID)) continue;
$defensePct[$fleetID] = $amount / $defenseAmount['total'];
}

// CALCUL DES PERTES !!!
$attacker_n = array();
$attacker_shield = 0;
$defenderAttack = 0;
foreach ($attackers as $fleetID => $attacker) {
$attacker_n[$fleetID] = array();

foreach($attacker['detail'] as $element => $amount) {
if ($amount <= 0) {
$attacker_n[$fleetID][$element] = 0;
continue;
}

$defender_moc = $amount * ($defenseDamage['total'] * $attackPct[$fleetID]) / $attackAmount[$fleetID];

if(isset($RF[$element])) {
foreach($RF[$element] as $shooter => $shots) {
foreach($defArray as $fID => $rfdef) {
if($rfdef[$shooter]['att'] <= 0 || $attackAmount[$fleetID] <= 0) continue;

$defender_moc += $rfdef[$shooter]['att'] * $shots / ($amount / $attackAmount[$fleetID] * $attackPct[$fleetID]);
$defenseAmount['total'] += $defenders[$fID]['def'][$shooter] * $shots;
}
}
}

$defenderAttack += $defender_moc;

if (($attArray[$fleetID][$element]['def'] / $amount) >= $defender_moc) {
$attacker_n[$fleetID][$element] = round($amount);
$attacker_shield += $defender_moc;
continue;
}

$max_removePoints = floor($amount * $defenseAmount['total'] / $attackAmount[$fleetID] * $attackPct[$fleetID]);

$attacker_shield += min($attArray[$fleetID][$element]['def'], $defender_moc);
$defender_moc -= min($attArray[$fleetID][$element]['def'], $defender_moc);

$ile_removePoints = max(min($max_removePoints, $amount * min($defender_moc / $attArray[$fleetID][$element]['shield'] * (rand(0, 200) / 100), 1)), 0);

$attacker_n[$fleetID][$element] = max(ceil($amount - $ile_removePoints), 0);
}
}

$defender_n = array();
$defender_shield = 0;
$attackerAttack = 0;
foreach ($defenders as $fleetID => $defender) {
$defender_n[$fleetID] = array();

foreach($defender['def'] as $element => $amount) {
if ($amount <= 0) {
$defender_n[$fleetID][$element] = 0;
continue;
}

$attacker_moc = $amount * ($attackDamage['total'] * $defensePct[$fleetID]) / $defenseAmount[$fleetID];
if (isset($RF[$element])) {
foreach($RF[$element] as $shooter => $shots) {
foreach($attArray as $fID => $rfatt) {
if ($rfatt[$shooter]['att'] <= 0 || $defenseAmount[$fleetID] <= 0 ) continue;

$attacker_moc += $rfatt[$shooter]['att'] * $shots / ($amount / $defenseAmount[$fleetID] * $defensePct[$fleetID]);
$attackAmount['total'] += $attackers[$fID]['detail'][$shooter] * $shots;
}
}
}

$attackerAttack += $attacker_moc;

if (($defArray[$fleetID][$element]['def'] / $amount) >= $attacker_moc) {
$defender_n[$fleetID][$element] = round($amount);
$defender_shield += $attacker_moc;
continue;
}

$max_removePoints = floor($amount * $attackAmount['total'] / $defenseAmount[$fleetID] * $defensePct[$fleetID]);
$defender_shield += min($defArray[$fleetID][$element]['def'], $attacker_moc);
$attacker_moc -= min($defArray[$fleetID][$element]['def'], $attacker_moc);

$ile_removePoints = max(min($max_removePoints, $amount * min($attacker_moc / $defArray[$fleetID][$element]['shield'] * (rand(0, 200) / 100), 1)), 0);

$defender_n[$fleetID][$element] = max(ceil($amount - $ile_removePoints), 0);
}
}

$ROUND[$ROUNDC]['attack'] = $attackerAttack;
$ROUND[$ROUNDC]['defense'] = $defenderAttack;
$ROUND[$ROUNDC]['attackShield'] = $attacker_shield;
$ROUND[$ROUNDC]['defShield'] = $defender_shield;
foreach ($attackers as $fleetID => $attacker) {
$attackers[$fleetID]['detail'] =  array_map('round', $attacker_n[$fleetID]);
}

foreach ($defenders as $fleetID => $defender) {
$defenders[$fleetID]['def'] = array_map('round', $defender_n[$fleetID]);
}
}

if ($attackAmount['total'] <= 0 && $defenseAmount['total'] > 0) {
$won = "r"; // defender
} elseif ($attackAmount['total'] > 0 && $defenseAmount['total'] <= 0) {
$won = "a"; // attacker
} else {
$won = "w"; // draw
#$ROUND[count($ROUND)] = array('attackers' => $attackers, 'defenders' => $defenders, 'attack' => $attackDamage, 'defense' => $defenseDamage, 'attackA' => $attackAmount, 'defenseA' => $defenseAmount);
}

// CDR
foreach ($attackers as $fleetID => $attacker) {    // flotte attaquant en CDR
foreach ($attacker['detail'] as $element => $amount) {
$TRES['attacker'] -= $pricelist[$element]['metal'] * $amount ;
$TRES['attacker'] -= $pricelist[$element]['crystal'] * $amount ;

$ARES['metal'] -= $pricelist[$element]['metal'] * $amount ;
$ARES['crystal'] -= $pricelist[$element]['crystal'] * $amount ;
}
}

$DRESDefs = array('metal' => 0, 'crystal' => 0);

foreach ($defenders as $fleetID => $defender) {
foreach ($defender['def'] as $element => $amount) {
if ($element < 300) { // flotte defenseur en CDR
$DRES['metal'] -= $pricelist[$element]['metal'] * $amount ;
$DRES['crystal'] -= $pricelist[$element]['crystal'] * $amount ;

$TRES['defender'] -= $pricelist[$element]['metal'] * $amount ;
$TRES['defender'] -= $pricelist[$element]['crystal'] * $amount ;
} else { // defs defenseur en CDR + reconstruction
$TRES['defender'] -= $pricelist[$element]['metal'] * $amount ;
$TRES['defender'] -= $pricelist[$element]['crystal'] * $amount ;

$lost = $STARTDEF[$element] - $amount;
$giveback = round($lost * (rand(56, 84) / 100));
$defenders[$fleetID]['def'][$element] += $giveback;
$DRESDefs['metal'] += $pricelist[$element]['metal'] * ($lost - $giveback) ;
$DRESDefs['crystal'] += $pricelist[$element]['crystal'] * ($lost - $giveback) ;
}
}
}

$ARES['metal'] = max($ARES['metal'], 0);
$ARES['crystal'] = max($ARES['crystal'], 0);
$DRES['metal'] = max($DRES['metal'], 0);
$DRES['crystal'] = max($DRES['crystal'], 0);
$TRES['attacker'] = max($TRES['attacker'], 0);
$TRES['defender'] = max($TRES['defender'], 0);

$totalLost = array('att' => $TRES['attacker'], 'def' => $TRES['defender']);
$debAttMet = ($ARES['metal'] * ($FleetTF / 100));
$debAttCry = ($ARES['crystal'] * ($FleetTF / 100));
$debDefMet = ($DRES['metal'] * ($FleetTF / 100)) + ($DRESDefs['metal'] * ($DefTF / 100));
$debDefCry = ($DRES['crystal'] * ($FleetTF / 100)) + ($DRESDefs['crystal'] * ($DefTF / 100));

return array('won' => $won, 'debree' => array('att' => array($debAttMet, $debAttCry), 'def' => array($debDefMet, $debDefCry)), 'rw' => $ROUND, 'lost' => $totalLost);
}
?>

et Calculatesteal.php

function calculateSteal($attackFleets, $defenderPlanet, $ForSim = false)
{
//Steal-Math by Slaver for 2Moons(http://www.titanspace.org) based on http://www.owiki.de/Beute
global $pricelist, $db;

$SortFleets = array();
$Sumcapacity  = '0';
foreach($attackFleets as $FleetID => $Attacker)
{
$SortFleets[$FleetID] = '0';
foreach($Attacker['detail'] as $Element => $amount)
{
$SortFleets[$FleetID] = bcadd($SortFleets[$FleetID], bcmul($pricelist[$Element]['capacity'], floattostring($amount)));
}

$SortFleets[$FleetID] = bcsub($SortFleets[$FleetID], $Attacker['fleet']['fleet_resource_metal']);
$SortFleets[$FleetID] = bcsub($SortFleets[$FleetID], $Attacker['fleet']['fleet_resource_crystal']);
$SortFleets[$FleetID] = bcsub($SortFleets[$FleetID], $Attacker['fleet']['fleet_resource_deuterium']);
$SortFleets[$FleetID] = bcsub($SortFleets[$FleetID], $Attacker['fleet']['fleet_resource_norio']);
$Sumcapacity = bcadd($Sumcapacity, $SortFleets[$FleetID]);
}

$AllCapacity = $Sumcapacity;

// Step 1
$booty['metal'] = min(bcdiv($Sumcapacity, 3), bcdiv(floattostring($defenderPlanet['metal']), 2));
$Sumcapacity = bcsub($Sumcapacity, $booty['metal']);

// Step 2
$booty['crystal'] = min(bcdiv($Sumcapacity, 2), bcdiv(floattostring($defenderPlanet['crystal']), 2));
$Sumcapacity = bcsub($Sumcapacity, $booty['crystal']);

// Step 3
$booty['norio'] = min(bcdiv($Sumcapacity, 2), bcdiv(floattostring($defenderPlanet['norio']), 2));
$Sumcapacity = bcsub($Sumcapacity, $booty['norio']);

// Step 4
$booty['deuterium'] = min($Sumcapacity, bcdiv(floattostring($defenderPlanet['deuterium']), 2));
$Sumcapacity = bcsub($Sumcapacity, $booty['deuterium']);

$oldMetalBooty   = $booty['metal'];
$booty['metal'] = bcadd($booty['metal'], min(bcdiv($Sumcapacity, 3), max(bcsub(bcdiv(floattostring($defenderPlanet['metal']), 2), $booty['metal']), 0)));
$Sumcapacity = bcsub($Sumcapacity, bcsub($booty['metal'], $oldMetalBooty));

$booty['crystal'] = bcadd($booty['crystal'], min($Sumcapacity, max(bcsub(bcdiv(floattostring($defenderPlanet['crystal']), 2), $booty['crystal']), 0)));

if($ForSim)
return $booty;

$Qry = "";


foreach($SortFleets as $FleetID => $Capacity)
{
$Factor = bcdiv($Capacity, $AllCapacity, 10);
$Qry .= "UPDATE ".FLEETS." SET ";
$Qry .= "`fleet_resource_metal` = `fleet_resource_metal` + '".bcmul($booty['metal'], $Factor, 0)."', ";
$Qry .= "`fleet_resource_crystal` = `fleet_resource_crystal` + '".bcmul($booty['crystal'], $Factor, 0)."', ";
$Qry .= "`fleet_resource_deuterium` = `fleet_resource_deuterium` + '".bcmul($booty['deuterium'], $Factor, 0)."', ";
$Qry .= "`fleet_resource_norio` = `fleet_resource_norio` + '".bcmul($booty['norio'], $Factor, 0)."' ";
$Qry .= "WHERE fleet_id = '".$FleetID."';";
}

$db->multi_query($Qry);
return $booty;
}

?>

Si vous avez des idées, je suis absolument prenneur ! :')

Encore merci les amis, et à bientôt (enfin pas si tôt que ça, espérons-le ! )

samedi 4 janvier 2014

Mizur Messages : 6618

Difficile, ne connaissant pas les fonctions utilisées... Mais ça pourrait être pas mal que tu affiches toi même les variables utilisées à certains moments, que tu fasses des tests pour savoir quelle variable est chelou. Peut etre qu'il sort que la capacité de tes vaisseaux est pleine, ou que la planète n'a pas de ressources, ou je ne sais pas...

Ici pour savoir comment debugger http://geekndev.com/4842-debuggez-votre-php-dans-votre-console-chrome-developpement-web-chromephp

samedi 4 janvier 2014

pyrosephiroth Messages : 62

Hum, je vais essayer d'utiliser l'outil que tu proposes : je vous tiens au courant ! Encore merci Mizur =)

samedi 4 janvier 2014

SnakeFear Messages : 112

Salut,

Pourrais tu nous montrer le fichier : MissionCaseAttack.php

Je ne sais pas si ça viens de ce fichier , mais je veux quand même vérifier pour voir s'il est différant du miens.

Bonne soirée

samedi 4 janvier 2014

pyrosephiroth Messages : 62

Bien sur SnakeFear, les voici :

MissionCaseattack.php

<?php

class MissionCaseAttack extends MissionFunctions
{
function __construct($Fleet)
{
$this->_fleet = $Fleet;
}

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');

#list($targetUser['factor'], $targetPlanet['factor']) = getFactors($targetUser, $targetPlanet, 'basic', $this->_fleet['fleet_start_time']);
$targetUser['factor'] = getFactors($targetUser, 'basic', $this->_fleet['fleet_start_time']);
$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` FROM ".USERS." WHERE `id` = '".$fleet['fleet_owner']."';");
    $attackFleets[$fleet['fleet_id']]['user']['factor']     = getFactors($attackFleets[$fleet['fleet_id']]['user'], 'attack', $this->_fleet['fleet_start_time']);
$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` FROM ".USERS." WHERE `id` = '".$this->_fleet['fleet_owner']."';");
$attackFleets[$this->_fleet['fleet_id']]['user']['factor'] = getFactors($attackFleets[$this->_fleet['fleet_id']]['user'], 'attack', $this->_fleet['fleet_start_time']);
$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` FROM ".USERS." WHERE `id` = '".$defRow['fleet_owner']."';");
$attackFleets[$this->_fleet['fleet_id']]['user']['factor'] = getFactors($defense[$defRow['fleet_id']]['user'], 'attack', $this->_fleet['fleet_start_time']);
$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;
$defense[0]['user']['factor'] = getFactors($defense[0]['user'], 'attack', $this->_fleet['fleet_start_time']);
$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']);

require_once('calculateAttack.php');
$result = calculateAttack($attackFleets, $defense,  $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['Fleet_Cdr'],  $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['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."';";
}

if ($result['won'] == "a")
{
require_once('calculateSteal.php');
$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;
}

$SQL .= $totalCount <= 0 ? "DELETE FROM ".FLEETS." WHERE `fleet_id`= '".$fleetID."';" : "UPDATE ".FLEETS." SET `fleet_array` = '".substr($fleetArray, 0, -1)."', `fleet_amount` = '".$totalCount."' WHERE `fleet_id` = '".$fleetID."';";
}
else
{
$fleetArray = '';
foreach ($defender['def'] as $element => $amount)
{
$fleetArray .= "`".$resource[$element]."` = '".floattostring($amount)."', ";
}

$SQL .= "UPDATE ".PLANETS." SET ";
$SQL .= $fleetArray;
$SQL .= "`metal` = `metal` - '".$steal['metal']."', ";
$SQL .= "`crystal` = `crystal` - '".$steal['crystal']."', ";
$SQL .= "`deuterium` = `deuterium` - '".$steal['deuterium']."', ";
$SQL .= "`norio` = `norio` - '".$steal['norio']."' ";
$SQL .= "WHERE ";
$SQL .= "`id` = '".$this->_fleet['fleet_end_id']."';";
}
}

$db->multi_query($SQL);

if($this->_fleet['fleet_end_type'] == 3)
$targetPlanet = array_merge($targetPlanet, $db->uniquequery("SELECT `der_metal`, `der_crystal` FROM ".PLANETS." WHERE `id_luna` = '".$this->_fleet['fleet_end_id']."';"));
$ShootMetal = $result['debree']['att'][0] + $result['debree']['def'][0];
$ShootCrystal = $result['debree']['att'][1] + $result['debree']['def'][1];
$FleetDebris = $ShootMetal + $ShootCrystal;
$DerbisMetal = $targetPlanet['der_metal']+ $ShootMetal;
$DerbisCrystal = $targetPlanet['der_crystal']+ $ShootCrystal;
$MoonChance        = min(round($FleetDebris / 100000 * MOON_CHANCE_FACTOR, 0), MAX_MOON_CHANCE);
$UserChance = mt_rand(1, 100);

if ($targetPlanet['planet_type'] == 1 && $targetPlanet['id_luna'] == 0 && $MoonChance > 0 && $UserChance <= $MoonChance)
{
require_once(ROOT_PATH.'includes/functions/CreateOneMoonRecord.php');
$INFO['moon']['name'] = CreateOneMoonRecord($this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet'], $this->_fleet['fleet_universe'], $TargetUserID, $this->_fleet['fleet_start_time'], '', $MoonChance);
$INFO['end_galaxy'] = $this->_fleet['fleet_end_galaxy'];
$INFO['end_system'] = $this->_fleet['fleet_end_system'];
$INFO['end_planet'] = $this->_fleet['fleet_end_planet'];

if(DESTROY_DERBIS_MOON_CREATE) {
#if($GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['debris_moon'] == 1) {
$DerbisMetal   = 0;
$DerbisCrystal   = 0;
}
}

$INFO['steal'] = $steal;
$INFO['fleet_start_time'] = $this->_fleet['fleet_start_time'];
$INFO['moon']['des'] = 0;
$INFO['moon']['chance'] = $MoonChance;
$INFO['attvsdef'] = implode(' & ', $Attacker['name']).' vs '.implode(' & ', $Defender['name']);
require_once('GenerateReport.php');
$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".'?>');
file_put_contents(ROOT_PATH.'raports/topkb_'.$rid.'.php', '<?php'."\n".'$raport = '.preg_replace("/\[\d+\:\d+\:\d+\]/i", "[X:X:X]", $raport).';'."\n".'?>');

if(DEBUG_EXTRA)
file_put_contents(ROOT_PATH.'includes/attack.log', date('[d-M-Y H:i:s]', $this->_fleet['fleet_start_time']).'(FleetID: '.$this->_fleet['fleet_id'].') Attacker: '.$this->_fleet['fleet_owner'].'/ Defender: '.$this->_fleet['fleet_target_owner'].' | TF: '.floattostring($DerbisMetal).'/'.floattostring($DerbisCrystal));

$WhereAtt = "";
$WhereDef = "";

foreach($Attacker['id'] as $id)
{
$WhereAtt .= "`id` = '".$id."' OR ";
}
foreach($Defender['id'] as $id)
{
$WhereDef .= "`id` = '".$id."' OR ";
}

$Won = 0;
$Lose = 0;
$Draw = 0;

switch($result['won'])
{
case "a":
$Won = 1;
break;
case "w":
$Draw = 1;
break;
case "r":
$Lose = 1;
break;
}

$SQL  = "UPDATE ".PLANETS." SET ";
$SQL .= "`der_metal` = ".floattostring($DerbisMetal).", ";
$SQL .= "`der_crystal` = ".floattostring($DerbisCrystal)." ";
$SQL .= "WHERE ";
$SQL .= "`universe` = '" . $this->_fleet['fleet_universe'] . "' AND ";
$SQL .= "`galaxy` = '" . $this->_fleet['fleet_end_galaxy'] . "' AND ";
        $SQL .= "`system` = '" . $this->_fleet['fleet_end_system'] . "' AND ";
        $SQL .= "`planet` = '" . $this->_fleet['fleet_end_planet'] . "' AND ";
        $SQL .= "`planet_type` = '1';";
$SQL .= "INSERT INTO ".RW." SET ";
$SQL .= "`time` = '".$this->_fleet['fleet_start_time']."', ";
$SQL .= "`owners` = '".implode(',', array_merge($Attacker['id'], $Defender['id']))."', ";
$SQL .= "`rid` = '".$rid."';";
$SQL .= "INSERT INTO ".TOPKB." SET ";
$SQL .= "`time` = '".$this->_fleet['fleet_start_time']."', ";
$SQL .= "`id_owner1` = '".implode(',', $Attacker['id'])."', ";
$SQL .= "`angreifer` = '".implode(' & ', $Attacker['name'])."', ";
$SQL .= "`id_owner2` = '".implode(',', $Defender['id'])."', ";
$SQL .= "`defender` = '".implode(' & ', $Defender['name'])."', ";
$SQL .= "`gesamtunits` = '".floattostring($result['lost']['att'] + $result['lost']['def'])."', ";
$SQL .= "`rid` = '". $rid ."', ";
$SQL .= "`universe` = '".$this->_fleet['fleet_universe']."', ";
$SQL .= "`fleetresult` = '". $result['won'] ."';";
$SQL .= "UPDATE ".USERS." SET ";
        $SQL .= "`wons` = wons + ".$Won.", ";
        $SQL .= "`loos` = loos + ".$Lose.", ";
        $SQL .= "`draws` = draws + ".$Draw.", ";
        $SQL .= "`kbmetal` = kbmetal + ".floattostring($ShootMetal).", ";
        $SQL .= "`kbcrystal` = kbcrystal + ".floattostring($ShootCrystal).", ";
        $SQL .= "`lostunits` = lostunits + ".floattostring($result['lost']['att']).", ";
        $SQL .= "`desunits` = desunits + ".floattostring($result['lost']['def'])." ";
        $SQL .= "WHERE ";
        $SQL .= substr($WhereAtt, 0, -4).";";
$SQL .= "UPDATE ".USERS." SET ";
        $SQL .= "`wons` = wons + ". $Lose .", ";
        $SQL .= "`loos` = loos + ". $Won .", ";
        $SQL .= "`draws` = draws + ". $Draw  .", ";
        $SQL .= "`kbmetal` = kbmetal + ".floattostring($ShootMetal).", ";
        $SQL .= "`kbcrystal` = kbcrystal + ".floattostring($ShootCrystal).", ";
        $SQL .= "`lostunits` = lostunits + ".floattostring($result['lost']['def']).", ";
        $SQL .= "`desunits` = desunits + ".floattostring($result['lost']['att'])." ";
        $SQL .= "WHERE ";
        $SQL .= substr($WhereDef, 0, -4).";";
$db->multi_query($SQL);

switch($result['won'])
{
case "r":
$ColorAtt = "red";
$ColorDef = "green";
break;
case "w":
$ColorAtt = "orange";
$ColorDef = "orange";
case "a":
$ColorAtt = "green";
$ColorDef = "red";
break;
}

foreach ($Attacker['id'] as $AttackersID)
{
if(empty($AttackersID))
continue;

$LNG = $LANG->GetUserLang($AttackersID);
$MessageAtt = sprintf('<a href="CombatReport.php?raport=%s" onclick="OpenPopup(\'CombatReport.php?raport=%s\', \'combat\', screen.width, screen.height);return false" target="combat"><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="#fff">%s</font> %s:<font color="#fff">%s</font> %s:<font color="#fff">%s</font> %s:<font color="#fff">%s</font><br><br>%s %s:<font color="#fff">%s</font> %s:<font color="#fff">%s</font><br />', $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['Norio'], pretty_number($steal['norio']), $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($AttackersID, 0, $this->_fleet['fleet_start_time'], 3, $LNG['sys_mess_tower'], $LNG['sys_mess_attack_report'], $MessageAtt); // review 3
}

foreach ($Defender['id'] as $DefenderID)
{
if(empty($DefenderID))
continue;

$LNG = $LANG->GetUserLang($DefenderID);
$MessageDef = sprintf('<a href="CombatReport.php?raport=%s" onclick="OpenPopup(\'CombatReport.php?raport=%s\', \'combat\', screen.width, screen.height);return false" target="combat"><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="#fff">%s</font> %s:<font color="#fff">%s</font> %s:<font color="#fff">%s</font> %s:<font color="#fff">%s</font><br><br>%s %s:<font color="#fff">%s</font> %s:<font color="#fff">%s</font><br />', $rid, $rid, $ColorDef, $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']), $ColorDef, $LNG['sys_perte_attaquant'], pretty_number($result['lost']['att']), $ColorAtt, $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['Norio'], pretty_number($steal['norio']), $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($DefenderID, 0, $this->_fleet['fleet_start_time'], 3, $LNG['sys_mess_tower'], $LNG['sys_mess_attack_report'], $MessageDef);// review 3
}
}

function EndStayEvent()
{
return;
}

function ReturnEvent()
{
global $LANG;
$LNG = $LANG->GetUserLang($this->_fleet['fleet_owner']);

$Message = sprintf( $LNG['sys_fleet_won'], $TargetName, GetTargetAdressLink($this->_fleet, ''), pretty_number($this->_fleet['fleet_resource_metal']), $LNG['Metal'], pretty_number($this->_fleet['fleet_resource_crystal']), $LNG['Crystal'], pretty_number($this->_fleet['fleet_resource_deuterium']), $LNG['Deuterium'], pretty_number($this->_fleet['fleet_resource_norio']), $LNG['Norio']);
SendSimpleMessage($this->_fleet['fleet_owner'], 0, $this->_fleet['fleet_end_time'], 3, $LNG['sys_mess_tower'], $LNG['sys_mess_fleetback'], $Message);

$this->RestoreFleet();
}
}

?>

J'espère sincèrement que le soucis provient de ce fichier, car je n'ai rien trouvé en en fouillant d'autre :3

samedi 4 janvier 2014

SnakeFear Messages : 112

Je viens de regarder , mais j'ai pas vue de différence, autant j'ai mal vue puis autant ça ne viens pas de la :-/

Essaie de copier celui ci on ne sait jamais :

<?php

/**
 _  \_/ |\ | /¯¯\ \  / /\    |¯¯) |_¯ \  / /¯¯\ |  |   |´¯|¯` | /¯¯\ |\ |5
 ¯  /¯\ | \| \__/  \/ /--\   |¯¯\ |__  \/  \__/ |__ \_/   |   | \__/ | \|Core.
 * @author: Copyright (C) 2011 by Brayan Narvaez (Prinick) developer of xNova Revolution
 * @author web: http://www.bnarvaez.com
 * @link: http://www.xnovarev.com

 * @package 2Moons
 * @author Slaver <slaver7@gmail.com>
 * @copyright 2009 Lucky <douglas@crockford.com> (XGProyecto)
 * @copyright 2011 Slaver <slaver7@gmail.com> (Fork/2Moons)
 * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
 * @version 1.3 (2011-01-21)
 * @link http://code.google.com/p/2moons/

 * Please do not remove the credits
*/

class MissionCaseAttack extends MissionFunctions
{
function __construct($Fleet)
{
$this->_fleet = $Fleet;
}

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');

#list($targetUser['factor'], $targetPlanet['factor']) = getFactors($targetUser, $targetPlanet, 'basic', $this->_fleet['fleet_start_time']);
$targetUser['factor'] = getFactors($targetUser, 'basic', $this->_fleet['fleet_start_time']);
$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` FROM ".USERS." WHERE `id` = '".$fleet['fleet_owner']."';");
    $attackFleets[$fleet['fleet_id']]['user']['factor']     = getFactors($attackFleets[$fleet['fleet_id']]['user'], 'attack', $this->_fleet['fleet_start_time']);
$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` FROM ".USERS." WHERE `id` = '".$this->_fleet['fleet_owner']."';");
$attackFleets[$this->_fleet['fleet_id']]['user']['factor'] = getFactors($attackFleets[$this->_fleet['fleet_id']]['user'], 'attack', $this->_fleet['fleet_start_time']);
$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` FROM ".USERS." WHERE `id` = '".$defRow['fleet_owner']."';");
$attackFleets[$this->_fleet['fleet_id']]['user']['factor'] = getFactors($defense[$defRow['fleet_id']]['user'], 'attack', $this->_fleet['fleet_start_time']);
$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;
$defense[0]['user']['factor'] = getFactors($defense[0]['user'], 'attack', $this->_fleet['fleet_start_time']);
$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']);

require_once('calculateAttack.php');
$result = calculateAttack($attackFleets, $defense,  $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['Fleet_Cdr'],  $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['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."';";
}

if ($result['won'] == "a")
{
require_once('calculateSteal.php');
$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;
}

$SQL .= $totalCount <= 0 ? "DELETE FROM ".FLEETS." WHERE `fleet_id`= '".$fleetID."';" : "UPDATE ".FLEETS." SET `fleet_array` = '".substr($fleetArray, 0, -1)."', `fleet_amount` = '".$totalCount."' WHERE `fleet_id` = '".$fleetID."';";
}
else
{
$fleetArray = '';
foreach ($defender['def'] as $element => $amount)
{
$fleetArray .= "`".$resource[$element]."` = '".floattostring($amount)."', ";
}

$SQL .= "UPDATE ".PLANETS." SET ";
$SQL .= $fleetArray;
$SQL .= "`metal` = `metal` - '".$steal['metal']."', ";
$SQL .= "`crystal` = `crystal` - '".$steal['crystal']."', ";
$SQL .= "`deuterium` = `deuterium` - '".$steal['deuterium']."', ";
$SQL .= "`norio` = `norio` - '".$steal['norio']."' ";
$SQL .= "WHERE ";
$SQL .= "`id` = '".$this->_fleet['fleet_end_id']."';";
}
}

$db->multi_query($SQL);

if($this->_fleet['fleet_end_type'] == 3)
$targetPlanet = array_merge($targetPlanet, $db->uniquequery("SELECT `der_metal`, `der_crystal` FROM ".PLANETS." WHERE `id_luna` = '".$this->_fleet['fleet_end_id']."';"));
$ShootMetal = $result['debree']['att'][0] + $result['debree']['def'][0];
$ShootCrystal = $result['debree']['att'][1] + $result['debree']['def'][1];
$FleetDebris = $ShootMetal + $ShootCrystal;
$DerbisMetal = $targetPlanet['der_metal']+ $ShootMetal;
$DerbisCrystal = $targetPlanet['der_crystal']+ $ShootCrystal;
$MoonChance        = min(round($FleetDebris / 100000 * MOON_CHANCE_FACTOR, 0), MAX_MOON_CHANCE);
$UserChance = mt_rand(1, 100);

if ($targetPlanet['planet_type'] == 1 && $targetPlanet['id_luna'] == 0 && $MoonChance > 0 && $UserChance <= $MoonChance)
{
require_once(ROOT_PATH.'includes/functions/CreateOneMoonRecord.php');
$INFO['moon']['name'] = CreateOneMoonRecord($this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet'], $this->_fleet['fleet_universe'], $TargetUserID, $this->_fleet['fleet_start_time'], '', $MoonChance);
$INFO['end_galaxy'] = $this->_fleet['fleet_end_galaxy'];
$INFO['end_system'] = $this->_fleet['fleet_end_system'];
$INFO['end_planet'] = $this->_fleet['fleet_end_planet'];

if(DESTROY_DERBIS_MOON_CREATE) {
#if($GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['debris_moon'] == 1) {
$DerbisMetal   = 0;
$DerbisCrystal   = 0;
}
}

$INFO['steal'] = $steal;
$INFO['fleet_start_time'] = $this->_fleet['fleet_start_time'];
$INFO['moon']['des'] = 0;
$INFO['moon']['chance'] = $MoonChance;
$INFO['attvsdef'] = implode(' & ', $Attacker['name']).' vs '.implode(' & ', $Defender['name']);
require_once('GenerateReport.php');
$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".'?>');
file_put_contents(ROOT_PATH.'raports/topkb_'.$rid.'.php', '<?php'."\n".'$raport = '.preg_replace("/\[\d+\:\d+\:\d+\]/i", "[X:X:X]", $raport).';'."\n".'?>');

if(DEBUG_EXTRA)
file_put_contents(ROOT_PATH.'includes/attack.log', date('[d-M-Y H:i:s]', $this->_fleet['fleet_start_time']).'(FleetID: '.$this->_fleet['fleet_id'].') Attacker: '.$this->_fleet['fleet_owner'].'/ Defender: '.$this->_fleet['fleet_target_owner'].' | TF: '.floattostring($DerbisMetal).'/'.floattostring($DerbisCrystal));

$WhereAtt = "";
$WhereDef = "";

foreach($Attacker['id'] as $id)
{
$WhereAtt .= "`id` = '".$id."' OR ";
}
foreach($Defender['id'] as $id)
{
$WhereDef .= "`id` = '".$id."' OR ";
}

$Won = 0;
$Lose = 0;
$Draw = 0;

switch($result['won'])
{
case "a":
$Won = 1;
break;
case "w":
$Draw = 1;
break;
case "r":
$Lose = 1;
break;
}

$SQL  = "UPDATE ".PLANETS." SET ";
$SQL .= "`der_metal` = ".floattostring($DerbisMetal).", ";
$SQL .= "`der_crystal` = ".floattostring($DerbisCrystal)." ";
$SQL .= "WHERE ";
$SQL .= "`universe` = '" . $this->_fleet['fleet_universe'] . "' AND ";
$SQL .= "`galaxy` = '" . $this->_fleet['fleet_end_galaxy'] . "' AND ";
        $SQL .= "`system` = '" . $this->_fleet['fleet_end_system'] . "' AND ";
        $SQL .= "`planet` = '" . $this->_fleet['fleet_end_planet'] . "' AND ";
        $SQL .= "`planet_type` = '1';";
$SQL .= "INSERT INTO ".RW." SET ";
$SQL .= "`time` = '".$this->_fleet['fleet_start_time']."', ";
$SQL .= "`owners` = '".implode(',', array_merge($Attacker['id'], $Defender['id']))."', ";
$SQL .= "`rid` = '".$rid."';";
$SQL .= "INSERT INTO ".TOPKB." SET ";
$SQL .= "`time` = '".$this->_fleet['fleet_start_time']."', ";
$SQL .= "`id_owner1` = '".implode(',', $Attacker['id'])."', ";
$SQL .= "`angreifer` = '".implode(' & ', $Attacker['name'])."', ";
$SQL .= "`id_owner2` = '".implode(',', $Defender['id'])."', ";
$SQL .= "`defender` = '".implode(' & ', $Defender['name'])."', ";
$SQL .= "`gesamtunits` = '".floattostring($result['lost']['att'] + $result['lost']['def'])."', ";
$SQL .= "`rid` = '". $rid ."', ";
$SQL .= "`universe` = '".$this->_fleet['fleet_universe']."', ";
$SQL .= "`fleetresult` = '". $result['won'] ."';";
$SQL .= "UPDATE ".USERS." SET ";
        $SQL .= "`wons` = wons + ".$Won.", ";
        $SQL .= "`loos` = loos + ".$Lose.", ";
        $SQL .= "`draws` = draws + ".$Draw.", ";
        $SQL .= "`kbmetal` = kbmetal + ".floattostring($ShootMetal).", ";
        $SQL .= "`kbcrystal` = kbcrystal + ".floattostring($ShootCrystal).", ";
        $SQL .= "`lostunits` = lostunits + ".floattostring($result['lost']['att']).", ";
        $SQL .= "`desunits` = desunits + ".floattostring($result['lost']['def'])." ";
        $SQL .= "WHERE ";
        $SQL .= substr($WhereAtt, 0, -4).";";
$SQL .= "UPDATE ".USERS." SET ";
        $SQL .= "`wons` = wons + ". $Lose .", ";
        $SQL .= "`loos` = loos + ". $Won .", ";
        $SQL .= "`draws` = draws + ". $Draw  .", ";
        $SQL .= "`kbmetal` = kbmetal + ".floattostring($ShootMetal).", ";
        $SQL .= "`kbcrystal` = kbcrystal + ".floattostring($ShootCrystal).", ";
        $SQL .= "`lostunits` = lostunits + ".floattostring($result['lost']['def']).", ";
        $SQL .= "`desunits` = desunits + ".floattostring($result['lost']['att'])." ";
        $SQL .= "WHERE ";
        $SQL .= substr($WhereDef, 0, -4).";";
$db->multi_query($SQL);

switch($result['won'])
{
case "r":
$ColorAtt = "red";
$ColorDef = "green";
break;
case "w":
$ColorAtt = "orange";
$ColorDef = "orange";
case "a":
$ColorAtt = "green";
$ColorDef = "red";
break;
}

foreach ($Attacker['id'] as $AttackersID)
{
if(empty($AttackersID))
continue;

$LNG = $LANG->GetUserLang($AttackersID);
$MessageAtt = sprintf('<a href="CombatReport.php?raport=%s" onclick="OpenPopup(\'CombatReport.php?raport=%s\', \'combat\', screen.width, screen.height);return false" target="combat"><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="#fff">%s</font> %s:<font color="#fff">%s</font> %s:<font color="#fff">%s</font> %s:<font color="#fff">%s</font><br><br>%s %s:<font color="#fff">%s</font> %s:<font color="#fff">%s</font><br />', $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['Norio'], pretty_number($steal['norio']), $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($AttackersID, 0, $this->_fleet['fleet_start_time'], 3, $LNG['sys_mess_tower'], $LNG['sys_mess_attack_report'], $MessageAtt); // review 3
}

foreach ($Defender['id'] as $DefenderID)
{
if(empty($DefenderID))
continue;

$LNG = $LANG->GetUserLang($DefenderID);
$MessageDef = sprintf('<a href="CombatReport.php?raport=%s" onclick="OpenPopup(\'CombatReport.php?raport=%s\', \'combat\', screen.width, screen.height);return false" target="combat"><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="#fff">%s</font> %s:<font color="#fff">%s</font> %s:<font color="#fff">%s</font> %s:<font color="#fff">%s</font><br><br>%s %s:<font color="#fff">%s</font> %s:<font color="#fff">%s</font><br />', $rid, $rid, $ColorDef, $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']), $ColorDef, $LNG['sys_perte_attaquant'], pretty_number($result['lost']['att']), $ColorAtt, $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['Norio'], pretty_number($steal['norio']), $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($DefenderID, 0, $this->_fleet['fleet_start_time'], 3, $LNG['sys_mess_tower'], $LNG['sys_mess_attack_report'], $MessageDef);// review 3
}
}

function EndStayEvent()
{
return;
}

function ReturnEvent()
{
global $LANG;
$LNG = $LANG->GetUserLang($this->_fleet['fleet_owner']);

$Message = sprintf( $LNG['sys_fleet_won'], $TargetName, GetTargetAdressLink($this->_fleet, ''), pretty_number($this->_fleet['fleet_resource_metal']), $LNG['Metal'], pretty_number($this->_fleet['fleet_resource_crystal']), $LNG['Crystal'], pretty_number($this->_fleet['fleet_resource_deuterium']), $LNG['Deuterium'], pretty_number($this->_fleet['fleet_resource_norio']), $LNG['Norio']);
SendSimpleMessage($this->_fleet['fleet_owner'], 0, $this->_fleet['fleet_end_time'], 3, $LNG['sys_mess_tower'], $LNG['sys_mess_fleetback'], $Message);

$this->RestoreFleet();
}
}

?>>
samedi 4 janvier 2014

stryker Messages : 367

a mon avis le pillage des ressource se fait avec Calculatesteal.php

j'utilise xnova révolution civilisation j'ai pas tout a fait la même formule...


public static function calculateAKSSteal($attackFleets, $defenderPlanet, $ForSim = false)
{
//Steal-Math by Slaver for 2Moons(http://code.google.com/p/2moons/) based on http://www.owiki.de/Beute
global $pricelist;

$SortFleets = array();
foreach ($attackFleets as $FleetID => $Attacker)
{
foreach($Attacker['detail'] as $Element => $amount)
{
$SortFleets[$FleetID]        += $pricelist[$Element]['capacity'] * $amount;
}

$SortFleets[$FleetID]            -= $Attacker['fleet']['fleet_resource_metal'] - $Attacker['fleet']['fleet_resource_crystal'] - $Attacker['fleet']['fleet_resource_deuterium'] - $Attacker['fleet']['fleet_resource_darkmatter'];
}

$Sumcapacity              = array_sum($SortFleets);

// Step 1
$booty['metal']         = min(($Sumcapacity / 3),  ($defenderPlanet['metal'] / 2));
$Sumcapacity             -= $booty['metal'];

// Step 2
$booty['crystal']         = min(($Sumcapacity / 2),  ($defenderPlanet['crystal'] / 2));
$Sumcapacity             -= $booty['crystal'];

// Step 3
$booty['deuterium']     = min($Sumcapacity,  ($defenderPlanet['deuterium'] / 2));
$Sumcapacity             -= $booty['deuterium'];

// Step 4
$booty['darkmatter']     = min($Sumcapacity,  ($defenderPlanet['darkmatter'] / 2));
$Sumcapacity             -= $booty['darkmatter'];

// Step 5
$oldMetalBooty             = $booty['metal'];
$booty['metal']         += min(($Sumcapacity / 2),  max((($defenderPlanet['metal']) / 2) - $booty['metal'], 0));
$Sumcapacity             += $oldMetalBooty - $booty['metal'];

// Step 6
$booty['crystal']         += min(($Sumcapacity),  max((($defenderPlanet['crystal']) / 2) - $booty['crystal'], 0));

$booty['metal']            = max($booty['metal'] ,0);
$booty['crystal']          = max($booty['crystal'] ,0);
$booty['deuterium']        = max($booty['deuterium'] ,0);
$booty['darkmatter']       = max($booty['darkmatter'] ,0);

$steal                    = array_map('floor', $booty);

if($ForSim)
return $steal;

$AllCapacity        = array_sum($SortFleets);
$QryUpdateFleet        = "";

foreach($SortFleets as $FleetID => $Capacity)
{
$QryUpdateFleet     = "UPDATE {{table}} SET ";
$QryUpdateFleet .= "`fleet_resource_metal` =  `fleet_resource_metal` + '".floattostring($steal['metal'] * ($Capacity /  $AllCapacity))."', ";
$QryUpdateFleet .= "`fleet_resource_crystal` =  `fleet_resource_crystal` +'".floattostring($steal['crystal'] * ($Capacity  / $AllCapacity))."', ";
$QryUpdateFleet .= "`fleet_resource_deuterium` =  `fleet_resource_deuterium` +'".floattostring($steal['deuterium'] * ($Capacity / $AllCapacity))."', ";
            $QryUpdateFleet .= "`fleet_resource_darkmatter` =  `fleet_resource_darkmatter` +'".floattostring($steal['darkmatter'] * ($Capacity / $AllCapacity))."' ";
$QryUpdateFleet .= "WHERE fleet_id = '".$FleetID."' ";
$QryUpdateFleet .= "LIMIT 1;";
doquery($QryUpdateFleet, 'fleets');

}

return $steal;
}
samedi 4 janvier 2014

Homer Messages : 1811
stryker :

a mon avis le pillage des ressource se fait avec Calculatesteal.php

Tout est dit

Vérifie la valeur des variables d'entrée fournit a la fonction, et passe au prochaine si tout est bon.

samedi 4 janvier 2014 (Dernière édition samedi 4 janvier 2014)

Mizur Messages : 6618

Oui ça vient de Calculatesteal, c'est pour ça que j'ai parlé de debugging des variables

dimanche 5 janvier 2014

pyrosephiroth Messages : 62

A cause de vous (houlala ), j'ai du abandonner mon firefox adoré pour me lancer sur Google Chrome (et utiliser le module que tu m'as indiqué Mizur). Eh bien il semblerait que je ne parvienne / ne sache pas m'en servir correctement ... :")

J'ai toutefois pris mon mal en patience et relu le calculesteal.php. Selon moi, les formules sont exactes ! é.à

Donc effectivement, le soucis devrait provenir de variables qui transporteraient de mauvaises informations.

J'en veux pour autre preuve que j'ai essayé d'utiliser le fichier de Stryker (merci à toi ) en changeant évidemment les noms de variables et que pour autant, toujours 0 ressource !

dimanche 5 janvier 2014

Page suivante »