Пример #1
0
 /**
  * Updates the map $map by processing the update map command
  *
  * @param \Mastercoding\Conquest\Object\Map $map
  * @param \Mastercoding\Conquest\Command\UpdateMap\Update $updateCommand
  */
 public function updateMap(\Mastercoding\Conquest\Object\Map $map, \Mastercoding\Conquest\Command\UpdateMap\Update $updateCommand)
 {
     // loop updates
     foreach ($updateCommand->getUpdates() as $update) {
         // get region by id
         $region = $map->getRegionById($update['regionId']);
         $region->setArmies($update['armies']);
         // owner
         if ($update['owner'] == 'neutral') {
             $region->setOwner(new \Mastercoding\Conquest\Object\Owner\Neutral());
         } else {
             foreach ($map->getPlayers() as $player) {
                 if ($player->getName() == $update['owner']) {
                     $region->setOwner($player);
                 }
             }
         }
     }
 }