Color Identity by Hellfish
There is a commit from Hellfish (r20671) that introduces color identities of cards.
I heartly welcome your next step towards EDH, but have to argue about it's implementation.
Since "color identity of a card is specified by all mana symbols that appear on the card anywhere, including within its rules text" it's easy to determine it.
We already have card's casting cost, that's one set of mana symbols. The remaining mana symbols can be parsed from oracle text, where all mana symbols are enclosed in curly braces. The only thing to do is write that parser, take StringTokenizer get that enclosed fragments and for each when it's not number feed it to ManaCostShard.parseNonGeneric() method.
Why not precalculate and store color identity in card scripts?
- Harder to mantain scripts (will have to add identity to newly created cards)
- Have to develop a tool to calculate anyway, that will mean parsing some external data sources, which can be late from the date the set is avaliable and Forge ready to play with it's cards.
- Excessive or duplicate data was never good.
Will you, Hellfish, please write a routine to calculate card's color identity?
PS: Answering the question in comments - forge.CardColor uses strings array to identify colors and has to be replaced with that newer other class, however that replace still was not made because the former class contains a timestamp. I don't think it's useful to create separate classes for color+timestamp, type+timestamp, but instead create a class TimeStamped<T> to store a number of values coupled with their timestamp.
I heartly welcome your next step towards EDH, but have to argue about it's implementation.
- Code: Select all
else if ("ColorIdentity".equals(key)) {
// This is forge.card.CardColor not forge.CardColor.
// Why do we have two classes with the same name?
ColorSet newCol = ColorSet.fromNames(value.split(","));
this.faces[this.curFace].setColorIdentity(newCol);
}
Since "color identity of a card is specified by all mana symbols that appear on the card anywhere, including within its rules text" it's easy to determine it.
We already have card's casting cost, that's one set of mana symbols. The remaining mana symbols can be parsed from oracle text, where all mana symbols are enclosed in curly braces. The only thing to do is write that parser, take StringTokenizer get that enclosed fragments and for each when it's not number feed it to ManaCostShard.parseNonGeneric() method.
Why not precalculate and store color identity in card scripts?
- Harder to mantain scripts (will have to add identity to newly created cards)
- Have to develop a tool to calculate anyway, that will mean parsing some external data sources, which can be late from the date the set is avaliable and Forge ready to play with it's cards.
- Excessive or duplicate data was never good.
Will you, Hellfish, please write a routine to calculate card's color identity?
PS: Answering the question in comments - forge.CardColor uses strings array to identify colors and has to be replaced with that newer other class, however that replace still was not made because the former class contains a timestamp. I don't think it's useful to create separate classes for color+timestamp, type+timestamp, but instead create a class TimeStamped<T> to store a number of values coupled with their timestamp.
