function moveIsValid(BaseUnit $movingUnit, $hexagon, $startHex = false, $firstHex = false)
 {
     // all 4 conditions must be true, so any one that is false
     //    will make the move invalid
     $isValid = true;
     if ($startHex === false) {
         $startHex = $movingUnit->getUnitHexagon()->name;
     }
     if ($firstHex === false) {
         $firstHex = $movingUnit->unitHasNotMoved();
     }
     // condition 1
     // can only move to nearby hexagon
     if ($this->rangeIsOneHexagon($startHex, $hexagon) == false) {
         $isValid = false;
     }
     // condition 2
     // check if unit has enough move points
     $moveAmount = $this->terrain->getTerrainMoveCost($startHex, $hexagon, $movingUnit->forceMarch, $movingUnit);
     // need move points, but can always move at least one hexagon
     //  can always move at least one hexagon if this->oneHex is true
     //  only check move amount if unit has been moving
     if (!($firstHex == true && $this->oneHex)) {
         if ($movingUnit->unitHasMoveAmountAvailable($moveAmount) == false) {
             $isValid = false;
         }
     }
     // condition 3
     // can only move across river hexside if at start of move
     //        if (($this->isAlongRail($startHex, $hexagon) == false) && $this->railMove) {
     //            $isValid = false;
     //        }
     // condition 4
     // can not exit
     if ($this->terrain->isExit($hexagon) == true) {
         $isValid = false;
     }
     return $isValid;
 }
Exemple #2
0
 public function resetUnit()
 {
     parent::resetUnit();
     $this->supplied = true;
 }
Exemple #3
0
 public function resetUnit()
 {
     parent::resetUnit();
     $this->isReduced = false;
 }