private function prcAttack(Dolumar_Underworld_Models_Army $target = null) { $text = Neuron_Core_Text::getInstance(); if (!isset($target)) { $target = Dolumar_Underworld_Mappers_ArmyMapper::getFromId($this->getInput('target'), $this->getServer()->getMap()); if (!isset($target)) { $this->alert('Invalid input, target not found.'); } } if (!$this->army->isEnemy($target)) { $this->alert('Invalid input: not an enemy.'); } $confirmed = $this->getInput('confirmed'); // Dialog to confirm if (!$confirmed == '1') { $this->dialog(Neuron_Core_Tools::putIntoText($text->get('attack', 'squad', 'underworld'), array($target->getDisplayName())), $text->get('dyes', 'main', 'main'), "windowAction (this, {'id':" . $this->army->getId() . ",'action':'attack','confirmed':1,'target':" . $target->getId() . "});", $text->get('dno', 'main', 'main'), 'void(0);'); } else { if (!$this->army->attack($this->me, $target)) { $this->alert($this->army->getError()); } } }
<?php $army1 = Dolumar_Underworld_Mappers_ArmyMapper::getFromId(1); $army2 = Dolumar_Underworld_Mappers_ArmyMapper::getFromId(3); $battle = $army1->attack($army2); $report = $battle->getReport(); $units = $report->getUnits(); echo '<h2>Units</h2>'; foreach ($units as $k => $v) { echo '<h3>' . $k . '</h3>'; echo '<table>'; echo '<tr>'; echo '<th>Unit</th>'; echo '<th>Amount</th>'; echo '<th>Died</th>'; echo '</tr>'; foreach ($v as $unit) { echo '<tr>'; echo '<td>' . $unit['unit']->getDisplayName() . '</td>'; echo '<td>' . $unit['amount'] . '</td>'; echo '<td>' . $unit['died'] . '</td>'; echo '</tr>'; } echo '</table>'; } echo '<h2>Fight log</h2>'; echo $report->getFightLog(0, true);
public function setData($data) { $this->setId($data['uat_id']); if (!empty($data['uat_attackerr'])) { $this->attacker = Dolumar_Underworld_Mappers_ArmyMapper::getFromId($data['uat_attacker']); } if (!empty($data['uat_defender'])) { $this->defender = Dolumar_Underworld_Mappers_ArmyMapper::getFromId($data['uat_defender']); } $report = Dolumar_Underworld_Models_Report::unserialize($data['uat_fightlog']); $report->setId($this->getId()); $this->startdate = $data['startdate']; $this->endtime = $data['enddate']; $this->setReport($report); $this->setAttackerSide(new Dolumar_Underworld_Models_Side($data['uat_attacker_side'])); $this->setDefenderSide(new Dolumar_Underworld_Models_Side($data['uat_defender_side'])); $this->setAttackerLocation(new Neuron_GameServer_Map_Location($data['uat_from_x'], $data['uat_from_y'])); $this->setDefenderLocation(new Neuron_GameServer_Map_Location($data['uat_to_x'], $data['uat_to_y'])); }