mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
*Removed ColorIdentity field from ICardCharacteristics,CardRules and scripts.
*Added experimental Oracle Color Identity parser.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
Name:Bosh, Iron Golem
|
||||
ManaCost:8
|
||||
ColorIdentity:Red
|
||||
Types:Legendary Artifact Creature Golem
|
||||
PT:6/7
|
||||
K:Trample
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
Name:Memnarch
|
||||
ManaCost:7
|
||||
ColorIdentity:Blue
|
||||
Types:Legendary Artifact Creature Wizard
|
||||
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.)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
Name:Rhys the Exiled
|
||||
ManaCost:2 G
|
||||
ColorIdentity:Green,Black
|
||||
Types:Legendary Creature Elf Warrior
|
||||
PT:3/2
|
||||
T:Mode$ Attacks | ValidCard$ Card.Self | Execute$ TrigGainLife | TriggerDescription$ Whenever CARDNAME attacks, you gain 1 life for each Elf you control.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
Name:Thelon of Havenwood
|
||||
ManaCost:G G
|
||||
ColorIdentity:Green,Black
|
||||
Types:Legendary Creature Elf Druid
|
||||
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.
|
||||
|
||||
@@ -29,7 +29,6 @@ final class CardFace implements ICardFace {
|
||||
private CardType type = null;
|
||||
private ManaCost manaCost = ManaCost.NO_COST;
|
||||
private ColorSet color = null;
|
||||
private ColorSet colorIdentity = null;
|
||||
|
||||
private String oracleText = null;
|
||||
private int iPower = -1;
|
||||
@@ -60,14 +59,6 @@ final class CardFace implements ICardFace {
|
||||
@Override public ManaCost getManaCost() { return this.manaCost; }
|
||||
@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
|
||||
@Override public Iterable<String> getKeywords() { return keywords; }
|
||||
@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 setManaCost(ManaCost manaCost0) { this.manaCost = manaCost0; }
|
||||
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 setInitialLoyalty(int value) { this.initialLoyalty = value; }
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import forge.CardColor;
|
||||
import forge.card.mana.ManaCost;
|
||||
|
||||
/**
|
||||
@@ -40,6 +41,8 @@ public final class CardRules implements ICardCharacteristics {
|
||||
|
||||
private CardAiHints aiHints;
|
||||
|
||||
private ColorSet colorIdentity = null;
|
||||
|
||||
public CardRules(ICardFace[] faces, CardSplitType altMode, CardAiHints cah, Map<String, CardInSet> sets) {
|
||||
splitType = altMode;
|
||||
mainPart = faces[0];
|
||||
@@ -57,6 +60,49 @@ public final class CardRules implements ICardCharacteristics {
|
||||
System.err.println(getName() + " was not assigned any set.");
|
||||
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() {
|
||||
@@ -178,16 +224,8 @@ public final class CardRules implements ICardCharacteristics {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ColorSet getColorIdentity() {
|
||||
if(this.otherPart != null)
|
||||
{
|
||||
return ColorSet.fromMask(mainPart.getColorIdentity().getColor() | otherPart.getColorIdentity().getColor());
|
||||
}
|
||||
else
|
||||
{
|
||||
return mainPart.getColorIdentity();
|
||||
}
|
||||
return colorIdentity;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,12 +138,6 @@ public class CardRulesReader {
|
||||
ColorSet newCol = ColorSet.fromNames(value.split(","));
|
||||
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;
|
||||
|
||||
case 'D':
|
||||
|
||||
@@ -7,7 +7,6 @@ public interface ICardCharacteristics {
|
||||
CardType getType();
|
||||
ManaCost getManaCost();
|
||||
ColorSet getColor();
|
||||
ColorSet getColorIdentity();
|
||||
|
||||
int getIntPower();
|
||||
int getIntToughness();
|
||||
|
||||
Reference in New Issue
Block a user