*Removed ColorIdentity field from ICardCharacteristics,CardRules and scripts.

*Added experimental Oracle Color Identity parser.
This commit is contained in:
Hellfish
2013-04-01 18:13:42 +00:00
parent 7811880919
commit 91fb2a8f8c
8 changed files with 48 additions and 31 deletions

View File

@@ -1,6 +1,5 @@
Name:Bosh, Iron Golem Name:Bosh, Iron Golem
ManaCost:8 ManaCost:8
ColorIdentity:Red
Types:Legendary Artifact Creature Golem Types:Legendary Artifact Creature Golem
PT:6/7 PT:6/7
K:Trample K:Trample

View File

@@ -1,6 +1,5 @@
Name:Memnarch Name:Memnarch
ManaCost:7 ManaCost:7
ColorIdentity:Blue
Types:Legendary Artifact Creature Wizard Types:Legendary Artifact Creature Wizard
PT:4/5 PT:4/5
A:AB$ Animate | Cost$ 1 U U | ValidTgts$ Permanent | TgtPrompt$ Select target permanent | Types$ Artifact | Permanent$ True | SpellDescription$ Target permanent becomes an artifact in addition to its other types. (This effect lasts indefinitely.) A:AB$ Animate | Cost$ 1 U U | ValidTgts$ Permanent | TgtPrompt$ Select target permanent | Types$ Artifact | Permanent$ True | SpellDescription$ Target permanent becomes an artifact in addition to its other types. (This effect lasts indefinitely.)

View File

@@ -1,6 +1,5 @@
Name:Rhys the Exiled Name:Rhys the Exiled
ManaCost:2 G ManaCost:2 G
ColorIdentity:Green,Black
Types:Legendary Creature Elf Warrior Types:Legendary Creature Elf Warrior
PT:3/2 PT:3/2
T:Mode$ Attacks | ValidCard$ Card.Self | Execute$ TrigGainLife | TriggerDescription$ Whenever CARDNAME attacks, you gain 1 life for each Elf you control. T:Mode$ Attacks | ValidCard$ Card.Self | Execute$ TrigGainLife | TriggerDescription$ Whenever CARDNAME attacks, you gain 1 life for each Elf you control.

View File

@@ -1,6 +1,5 @@
Name:Thelon of Havenwood Name:Thelon of Havenwood
ManaCost:G G ManaCost:G G
ColorIdentity:Green,Black
Types:Legendary Creature Elf Druid Types:Legendary Creature Elf Druid
PT:2/2 PT:2/2
S:Mode$ Continuous | Affected$ Creature.Fungus | AffectedZone$ Battlefield | AddPower$ AffectedX | AddToughness$ AffectedX | Description$ Each Fungus creature gets +1/+1 for each spore counter on it. S:Mode$ Continuous | Affected$ Creature.Fungus | AffectedZone$ Battlefield | AddPower$ AffectedX | AddToughness$ AffectedX | Description$ Each Fungus creature gets +1/+1 for each spore counter on it.

View File

