function selectNextPhase($click) { global $phase_name; if ($this->mode == MOVING_MODE && $this->moveRules->movesLeft()) { return false; } if ($this->moveRules->anyUnitIsMoving) { $this->moveRules->stopMove($this->force->units[$this->moveRules->movingUnitId]); } if (($this->gameHasCombatResolutionMode == false || $this->force->moreCombatToResolve() == false) && $this->moveRules->anyUnitIsMoving == false) { /* @var Battle $battle */ $battle = Battle::getBattle(); $victory = $battle->victory; for ($i = 0; $i < count($this->phaseChanges); $i++) { if ($this->phaseChanges[$i]->currentPhase == $this->phase) { $this->phase = $this->phaseChanges[$i]->nextPhase; // $prevMode = $this->mode; $this->mode = $this->phaseChanges[$i]->nextMode; // if($this->gameHasCombatResolutionMode === false && $this->mode == COMBAT_RESOLUTION_MODE && $prevMode == COMBAT_SETUP_MODE){ // $this->combatRules->combatsToResolve = $this->combatRules->combats; // } $this->replacementsAvail = false; $this->phaseClicks[] = $click + 1; $this->phaseClickNames[] = $phase_name[$this->phase]; if ($this->phaseChanges[$i]->phaseWillIncrementTurn == true) { $this->incrementTurn(); } if ($this->attackingForceId != $this->phaseChanges[$i]->nextAttackerId) { $battle = Battle::getBattle(); $players = $battle->players; $this->playTurnClicks[] = $click + 1; if ($players[1] != $players[2]) { Battle::pokePlayer($players[$this->phaseChanges[$i]->nextAttackerId]); } $victory->playerTurnChange($this->phaseChanges[$i]->nextAttackerId); } $this->attackingForceId = $this->phaseChanges[$i]->nextAttackerId; $this->defendingForceId = $this->phaseChanges[$i]->nextDefenderId; $this->force->setAttackingForceId($this->attackingForceId, $this->defendingForceId); $victory->phaseChange(); $this->force->recoverUnits($this->phase, $this->moveRules, $this->mode); if ($this->turn > $this->maxTurn) { $victory->gameEnded(); $this->flashMessages[] = "@gameover"; } return true; } } } return false; }