diff --git a/forge-game/src/main/java/forge/game/ability/effects/ProtectAllEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ProtectAllEffect.java index aa7660f7..fc10c08a 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ProtectAllEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ProtectAllEffect.java @@ -1,5 +1,7 @@ package forge.game.ability.effects; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; import forge.GameCommand; import forge.card.ColorSet; import forge.card.MagicColor; @@ -14,12 +16,11 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.Lang; +import forge.util.TextUtil; import java.util.ArrayList; import java.util.List; -import com.google.common.collect.ImmutableList; - public class ProtectAllEffect extends SpellAbilityEffect { @Override @@ -73,6 +74,11 @@ public class ProtectAllEffect extends SpellAbilityEffect { } } + List gainsKWList = Lists.newArrayList(); + for (String color : gains) { + gainsKWList.add(TextUtil.concatWithSpace("Protection from", color)); + } + // Deal with permanents String valid = ""; if (sa.hasParam("ValidCards")) { @@ -84,10 +90,7 @@ public class ProtectAllEffect extends SpellAbilityEffect { for (final Card tgtC : list) { if (tgtC.isInPlay()) { - for (final String gain : gains) { - tgtC.addExtrinsicKeyword("Protection from " + gain); - tgtC.updateKeywords(); - } + tgtC.addChangedCardKeywords(gainsKWList, ImmutableList.of(), false, timestamp, true); if (!sa.hasParam("Permanent")) { // If not Permanent, remove protection at EOT @@ -97,9 +100,7 @@ public class ProtectAllEffect extends SpellAbilityEffect { @Override public void run() { if (tgtC.isInPlay()) { - for (final String gain : gains) { - tgtC.removeExtrinsicKeyword("Protection from " + gain); - } + tgtC.removeChangedCardKeywords(timestamp, true); } } }; diff --git a/forge-game/src/main/java/forge/game/ability/effects/ProtectEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ProtectEffect.java index 918aebd3..b399bdff 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ProtectEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ProtectEffect.java @@ -1,5 +1,7 @@ package forge.game.ability.effects; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; import forge.GameCommand; import forge.card.MagicColor; import forge.game.Game; @@ -10,6 +12,7 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetRestrictions; import forge.util.Lang; +import forge.util.TextUtil; import java.util.ArrayList; import java.util.Arrays; @@ -121,6 +124,11 @@ public class ProtectEffect extends SpellAbilityEffect { } } + List gainsKWList = Lists.newArrayList(); + for (String color : gains) { + gainsKWList.add(TextUtil.concatWithSpace("Protection from", color)); + } + final List untargetedCards = new ArrayList(); final TargetRestrictions tgt = sa.getTargetRestrictions(); @@ -132,6 +140,8 @@ public class ProtectEffect extends SpellAbilityEffect { } + final long timestamp = game.getNextTimestamp(); + for (final Card tgtC : tgtCards) { // only pump things in play if (!tgtC.isInPlay()) { @@ -143,10 +153,7 @@ public class ProtectEffect extends SpellAbilityEffect { continue; } - for (final String gain : gains) { - tgtC.addExtrinsicKeyword("Protection from " + gain); - tgtC.updateKeywords(); - } + tgtC.addChangedCardKeywords(gainsKWList, ImmutableList.of(), false, timestamp, true); if (!sa.hasParam("Permanent")) { // If not Permanent, remove protection at EOT @@ -156,9 +163,7 @@ public class ProtectEffect extends SpellAbilityEffect { @Override public void run() { if (tgtC.isInPlay()) { - for (final String gain : gains) { - tgtC.removeExtrinsicKeyword("Protection from " + gain); - } + tgtC.removeChangedCardKeywords(timestamp, true); } } }; @@ -176,10 +181,7 @@ public class ProtectEffect extends SpellAbilityEffect { continue; } - for (final String gain : gains) { - unTgtC.addExtrinsicKeyword("Protection from " + gain); - unTgtC.updateKeywords(); - } + unTgtC.addChangedCardKeywords(gainsKWList, ImmutableList.of(), false, timestamp, true); if (!sa.hasParam("Permanent")) { // If not Permanent, remove protection at EOT @@ -189,9 +191,7 @@ public class ProtectEffect extends SpellAbilityEffect { @Override public void run() { if (unTgtC.isInPlay()) { - for (final String gain : gains) { - unTgtC.removeExtrinsicKeyword("Protection from " + gain); - } + unTgtC.removeChangedCardKeywords(timestamp, true); } } };