From d8cc879a1ebcd311ae6ee9ec95c21f0f4d113086 Mon Sep 17 00:00:00 2001 From: Northmoc Date: Wed, 18 May 2022 22:13:43 -0400 Subject: [PATCH] modify applyCantAttackAbility() "DefenderKeyword" --- .../staticability/StaticAbilityCantAttackBlock.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantAttackBlock.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantAttackBlock.java index d428a9ff519..a981af141df 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantAttackBlock.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantAttackBlock.java @@ -52,6 +52,7 @@ public class StaticAbilityCantAttackBlock { */ public static boolean applyCantAttackAbility(final StaticAbility stAb, final Card card, final GameEntity target) { final Card hostCard = stAb.getHostCard(); + final Game game = hostCard.getGame(); if (!stAb.matchesValidParam("ValidCard", card)) { return false; @@ -62,6 +63,15 @@ public class StaticAbilityCantAttackBlock { } if (stAb.hasParam("DefenderKeyword")) { + //return false if something allows it to attack normally + for (final Card ca : game.getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES)) { + for (final StaticAbility defStAb : ca.getStaticAbilities()) { + if (defStAb.applyAbility("CanAttackDefender", card, target)) { + return false; + } + } + } + //TODO goal is to remove the next three lines if (card.hasKeyword("CARDNAME can attack as though it didn't have defender.")) { return false; } @@ -85,7 +95,7 @@ public class StaticAbilityCantAttackBlock { } if (stAb.hasParam("DefenderNotNearestToYouInChosenDirection") && (hostCard.getChosenDirection() == null - || defender.equals(hostCard.getGame().getNextPlayerAfter(card.getController(), hostCard.getChosenDirection())))) { + || defender.equals(game.getNextPlayerAfter(card.getController(), hostCard.getChosenDirection())))) { return false; } if (stAb.hasParam("UnlessDefender")) {