- Simplified the code found in forge.GameActionUtil and forge.PlayerZone_ComesIntoPlay and forge.RunTest. Updating c.getType().contains(string) to c.isType(string).

This commit is contained in:
jendave
2011-08-07 01:30:14 +00:00
parent 55f8f4e8ee
commit 94b1702aad
3 changed files with 41 additions and 38 deletions

View File

@@ -289,7 +289,8 @@ public class GameActionUtil {
}//For }//For
GuiUtils.getChoiceOptional("Revealed cards:", revealed.toArray()); GuiUtils.getChoiceOptional("Revealed cards:", revealed.toArray());
for (int i = 0; i < RippleMax; i++) { for (int i = 0; i < RippleMax; i++) {
if(RippledCards[i] != null && !RippledCards[i].isUnCastable()) { if (RippledCards[i] != null
&& !RippledCards[i].isUnCastable()) {
if (RippledCards[i].getController().isHuman()) { if (RippledCards[i].getController().isHuman()) {
Object[] possibleValues = {"Yes", "No"}; Object[] possibleValues = {"Yes", "No"};
@@ -305,7 +306,8 @@ public class GameActionUtil {
ArrayList<SpellAbility> choices = RippledCards[i].getBasicSpells(); ArrayList<SpellAbility> choices = RippledCards[i].getBasicSpells();
for (SpellAbility sa:choices) { for (SpellAbility sa:choices) {
if(sa.canPlayAI() && !sa.getSourceCard().getType().contains("Legendary")) { if (sa.canPlayAI()
&& !sa.getSourceCard().isType("Legendary")) {
ComputerUtil.playStackFree(sa); ComputerUtil.playStackFree(sa);
revealed.remove(RippledCards[i]); revealed.remove(RippledCards[i]);
break; break;
@@ -543,7 +545,8 @@ public class GameActionUtil {
final int cmc = CardUtil.getConvertedManaCost(c.getManaCost()); final int cmc = CardUtil.getConvertedManaCost(c.getManaCost());
list = list.getName("Dovescape"); list = list.getName("Dovescape");
final CardList cl = list; final CardList cl = list;
if(!c.getType().contains("Creature") && list.size() > 0) { if (!c.isType("Creature")
&& list.size() > 0) {
final Card card = list.get(0); final Card card = list.get(0);
Ability ability2 = new Ability(card, "0") { Ability ability2 = new Ability(card, "0") {
@@ -558,8 +561,8 @@ public class GameActionUtil {
AllZone.GameAction.moveToGraveyard(sa.getSourceCard()); AllZone.GameAction.moveToGraveyard(sa.getSourceCard());
for (int j = 0; j < cl.size() * cmc; j++) { for (int j = 0; j < cl.size() * cmc; j++) {
CardFactoryUtil.makeToken("Bird", "WU 1 1 Bird", sa.getSourceCard().getController(), "W U", new String[] { CardFactoryUtil.makeToken("Bird", "WU 1 1 Bird", sa.getSourceCard().getController(), "W U",
"Creature", "Bird"}, 1, 1, new String[] {"Flying"}); new String[] {"Creature", "Bird"}, 1, 1, new String[] {"Flying"});
} }
/* /*
@@ -3652,7 +3655,7 @@ public class GameActionUtil {
for (int i = 0; i < max; i++) { for (int i = 0; i < max; i++) {
Card c = libraryList.get(i); Card c = libraryList.get(i);
cardsToReveal.add(c); cardsToReveal.add(c);
if (c.getType().contains("Creature")) { if (c.isType("Creature")) {
AllZone.GameAction.moveTo(battlefield, c); AllZone.GameAction.moveTo(battlefield, c);
break; break;
} }
@@ -5006,7 +5009,7 @@ public class GameActionUtil {
{ {
public boolean addCard(Card crd) public boolean addCard(Card crd)
{ {
return crd.getType().contains("Mountain"); return crd.isType("Mountain");
} }
}); });
@@ -5651,7 +5654,7 @@ public class GameActionUtil {
if (!Already_Added.contains(Type.get(x))) { if (!Already_Added.contains(Type.get(x))) {
if (!Type.get(x).getType().get(x2).equals("Creature") && !Type.get(x).getType().get(x2).equals("Legendary") if (!Type.get(x).getType().get(x2).equals("Creature") && !Type.get(x).getType().get(x2).equals("Legendary")
&& !Type.get(x).getType().get(x2).equals("Artifact") ) { && !Type.get(x).getType().get(x2).equals("Artifact") ) {
if (crd.getType().contains(Type.get(x).getType().get(x2)) if (crd.isType(Type.get(x).getType().get(x2))
|| crd.hasKeyword("Changeling") || crd.hasKeyword("Changeling")
|| Type.get(x).hasKeyword("Changeling")) { || Type.get(x).hasKeyword("Changeling")) {
Already_Added.add(Type.get(x)); Already_Added.add(Type.get(x));

View File

@@ -88,7 +88,7 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
} }
/* /*
// Check for a mountain // Check for a mountain
if (!listValakut.isEmpty() && c.getType().contains("Mountain") ) { if (!listValakut.isEmpty() && c.isType("Mountain") ) {
for (int i = 0; i < listValakut.size(); i++) { for (int i = 0; i < listValakut.size(); i++) {
boolean b = GameActionUtil.executeValakutEffect(listValakut.get(i),c); boolean b = GameActionUtil.executeValakutEffect(listValakut.get(i),c);
if (!b) { if (!b) {

View File

@@ -20,23 +20,23 @@ public class RunTest
check("1", c.getOwner().isComputer()); check("1", c.getOwner().isComputer());
check("1.1", c.getName().equals("Elvish Warrior")); check("1.1", c.getName().equals("Elvish Warrior"));
check("2", c.getManaCost().equals("G G")); check("2", c.getManaCost().equals("G G"));
check("2.1", c.getType().contains("Creature")); check("2.1", c.isType("Creature"));
check("2.2", c.getType().contains("Elf")); check("2.2", c.isType("Elf"));
check("2.3", c.getType().contains("Warrior")); check("2.3", c.isType("Warrior"));
check("3", c.getText().equals("")); check("3", c.getText().equals(""));
check("4", c.getNetAttack() == 2); check("4", c.getNetAttack() == 2);
check("5", c.getNetDefense() == 3); check("5", c.getNetDefense() == 3);
check("6", c.getKeyword().isEmpty()); check("6", c.getKeyword().isEmpty());
c = cf.getCard("Shock", null); c = cf.getCard("Shock", null);
check("14", c.getType().contains("Instant")); check("14", c.isType("Instant"));
//check("15", c.getText().equals("Shock deals 2 damge to target creature or player.")); //check("15", c.getText().equals("Shock deals 2 damge to target creature or player."));
c = cf.getCard("Bayou", null); c = cf.getCard("Bayou", null);
check("17", c.getManaCost().equals("")); check("17", c.getManaCost().equals(""));
check("18", c.getType().contains("Land")); check("18", c.isType("Land"));
check("19", c.getType().contains("Swamp")); check("19", c.isType("Swamp"));
check("20", c.getType().contains("Forest")); check("20", c.isType("Forest"));
//********* test ManaCost //********* test ManaCost
ManaCost manaCost = new ManaCost("G"); ManaCost manaCost = new ManaCost("G");