Card Development Questions
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Re: Card Development Questions
by friarsol » 20 Aug 2013, 16:44
Odd to see these Matrices as O and X instead of 0 and 1, I guess they don't line up as well with a 1. I believe, the Celestial Dawn restriction Matrix needs to be ANDed not ORed.Marek14 wrote:Now, a rules question I'm not sure about is: what if I have two Celestial Dawns and one of them is sleighted, say, black? The table for this modified Celestial Dawn would look like this:
I'll confirm with an actual judges ruling, but it doesn't really fit into layers, so I don't think timestamps matter here. I'm pretty sure it's literally, this one says Blue can do things and everything else can't. And that one says White can do things and everything else can't. So nothing can do things (except colorless things).
We can probably do it like this:
1. Start with original matrix (each color being able to pay for itself, and all being able to pay for colorless)
2. OR all of the positive allowances to the matrix (which is all of them except for the restriction in Celestial Dawn)
3. AND that to the payment restriction (just second half of Celestial Dawn)
4. Apply the payment matrix when trying to pay mana.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Card Development Questions
by Marek14 » 20 Aug 2013, 18:19
Yup, hope it was a bit helpful. I started to try something similar for mana generation replacement, but there's too many corner cases to put it in a reasonable-looking algorithms when multiple effects interact.
EDIT: Thinking about it, probably the best solution would be to compute all permutations of mana replacement effects and give player choices based on all the different options. This should work fine until the number of replacement effects reaches 10 or so, and that should only happen in very dedicated decks.
EDIT: Thinking about it, probably the best solution would be to compute all permutations of mana replacement effects and give player choices based on all the different options. This should work fine until the number of replacement effects reaches 10 or so, and that should only happen in very dedicated decks.
Re: Card Development Questions
by swordshine » 29 Sep 2013, 00:40
I've just added initial codes to support mana generation replacement. I'm quite sure AI cannot handle this effect. Some global mana replacement would made ai fail to cast cards, e.g. Naked Singularity, Contamination. If AI fails to cast a spell, that card will disappear.

