diff --git a/forge-game/src/main/java/forge/game/GameAction.java b/forge-game/src/main/java/forge/game/GameAction.java index dfa942ba07f..5d791604fab 100644 --- a/forge-game/src/main/java/forge/game/GameAction.java +++ b/forge-game/src/main/java/forge/game/GameAction.java @@ -1233,6 +1233,8 @@ public class GameAction { // use a copy that preserves last known information about the card (e.g. for Savra, Queen of the Golgari + Painter's Servant) runParams.put("Card", CardFactory.copyCardWithChangedStats(c, false)); runParams.put("Cause", source); + runParams.put("CostStack", game.costPaymentStack); + runParams.put("IndividualCostPaymentInstance", game.costPaymentStack.peek()); game.getTriggerHandler().runTrigger(TriggerType.Sacrificed, runParams, false); return sacrificeDestroy(c); diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerSacrificed.java b/forge-game/src/main/java/forge/game/trigger/TriggerSacrificed.java index 5c6631923bb..5963ee95fe4 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerSacrificed.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerSacrificed.java @@ -18,7 +18,9 @@ package forge.game.trigger; import forge.game.card.Card; +import forge.game.cost.IndividualCostPaymentInstance; import forge.game.spellability.SpellAbility; +import forge.game.zone.CostPaymentStack; /** *

@@ -69,6 +71,41 @@ public class TriggerSacrificed extends Trigger { return false; } } + + if (this.mapParams.containsKey("WhileKeyword")) { + final String keyword = this.mapParams.get("WhileKeyword"); + boolean withKeyword = false; + + // When cast with Emerge, the cost instance is there + IndividualCostPaymentInstance currentPayment = (IndividualCostPaymentInstance) runParams2.get("IndividualCostPaymentInstance"); + SpellAbility sa = currentPayment.getPayment().getAbility(); + + if (sa != null && sa.getHostCard() != null) { + if (sa.isSpell() && sa.getHostCard().hasStartOfUnHiddenKeyword(keyword)) { + withKeyword = true; + } + } + if (!withKeyword) { + // When done for another card to get the Mana, the Emerge card is there + CostPaymentStack stack = (CostPaymentStack) runParams2.get("CostStack"); + + for (IndividualCostPaymentInstance individual : stack) { + sa = individual.getPayment().getAbility(); + + if (sa == null || sa.getHostCard() == null) + continue; + + if (sa.isSpell() && sa.getHostCard().hasStartOfUnHiddenKeyword(keyword)) { + withKeyword = true; + break; + } + } + } + + if (!withKeyword) + return false; + } + return true; }