Skip to content

Commit

Permalink
market_gnome.txt and support
Browse files Browse the repository at this point in the history
  • Loading branch information
Northmoc committed Nov 22, 2023
1 parent 0c9fda2 commit 83e9766
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 3 deletions.
7 changes: 4 additions & 3 deletions forge-ai/src/main/java/forge/ai/AiCostDecision.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,21 @@ public PaymentDecision visit(CostDraw cost) {

@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) {
Expand Down
2 changes: 2 additions & 0 deletions forge-game/src/main/java/forge/game/GameAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,8 @@ public final Card exile(final Card c, SpellAbility cause, Map<AbilityKey, Object
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);

Expand Down
39 changes: 39 additions & 0 deletions forge-game/src/main/java/forge/game/trigger/TriggerExiled.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

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;
Expand Down Expand Up @@ -77,6 +79,43 @@ public final boolean performTest(final Map<AbilityKey, Object> runParams) {
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;
}

Expand Down
11 changes: 11 additions & 0 deletions forge-gui/res/cardsfolder/upcoming/market_gnome.txt
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 83e9766

Please sign in to comment.