- Contamination | Open
- Code: Select all
Name:Contamination
ManaCost:2 B
Types:Enchantment
T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | Execute$ TrigSacUnless | TriggerZones$ Battlefield | TriggerDescription$ At the beginning of your upkeep, sacrifice CARDNAME unless you sacrifice a creature.
SVar:TrigSacUnless:AB$ Sacrifice | Cost$ 0 | UnlessCost$ Sac<1/Creature> | UnlessPayer$ You
R:Event$ ProduceMana | ActiveZones$ Battlefield | ValidCard$ Land | ManaReplacement$ ProduceB | Description$ If a land is tapped for mana, it produces B instead of any other type and amount.
SVar:ProduceB:Any->B
SVar:RemAIDeck:True
SVar:NonStackingEffect:True
SVar:Picture:http://www.wizards.com/global/images/magic/general/contamination.jpg
Oracle:At the beginning of your upkeep, sacrifice Contamination unless you sacrifice a creature.\nIf a land is tapped for mana, it produces {B} instead of any other type and amount.
- Naked Singularity | Open
- Code: Select all
Name:Naked Singularity
ManaCost:5
Types:Artifact
Text:If tapped for mana, Plains produce R, Islands produce G, Swamps produce W, Mountains produce U, and Forests produce B instead of any other type.
K:Cumulative upkeep:3
R:Event$ ProduceMana | ActiveZones$ Battlefield | ValidCard$ Plains | ManaReplacement$ ProduceR | Secondary$ True | Description$ If tapped for mana, Plains produce R.
SVar:ProduceR:Colorless->R & B->R & U->R & G->R & W->R
R:Event$ ProduceMana | ActiveZones$ Battlefield | ValidCard$ Island | ManaReplacement$ ProduceG | Secondary$ True | Description$ If tapped for mana, Islands produce G.
SVar:ProduceG:Colorless->G & B->G & U->G & R->G & W->G
R:Event$ ProduceMana | ActiveZones$ Battlefield | ValidCard$ Swamp | ManaReplacement$ ProduceW | Secondary$ True | Description$ If tapped for mana, Swamps produce W.
SVar:ProduceW:Colorless->W & B->W & U->W & R->W & G->W
R:Event$ ProduceMana | ActiveZones$ Battlefield | ValidCard$ Mountain | ManaReplacement$ ProduceU | Secondary$ True | Description$ If tapped for mana, Mountains produce U.
SVar:ProduceU:Colorless->U & B->U & G->U & R->U & W->U
R:Event$ ProduceMana | ActiveZones$ Battlefield | ValidCard$ Forest | ManaReplacement$ ProduceB | Secondary$ True | Description$ If tapped for mana, Forests produce B.
SVar:ProduceB:Colorless->B & G->B & U->B & R->B & W->B
SVar:RemAIDeck:True
SVar:RemRandomDeck:True
SVar:Picture:http://www.wizards.com/global/images/magic/general/naked_singularity.jpg
Oracle:Cumulative upkeep {3} (At the beginning of your upkeep, put an age counter on this permanent, then sacrifice it unless you pay its upkeep cost for each age counter on it.)\nIf tapped for mana, Plains produce {R}, Islands produce {G}, Swamps produce {W}, Mountains produce {U}, and Forests produce {B} instead of any other type.
- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Re: Card Development Questions
by Marek14 » 29 Sep 2013, 05:57
So that's why the AI commanders tend to disappear?
Re: Card Development Questions
by Sloth » 29 Sep 2013, 06:46
I will try to solve this.swordshine wrote:I've just added initial codes to support mana generation replacement. I'm quite sure AI cannot handle this effect. Some global mana replacement would made ai fail to cast cards, e.g. Naked Singularity, Contamination. If AI fails to cast a spell, that card will disappear.![]()
- Contamination | Open
- Code: Select all
Name:Contamination
ManaCost:2 B
Types:Enchantment
T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | Execute$ TrigSacUnless | TriggerZones$ Battlefield | TriggerDescription$ At the beginning of your upkeep, sacrifice CARDNAME unless you sacrifice a creature.
SVar:TrigSacUnless:AB$ Sacrifice | Cost$ 0 | UnlessCost$ Sac<1/Creature> | UnlessPayer$ You
R:Event$ ProduceMana | ActiveZones$ Battlefield | ValidCard$ Land | ManaReplacement$ ProduceB | Description$ If a land is tapped for mana, it produces B instead of any other type and amount.
SVar:ProduceB:Any->B
SVar:RemAIDeck:True
SVar:NonStackingEffect:True
SVar:Picture:http://www.wizards.com/global/images/magic/general/contamination.jpg
Oracle:At the beginning of your upkeep, sacrifice Contamination unless you sacrifice a creature.\nIf a land is tapped for mana, it produces {B} instead of any other type and amount.
- Naked Singularity | Open
- Code: Select all
Name:Naked Singularity
ManaCost:5
Types:Artifact
Text:If tapped for mana, Plains produce R, Islands produce G, Swamps produce W, Mountains produce U, and Forests produce B instead of any other type.
K:Cumulative upkeep:3
R:Event$ ProduceMana | ActiveZones$ Battlefield | ValidCard$ Plains | ManaReplacement$ ProduceR | Secondary$ True | Description$ If tapped for mana, Plains produce R.
SVar:ProduceR:Colorless->R & B->R & U->R & G->R & W->R
R:Event$ ProduceMana | ActiveZones$ Battlefield | ValidCard$ Island | ManaReplacement$ ProduceG | Secondary$ True | Description$ If tapped for mana, Islands produce G.
SVar:ProduceG:Colorless->G & B->G & U->G & R->G & W->G
R:Event$ ProduceMana | ActiveZones$ Battlefield | ValidCard$ Swamp | ManaReplacement$ ProduceW | Secondary$ True | Description$ If tapped for mana, Swamps produce W.
SVar:ProduceW:Colorless->W & B->W & U->W & R->W & G->W
R:Event$ ProduceMana | ActiveZones$ Battlefield | ValidCard$ Mountain | ManaReplacement$ ProduceU | Secondary$ True | Description$ If tapped for mana, Mountains produce U.
SVar:ProduceU:Colorless->U & B->U & G->U & R->U & W->U
R:Event$ ProduceMana | ActiveZones$ Battlefield | ValidCard$ Forest | ManaReplacement$ ProduceB | Secondary$ True | Description$ If tapped for mana, Forests produce B.
SVar:ProduceB:Colorless->B & G->B & U->B & R->B & W->B
SVar:RemAIDeck:True
SVar:RemRandomDeck:True
SVar:Picture:http://www.wizards.com/global/images/magic/general/naked_singularity.jpg
Oracle:Cumulative upkeep {3} (At the beginning of your upkeep, put an age counter on this permanent, then sacrifice it unless you pay its upkeep cost for each age counter on it.)\nIf tapped for mana, Plains produce {R}, Islands produce {G}, Swamps produce {W}, Mountains produce {U}, and Forests produce {B} instead of any other type.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Card Development Questions
by Idontknow84 » 03 Oct 2013, 18:03
I think the card Nest Invader has a wrong description. In fact, in place of the words "They have" in the TriggerDescription (file nest_invader.txt, line 5), you should have "It has".
- Idontknow84
- Posts: 5
- Joined: 15 Sep 2013, 13:37
- Has thanked: 0 time
- Been thanked: 0 time
Re: Card Development Questions
by swordshine » 07 Oct 2013, 13:32
Just added a card from Commander 2013: Derevi, Empyrial Tactician.
It's necessary to record the mana spent to cast/activate a spell or ability in order to implement the other two cards (Jeleva, Nephalia's Scourge and Prossh, Skyraider of Kher) and some of remaining cards (Nix, Ice Cauldron, Jeweled Amulet, and Balduvian Fallen).
It's necessary to record the mana spent to cast/activate a spell or ability in order to implement the other two cards (Jeleva, Nephalia's Scourge and Prossh, Skyraider of Kher) and some of remaining cards (Nix, Ice Cauldron, Jeweled Amulet, and Balduvian Fallen).
- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Re: Card Development Questions
by moomarc » 08 Oct 2013, 08:14
I did some initial work on this for Nix, but never managed to crack colorless mana. That 0 byte is a pain. Managed to get everything else working though, mostly following Sunburst but keeping a map of the colour bytes instead of a straight list. Hope you have better luck than I did.swordshine wrote:Just added a card from Commander 2013: Derevi, Empyrial Tactician.
It's necessary to record the mana spent to cast/activate a spell or ability in order to implement the other two cards (Jeleva, Nephalia's Scourge and Prossh, Skyraider of Kher) and some of remaining cards (Nix, Ice Cauldron, Jeweled Amulet, and Balduvian Fallen).
-Marc
-
moomarc - Pixel Commander
- Posts: 2091
- Joined: 04 Jun 2010, 15:22
- Location: Johannesburg, South Africa
- Has thanked: 371 times
- Been thanked: 372 times
Re: Card Development Questions
by Sloth » 10 Nov 2013, 08:18
@swordshine: Some of the scripts you made are not 100% correct.
Quicksilver Dragon: The ability should be able to target any spell, but only take effect when the condition is met (similar to Pyroblast).
Arboria:
1. Keeping track of player's actions with invisible static trigger can be turned off with cards like Humility and causes problems when the card gets cloned.
2. This card cares who puts a nontoken permanent onto the battlefield. When i cast Flicker on an opponent's creature i put a card onto the battlefield.
Premature Burial:
Does not work when cast by another player.
Quicksilver Dragon: The ability should be able to target any spell, but only take effect when the condition is met (similar to Pyroblast).
Arboria:
1. Keeping track of player's actions with invisible static trigger can be turned off with cards like Humility and causes problems when the card gets cloned.
2. This card cares who puts a nontoken permanent onto the battlefield. When i cast Flicker on an opponent's creature i put a card onto the battlefield.
Premature Burial:
Does not work when cast by another player.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Card Development Questions
by swordshine » 10 Nov 2013, 10:54
I can handle Quicksilver Dragon, the other cards are really difficult.Sloth wrote:@swordshine: Some of the scripts you made are not 100% correct.
Quicksilver Dragon: The ability should be able to target any spell, but only take effect when the condition is met (similar to Pyroblast).
Arboria:
1. Keeping track of player's actions with invisible static trigger can be turned off with cards like Humility and causes problems when the card gets cloned.
2. This card cares who puts a nontoken permanent onto the battlefield. When i cast Flicker on an opponent's creature i put a card onto the battlefield.
Premature Burial:
Does not work when cast by another player.
It looks like Summoning Trap suffers the same bug with Premature Burial.

- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Re: Card Development Questions
by Sloth » 10 Nov 2013, 12:38
Cards like this need more bookkeeping. Summoning Trap would need a boolean variable CreatureSpellWasCounteredByOpponentThisTurn in the Player class. Prematural Burial would need a list of Players variable called TurnsEndedSinceOnTheBattlefield. Arboria needs ... a lot.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Card Development Questions
by swordshine » 10 Nov 2013, 13:42
We can remove Arboria before the release of new snapshots.Sloth wrote:Cards like this need more bookkeeping. Summoning Trap would need a boolean variable CreatureSpellWasCounteredByOpponentThisTurn in the Player class. Prematural Burial would need a list of Players variable called TurnsEndedSinceOnTheBattlefield. Arboria needs ... a lot.
- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Re: Card Development Questions
by drdev » 12 Nov 2013, 17:00
I'm currently working on supporting display mana symbols as icons instead of text characters. It's become apparent that this will require script changes to reliably replace characters that represent mana symbols and not replace indentical characters that aren't mana symbols. For example, X in some contexts is a mana symbol, and in others it should be displayed as just the character "X". Similarly, "Tap" is sometimes the tab symbol and sometimes the word "Tap" at the beginning of a sentence, like "Tap target creature."
What I'd like to propose is wrapping actual mana symbol characters in the script in {} to mark them as mana symbols. For example, "Tap, G:" would become "{T},
:" (ironically, this forum already converts "{G}" to the icon as you can see). Note that by using {}, we no longer need spaces between consecutive symbols, so "W/G W/G" will become "{W/G}{W/G}" to avoid a space appearing between the icons.
This implementation will have the additional advantage of allowing search functionality to be enhanced to search for mana symbols accurately. I'm even planning to support displaying a symbol table while the focus is in any text field.
I'm planning to convert the code I've already been working on into a script to parse all card script files and make this change to them. I'll then go through and clean up any places that get missed. Going forward, any script changes will need to wrap mana symbol characters in {}, otherwise they'll just appear as plain text everywhere and not be matched on mana symbol searches.
Does this change sound ok to everyone?
What I'd like to propose is wrapping actual mana symbol characters in the script in {} to mark them as mana symbols. For example, "Tap, G:" would become "{T},

