Пример #1
0
 public static function create(Game $game, $abbr, $name_official, $name_long, $name_short)
 {
     $o = new Empire();
     $o->setGame($game);
     $o->setAbbr($abbr);
     $o->setName($name_official);
     $o->setNameLong($name_long);
     $o->setNameShort($name_short);
     $o->save();
     return $o;
 }
Пример #2
0
 /**
  * Reads in a JSON object with all the empires defined.
  * [{id: 'CAN', name_official: 'Canada', name_long: 'Dominion of Canada', name_short: 'Canada' }, ...]
  */
 public function loadEmpires(array $objs)
 {
     //print_r($objs);
     //$empires = array();
     foreach ($objs as $obj) {
         $t = Empire::create($this, $obj->id, $obj->name_official, $obj->name_long, $obj->name_short);
         $this->addEmpire($t);
     }
     $this->save();
 }
Пример #3
0
 public function inc(Empire $empire, Order $order = null)
 {
     if (!array_key_exists($empire->getEmpireId(), $this->map)) {
         $this->map[$empire->getEmpireId()] = array('tally' => 0, 'empire' => $empire, 'orders' => array(), 'lost' => false);
     }
     //print "Incrementing $empire\n";
     $this->map[$empire->getEmpireId()]['tally']++;
     if (!is_null($order)) {
         $this->map[$empire->getEmpireId()]['orders'][$order->getPrimaryKey()] = $order;
     }
 }