market_gnome.txt and support

This commit is contained in:
Northmoc
2023-11-21 13:15:21 -05:00
committed by Northmoc
parent b4e1793c11
commit e14b489ffe
4 changed files with 56 additions and 3 deletions

View File

@@ -141,20 +141,21 @@ public class AiCostDecision extends CostDecisionMakerBase {
@Override
public PaymentDecision visit(CostExile cost) {
String type = cost.getType();
if (cost.payCostFromSource()) {
return PaymentDecision.card(source);
}
if (cost.getType().equals("All")) {
if (type.equals("All")) {
return PaymentDecision.card(player.getCardsIn(cost.getFrom()));
}
else if (cost.getType().contains("FromTopGrave")) {
else if (type.contains("FromTopGrave")) {
return null;
}
int c = cost.getAbilityAmount(ability);
if (cost.getFrom().equals(ZoneType.Library)) {
if (cost.from.size() == 1 && cost.getFrom().get(0).equals(ZoneType.Library)) {
return PaymentDecision.card(player.getCardsIn(ZoneType.Library, c));
}
else if (cost.zoneRestriction == 0) {

View File

@@ -945,6 +945,8 @@ public class GameAction {
if (params != null) {
runParams.putAll(params);
}
runParams.put(AbilityKey.CostStack, game.costPaymentStack);
runParams.put(AbilityKey.IndividualCostPaymentInstance, game.costPaymentStack.peek());
game.getTriggerHandler().runTrigger(TriggerType.Exiled, runParams, false);

View File

@@ -19,6 +19,8 @@ package forge.game.trigger;
import java.util.Map;
import forge.game.cost.IndividualCostPaymentInstance;
import forge.game.zone.CostPaymentStack;
import org.apache.commons.lang3.ArrayUtils;
import forge.game.ability.AbilityKey;
@@ -77,6 +79,43 @@ public class TriggerExiled extends Trigger {
return false;
}
if (hasParam("WhileKeyword")) {
final String keyword = getParam("WhileKeyword");
boolean withKeyword = false;
IndividualCostPaymentInstance currentPayment = (IndividualCostPaymentInstance) runParams.get(AbilityKey.IndividualCostPaymentInstance);
SpellAbility sa;
if (currentPayment != null) {
sa = currentPayment.getPayment().getAbility();
if (sa != null && sa.getHostCard() != null) {
if ((sa.isSpell() || sa.isAbility()) && sa.getHostCard().hasStartOfUnHiddenKeyword(keyword)) {
withKeyword = true;
}
}
}
if (!withKeyword) {
CostPaymentStack stack = (CostPaymentStack) runParams.get(AbilityKey.CostStack);
for (IndividualCostPaymentInstance individual : stack) {
sa = individual.getPayment().getAbility();
if (sa == null || sa.getHostCard() == null)
continue;
if ((sa.isSpell() || sa.isAbility()) && sa.getHostCard().hasStartOfUnHiddenKeyword(keyword)) {
withKeyword = true;
break;
}
}
}
if (!withKeyword)
return false;
}
return true;
}

View File

@@ -0,0 +1,11 @@
Name:Market Gnome
ManaCost:W
Types:Artifact Creature Gnome
PT:0/3
T:Mode$ ChangesZone | Origin$ Battlefield | Destination$ Graveyard | ValidCard$ Card.Self | Execute$ TrigGainLife | TriggerDescription$ When CARDNAME dies, you gain 1 life and draw a card.
T:Mode$ Exiled | Origin$ Battlefield | WhileKeyword$ Craft | ValidCard$ Card.Self | Execute$ TrigGainLife | TriggerDescription$ When CARDNAME is exiled from the battlefield while you're activating a craft ability, you gain 1 life and draw a card.
SVar:TrigGainLife:DB$ GainLife | LifeAmount$ 1 | SubAbility$ DBDraw
SVar:DBDraw:DB$ Draw
DeckHas:Ability$LifeGain
SVar:SacMe:2
Oracle:When Market Gnome dies, you gain 1 life and draw a card.\nWhen Market Gnome is exiled from the battlefield while you're activating a craft ability, you gain 1 life and draw a card.