예제 #1
0
 public static function getInstance()
 {
     if (!AreaData::$instance) {
         AreaData::$instance = new AreaData();
     }
     return AreaData::$instance;
 }
예제 #2
0
 function __construct(AreaForce $Force, AreaTerrain $Terrain, $data = null)
 {
     // Class references
     $this->mapData = AreaData::getInstance();
     $this->moves = new stdClass();
     $this->path = new stdClass();
     $this->force = $Force;
     $this->terrain = $Terrain;
     if ($data) {
         foreach ($data as $k => $v) {
             $this->{$k} = $v;
         }
     } else {
     }
 }
예제 #3
0
 function __construct($data = null, $arg = false, $scenario = false)
 {
     $this->areaData = AreaData::getInstance();
     $this->mapData = $this->areaData;
     if ($data) {
         $this->scenario = $data->scenario;
         $this->force = new AreaForce($data->force);
         if (isset($data->terrain)) {
             $this->terrain = new AreaTerrain($data->terrain);
         } else {
             $this->terrain = new \stdClass();
         }
         $this->combatRules = new CombatRules($this->force, $this->terrain, $data->combatRules);
         $this->moveRules = new AreaMoveRules($this->force, $this->terrain, $data->moveRules);
         $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->display = new stdClass();
         //            $this->mapViewer = array(new MapViewer(), new MapViewer(), new MapViewer());
         $this->force = new AreaForce();
         $this->terrain = new AreaTerrain();
         $this->moveRules = new AreaMoveRules($this->force, $this->terrain);
         $this->combatRules = new CombatRules($this->force, $this->terrain);
         $this->gameRules = new GameRules($this->moveRules, $this->combatRules, $this->force);
     }
     if ($data) {
         $this->specialHexA = $data->specialHexA;
     } else {
         //            $this->victory = new Victory("Wargame\TMCW/Area1/area1VictoryCore.php");
         //            if ($scenario->supplyLen) {
         //                $this->victory->setSupplyLen($scenario->supplyLen);
         //            }
         //            $this->moveRules = new MoveRules($this->force, $this->terrain);
         //            if ($scenario && $scenario->supply === true) {
         //                $this->moveRules->enterZoc = 2;
         //                $this->moveRules->exitZoc = 1;
         //                $this->moveRules->noZocZocOneHex = true;
         //            } else {
         //                $this->moveRules->enterZoc = "stop";
         //                $this->moveRules->exitZoc = 0;
         //                $this->moveRules->noZocZocOneHex = false;
         //            }
         // game data
         $this->gameRules->setMaxTurn(7);
         $this->gameRules->setInitialPhaseMode(RED_DEPLOY_PHASE, DEPLOY_MODE);
         $this->gameRules->attackingForceId = RED_FORCE;
         /* object oriented! */
         $this->gameRules->defendingForceId = BLUE_FORCE;
         /* object oriented! */
         $this->force->setAttackingForceId($this->gameRules->attackingForceId);
         /* so object oriented */
         $this->gameRules->addPhaseChange(RED_DEPLOY_PHASE, BLUE_DEPLOY_PHASE, DEPLOY_MODE, BLUE_FORCE, RED_FORCE, false);
         $this->gameRules->addPhaseChange(BLUE_DEPLOY_PHASE, BLUE_MOVE_PHASE, MOVING_MODE, BLUE_FORCE, RED_FORCE, false);
         $this->gameRules->addPhaseChange(BLUE_MOVE_PHASE, BLUE_COMBAT_PHASE, COMBAT_SETUP_MODE, BLUE_FORCE, RED_FORCE, false);
         $this->gameRules->addPhaseChange(BLUE_COMBAT_PHASE, RED_MOVE_PHASE, MOVING_MODE, RED_FORCE, BLUE_FORCE, false);
         $this->gameRules->addPhaseChange(RED_MOVE_PHASE, RED_COMBAT_PHASE, COMBAT_SETUP_MODE, RED_FORCE, BLUE_FORCE, false);
         $this->gameRules->addPhaseChange(RED_COMBAT_PHASE, RED_MECH_PHASE, MOVING_MODE, RED_FORCE, BLUE_FORCE, false);
         $this->gameRules->addPhaseChange(RED_MECH_PHASE, BLUE_MOVE_PHASE, MOVING_MODE, BLUE_FORCE, RED_FORCE, true);
     }
 }