Implementing new Ability Factories and Card Support Code
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Agetian, friarsol, Blacksmith, KrazyTheFox, CCGHQ Admins
Re: Implementing new Ability Factories and Card Support Code
by Agetian » 17 Dec 2012, 08:53
kk I can think of a possible way out for the problem with CMC - maybe the code that queries CMC can also query the special "SplitCard" parameter in the script, and, if it exists, also call something like getCMC2() which will return the alternate CMC. It could even be a SVar or a set of SVars defining the properties of the card that are only applicable to split cards (secondary mana cost and secondary color come to mind). E.g.:
Does anybody have an idea or at least a short list "to begin with" (not necessarily comprehensive, just something to start with and to learn a bit more about what to look for in the code)?
- Agetian
- Code: Select all
SVar:SplitCard:SecondaryColor$ Red | SecondaryManaCost$ 3 R
Does anybody have an idea or at least a short list "to begin with" (not necessarily comprehensive, just something to start with and to learn a bit more about what to look for in the code)?
- Agetian
- Agetian
- Programmer
- Posts: 3490
- Joined: 14 Mar 2011, 05:58
- Has thanked: 684 times
- Been thanked: 572 times
Re: Implementing new Ability Factories and Card Support Code
by Sloth » 17 Dec 2012, 10:03
Yes, this should be enough info.Agetian wrote:
- Code: Select all
SVar:SplitCard:SecondaryColor$ Red | SecondaryManaCost$ 3 R
Example:
- Fire//Ice | Open
- Name:Fire//Ice
ManaCost:1 R
Types:Instant
Text:no text
A:SP$ Effect | Cost$ 1 R | SP$ DealDamage | ValidTgts$ Creature,Player | TgtPrompt$ Select target creature or player (1) | NumDmg$ 1 | SubAbility$ DBDamage2 | SpellDescription$ Fire deals 2 damage divided as you choose among one or two target creatures and/or players.
SVar:DBDamage2:DB$DealDamage | Cost$ 0 | ValidTgts$ Creature,Player | TgtPrompt$ Select target creature or player (2) | NumDmg$ 1
A:SP$ Effect | Cost$ 1 U | SP$ Tap | ValidTgts$ Permanent | TgtPrompt$ Select target permanent | SubAbility$ DBDraw | SpellDescription$ Tap target permanent. Draw a card.
SVar:DBDraw:DB$Draw | Cost$ 0 | NumCards$ 1
SVar:SplitCard:SecondaryColor$ Blue | SecondaryManaCost$ 1 U
SVar:RemAIDeck:True
SVar:Rarity:Uncommon
SVar:Picture:http://www.wizards.com/global/images/magic/general/fire_ice.jpg
SetInfo:APC|Uncommon|http://magiccards.info/scans/en/ap/128.jpg
Oracle: Fire deals 2 damage divided as you choose among one or two target creatures and/or players.|| Tap target permanent. Draw a card.
End
I would start with the easy stuff. getColor should return all colors and getCMC should return the sum of both cmc's.Agetian wrote:The problem here is mostly just knowing which spellabilities and stuff query CMC and colors in that way, to know where the code like that has to be hooked. Hooking it as such should not present a super major problem.
Does anybody have an idea or at least a short list "to begin with" (not necessarily comprehensive, just something to start with and to learn a bit more about what to look for in the code)?
-

Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Implementing new Ability Factories and Card Support Code
by krevett » 17 Dec 2012, 10:18
Just an idea, can getCMC return both cmc separately? That way you just need to alter scripts of problematic cards (Counterbalance and Dark Confidant come to mind) and check for the sVar Split card. If it's TRUE, you can check against both cmc for Counterbalance and lose life for both cmc for Dark Confidant.
I speak about those two cards because I think they are the most emblematic with split cards, but there's also Isochron Scepter to consider (you can imprint a split card if one of the cmc is 2 or less and then play the card for any of its cmc)
I just post some supposition as I don't even know how java works
so perhaps I'm thinking the wrong way!
Edit: with the code posted by Sloth wouldn't the card be red when in hand? If that's the case that would cause a problem...
I speak about those two cards because I think they are the most emblematic with split cards, but there's also Isochron Scepter to consider (you can imprint a split card if one of the cmc is 2 or less and then play the card for any of its cmc)
I just post some supposition as I don't even know how java works
Edit: with the code posted by Sloth wouldn't the card be red when in hand? If that's the case that would cause a problem...
- krevett
- Posts: 109
- Joined: 21 Feb 2012, 22:24
- Location: France
- Has thanked: 18 times
- Been thanked: 9 times
Re: Implementing new Ability Factories and Card Support Code
by Agetian » 17 Dec 2012, 11:20
Thanks for the suggestions, guys! I'll think it over and will get down to implementation! 
- Agetian
- Agetian
- Agetian
- Programmer
- Posts: 3490
- Joined: 14 Mar 2011, 05:58
- Has thanked: 684 times
- Been thanked: 572 times
Re: Implementing new Ability Factories and Card Support Code
by friarsol » 17 Dec 2012, 13:23
So I think the easiest way to handle this is to make some medium size changes in hasProperty().
Basically, in places that care about CMC we need to split it into totalCMC and regular old CMC.
totalCMC = Dark Confidant/Pyromancy, where it'll loop over all of the base spells on a card and tally up the CMC for each and compare via that value.
CMC = Counterbalance, this will loop over all of the base spells on a card, and compare the value to each spell's CMC. If all of them don't succeed, return false.
I think this is much cleaner than a SplitCard SVar (which could be accidentally overwritten).
Basically, in places that care about CMC we need to split it into totalCMC and regular old CMC.
totalCMC = Dark Confidant/Pyromancy, where it'll loop over all of the base spells on a card and tally up the CMC for each and compare via that value.
CMC = Counterbalance, this will loop over all of the base spells on a card, and compare the value to each spell's CMC. If all of them don't succeed, return false.
I think this is much cleaner than a SplitCard SVar (which could be accidentally overwritten).
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Implementing new Ability Factories and Card Support Code
by Sloth » 17 Dec 2012, 13:41
Scripts overwriting the SplitCard SVar shouldn't be there (and can easily be fixed). But i think there are effects that can clear all base spells (AF Animate and continuous static abilities).friarsol wrote:totalCMC = Dark Confidant/Pyromancy, where it'll loop over all of the base spells on a card and tally up the CMC for each and compare via that value.
CMC = Counterbalance, this will loop over all of the base spells on a card, and compare the value to each spell's CMC. If all of them don't succeed, return false.
I think this is much cleaner than a SplitCard SVar (which could be accidentally overwritten).
-

Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Implementing new Ability Factories and Card Support Code
by Agetian » 17 Dec 2012, 14:54
Here's one more question: if a card color of a split card becomes overridden by something (isColorOverridden returns true), e.g., I assume, by another effect that says "card becomes <color>", does it means that it should only show the overriding color (so, it temporarily/permanently, depending on the effect, becomes mono-colored and is of the overriding color)?
- Agetian
- Agetian
- Agetian
- Programmer
- Posts: 3490
- Joined: 14 Mar 2011, 05:58
- Has thanked: 684 times
- Been thanked: 572 times
Re: Implementing new Ability Factories and Card Support Code
by Agetian » 17 Dec 2012, 15:12
And also, one more question that simply got me baffled: looks like there are two incompatible card color classes in Forge, forge.CardColor and forge.card.CardColor. I wanted the CardCharacteristics class to take care of the colors (basically, implement the second color as an extra card characteristic and implement getters/setters for that, to begin with), but I don't know how to properly convert the string representation of a mana cost (e.g. "3 B") to its forge.CardColor representation, which is something that is stored inside CardCharacteristics for the primary color (and I can't seem to find how even with the "Find Usages" feature of Netbeans on setColor(), both of the characteristics object and of the card object itself). I know of a way to create the forge.card.CardColor representation from a string representation of the mana cost, but then there's no way to convert to forge.CardColor, which means that two arrays (storing the main color and the secondary color) will be incompatible, which is definitely not something I want. Do you have any ideas how to approach this?...
- Agetian
- Agetian
- Agetian
- Programmer
- Posts: 3490
- Joined: 14 Mar 2011, 05:58
- Has thanked: 684 times
- Been thanked: 572 times
Re: Implementing new Ability Factories and Card Support Code
by friarsol » 17 Dec 2012, 16:19
While there are definitely cards that should clear all abilities Humility etc, I can't think of any cards that clear Base Spells that doesn't replace them (like I do in Animate Dead). Am I just missing some?Sloth wrote:Scripts overwriting the SplitCard SVar shouldn't be there (and can easily be fixed). But i think there are effects that can clear all base spells (AF Animate and continuous static abilities).
And I realized that the TotalCMC is more of a Count thing, so there shouldn't be a need to split anything up in hasProperty.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Implementing new Ability Factories and Card Support Code
by Agetian » 17 Dec 2012, 16:57
Umm a Count thing? Can you please elaborate a bit on what you suggest for the implementation then?.. Thanks in advance!
- Agetian
- Agetian
- Agetian
- Programmer
- Posts: 3490
- Joined: 14 Mar 2011, 05:58
- Has thanked: 684 times
- Been thanked: 572 times
Re: Implementing new Ability Factories and Card Support Code
by Sloth » 17 Dec 2012, 17:22
He means the xCount function with the parameter "CardManaCost" (used by Dark Confidant for example).Agetian wrote:Umm a Count thing? Can you please elaborate a bit on what you suggest for the implementation then?.. Thanks in advance!
-

Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Implementing new Ability Factories and Card Support Code
by friarsol » 17 Dec 2012, 17:26
Like when scripts say Count$ CardManaCost (or something similar). It would still be as I said though if you were going the route I suggested (not if you do the SVar), where you loop through all the base spells and tally the CMC of each.Agetian wrote:Umm a Count thing? Can you please elaborate a bit on what you suggest for the implementation then?.. Thanks in advance!
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Implementing new Ability Factories and Card Support Code
by Agetian » 17 Dec 2012, 17:33
Oh OK, gotcha. Thanks!
- Agetian
- Agetian
- Agetian
- Programmer
- Posts: 3490
- Joined: 14 Mar 2011, 05:58
- Has thanked: 684 times
- Been thanked: 572 times
Re: Implementing new Ability Factories and Card Support Code
by Agetian » 22 Dec 2012, 05:27
OK, now that I feel a little bit better already, I'll hopefully be getting back to coding Forge and, as such, to my primary developer target outlined above (split cards), relatively shortly.
- Agetian
- Agetian
- Agetian
- Programmer
- Posts: 3490
- Joined: 14 Mar 2011, 05:58
- Has thanked: 684 times
- Been thanked: 572 times
Re: Implementing new Ability Factories and Card Support Code
by krevett » 22 Dec 2012, 07:59
Glad to hear you're getting better before christmas!
- krevett
- Posts: 109
- Joined: 21 Feb 2012, 22:24
- Location: France
- Has thanked: 18 times
- Been thanked: 9 times
Who is online
Users browsing this forum: No registered users and 18 guests