Card Development Questions
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Re: Card Development Questions
by swordshine » 11 Mar 2014, 12:57
It worked in Dev mode. I added some basic logic so AI paid Join Forces of its Minds Aglow.friarsol wrote:Seems functional, but hackish. Does it work ok in practice?swordshine wrote:Join Forces cards are popular in Commander games. I tried to script these cards using RepeatEach->ChooseNumber(the mana will be paid)->StoreSVar(UnlessCost: the chosen number and UnlessSwitched)->Join Forces effect.
Sample:
Any suggestions?
Patch:
- Code: Select all
### Eclipse Workspace Patch 1.0
#P ForgeLocal
Index: forge-game/src/main/java/forge/game/cost/CostPayment.java
===================================================================
--- forge-game/src/main/java/forge/game/cost/CostPayment.java (revision 25142)
+++ forge-game/src/main/java/forge/game/cost/CostPayment.java (working copy)
@@ -153,7 +153,9 @@
public final boolean payComputerCosts(final CostDecisionMakerBase decisionMaker) {
// Just in case it wasn't set, but honestly it shouldn't have gotten
// here without being set
- this.ability.setActivatingPlayer(decisionMaker.getPlayer());
+ if (this.ability.getActivatingPlayer() == null) {
+ this.ability.setActivatingPlayer(decisionMaker.getPlayer());
+ }
Map<Class<? extends CostPart>, PaymentDecision> decisions = new HashMap<Class<? extends CostPart>, PaymentDecision>();
Index: forge-game/src/main/java/forge/game/ability/effects/ChooseNumberEffect.java
===================================================================
--- forge-game/src/main/java/forge/game/ability/effects/ChooseNumberEffect.java (revision 25142)
+++ forge-game/src/main/java/forge/game/ability/effects/ChooseNumberEffect.java (working copy)
@@ -32,6 +32,7 @@
//final int min = sa.containsKey("Min") ? Integer.parseInt(sa.get("Min")) : 0;
//final int max = sa.containsKey("Max") ? Integer.parseInt(sa.get("Max")) : 99;
final boolean random = sa.hasParam("Random");
+ final boolean anyNumber = sa.hasParam("ChooseAnyNumber");
final String sMin = sa.getParamOrDefault("Min", "0");
final int min = AbilityUtils.calculateAmount(card, sMin, sa);
@@ -50,7 +51,11 @@
p.getGame().getAction().nofityOfValue(sa, p, Integer.toString(chosen), null);
} else {
String title = sa.hasParam("ListTitle") ? sa.getParam("ListTitle") : "Choose a number";
- chosen = p.getController().chooseNumber(sa, title, min, max);
+ if (anyNumber) {
+ chosen = p.getController().announceRequirements(sa, title, true);
+ } else {
+ chosen = p.getController().chooseNumber(sa, title, min, max);
+ }
// don't notify here, because most scripts I've seen don't store that number in a long term
}
card.setChosenNumber(chosen);
Index: forge-ai/src/main/java/forge/ai/PlayerControllerAi.java
===================================================================
--- forge-ai/src/main/java/forge/ai/PlayerControllerAi.java (revision 25142)
+++ forge-ai/src/main/java/forge/ai/PlayerControllerAi.java (working copy)
@@ -110,6 +110,14 @@
@Override
public Integer announceRequirements(SpellAbility ability, String announce, boolean allowZero) {
// For now, these "announcements" are made within the AI classes of the appropriate SA effects
+ if (ability.getApi() != null) {
+ switch (ability.getApi()) {
+ case ChooseNumber:
+ return ability.getActivatingPlayer().isOpponentOf(player) ? 0 : ComputerUtilMana.determineLeftoverMana(ability, player);
+ default:
+ return null;
+ }
+ }
return null; // return incorrect value to indicate that
}
Index: forge-gui/res/cardsfolder/m/minds_aglow.txt
===================================================================
--- forge-gui/res/cardsfolder/m/minds_aglow.txt (revision 0)
+++ forge-gui/res/cardsfolder/m/minds_aglow.txt (working copy)
@@ -0,0 +1,11 @@
+Name:Minds Aglow
+ManaCost:U
+Types:Sorcery
+A:SP$ RepeatEach | Cost$ U | RepeatPlayers$ Player | StartingWithActivator$ True | RepeatSubAbility$ DBPay | SubAbility$ DBDraw | StackDescription$ SpellDescription | SpellDescription$ Join forces - Starting with you, each player may pay any amount of mana. Each player draws X cards, where X is the total amount of mana paid this way.
+SVar:DBPay:DB$ ChooseNumber | Defined$ Player.IsRemembered | ChooseAnyNumber$ True | ListTitle$ Pay Any Mana |SubAbility$ DBStore
+SVar:DBStore:DB$ StoreSVar | SVar$ JoinForcesAmount | Type$ CountSVar | Expression$ JoinForcesAmount/Plus.X | UnlessCost$ X | UnlessPayer$ Player.IsRemembered | UnlessSwitched$ True | UnlessAI$ OnlyOwn | References$ X,JoinForcesAmount
+SVar:DBDraw:DB$ Draw | Defined$ Each | NumCards$ JoinForcesAmount | SubAbility$ DBReset | References$ JoinForcesAmount | StackDescription$ None
+SVar:DBReset:DB$ StoreSVar | SVar$ JoinForcesAmount | Type$ Number | Expression$ 0 | References$ JoinForcesAmount
+SVar:X:Count$ChosenNumber
+SVar:JoinForcesAmount:Number$0
+SVar:Picture:http://www.wizards.com/global/images/magic/general/minds_aglow.jpg
\ No newline at end of file
- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Re: Card Development Questions
by swordshine » 16 Mar 2014, 12:31
I fixed a bug related to delayed triggers (r25196-25198). This bug made me crazy when I was playing my Roon of the Hidden Realm commander deck if I exiled multiple cards in one turn by it. Please test these cards. Maybe we could convert some hidden keywords to delayed triggers now ("At the beginning of the end step, ...").
- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Re: Card Development Questions
by Marek14 » 17 Mar 2014, 06:38
Will delayed "return from exile" triggers now work correctly on commanders? (Since these triggers don't actually specify that they return card from EXILE, they should return it even when it goes to command zone instead of being exiled, as long as it makes no further zone changes.)swordshine wrote:I fixed a bug related to delayed triggers (r25196-25198). This bug made me crazy when I was playing my Roon of the Hidden Realm commander deck if I exiled multiple cards in one turn by it. Please test these cards. Maybe we could convert some hidden keywords to delayed triggers now ("At the beginning of the end step, ...").
Also, is this the reason why tokens from Kiki-Jiki get sacrificed even when they are under control of different player than the controller of the original ability?
Re: Card Development Questions
by swordshine » 17 Mar 2014, 07:49
Actually, I didn't fix that "return from exile" triggers on commanders. In previous versions, Roon of the Hidden Realm and friends will create a delayed trigger and when the trigger fires, it will return the card remembered by the card. If I try to untap Roon of the Hidden Realm and activate its ability multiple times in a turn, only the last card will return and the others will be exiled.Marek14 wrote:Will delayed "return from exile" triggers now work correctly on commanders? (Since these triggers don't actually specify that they return card from EXILE, they should return it even when it goes to command zone instead of being exiled, as long as it makes no further zone changes.)
Also, is this the reason why tokens from Kiki-Jiki get sacrificed even when they are under control of different player than the controller of the original ability?
Kiki-Jiki‘s bug is caused by hardcoded delayed triggers in CopyPermanent effect. I think it will work fine if converted to delayed trigger effect (though the scripts would be complex).
Also I found some other bugs related to hardcoded abilities. Activate an unearth card and then exile the graveyard, the exiled card will come into play from exile zone.
- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Re: Card Development Questions
by timmermac » 04 Apr 2014, 15:22
If I wanted to create a custom card for use here, would the program accept it?
"I just woke up, haven't had coffee, let alone a pee in 7 days, and I find out you stole my ass and made a ...mini-me! Carter, I should be irked currently, yes?" - Jack O'Neill
Re: Card Development Questions
by friarsol » 04 Apr 2014, 15:43
We wouldn't add it to the normal release, but you could certainly play it on your own. IIRC, anything inside the res/cardsfolder directory is loaded into the game. If you are trying to create your own set, I'd recommend creating a new folder for that set, rather than trying to add into the a-z folders. You may need to unzip the cards zip file (and potentially delete it) to get this to work in the releases.timmermac wrote:If I wanted to create a custom card for use here, would the program accept it?
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Card Development Questions
by timmermac » 04 Apr 2014, 16:28
So here is the card I just made that I want to use. I based it off of Lord of Atlantis
Name:Ruler of the Pride
ManaCost:W W
Types:Creature Cat
PT:2/2
S:Mode$ Continuous | Affected$ Creature.Cat+Other | AddPower$ 1 | AddToughness$ 1 | AddKeyword$ Plainswalk | Description$ Other Cat creatures get +1/+1 and have plainswalk.
SVar:PlayMain1:TRUE
Name:Ruler of the Pride
ManaCost:W W
Types:Creature Cat
PT:2/2
S:Mode$ Continuous | Affected$ Creature.Cat+Other | AddPower$ 1 | AddToughness$ 1 | AddKeyword$ Plainswalk | Description$ Other Cat creatures get +1/+1 and have plainswalk.
SVar:PlayMain1:TRUE
"I just woke up, haven't had coffee, let alone a pee in 7 days, and I find out you stole my ass and made a ...mini-me! Carter, I should be irked currently, yes?" - Jack O'Neill
Re: Card Development Questions
by rikkusguardian » 17 Apr 2014, 00:18
Sorry to bother. I'm a bit new here, though I've been playing forge and making MTG cards in Magic Set Editor since Dark Ascension.
Using the Wiki you guys made, i thought I could make some cards, and I was able to do simple cards (Creatures with power and toughness, a keyword effect or two) but...
I tried to make a planeswalker, but oh my god, that is tricky....
Due to the average dislike of sexy anime girls, i censored the card a bit, since the last time I asked for help (on a different site) they refused to help me because I make "oversexualized anime walking boobs in bikini armor"
At best, I could only make her first ability work.
Using the Wiki you guys made, i thought I could make some cards, and I was able to do simple cards (Creatures with power and toughness, a keyword effect or two) but...
I tried to make a planeswalker, but oh my god, that is tricky....
Due to the average dislike of sexy anime girls, i censored the card a bit, since the last time I asked for help (on a different site) they refused to help me because I make "oversexualized anime walking boobs in bikini armor"
At best, I could only make her first ability work.
- Code: Select all
Name:Sympatha, Healing Love
ManaCost:1 W W
Types:Planeswalker Sympatha
Loyalty:2
A:AB$ GainLife | Cost$ AddCounter<1/LOYALTY> | LifeAmount$ 3 | Planeswalker$ True | SpellDescription$ You gain 3 life.
A:AB$ Effect | Cost$ SubCounter<5/LOYALTY> | Name$ Emblem Sympatha Healing Love 1 | Image$ Emblem_Sympatha_Healing_Love_1 | StaticAbilities$ TapsForMana | ValidCard$ Land.YouCtrl | TriggerZones$ Battlefield | Execute$ GainLife | LifeAmount$ 2 | Planeswalker$ True | Duration$ Permanent| AILogic$ Always | SpellDescription$ You get an emblem with "Whenever a land you control is tapped for mana, gain 2 life."
- rikkusguardian
- Posts: 15
- Joined: 04 Jul 2013, 10:29
- Has thanked: 7 times
- Been thanked: 0 time
Re: Card Development Questions
by friarsol » 17 Apr 2014, 01:06
The second ability is kinda halfway between Bubbling Muck and Sanctimony, so it'd be something like:
A:AB$ Effect | Cost$ SubCounter<5/LOYALTY> | Name$ Emblem 1 | Triggers$ TapTrigger | SVars$ TrigGainLife | Planeswalker$ True | Duration$ Permanent | SpellDescription$ You get an emblem with "Whenever a land you control is tapped for mana, gain 2 life."
SVar:TapTrigger:Mode$ TapsForMana | ValidCard$ Land.YouCtrl | TriggerZones$ Battlefield | Execute$ TrigGainLife | TriggerDescription$ Whenever a land you control is tapped for mana, you may gain 1 life.
SVar:TrigGainLife:AB$GainLife | Cost$ 0 | Defined$ You | LifeAmount$ 2
I don't think the ultimate is possible, since "You can't lose life" doesn't exist on any magic card.
A:AB$ Effect | Cost$ SubCounter<5/LOYALTY> | Name$ Emblem 1 | Triggers$ TapTrigger | SVars$ TrigGainLife | Planeswalker$ True | Duration$ Permanent | SpellDescription$ You get an emblem with "Whenever a land you control is tapped for mana, gain 2 life."
SVar:TapTrigger:Mode$ TapsForMana | ValidCard$ Land.YouCtrl | TriggerZones$ Battlefield | Execute$ TrigGainLife | TriggerDescription$ Whenever a land you control is tapped for mana, you may gain 1 life.
SVar:TrigGainLife:AB$GainLife | Cost$ 0 | Defined$ You | LifeAmount$ 2
I don't think the ultimate is possible, since "You can't lose life" doesn't exist on any magic card.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Card Development Questions
by rikkusguardian » 17 Apr 2014, 01:12
Thank you SOOOO much for the quick reply!! I've been stuck with this for a day now @_@ I was looking into cards like Domri Rade, Sasaya Orochi and Elspeth cards, but had no luck.
Testing it now! Thank you again <3
Hmm, as for her ultimate, I was thinking of the opposite of Erbos, God of the Dead. But if that wont work, maybe an emblem that prevents me from receiving any damage from opponents spells and creatures?
Testing it now! Thank you again <3
Hmm, as for her ultimate, I was thinking of the opposite of Erbos, God of the Dead. But if that wont work, maybe an emblem that prevents me from receiving any damage from opponents spells and creatures?
- rikkusguardian
- Posts: 15
- Joined: 04 Jul 2013, 10:29
- Has thanked: 7 times
- Been thanked: 0 time
Re: Card Development Questions
by rikkusguardian » 17 Apr 2014, 01:25
Darn...the trigger does not seem to work for some reason.
And the image for the Emblem for Sympatha is completly black
Current state is for testing reasons, so i can play her as soon as i draw her.
And the image for the Emblem for Sympatha is completly black

