From 4cfad0a001ecc7bff661c968a31b3e992e17c0f2 Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Mon, 6 Jun 2022 21:00:48 +0200 Subject: [PATCH] GameAction: 400.7a to keep Keyword from static ability --- .../src/main/java/forge/game/GameAction.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/forge-game/src/main/java/forge/game/GameAction.java b/forge-game/src/main/java/forge/game/GameAction.java index dfda9c27aa6..011c5a2a597 100644 --- a/forge-game/src/main/java/forge/game/GameAction.java +++ b/forge-game/src/main/java/forge/game/GameAction.java @@ -37,6 +37,7 @@ import com.google.common.collect.Maps; import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; import com.google.common.collect.Sets; +import com.google.common.collect.Table; import forge.GameCommand; import forge.StaticData; @@ -66,6 +67,7 @@ import forge.game.event.GameEventGameStarted; import forge.game.event.GameEventScry; import forge.game.keyword.Keyword; import forge.game.keyword.KeywordInterface; +import forge.game.keyword.KeywordsChange; import forge.game.mulligan.MulliganService; import forge.game.player.GameLossReason; import forge.game.player.Player; @@ -489,6 +491,36 @@ public class GameAction { if (!zoneTo.is(ZoneType.Exile) && !zoneTo.is(ZoneType.Stack)) { c.cleanupExiledWith(); } + + // 400.7a Effects from static abilities that give a permanent spell on the stack an ability + // that allows it to be cast for an alternative cost continue to apply to the permanent that spell becomes. + if (zoneFrom.is(ZoneType.Stack) && toBattlefield) { + List newKw = Lists.newArrayList(); + for (Table.Cell cell : c.getChangedCardKeywords().cellSet()) { + // comes from a static ability + if (cell.getColumnKey() == 0) { + continue; + } + for (KeywordInterface ki : cell.getValue().getKeywords()) { + boolean keepKeyword = false; + for (SpellAbility sa : ki.getAbilities()) { + if (!sa.isSpell()) { + continue; + } + if (sa.getAlternativeCost() != null) { + keepKeyword = true; + break; + } + } + if (keepKeyword) { + newKw.add(ki); + } + } + } + if (!newKw.isEmpty()) { + copied.addChangedCardKeywordsInternal(newKw, null, false, copied.getTimestamp(), 0, true); + } + } } // if an adventureCard is put from Stack somewhere else, need to reset to Original State