Search in sources :

Example 1 with EndOfCombatStep

use of mage.game.turn.EndOfCombatStep in project mage by magefree.

the class CombatUtil method willItSurvive.

public static SurviveInfo willItSurvive(Game game, UUID attackingPlayerId, UUID defendingPlayerId, Permanent attacker, Permanent blocker) {
    Game sim = game.copy();
    Combat combat = sim.getCombat();
    combat.setAttacker(attackingPlayerId);
    combat.setDefenders(sim);
    if (blocker == null || attacker == null || sim.getPlayer(defendingPlayerId) == null) {
        return null;
    }
    sim.getPlayer(defendingPlayerId).declareBlocker(defendingPlayerId, blocker.getId(), attacker.getId(), sim);
    sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_BLOCKERS, defendingPlayerId, defendingPlayerId));
    sim.checkStateAndTriggered();
    while (!sim.getStack().isEmpty()) {
        sim.getStack().resolve(sim);
        sim.applyEffects();
    }
    sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARE_BLOCKERS_STEP_POST, sim.getActivePlayerId(), sim.getActivePlayerId()));
    simulateStep(sim, new FirstCombatDamageStep());
    simulateStep(sim, new CombatDamageStep());
    simulateStep(sim, new EndOfCombatStep());
    // sim.checkStateAndTriggered();
    while (!sim.getStack().isEmpty()) {
        sim.getStack().resolve(sim);
        sim.applyEffects();
    }
    return new SurviveInfo(!sim.getBattlefield().containsPermanent(attacker.getId()), !sim.getBattlefield().containsPermanent(blocker.getId()));
}
Also used : FirstCombatDamageStep(mage.game.turn.FirstCombatDamageStep) CombatDamageStep(mage.game.turn.CombatDamageStep) Game(mage.game.Game) EndOfCombatStep(mage.game.turn.EndOfCombatStep) Combat(mage.game.combat.Combat) FirstCombatDamageStep(mage.game.turn.FirstCombatDamageStep)

Example 2 with EndOfCombatStep

use of mage.game.turn.EndOfCombatStep in project mage by magefree.

the class CombatUtil method getCombatInfo.

public static SurviveInfo getCombatInfo(Game game, UUID attackingPlayerId, UUID defendingPlayerId, Permanent attacker) {
    Game sim = game.copy();
    Combat combat = sim.getCombat();
    combat.setAttacker(attackingPlayerId);
    combat.setDefenders(sim);
    UUID defenderId = sim.getCombat().getDefenders().iterator().next();
    boolean triggered = false;
    sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_BLOCKERS, defendingPlayerId, defendingPlayerId));
    sim.checkStateAndTriggered();
    while (!sim.getStack().isEmpty()) {
        triggered = true;
        sim.getStack().resolve(sim);
        sim.applyEffects();
    }
    sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARE_BLOCKERS_STEP_POST, sim.getActivePlayerId(), sim.getActivePlayerId()));
    simulateStep(sim, new FirstCombatDamageStep());
    simulateStep(sim, new CombatDamageStep());
    simulateStep(sim, new EndOfCombatStep());
    // sim.checkStateAndTriggered();
    while (!sim.getStack().isEmpty()) {
        triggered = true;
        sim.getStack().resolve(sim);
        sim.applyEffects();
    }
    return new SurviveInfo(!sim.getBattlefield().containsPermanent(attacker.getId()), false, sim.getPlayer(defenderId), triggered);
}
Also used : FirstCombatDamageStep(mage.game.turn.FirstCombatDamageStep) CombatDamageStep(mage.game.turn.CombatDamageStep) Game(mage.game.Game) EndOfCombatStep(mage.game.turn.EndOfCombatStep) Combat(mage.game.combat.Combat) FirstCombatDamageStep(mage.game.turn.FirstCombatDamageStep)

Aggregations

Game (mage.game.Game)2 Combat (mage.game.combat.Combat)2 CombatDamageStep (mage.game.turn.CombatDamageStep)2 EndOfCombatStep (mage.game.turn.EndOfCombatStep)2 FirstCombatDamageStep (mage.game.turn.FirstCombatDamageStep)2