mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
temporarily inlined PhaseUtil.handleDeclareAttackers and handleAttackingTriggers,
fixed multiple triggering for Souverigns of the Lost Alara, extracted method for their 2nd ability
This commit is contained in:
@@ -1300,13 +1300,10 @@ public class CombatUtil {
|
|||||||
|
|
||||||
game.getStack().addSimultaneousStackEntry(ability);
|
game.getStack().addSimultaneousStackEntry(ability);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final Player phasingPlayer = c.getController();
|
public static void souverignsOfAlara2ndAbility(final Game game, final Card attacker) {
|
||||||
|
final Ability ability4 = new Ability(attacker, ManaCost.ZERO) {
|
||||||
if (phasingPlayer.getCardsIn(ZoneType.Battlefield, "Sovereigns of Lost Alara").size() > 0) {
|
|
||||||
for (int i = 0; i < phasingPlayer.getCardsIn(ZoneType.Battlefield, "Sovereigns of Lost Alara").size(); i++) {
|
|
||||||
final Card attacker = c;
|
|
||||||
final Ability ability4 = new Ability(c, ManaCost.ZERO) {
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
List<Card> enchantments =
|
List<Card> enchantments =
|
||||||
@@ -1347,15 +1344,13 @@ public class CombatUtil {
|
|||||||
}; // ability4
|
}; // ability4
|
||||||
|
|
||||||
final StringBuilder sb4 = new StringBuilder();
|
final StringBuilder sb4 = new StringBuilder();
|
||||||
sb4.append(c).append(
|
sb4.append(attacker).append(
|
||||||
" - (Exalted) searches library for an Aura card that could enchant that creature, ");
|
" - (Exalted) searches library for an Aura card that could enchant that creature, ");
|
||||||
sb4.append("put it onto the battlefield attached to that creature, then shuffles library.");
|
sb4.append("put it onto the battlefield attached to that creature, then shuffles library.");
|
||||||
ability4.setDescription(sb4.toString());
|
ability4.setDescription(sb4.toString());
|
||||||
ability4.setStackDescription(sb4.toString());
|
ability4.setStackDescription(sb4.toString());
|
||||||
|
|
||||||
game.getStack().addSimultaneousStackEntry(ability4);
|
game.getStack().addSimultaneousStackEntry(ability4);
|
||||||
} // For
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -268,10 +268,63 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
|
|
||||||
playerTurn.getController().declareAttackers();
|
playerTurn.getController().declareAttackers();
|
||||||
|
|
||||||
PhaseUtil.handleDeclareAttackers(game);
|
game.getCombat().verifyCreaturesInPlay();
|
||||||
|
|
||||||
|
// Handles removing cards like Mogg Flunkies from combat if group attack
|
||||||
|
// didn't occur
|
||||||
|
for (Card c1 : game.getCombat().getAttackers()) {
|
||||||
|
if (c1.hasKeyword("CARDNAME can't attack or block alone.") && c1.isAttacking()) {
|
||||||
|
if (game.getCombat().getAttackers().size() < 2) {
|
||||||
|
game.getCombat().removeFromCombat(c1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO move propaganda to happen as the Attacker is Declared
|
||||||
|
|
||||||
|
for (final Card c2 : game.getCombat().getAttackers()) {
|
||||||
|
boolean canAttack = CombatUtil.checkPropagandaEffects(game, c2);
|
||||||
|
if ( canAttack ) {
|
||||||
|
if (!c2.hasKeyword("Vigilance"))
|
||||||
|
c2.tap();
|
||||||
|
} else {
|
||||||
|
game.getCombat().removeFromCombat(c2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Then run other Attacker bonuses
|
||||||
|
// check for exalted:
|
||||||
|
if (game.getCombat().getAttackers().size() == 1) {
|
||||||
|
final Player attackingPlayer = game.getCombat().getAttackingPlayer();
|
||||||
|
final Card attacker = game.getCombat().getAttackers().get(0);
|
||||||
|
for (Card card : attackingPlayer.getCardsIn(ZoneType.Battlefield)) {
|
||||||
|
int exaltedMagnitude = card.getKeywordAmount("Exalted");
|
||||||
|
if (exaltedMagnitude > 0) {
|
||||||
|
CombatUtil.executeExaltedAbility(game, attacker, exaltedMagnitude, card);
|
||||||
|
// Make sure exalted effects get applied only once per combat
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("Sovereigns of Lost Alara".equals(card.getName())) {
|
||||||
|
CombatUtil.souverignsOfAlara2ndAbility(game, attacker);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
game.getGameLog().addCombatAttackers(game.getCombat());
|
||||||
|
|
||||||
|
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||||
|
runParams.put("Attackers", game.getCombat().getAttackers());
|
||||||
|
runParams.put("AttackingPlayer", game.getCombat().getAttackingPlayer());
|
||||||
|
game.getTriggerHandler().runTrigger(TriggerType.AttackersDeclared, runParams, false);
|
||||||
|
|
||||||
|
for (final Card c : game.getCombat().getAttackers()) {
|
||||||
|
CombatUtil.checkDeclareAttackers(game, c);
|
||||||
|
}
|
||||||
|
game.getStack().unfreezeStack();
|
||||||
|
|
||||||
this.bCombat = !game.getCombat().getAttackers().isEmpty();
|
this.bCombat = !game.getCombat().getAttackers().isEmpty();
|
||||||
game.getStack().unfreezeStack();
|
|
||||||
this.nCombatsThisTurn++;
|
this.nCombatsThisTurn++;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -68,81 +68,6 @@ public class PhaseUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ********* Declare Attackers ***********
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* handleDeclareAttackers.
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public static void handleDeclareAttackers(final Game game) {
|
|
||||||
final Combat combat = game.getCombat();
|
|
||||||
combat.verifyCreaturesInPlay();
|
|
||||||
|
|
||||||
// Handles removing cards like Mogg Flunkies from combat if group attack
|
|
||||||
// didn't occur
|
|
||||||
final List<Card> filterList = combat.getAttackers();
|
|
||||||
for (Card c : filterList) {
|
|
||||||
if (c.hasKeyword("CARDNAME can't attack or block alone.") && c.isAttacking()) {
|
|
||||||
if (combat.getAttackers().size() < 2) {
|
|
||||||
combat.removeFromCombat(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final List<Card> list = combat.getAttackers();
|
|
||||||
|
|
||||||
// TODO move propaganda to happen as the Attacker is Declared
|
|
||||||
// Remove illegal Propaganda attacks first only for attacking the Player
|
|
||||||
|
|
||||||
|
|
||||||
for (final Card c : list) {
|
|
||||||
boolean canAttack = CombatUtil.checkPropagandaEffects(game, c);
|
|
||||||
if ( canAttack ) {
|
|
||||||
if (!c.hasKeyword("Vigilance")) { c.tap(); }
|
|
||||||
} else {
|
|
||||||
game.getCombat().removeFromCombat(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PhaseUtil.handleAttackingTriggers(game);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* handleAttackingTriggers.
|
|
||||||
* </p>
|
|
||||||
* @param game
|
|
||||||
*/
|
|
||||||
public static void handleAttackingTriggers(Game game) {
|
|
||||||
final List<Card> list = game.getCombat().getAttackers();
|
|
||||||
game.getStack().freezeStack();
|
|
||||||
// Then run other Attacker bonuses
|
|
||||||
// check for exalted:
|
|
||||||
if (list.size() == 1) {
|
|
||||||
final Player attackingPlayer = game.getCombat().getAttackingPlayer();
|
|
||||||
final Card attacker = list.get(0);
|
|
||||||
for (Card card : attackingPlayer.getCardsIn(ZoneType.Battlefield)) {
|
|
||||||
int exaltedMagnitude = card.getKeywordAmount("Exalted");
|
|
||||||
if (exaltedMagnitude > 0) {
|
|
||||||
CombatUtil.executeExaltedAbility(game, attacker, exaltedMagnitude, card);
|
|
||||||
// Make sure exalted effects get applied only once per combat
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
game.getGameLog().addCombatAttackers(game.getCombat());
|
|
||||||
|
|
||||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
|
||||||
runParams.put("Attackers", list);
|
|
||||||
runParams.put("AttackingPlayer", game.getCombat().getAttackingPlayer());
|
|
||||||
game.getTriggerHandler().runTrigger(TriggerType.AttackersDeclared, runParams, false);
|
|
||||||
|
|
||||||
for (final Card c : list) {
|
|
||||||
CombatUtil.checkDeclareAttackers(game, c);
|
|
||||||
}
|
|
||||||
game.getStack().unfreezeStack();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* handleDeclareBlockers.
|
* handleDeclareBlockers.
|
||||||
|
|||||||
Reference in New Issue
Block a user