Пример #1
0
 function set($unitId, $unitName, $unitForceId, $unitHexagon, $unitImage, $unitMaxStrength, $unitMinStrength, $unitMaxMove, $isReduced, $unitStatus, $unitReinforceZone, $unitReinforceTurn, $range, $nationality = "neutral", $forceMarch, $class, $unitDesig)
 {
     $this->dirty = true;
     $this->id = $unitId;
     $this->name = $unitName;
     $this->forceId = $unitForceId;
     $this->class = $class;
     $this->hexagon = new Hexagon($unitHexagon);
     /* blah! this can get called from the constructor of Battle. so we can't get ourselves while creating ourselves */
     //        $battle = Battle::getBattle();
     //        $mapData = $battle->mapData;
     $mapData = MapData::getInstance();
     $mapHex = $mapData->getHex($this->hexagon->getName());
     if ($mapHex) {
         $mapHex->setUnit($this->forceId, $this);
     }
     $this->image = $unitImage;
     //        $this->strength = $isReduced ? $unitMinStrength : $unitMaxStrength;
     $this->maxMove = $unitMaxMove;
     $this->moveAmountUnused = $unitMaxMove;
     $this->maxStrength = $unitMaxStrength;
     $this->minStrength = $unitMinStrength;
     $this->isReduced = $isReduced;
     $this->status = $unitStatus;
     $this->moveAmountUsed = 0;
     $this->reinforceZone = $unitReinforceZone;
     $this->reinforceTurn = $unitReinforceTurn;
     $this->combatNumber = 0;
     $this->combatIndex = 0;
     $this->combatOdds = "";
     $this->moveCount = 0;
     $this->retreatCountRequired = 0;
     $this->combatResults = NE;
     $this->range = $range;
     $this->nationality = $nationality;
     $this->forceMarch = $forceMarch;
     $this->unitDesig = $unitDesig;
 }
Пример #2
0
 function __construct($data = null, $arg = false, $scenario = false, $game = false)
 {
     $this->mapData = MapData::getInstance();
     if ($data) {
         $this->arg = $data->arg;
         $this->scenario = $data->scenario;
         $this->terrainName = $data->terrainName;
         $this->game = $data->game;
         $this->mapData->init($data->mapData);
         $this->mapViewer = array(new MapViewer($data->mapViewer[0]), new MapViewer($data->mapViewer[1]), new MapViewer($data->mapViewer[2]));
         $units = $data->force->units;
         unset($data->force->units);
         $this->force = new NavalForce($data->force);
         foreach ($units as $unit) {
             $this->force->injectUnit(static::buildUnit($unit));
         }
         if (isset($data->terrain)) {
             $this->terrain = new Terrain($data->terrain);
         } else {
             $this->terrain = new \stdClass();
         }
         $this->moveRules = new NavalMoveRules($this->force, $this->terrain, $data->moveRules);
         $this->combatRules = new NavalCombatRules($this->force, $this->terrain, $data->combatRules);
         $this->gameRules = new GameRules($this->moveRules, $this->combatRules, $this->force, $data->gameRules);
         $this->victory = new Victory($data);
         $this->players = $data->players;
     } else {
         $this->arg = $arg;
         $this->scenario = $scenario;
         $this->game = $game;
         $this->mapViewer = array(new MapViewer(), new MapViewer(), new MapViewer());
         $this->force = new NavalForce();
         $this->terrain = new Terrain();
         $this->moveRules = new NavalMoveRules($this->force, $this->terrain);
         $this->combatRules = new NavalCombatRules($this->force, $this->terrain);
         $this->gameRules = new GameRules($this->moveRules, $this->combatRules, $this->force);
     }
 }