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 » 22 Dec 2012, 14:23
OK, I'm back to looking at the code to come up with the best strategy to implement the split cards. So far, here are the issues that have shown up and that probably need some discussion:
1) Split cards behave differently when on stack. In particular, their color and CMC should temporarily (as long as they're on stack, as far as I understand) be seen by all entities of the game as only those of the part currently cast. I thought of adding a special property to the spell abilities which comprise the split card, for example, something like "IsSplitCardSide$ True", which, if present, will signal the game that it should place the effect on stack with the color and CMC of the spell effect itself instead of the card as a whole. However, I'd need some advice on how exactly effects go on stack in Forge - say, the "Fire / Ice" card above is cast, and the player chooses to play the Ice effect. Where exactly in the code does it go on stack so that it appears in the stack list in the game? Can you please direct me to the right spot?
2) I have found a relatively high number of methods in the Card class and CardCharacteristics class that deal with the card color - namely, in addition to the simple getColor, there's also determineColor, in addition to setColor there's also addColor. Am I correct that all of these methods will have to be changed to account for the split card mechanics? In that case, I think that whether they take information from the basic card information or from the individual spell effects will depend on the presence of the SplitCard SVar or whatever other form will exist that will flag the card as a split card.
3) For CMC, it's probably going to be best to implement it as a part of the xCount function with CardManaCost, as described by Sol above. Would this be an acceptable route?
With all three points above considered together, I'm not sure if we'll actually need the IsSplitCardSide property to determine which spell effects comprise the sides of the split card (I mean, as long as SplitCard SVar is present, maybe it can just automatically consider all SP$ lines as parts of the split card, or is it dangerous to choose this route?)
- Agetian
1) Split cards behave differently when on stack. In particular, their color and CMC should temporarily (as long as they're on stack, as far as I understand) be seen by all entities of the game as only those of the part currently cast. I thought of adding a special property to the spell abilities which comprise the split card, for example, something like "IsSplitCardSide$ True", which, if present, will signal the game that it should place the effect on stack with the color and CMC of the spell effect itself instead of the card as a whole. However, I'd need some advice on how exactly effects go on stack in Forge - say, the "Fire / Ice" card above is cast, and the player chooses to play the Ice effect. Where exactly in the code does it go on stack so that it appears in the stack list in the game? Can you please direct me to the right spot?
2) I have found a relatively high number of methods in the Card class and CardCharacteristics class that deal with the card color - namely, in addition to the simple getColor, there's also determineColor, in addition to setColor there's also addColor. Am I correct that all of these methods will have to be changed to account for the split card mechanics? In that case, I think that whether they take information from the basic card information or from the individual spell effects will depend on the presence of the SplitCard SVar or whatever other form will exist that will flag the card as a split card.
3) For CMC, it's probably going to be best to implement it as a part of the xCount function with CardManaCost, as described by Sol above. Would this be an acceptable route?
With all three points above considered together, I'm not sure if we'll actually need the IsSplitCardSide property to determine which spell effects comprise the sides of the split card (I mean, as long as SplitCard SVar is present, maybe it can just automatically consider all SP$ lines as parts of the split card, or is it dangerous to choose this route?)
- Agetian
Last edited by Agetian on 22 Dec 2012, 14:57, edited 1 time in total.
- 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 » 22 Dec 2012, 14:50
1. MagicStack.add() which is called from SpellAbilityRequirements (I forget the name of the function in this class, it's something like addToStack().Agetian wrote:1) [...] Where exactly in the code does it go on stack so that it appears in the stack list in the game?
- 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 ArsenalNut » 22 Dec 2012, 17:11
In the Counterbalance example, should it be if any of the CMC match, return true?friarsol wrote: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).
708.6a An effect that performs a positive comparison (such as asking if a card is red) or a relative
comparison (such as asking if a card’s converted mana cost is less than 2) involving
characteristics of one or more split cards in any zone other than the stack gets only one answer.
This answer is “yes” if either side of each split card in the comparison would return a “yes”
answer if compared individually.
So many cards, so little time
-

ArsenalNut - Posts: 512
- Joined: 08 Jul 2011, 03:49
- Has thanked: 27 times
- Been thanked: 121 times
Re: Implementing new Ability Factories and Card Support Code
by friarsol » 22 Dec 2012, 17:29
Sort of, but that's hot how hasProperty works. I guess the phrase "all of them don't succeed" was ambiguous, basically what I meant is this. (Half pseudo code, but you should get the idea)ArsenalNut wrote:In the Counterbalance example, should it be if any of the CMC match, return true?
- Code: Select all
else if (property.startsWith("cmc")) {
boolean matchesBaseCMC = false;
String rhs = property.substring(5);
int cmc = 0, x = 0;
try {
x = Integer.parseInt(rhs);
} catch (final NumberFormatException e) {
x = CardFactoryUtil.xCount(source, source.getSVar(rhs));
}
for(SpellAbility sa : card.getBaseSpells()) {
cmc = sa.getCost().getCMC();
matchesBaseCMC |= Expressions.compare(y, property, x));
if (matchesBaseCMC) {
break;
}
}
if (!matchesBaseCMC) {
return false;
}
}
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Who is online
Users browsing this forum: No registered users and 17 guests