This implementation will have the additional advantage of allowing search functionality to be enhanced to search for mana symbols accurately. I'm even planning to support displaying a symbol table while the focus is in any text field.
I'm planning to convert the code I've already been working on into a script to parse all card script files and make this change to them. I'll then go through and clean up any places that get missed. Going forward, any script changes will need to wrap mana symbol characters in {}, otherwise they'll just appear as plain text everywhere and not be matched on mana symbol searches.
Does this change sound ok to everyone?
- drdev
- Programmer
- Posts: 1958
- Joined: 27 Jul 2013, 02:07
- Has thanked: 189 times
- Been thanked: 565 times
Re: Card Development Questions
by friarsol » 12 Nov 2013, 17:47
You'd be basically changing every single card. We need to have a larger discussion about that. I'd think there's a smarter way of handling this. Every time we've changed every single card script there's been lots of issues with svn and other things like that.
What scenarios are actual mana symbols used in? Costs and Mana generation. We already have separate functions for those, so why not just output differently from those functions?
What scnearios is the tap symbol used in? Costs.
It seems like you'd be better off just changing the tostring in costs to wrap mana symbols instead of trying to change our whole procedure.
What scenarios are actual mana symbols used in? Costs and Mana generation. We already have separate functions for those, so why not just output differently from those functions?
What scnearios is the tap symbol used in? Costs.
It seems like you'd be better off just changing the tostring in costs to wrap mana symbols instead of trying to change our whole procedure.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Card Development Questions
by Max mtg » 12 Nov 2013, 17:57
All scenarios except for ability descriptions such as 'add {g} to your mana pool' can use parsed mana costs from oracle texts or abilities
Why change toString of manacosts, and then re-parse it, if manacosts already contain all mana shards?
Why change toString of manacosts, and then re-parse it, if manacosts already contain all mana shards?
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Who is online
Users browsing this forum: No registered users and 26 guests