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; }
private static function getObjectFromReader($data) { $out = new Dolumar_Underworld_Models_Army($data['ua_id']); $out->setData($data); $out->setLocation(new Neuron_GameServer_Map_Location($data['ua_x'], $data['ua_y'])); $out->setSide(new Dolumar_Underworld_Models_Side($data['ua_side'])); return $out; }
public function getHistoricalArmyData(Dolumar_Underworld_Models_Army $army) { $report = $this->getReport(); $units = $report->getUnits(); if ($this->getAttackerSide()->equals($army->getSide())) { // Attacker return $units['attacking']; } else { if ($this->getDefenderSide()->equals($army->getSide())) { // Defender return $units['defending']; } } return null; }
/** * Attack */ public function attack(Dolumar_Players_Player $me, Dolumar_Underworld_Models_Army $army) { if (!$this->canAttack($me)) { $this->error = 'move_not_authorized'; return false; } $path = $this->canReach($army->getLocation(), true); if (!$this->isEnemy($army)) { $this->error = 'not_an_enemy'; return false; } else { if (!$path) { $this->error = 'cannot_reach_target'; return false; } else { if ($this->isFighting()) { $this->error = 'army_not_idle'; return false; } else { if ($army->isFighting()) { // This should be replaced by queing $this->error = 'target_not_idle'; return false; } else { $fight = $this->prcFight($army); $this->getMap()->getMission()->getLogger()->attack($me, $this, $army, $army->getLocation(), $path, $fight); return $fight; } } } } }
public function onMove(Dolumar_Underworld_Models_Army $army, Neuron_GameServer_Map_Location $old, Neuron_GameServer_Map_Location $new) { if ($new instanceof Dolumar_Underworld_Map_Locations_Checkpoint) { $this->setCheckpointSide($new, $army->getSide()); } }
public static function addSpawnLog(Dolumar_Underworld_Models_Mission $mission, Neuron_GameServer_Player $player, Dolumar_Underworld_Models_Army $army, Neuron_GameServer_Map_Location $location, Dolumar_Players_Clan $clan) { $db = Neuron_DB_Database::getInstance(); self::addClan($mission, $clan, $army->getSide()); $missionId = self::getMissionId($mission); $armyId = self::getArmyId($mission, $army); $sql = "\n\t\t\tINSERT INTO\n\t\t\t\tunderworld_log_event\n\t\t\tSET\n\t\t\t\tul_m_id = '{$missionId}',\n\t\t\t\tplid = '{$player->getId()}',\n\t\t\t\tul_a_vid = '{$armyId}',\n\t\t\t\tul_e_action = 'SPAWN',\n\t\t\t\tul_e_x = '{$location->x()}',\n\t\t\t\tul_e_y = '{$location->y()}',\n\t\t\t\tul_e_date = NOW()\n\t\t"; $db->query($sql); }