Skip to content

Commit

Permalink
better WhileKeyword
Browse files Browse the repository at this point in the history
  • Loading branch information
Northmoc committed Dec 2, 2023
1 parent 2214bde commit a0d844a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
4 changes: 4 additions & 0 deletions forge-game/src/main/java/forge/game/ForgeScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,14 @@ public static boolean spellAbilityHasProperty(SpellAbility sa, String property,
return sa.isBlitz();
} else if (property.equals("Buyback")) {
return sa.isBuyBackAbility();
} else if (property.equals("Craft")) {
return sa.isCraft();
} else if (property.equals("Cycling")) {
return sa.isCycling();
} else if (property.equals("Dash")) {
return sa.isDash();
} else if (property.equals("Emerge")) {
return sa.isEmerge();
} else if (property.equals("Flashback")) {
return sa.isFlashBackAbility();
} else if (property.equals("Jumpstart")) {
Expand Down
14 changes: 3 additions & 11 deletions forge-game/src/main/java/forge/game/trigger/Trigger.java
Original file line number Diff line number Diff line change
Expand Up @@ -626,33 +626,25 @@ public void setOverridingAbility(SpellAbility overridingAbility0) {
overridingAbility0.setTrigger(this);
}

boolean whileKeywordCheck(final String keyword, final Map<AbilityKey, Object> runParams) {
boolean whileKeywordCheck(final String param, final Map<AbilityKey, Object> runParams) {
SpellAbility sa;

IndividualCostPaymentInstance currentPayment =
(IndividualCostPaymentInstance) runParams.get(AbilityKey.IndividualCostPaymentInstance);
if (currentPayment != null) {
sa = currentPayment.getPayment().getAbility();
if (sa != null) {
if (whileKeywordSACheck(keyword, sa)) return true;
if (matchesValidParam(param, sa)) return true;
}
}

CostPaymentStack stack = (CostPaymentStack) runParams.get(AbilityKey.CostStack);
for (IndividualCostPaymentInstance individual : stack) {
sa = individual.getPayment().getAbility();
if (whileKeywordSACheck(keyword, sa)) return true;
if (matchesValidParam(param, sa)) return true;
}

return false;
}

private boolean whileKeywordSACheck(final String keyword, final SpellAbility sa) {
if (sa == null || sa.getHostCard() == null) return false;
if (sa.isAbility()) {
return (keyword.equals("Craft") && sa.isCraft());
}
return sa.isSpell() && sa.getHostCard().hasStartOfUnHiddenKeyword(keyword);
}

}
6 changes: 3 additions & 3 deletions forge-gui/res/cardsfolder/f/foul_emissary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Types:Creature Human Horror
PT:1/1
T:Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Any | Destination$ Battlefield | Execute$ TrigDig | TriggerDescription$ When CARDNAME enters the battlefield, look at the top four cards of your library. You may reveal a creature card from among them and put it into your hand. Put the rest on the bottom of your library in any order.
SVar:TrigDig:DB$ Dig | DigNum$ 4 | ChangeNum$ 1 | Optional$ True | ChangeValid$ Creature
T:Mode$ Sacrificed | ValidCard$ Card.Self | WhileKeyword$ Emerge | Execute$ TrigToken | TriggerZones$ Battlefield | TriggerDescription$ When you sacrifice CARDNAME while casting a spell with emerge, create a 3/2 colorless Eldrazi Horror creature token.
T:Mode$ Sacrificed | ValidCard$ Card.Self | WhileKeyword$ Spell.Emerge | Execute$ TrigToken | TriggerZones$ Battlefield | TriggerDescription$ When you sacrifice CARDNAME while casting a spell with emerge, create a 3/2 colorless Eldrazi Horror creature token.
SVar:TrigToken:DB$ Token | TokenAmount$ 1 | TokenScript$ c_3_2_eldrazi_horror | TokenOwner$ You
DeckHints:Type$Eldrazi|Horror & Keyword$Emerge
DeckHas:Ability$Token
DeckHints:Eldrazi|Horror & Keyword$Emerge
DeckHas:Ability$Token & Type$Eldrazi
Oracle:When Foul Emissary enters the battlefield, look at the top four cards of your library. You may reveal a creature card from among them and put it into your hand. Put the rest on the bottom of your library in any order.\nWhen you sacrifice Foul Emissary while casting a spell with emerge, create a 3/2 colorless Eldrazi Horror creature token.
2 changes: 1 addition & 1 deletion forge-gui/res/cardsfolder/upcoming/market_gnome.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ 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.
T:Mode$ Exiled | Origin$ Battlefield | WhileKeyword$ Ability.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
Expand Down

0 comments on commit a0d844a

Please sign in to comment.