@@ -29,7 +29,6 @@ final class CardFace implements ICardFace {
private CardType type = null; private CardType type = null;
private ManaCost manaCost = ManaCost.NO_COST; private ManaCost manaCost = ManaCost.NO_COST;
private ColorSet color = null; private ColorSet color = null;
private ColorSet colorIdentity = null;
private String oracleText = null; private String oracleText = null;
private int iPower = -1; private int iPower = -1;
@@ -59,15 +58,7 @@ final class CardFace implements ICardFace {
@Override public CardType getType() { return this.type; } @Override public CardType getType() { return this.type; }
@Override public ManaCost getManaCost() { return this.manaCost; } @Override public ManaCost getManaCost() { return this.manaCost; }
@Override public ColorSet getColor() { return this.color; } @Override public ColorSet getColor() { return this.color; }
@Override
public ColorSet getColorIdentity() {
if(this.colorIdentity != null)
return this.colorIdentity;
return this.color;
}
// these are raw and unparsed used for Card creation // these are raw and unparsed used for Card creation
@Override public Iterable<String> getKeywords() { return keywords; } @Override public Iterable<String> getKeywords() { return keywords; }
@Override public Iterable<String> getAbilities() { return abilities; } @Override public Iterable<String> getAbilities() { return abilities; }
@@ -86,7 +77,6 @@ final class CardFace implements ICardFace {
public void setType(CardType type0) { this.type = type0; } public void setType(CardType type0) { this.type = type0; }
public void setManaCost(ManaCost manaCost0) { this.manaCost = manaCost0; } public void setManaCost(ManaCost manaCost0) { this.manaCost = manaCost0; }
public void setColor(ColorSet color0) { this.color = color0; } public void setColor(ColorSet color0) { this.color = color0; }
public void setColorIdentity(ColorSet color0) { this.colorIdentity = color0; }
public void setOracleText(String text) { this.oracleText = text; } public void setOracleText(String text) { this.oracleText = text; }
public void setInitialLoyalty(int value) { this.initialLoyalty = value; } public void setInitialLoyalty(int value) { this.initialLoyalty = value; }

View File

@@ -23,6 +23,7 @@ import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
import forge.CardColor;
import forge.card.mana.ManaCost; import forge.card.mana.ManaCost;
/** /**
@@ -39,6 +40,8 @@ public final class CardRules implements ICardCharacteristics {
private final Map<String, CardInSet> setsPrinted = new TreeMap<String, CardInSet>(String.CASE_INSENSITIVE_ORDER); private final Map<String, CardInSet> setsPrinted = new TreeMap<String, CardInSet>(String.CASE_INSENSITIVE_ORDER);
private CardAiHints aiHints; private CardAiHints aiHints;
private ColorSet colorIdentity = null;
public CardRules(ICardFace[] faces, CardSplitType altMode, CardAiHints cah, Map<String, CardInSet> sets) { public CardRules(ICardFace[] faces, CardSplitType altMode, CardAiHints cah, Map<String, CardInSet> sets) {
splitType = altMode; splitType = altMode;
@@ -57,6 +60,49 @@ public final class CardRules implements ICardCharacteristics {
System.err.println(getName() + " was not assigned any set."); System.err.println(getName() + " was not assigned any set.");
setsPrinted.put(CardEdition.UNKNOWN.getCode(), new CardInSet(CardRarity.Common, 1) ); setsPrinted.put(CardEdition.UNKNOWN.getCode(), new CardInSet(CardRarity.Common, 1) );
} }
//Calculate Color Identity
byte colMask = calculateColorIdentity(mainPart);
if(otherPart != null)
{
colMask |= calculateColorIdentity(otherPart);
}
colorIdentity = ColorSet.fromMask(colMask);
}
private byte calculateColorIdentity(ICardFace face)
{
byte res = face.getManaCost() == null ? 0 : face.getManaCost().getColorProfile();
boolean isReminder = false;
boolean isSymbol = false;
for(char c : face.getOracleText().toCharArray()) {
switch(c)
{
case('('): isReminder = true; break;
case(')'): isReminder = false; break;
case('{'): isSymbol = true; break;
case('}'): isSymbol = false; break;
default:
if(isSymbol && !isReminder) {
switch(c)
{
case('W'): res |= MagicColor.WHITE; break;
case('U'): res |= MagicColor.BLUE; break;
case('B'): res |= MagicColor.BLACK; break;
case('R'): res |= MagicColor.RED; break;
case('G'): res |= MagicColor.GREEN; break;
}
}
else
{
continue;
}
break;
}
}
return res;
} }
public boolean isTraditional() { public boolean isTraditional() {
@@ -178,16 +224,8 @@ public final class CardRules implements ICardCharacteristics {
return null; return null;
} }
@Override
public ColorSet getColorIdentity() { public ColorSet getColorIdentity() {
if(this.otherPart != null) return colorIdentity;
{
return ColorSet.fromMask(mainPart.getColorIdentity().getColor() | otherPart.getColorIdentity().getColor());
}
else
{
return mainPart.getColorIdentity();
}
} }
} }

View File

@@ -138,12 +138,6 @@ public class CardRulesReader {
ColorSet newCol = ColorSet.fromNames(value.split(",")); ColorSet newCol = ColorSet.fromNames(value.split(","));
this.faces[this.curFace].setColor(newCol); this.faces[this.curFace].setColor(newCol);
} }
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);
}
break; break;
case 'D': case 'D':

View File

@@ -7,7 +7,6 @@ public interface ICardCharacteristics {
CardType getType(); CardType getType();
ManaCost getManaCost(); ManaCost getManaCost();
ColorSet getColor(); ColorSet getColor();
ColorSet getColorIdentity();
int getIntPower(); int getIntPower();
int getIntToughness(); int getIntToughness();