(final Game game, final Player attackingPlayer, final Player defendingPlayer, final boolean toDeclareBlockers)
| 703 | } |
| 704 | |
| 705 | private void handleCombat(final Game game, final Player attackingPlayer, final Player defendingPlayer, final boolean toDeclareBlockers) { |
| 706 | // First we need to ensure that all attackers are declared in the Declare Attackers step, |
| 707 | // even if proceeding straight to Declare Blockers |
| 708 | game.getPhaseHandler().devModeSet(PhaseType.COMBAT_DECLARE_ATTACKERS, attackingPlayer, turn); |
| 709 | |
| 710 | if (game.getPhaseHandler().getCombat() == null) { |
| 711 | game.getPhaseHandler().setCombat(new Combat(attackingPlayer)); |
| 712 | game.updateCombatForView(); |
| 713 | } |
| 714 | |
| 715 | Combat combat = game.getPhaseHandler().getCombat(); |
| 716 | for (Entry<Card, Card> attackMap : cardAttackMap.entrySet()) { |
| 717 | Card attacker = attackMap.getKey(); |
| 718 | Card attacked = attackMap.getValue(); |
| 719 | |
| 720 | combat.addAttacker(attacker, attacked == null ? defendingPlayer : attacked); |
| 721 | } |
| 722 | |
| 723 | // Run the necessary combat events and triggers to set things up correctly as if the |
| 724 | // attack was actually declared by the attacking player |
| 725 | Multimap<GameEntity, Card> attackersMap = ArrayListMultimap.create(); |
| 726 | for (GameEntity ge : combat.getDefenders()) { |
| 727 | attackersMap.putAll(ge, combat.getAttackersOf(ge)); |
| 728 | } |
| 729 | game.fireEvent(new GameEventAttackersDeclared(attackingPlayer, attackersMap)); |
| 730 | |
| 731 | for (final Card c : combat.getAttackers()) { |
| 732 | CombatUtil.checkDeclaredAttacker(game, c, combat, false); |
| 733 | } |
| 734 | |
| 735 | game.updateCombatForView(); |
| 736 | game.fireEvent(new GameEventCombatChanged()); |
| 737 | |
| 738 | // Gracefully proceed to Declare Blockers, giving priority to the defending player, |
| 739 | // but only if the stack is empty (otherwise the game will crash). |
| 740 | game.getStack().addAllTriggeredAbilitiesToStack(); |
| 741 | if (toDeclareBlockers && game.getStack().isEmpty()) { |
| 742 | game.getPhaseHandler().devAdvanceToPhase(PhaseType.COMBAT_DECLARE_BLOCKERS); |
| 743 | } |
| 744 | } |
| 745 | |
| 746 | private void handleRememberedEntities() { |
| 747 | // Remembered: X |
no test coverage detected