Current state is for testing reasons, so i can play her as soon as i draw her.
- Code: Select all
Name:Sympatha, Healing Love
ManaCost:0
Types:Planeswalker Sympatha
Loyalty:20
A:AB$ GainLife | Cost$ AddCounter<1/LOYALTY> | LifeAmount$ 3 | Planeswalker$ True | SpellDescription$ You gain 3 life.
A:AB$ Effect | Cost$ SubCounter<5/LOYALTY> | Name$ Emblem Sympatha | Triggers$ TapTrigger | SVars$ TrigGainLife | Planeswalker$ True | Duration$ Permanent | SpellDescription$ You get an emblem with "Whenever a land you control is tapped for mana, gain 2 life."
SVar:TapTrigger:Mode$ TapsForMana | ValidCard$ Land.YouCtrl | TriggerZones$ Battlefield | Execute$ TrigGainLife | TriggerDescription$ Whenever a land you control is tapped for mana, you may gain 2 life.
SVar:TrigGainLife:AB$GainLife | Cost$ 0 | Defined$ You | LifeAmount$ 2
- rikkusguardian
- Posts: 15
- Joined: 04 Jul 2013, 10:29
- Has thanked: 7 times
- Been thanked: 0 time
Re: Card Development Questions
by friarsol » 17 Apr 2014, 02:28
Ah it probably should be: TriggerZones$ Command not TriggerZones$ Battlefield, since that's where the Emblem lives once it's generated.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Card Development Questions
by rikkusguardian » 17 Apr 2014, 02:37
YES!!! Oh man! That was it! Thank you soooo much! Whew! Man, this gave me so many problems!
All that is left is the ultimate, which I think I can change to something like
"You gain an emblem with "Prevent all damage dealt to you by opponents creature, instants and sorcery spells."
All that is left is the ultimate, which I think I can change to something like
"You gain an emblem with "Prevent all damage dealt to you by opponents creature, instants and sorcery spells."
- rikkusguardian
- Posts: 15
- Joined: 04 Jul 2013, 10:29
- Has thanked: 7 times
- Been thanked: 0 time
Re: Card Development Questions
by rikkusguardian » 17 Apr 2014, 03:41
I apologize again, but I am having a VERY hard time getting my image of the Emblem (which I'll make a better image of, soon) of the same planeswalker to show. Instead it shows a copy of the Planeswalker card instead of it's token emblem. It's a really minor thing, but just one thing I would like to master about Forge coding.
Here is the ability that triggers the emblem.
Here is the ability that triggers the emblem.
- Code: Select all
A:AB$ Effect | Cost$ SubCounter<5/LOYALTY> | Name$ Sympatha Emblem | Triggers$ TapTrigger | SVars$ TrigGainLife | Planeswalker$ True | Duration$ Permanent | SpellDescription$ You get an emblem with "Whenever a land you control is tapped for mana, gain 2 life."
SVar:TapTrigger:Mode$ TapsForMana | ValidCard$ Land.YouCtrl | TriggerZones$ Command | Execute$ TrigGainLife | TriggerDescription$ Whenever a land you control is tapped for mana, you gain 2 life.
SVar:TrigGainLife:AB$GainLife | Cost$ 0 | Defined$ You | LifeAmount$ 2
- rikkusguardian
- Posts: 15
- Joined: 04 Jul 2013, 10:29
- Has thanked: 7 times
- Been thanked: 0 time
Re: Card Development Questions
by Marek14 » 17 Apr 2014, 06:23
Not in this form, but it IS part of Platinum Emperion's effect.friarsol wrote:The second ability is kinda halfway between Bubbling Muck and Sanctimony, so it'd be something like:
A:AB$ Effect | Cost$ SubCounter<5/LOYALTY> | Name$ Emblem 1 | Triggers$ TapTrigger | SVars$ TrigGainLife | Planeswalker$ True | Duration$ Permanent | SpellDescription$ You get an emblem with "Whenever a land you control is tapped for mana, gain 2 life."
SVar:TapTrigger:Mode$ TapsForMana | ValidCard$ Land.YouCtrl | TriggerZones$ Battlefield | Execute$ TrigGainLife | TriggerDescription$ Whenever a land you control is tapped for mana, you may gain 1 life.
SVar:TrigGainLife:AB$GainLife | Cost$ 0 | Defined$ You | LifeAmount$ 2
I don't think the ultimate is possible, since "You can't lose life" doesn't exist on any magic card.
Who is online
Users browsing this forum: No registered users and 56 guests