Added method to CardColor to identify if another CardColor shares color with another.

Added method to CardType to identify if another CardType shares a subtype with another.
This commit is contained in:
Rob Cashwalker
2011-12-26 03:14:27 +00:00
parent b7d550ae7b
commit 4af36404b9
2 changed files with 32 additions and 0 deletions

View File

@@ -300,4 +300,24 @@ public final class CardColor implements Comparable<CardColor> {
public static void setNullColor(final CardColor nullColor0) {
CardColor.nullColor = nullColor0;
}
public boolean sharesColorWith(CardColor ccOther) {
if (this.isWhite() && ccOther.isWhite())
return true;
if (this.isBlue() && ccOther.isBlue())
return true;
if (this.isBlack() && ccOther.isBlack())
return true;
if (this.isRed() && ccOther.isRed())
return true;
if (this.isGreen() && ccOther.isGreen())
return true;
return false;
}
}

View File

@@ -296,4 +296,16 @@ public final class CardType implements Comparable<CardType> {
return this.toString().compareTo(o.toString());
}
public List<String> getSubTypes() {
return this.subType;
}
public boolean sharesSubTypeWith(CardType ctOther) {
for (String t : ctOther.getSubTypes()) {
if (this.subTypeContains(t))
return true;
}
return false;
}
}