/** * Return all display objects that are within $radius * of $location (so basically loading a bubble) */ public function getDisplayObjects(Neuron_GameServer_Map_Area $area, $useFogOfWar = true) { $objects = array(); $armies = Dolumar_Underworld_Mappers_ArmyMapper::getFromArea($this->mission, $area); foreach ($armies as $v) { if (!$useFogOfWar || $this->getExploreStatus($v->getLocation()) == Dolumar_Underworld_Map_FogOfWar::VISIBLE) { $objects[] = $v; } } return $objects; }
private function loadAllMyLocations() { if (!isset($this->allMyLocations)) { $this->allMyLocations = array(); // Load all me currents objects $all = Dolumar_Underworld_Mappers_ArmyMapper::getFromSide($this->mission, $this->side); foreach ($all as $v) { $this->allMyLocations[] = $v->getLocation(); } $this->exploredLocations = Dolumar_Underworld_Mappers_ExploredMapper::getExploredLocations($this->mission, $this->side); } }
<?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 createArmy(Dolumar_Underworld_Map_Locations_Location $location, Dolumar_Underworld_Models_Side $side, array $squads) { if (count($squads) === 0) { return false; } $army = new Dolumar_Underworld_Models_Army(null); $army->setSide($side); $army->setLocation($location); Dolumar_Underworld_Mappers_ArmyMapper::create($this, $army); $players = array(); foreach ($squads as $v) { $army->addSquad($v); $player = $squads[0]->getVillage()->getOwner(); $players[$player->getId()] = $player; } foreach ($players as $player) { $army->promote_nocheck($player); } $this->getMap()->addMapUpdate($location, 'BUILD'); // Notify objective $this->getObjective()->onSpawn($army); return $army; }
public static function remove(Dolumar_Underworld_Models_Mission $mission) { Dolumar_Underworld_Mappers_ArmyMapper::removeFromMission($mission); Dolumar_Underworld_Mappers_CheckpointMapper::removeFromMission($mission); Dolumar_Underworld_Mappers_ExploredMapper::removeFromMission($mission); Dolumar_Underworld_Mappers_ScoreMapper::removeFromMission($mission); $db = Neuron_DB_Database::getInstance(); $db->query("\n\t\t\tDELETE FROM\n\t\t\t\tunderworld_missions_clans\n\t\t\tWHERE\n\t\t\t\tum_id = {$mission->getId()}\n\t\t"); $db->query("\n\t\t\tDELETE FROM\n\t\t\t\tunderworld_missions\n\t\t\tWHERE\n\t\t\t\tum_id = {$mission->getId()}\n\t\t"); }
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()); } } }
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'])); }
/** * Remove this squad */ public function destroy() { $this->getMap()->addMapUpdate($this->getLocation(), 'DESTROY'); Dolumar_Underworld_Mappers_ArmyMapper::remove($this); }
public function getInitialLocation() { $player = Neuron_GameServer::getPlayer(); if ($player) { $side = $this->getMission()->getPlayerSide($player); $armies = Dolumar_Underworld_Mappers_ArmyMapper::getFromSide($this->getMission(), $side); foreach ($armies as $v) { if ($v->isLeader($player)) { $location = $v->getLocation(); $l = array($location->x(), $location->y()); return $l; } } if (count($armies) > 0) { $location = $armies[0]->getLocation(); return array($location->x(), $location->y()); } } return array(0, 0); }