Search in sources :

Example 1 with PhaseStep

use of mage.constants.PhaseStep in project mage by magefree.

the class Phase method resumePlay.

public boolean resumePlay(Game game, PhaseStep stepType, boolean wasPaused) {
    if (game.isPaused() || game.checkIfGameIsOver()) {
        return false;
    }
    this.activePlayerId = game.getActivePlayerId();
    Iterator<Step> it = steps.iterator();
    Step step;
    do {
        step = it.next();
        currentStep = step;
    } while (step.getType() != stepType);
    resumeStep(game, wasPaused);
    while (it.hasNext()) {
        step = it.next();
        if (game.isPaused() || game.checkIfGameIsOver()) {
            return false;
        }
        currentStep = step;
        if (!game.getState().getTurnMods().skipStep(activePlayerId, currentStep.getType())) {
            playStep(game);
            if (game.executingRollback()) {
                return true;
            }
        }
    }
    if (game.isPaused() || game.checkIfGameIsOver()) {
        return false;
    }
    count++;
    endPhase(game, activePlayerId);
    return true;
}
Also used : PhaseStep(mage.constants.PhaseStep)

Example 2 with PhaseStep

use of mage.constants.PhaseStep in project mage by magefree.

the class Phase method playExtraSteps.

private void playExtraSteps(Game game, PhaseStep afterStep) {
    while (true) {
        Step extraStep = game.getState().getTurnMods().extraStep(activePlayerId, afterStep);
        if (extraStep == null) {
            return;
        }
        currentStep = extraStep;
        playStep(game);
    }
}
Also used : PhaseStep(mage.constants.PhaseStep)

Example 3 with PhaseStep

use of mage.constants.PhaseStep in project mage by magefree.

the class Turn method resumePlay.

public void resumePlay(Game game, boolean wasPaused) {
    activePlayerId = game.getActivePlayerId();
    UUID priorityPlayerId = game.getPriorityPlayerId();
    TurnPhase phaseType = game.getPhase().getType();
    PhaseStep stepType = game.getStep().getType();
    Iterator<Phase> it = phases.iterator();
    Phase phase;
    do {
        phase = it.next();
        currentPhase = phase;
    } while (phase.type != phaseType);
    if (phase.resumePlay(game, stepType, wasPaused)) {
        // 20091005 - 500.4/703.4n
        game.emptyManaPools(null);
        // game.saveState();
        // 20091005 - 500.8
        playExtraPhases(game, phase.getType());
    }
    while (it.hasNext()) {
        phase = it.next();
        if (game.isPaused() || game.checkIfGameIsOver()) {
            return;
        }
        currentPhase = phase;
        if (!game.getState().getTurnMods().skipPhase(activePlayerId, currentPhase.getType())) {
            if (phase.play(game, activePlayerId)) {
                // 20091005 - 500.4/703.4n
                game.emptyManaPools(null);
                // game.saveState();
                // 20091005 - 500.8
                playExtraPhases(game, phase.getType());
            }
        }
        if (!currentPhase.equals(phase)) {
            // phase was changed from the card
            game.fireEvent(new PhaseChangedEvent(activePlayerId, null));
            break;
        }
    }
}
Also used : TurnPhase(mage.constants.TurnPhase) PhaseChangedEvent(mage.game.events.PhaseChangedEvent) PhaseStep(mage.constants.PhaseStep) UUID(java.util.UUID) TurnPhase(mage.constants.TurnPhase)

Example 4 with PhaseStep

use of mage.constants.PhaseStep in project mage by magefree.

the class EndOfTurnOneOpponentTest method prepareStepChecks.

public static void prepareStepChecks(CardTestPlayerAPIImpl testEngine, String testName, int turnNum, TestPlayer player, boolean willBeBattle, PhaseStep mustExistUntilStep) {
    for (PhaseStep step : PhaseStep.values()) {
        // skip auto-steps without priority/checks
        switch(step) {
            case UNTAP:
            case DRAW:
            case UPKEEP:
            case FIRST_COMBAT_DAMAGE:
            case CLEANUP:
                // auto-skip steps without priority
                continue;
            case PRECOMBAT_MAIN:
            case POSTCOMBAT_MAIN:
            case END_TURN:
                // always use
                break;
            case BEGIN_COMBAT:
            case DECLARE_ATTACKERS:
            case DECLARE_BLOCKERS:
            case COMBAT_DAMAGE:
            case END_COMBAT:
                // combat skip
                if (!willBeBattle)
                    continue;
                break;
            default:
                throw new IllegalStateException("Unknown phase step " + step);
        }
        int permP = 2;
        int permT = 2;
        String existsStr = "must NOT EXISTS";
        if (mustExistUntilStep != null && step.getIndex() <= mustExistUntilStep.getIndex()) {
            permP++;
            permT++;
            existsStr = "must EXISTS";
        }
        testEngine.checkPT(testName + " " + existsStr + " on turn " + turnNum + " - " + step.toString() + " for " + player.getName(), turnNum, step, player, cardBear2, permP, permT);
    }
}
Also used : PhaseStep(mage.constants.PhaseStep)

Example 5 with PhaseStep

use of mage.constants.PhaseStep in project mage by magefree.

the class LoadPhaseManager method isSkip.

public boolean isSkip(GameView gameView, String message, UUID playerId) {
    // skip callbacks
    UUID activePlayer = null;
    Map<PhaseStep, Boolean> map = skipOthers;
    for (PlayerView playerView : gameView.getPlayers()) {
        if (playerView.isActive()) {
            activePlayer = playerView.getPlayerId();
            if (activePlayer.equals(playerId)) {
                map = skipYou;
            }
        }
    }
    if (activePlayer == null) {
        throw new IllegalStateException("No active player found.");
    }
    if (map.containsKey(gameView.getStep())) {
        return map.get(gameView.getStep());
    } else {
        log.error("Unknown phase manager step: " + gameView.getStep().toString());
        return false;
    }
}
Also used : PlayerView(mage.view.PlayerView) PhaseStep(mage.constants.PhaseStep) UUID(java.util.UUID)

Aggregations

PhaseStep (mage.constants.PhaseStep)6 UUID (java.util.UUID)2 TurnPhase (mage.constants.TurnPhase)1 PhaseChangedEvent (mage.game.events.PhaseChangedEvent)1 PlayerView (mage.view.PlayerView)1