diff --git a/forge-game/src/main/java/forge/game/combat/CombatUtil.java b/forge-game/src/main/java/forge/game/combat/CombatUtil.java index a11ead407f0..5cfce30d06d 100644 --- a/forge-game/src/main/java/forge/game/combat/CombatUtil.java +++ b/forge-game/src/main/java/forge/game/combat/CombatUtil.java @@ -856,6 +856,8 @@ public class CombatUtil { for (String keyword : c.getKeyword()) { if (keyword.equals("CARDNAME can't attack.") || keyword.equals("CARDNAME can't attack or block.")) { return false; + } else if (keyword.equals("CARDNAME can't attack if you cast a spell this turn.") && c.getController().getSpellsCastThisTurn() > 0) { + return false; } else if (keyword.equals("Defender") && !c.hasKeyword("CARDNAME can attack as though it didn't have defender.")) { return false; } else if (keyword.equals("CARDNAME can't attack during extra turns.")) { diff --git a/forge-game/src/main/java/forge/game/phase/PhaseHandler.java b/forge-game/src/main/java/forge/game/phase/PhaseHandler.java index fa0e27404dc..d29b61e5cf0 100644 --- a/forge-game/src/main/java/forge/game/phase/PhaseHandler.java +++ b/forge-game/src/main/java/forge/game/phase/PhaseHandler.java @@ -721,6 +721,7 @@ public class PhaseHandler implements java.io.Serializable { for (Player p : game.getPlayers()) { p.resetProwl(); + p.resetSpellsCastThisTurn(); p.setLifeLostLastTurn(p.getLifeLostThisTurn()); p.setLifeLostThisTurn(0); p.setLifeGainedThisTurn(0); diff --git a/forge-game/src/main/java/forge/game/player/Player.java b/forge-game/src/main/java/forge/game/player/Player.java index c561d7ef6fa..3cbfbf7b521 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -81,6 +81,9 @@ public class Player extends GameEntity implements Comparable { /** The assigned damage. */ private final Map assignedDamage = new HashMap(); + /** Number of spells cast this turn. */ + private int spellsCastThisTurn = 0; + /** The life lost this turn. */ private int lifeLostThisTurn = 0; @@ -1239,28 +1242,6 @@ public class Player extends GameEntity implements Comparable { return false; } - /** - *

- * canPlaySpells. - *

- * - * @return a boolean. - */ - public final boolean canCastSpells() { - return !this.keywords.contains("Can't cast spells"); - } - - /** - *

- * canPlayAbilities. - *

- * - * @return a boolean. - */ - public final boolean canActivateAbilities() { - return !this.keywords.contains("Can't activate abilities"); - } - // ////////////////////////////// // / // / replaces Singletons.getModel().getGameAction().draw* methods @@ -2655,6 +2636,27 @@ public class Player extends GameEntity implements Comparable { this.numLandsPlayed = n; } + /** + * @return the number of spells cast by this player this turn. + */ + public final int getSpellsCastThisTurn() { + return this.spellsCastThisTurn; + } + + /** + * Adds 1 to the number of spells cast by this player this turn. + */ + public final void addSpellCastThisTurn() { + this.spellsCastThisTurn++; + } + + /** + * Resets the number of spells cast by this player this turn to 0. + */ + public final void resetSpellsCastThisTurn() { + this.spellsCastThisTurn = 0; + } + /** *

* Getter for the field lifeGainedThisTurn. diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbility.java b/forge-game/src/main/java/forge/game/staticability/StaticAbility.java index 02982de4d35..65b89cda6d5 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbility.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbility.java @@ -271,7 +271,7 @@ public class StaticAbility extends CardTraitBase { return false; } - if (this.isSuppressed() || !this.checkConditions()) { + if (this.isSuppressed() || !this.checkPlayerSpecificConditions(player)) { return false; } @@ -398,10 +398,31 @@ public class StaticAbility extends CardTraitBase { return StaticAbilityCantAttackBlock.getBlockCost(this, blocker, attacker); } + /** + * Check conditions for static abilities acting on a specific player. Also + * automatically check the general conditions. + * + * @param player a {@link Player}. + * @return true, if the static ability is applicable. + * @see {@link StaticAbility#checkConditions()} + */ + public final boolean checkPlayerSpecificConditions(final Player player) { + if (!checkConditions()) { + return false; + } + + if (this.mapParams.containsKey("PlayerAttackedWithCreatureThisTurn") + && !player.getAttackedWithCreatureThisTurn()) { + return false; + } + + return true; + } + /** * Check conditions. * - * @return true, if successful + * @return true, if the static ability is applicable. */ public final boolean checkConditions() { final Player controller = this.hostCard.getController(); @@ -451,11 +472,6 @@ public class StaticAbility extends CardTraitBase { } } - if (this.mapParams.containsKey("OpponentAttackedWithCreatureThisTurn") - && !controller.getOpponent().getAttackedWithCreatureThisTurn()) { - return false; - } - if (this.mapParams.containsKey("Phases")) { List phases = PhaseType.parseRange(this.mapParams.get("Phases")); if (!phases.contains(controller.getGame().getPhaseHandler().getPhase())) { diff --git a/forge-game/src/main/java/forge/game/zone/MagicStack.java b/forge-game/src/main/java/forge/game/zone/MagicStack.java index cdcab6aee86..e8d45e7f915 100644 --- a/forge-game/src/main/java/forge/game/zone/MagicStack.java +++ b/forge-game/src/main/java/forge/game/zone/MagicStack.java @@ -523,6 +523,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable