game = $game; $this->players = $game->getLib('beta5/player'); } function getSender() { return 'Military Advisor'; } function getSLink() { return ""; } function getRecipient() { $pinf = $this->players->call('getName', $this->player); return utf8entities($pinf); } function getRLink() { return ""; } function getSubject() { return "Battle report for " . utf8entities($this->data['planet']); } function getReplyLink() { return ""; } function getContents() { $vacation = ($this->data['o_power'] == 0); $str = 'Sir! ' . ($vacation ? "Forces " : "Our forces ") . 'have been fighting in orbit around ' . utf8entities($this->data['planet']) . ". " . ($this->data['heroic_def'] == -1 ? 'The defending forces, overwhelmed, resisted to the last man. Their heroic actions have caused us unexpected losses. ' : '') . ($this->data['heroic_def'] == 1 ? 'While our forces were greatly outnumbered, they opposed the attacking forces heroically. ' : '') . "We have received an update on the latest casualties:

" . ""; if ($this->data['a_power'] > 0) { $str .= ""; } $str .= ""; if ($this->data['a_power'] > 0) { $str .= ""; } $str .= ""; for ($i=0;$i<4;$i++) { $n = $this->sfn[$i]; if ($this->data["o_$n"] + $this->data["a_$n"] + $this->data["e_$n"] == 0) { continue; } $str .= ""; if ($this->data['a_power'] > 0) $str .= ""; $str .= ""; $str .= ""; } $tmode = $this->data['tmode']; if ($tmode != 0) { $str .= ""; } $str .= ""; if ($this->data['a_power'] > 0) $str .= ""; $str .= "
 Own TroopsAllied TroopsEnemy Troops
StartLostStartLostStartLost
" . $this->sdn[$i] . "" . number_format($this->data["o_$n"]) . "" . number_format($this->data["ol_$n"]) . "" . number_format($this->data["a_$n"]) . "" . number_format($this->data["al_$n"]) . "" . number_format($this->data["e_$n"]) . "" . number_format($this->data["el_$n"]) . "
Turrets"; if ($tmode == 1) $str .= number_format($this->data["turrets"]) . "" . number_format($this->data["l_turrets"]); else $str .= "--"; $str .= ""; if ($tmode == 2) $str .= number_format($this->data["turrets"]) . "" . number_format($this->data["l_turrets"]) . ""; elseif ($this->data['a_power'] > 0) $str .= "--"; if ($tmode == 3) $str .= number_format($this->data["turrets"]) . "" . number_format($this->data["l_turrets"]); else $str .= "--"; $str .= "
Fleet Power" . number_format($this->data['o_power']) . "" . number_format($this->data['ol_power']) . "" . number_format($this->data['a_power']) . "" . number_format($this->data['al_power']) . "" . number_format($this->data['e_power']) . "" . number_format($this->data['el_power']) . "

"; $ePower = $this->data['e_power']; $eLoss = $this->data['el_power']; $aPower = $this->data['a_power'] + $this->data['o_power']; $aLoss = $this->data['al_power'] + $this->data['ol_power']; if ($aPower == $aLoss && $ePower == $eLoss) { $str .= "The fleets annihilated each other."; } elseif ($ePower == $eLoss) { $str .= "Victory is ours! The enemy has been annihilated!"; } elseif ($aPower == $aLoss) { $str .= "Our forces were annihilated!"; } else { $ePLoss = $eLoss / $ePower; $aPLoss = $aLoss / $aPower; if ($ePower - $eLoss > $aPower - $aLoss) { $ratio = $ePLoss ? ($aPLoss / $ePLoss) : 11; if ($ratio > 10) { $str .= "Sir, our forces have to retreat from this losing battle!"; } elseif ($ratio > 3) { $str .= "We are getting whacked. We need reinforcements!"; } elseif ($ratio > 1.2) { $str .= "The situation doesn't look too good for us."; } else { $str .= "Our forces and the enemy's forces are a close match."; } } elseif ($ePower - $eLoss < $aPower - $aLoss) { $ratio = $aPLoss ? ($ePLoss / $aPLoss) : 11; if ($ratio > 10) { $str .= "The enemy will soon be crushed."; } else if ($ratio > 3) { $str .= "We are clearly winning this fight."; } else if ($ratio > 1.2) { $str .= "The enemy is bound to lose this fight in the long run."; } else { $str .= "Our forces and the enemy's forces are a close match."; } } else { $str .= "Our forces and the enemy's forces are a close match."; } } return $str; } } ?>