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; }