mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
GameAction & TriggerSacrificed: give the TriggerSacrificed to CostPaymentStack and its peek.
add WhileKeyword to TriggerSacrificed, to check if a Spell with given Keyword is on CostStack (or its cost is in paying) Currently used once for Emerge
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user