Example #1
0
 public function updateUnit(Dolumar_Battle_Unit $oldunit, Dolumar_Battle_Unit $newunit)
 {
     $oldunit->setFrontage($newunit->getFrontage());
 }
Example #2
0
 private function getUnit($data)
 {
     $data = json_decode($data, true);
     $data = array_values($data);
     if (!$data) {
         $vil = Dolumar_Players_Village::getVillage($data[1]);
         return new Dolumar_Units_Unit($vil);
     }
     $sKey = $data[0] . '_' . $data[1] . '_' . $data[2] . '_' . $data[6];
     // 6: race
     if (!isset($this->unitCache[$sKey])) {
         $vil = Dolumar_Players_Village::getVillage($data[1]);
         $race = Dolumar_Races_Race::getFromId($data[6]);
         $this->unitCache[$sKey] = Dolumar_Units_Unit::getUnitFromId($data[0], $race, $vil);
     }
     $unit = new Dolumar_Battle_Unit();
     $unit->setUnit($this->unitCache[$sKey]);
     $unit->setAmount($data[5]);
     // Squad (4 or 'squad')
     if ($data[4] > 0 && isset($this->squads[$data[4] - 1])) {
         $unit->setName($this->squads[$data[4] - 1]);
     }
     // Frontage
     $frontage = isset($data[7]) ? $data[7] : 0;
     $unit->setFrontage($frontage);
     return $unit;
 }