- Removed the function isValidCard in favor of isValid in GameEntity.

This commit is contained in:
Sloth
2011-09-26 20:36:49 +00:00
parent c9e57ba824
commit 62beec1ac5
25 changed files with 50 additions and 72 deletions

View File

@@ -4862,29 +4862,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|| ((isCreature() || isTribal())
&& CardUtil.isACreatureType(cardType) && typeContains("AllCreatureTypes"))) return true;
return false;
}
/**
* <p>isValidCard.</p>
* Takes an array of arguments like Permanent.Blue+withFlying, only one of them has to be true
*
* @param Restrictions an array of {@link java.lang.String} objects.
* @param sourceController a {@link forge.Player} object.
* @param source a {@link forge.Card} object.
* @return a boolean.
*/
public boolean isValidCard(final String Restrictions[], final Player sourceController, final Card source) {
if (getName().equals("Mana Pool") || isImmutable()) return false;
for (int i = 0; i < Restrictions.length; i++) {
if (isValid(Restrictions[i], sourceController, source)) return true;
}
return false;
}//isValidCard
}//isType
// Takes one argument like Permanent.Blue+withFlying
/**
@@ -4920,7 +4898,7 @@ public class Card extends GameEntity implements Comparable<Card> {
if (hasProperty(exR[j], sourceController, source) == false) return false;
}
return true;
}//isValidCard(String Restriction)
}//isValid(String Restriction)
// Takes arguments like Blue or withFlying
/**

View File

@@ -675,7 +675,7 @@ public class CardList implements Iterable<Card> {
public final CardList getValidCards(final String[] restrictions, final Player sourceController, final Card source) {
return this.filter(new CardListFilter() {
public boolean addCard(final Card c) {
return c != null && c.isValidCard(restrictions, sourceController, source);
return c != null && c.isValid(restrictions, sourceController, source);
}
});
}

View File

@@ -707,7 +707,7 @@ public final class CardUtil {
}
for(Card c : AllZoneUtil.getColorInPlay(strCol))
{
if(!res.contains(c) && c.isValidCard(valid, source.getController(), source) && !c.equals(origin)) {
if(!res.contains(c) && c.isValid(valid, source.getController(), source) && !c.equals(origin)) {
res.add(c);
}
}

View File

@@ -372,7 +372,7 @@ public class CombatUtil {
String parse = attacker.getKeyword().get(KeywordPosition).toString();
String k[] = parse.split(" ", 2);
final String restrictions[] = k[1].split(",");
if (blocker.isValidCard(restrictions, attacker.getController(), attacker))
if (blocker.isValid(restrictions, attacker.getController(), attacker))
return false;
}
@@ -381,7 +381,7 @@ public class CombatUtil {
String parse = blocker.getKeyword().get(KeywordPosition).toString();
String k[] = parse.split(" ", 2);
final String restrictions[] = k[1].split(",");
if (attacker.isValidCard(restrictions, blocker.getController(), blocker))
if (attacker.isValid(restrictions, blocker.getController(), blocker))
return false;
}
@@ -1187,8 +1187,8 @@ public class CombatUtil {
if (abilityParams.containsKey("Defined") && abilityParams.get("Defined").equals("TriggeredAttacker"))
list.add(attacker);
if (abilityParams.containsKey("ValidCards"))
if (attacker.isValidCard(abilityParams.get("ValidCards").split(","), source.getController(), source)
|| attacker.isValidCard(abilityParams.get("ValidCards").replace("attacking+", "").split(",")
if (attacker.isValid(abilityParams.get("ValidCards").split(","), source.getController(), source)
|| attacker.isValid(abilityParams.get("ValidCards").replace("attacking+", "").split(",")
, source.getController(), source))
list.add(attacker);
if (list.isEmpty()) continue;
@@ -1265,8 +1265,8 @@ public class CombatUtil {
if (abilityParams.containsKey("Defined") && abilityParams.get("Defined").equals("TriggeredAttacker"))
list.add(attacker);
if (abilityParams.containsKey("ValidCards"))
if (attacker.isValidCard(abilityParams.get("ValidCards").split(","), source.getController(), source)
|| attacker.isValidCard(abilityParams.get("ValidCards").replace("attacking+", "").split(",")
if (attacker.isValid(abilityParams.get("ValidCards").split(","), source.getController(), source)
|| attacker.isValid(abilityParams.get("ValidCards").replace("attacking+", "").split(",")
, source.getController(), source))
list.add(attacker);
if (list.isEmpty()) continue;

View File

@@ -101,7 +101,7 @@ public class ComputerAI_General implements Computer {
if (buffedcard.getSVar("BuffedBy").length() > 0) {
String buffedby = buffedcard.getSVar("BuffedBy");
String[] bffdby = buffedby.split(",");
if (c.isValidCard(bffdby, c.getController(), c)) {
if (c.isValid(bffdby, c.getController(), c)) {
return true;
}
}
@@ -114,7 +114,7 @@ public class ComputerAI_General implements Computer {
if (buffedcard.getSVar("AntiBuffedBy").length() > 0) {
String buffedby = buffedcard.getSVar("AntiBuffedBy");
String[] bffdby = buffedby.split(",");
if (c.isValidCard(bffdby, c.getController(), c)) {
if (c.isValid(bffdby, c.getController(), c)) {
return true;
}
}

View File

@@ -745,13 +745,13 @@ public class GameAction {
if (entity instanceof Card){
Card perm = (Card)entity;
// I think the Keyword checks might be superfluous with the isValidCard check
// I think the Keyword checks might be superfluous with the isValid check
if (!AllZoneUtil.isCardInPlay(perm)
|| CardFactoryUtil.hasProtectionFrom(c, perm)
|| ((c.hasKeyword("Enchant creature") || c.hasKeyword("Enchant tapped creature"))
&& !perm.isCreature())
|| (c.hasKeyword("Enchant tapped creature") && perm.isUntapped())
|| (tgt != null && !perm.isValidCard(tgt.getValidTgts(), c.getController(), c))){
|| (tgt != null && !perm.isValid(tgt.getValidTgts(), c.getController(), c))){
c.unEnchantEntity(perm);
moveToGraveyard(c);
checkAgain = true;

View File

@@ -222,7 +222,7 @@ public abstract class GameEntity extends MyObservable {
}
return false;
}//isValidCard
}//isValid
public boolean isValid(final String Restriction, final Player sourceController, final Card source) {
return false;

View File

@@ -281,7 +281,7 @@ public class PhaseUtil {
String k[] = parse.split(":");
final String restrictions[] = k[1].split(",");
final Card card = ca;
if (c.isValidCard(restrictions, card.getController(), card)) return false;
if (c.isValid(restrictions, card.getController(), card)) return false;
}
} // end of Permanents don't untap during their controllers' untap steps

View File

@@ -900,7 +900,7 @@ public class Upkeep implements java.io.Serializable {
// We do not want to slow down the pace of the game by asking too many questions.
// Dialogs outside of the Ability appear at the previous end of turn phase !!!
if (peek[0].isValidCard(shareTypes, k.getController(), k)) {
if (peek[0].isValid(shareTypes, k.getController(), k)) {
if (player.isHuman()) {
StringBuilder question = new StringBuilder();
question.append("Your top card is ").append(peek[0].getName());
@@ -980,7 +980,7 @@ public class Upkeep implements java.io.Serializable {
// We do not want to slow down the pace of the game by asking too many questions.
// Dialogs outside of the Ability appear at the previous end of turn phase !!!
if (peek[0].isValidCard(shareTypes, k.getController(), k)) {
if (peek[0].isValid(shareTypes, k.getController(), k)) {
if (player.isHuman()) {
StringBuilder question = new StringBuilder();
question.append("Your top card is ").append(peek[0].getName());
@@ -1075,7 +1075,7 @@ public class Upkeep implements java.io.Serializable {
// We do not want to slow down the pace of the game by asking too many questions.
// Dialogs outside of the Ability appear at the previous end of turn phase !!!
if (peek[0].isValidCard(shareTypes, k.getController(), k)) {
if (peek[0].isValid(shareTypes, k.getController(), k)) {
if (player.isHuman()) {
StringBuilder question = new StringBuilder();
question.append("Your top card is ").append(peek[0].getName());
@@ -1169,7 +1169,7 @@ public class Upkeep implements java.io.Serializable {
// We do not want to slow down the pace of the game by asking too many questions.
// Dialogs outside of the Ability appear at the previous end of turn phase !!!
if (peek[0].isValidCard(shareTypes, k.getController(), k)) {
if (peek[0].isValid(shareTypes, k.getController(), k)) {
if (player.isHuman()) {
StringBuilder question = new StringBuilder();
question.append("Your top card is ").append(peek[0].getName());
@@ -1260,7 +1260,7 @@ public class Upkeep implements java.io.Serializable {
// We do not want to slow down the pace of the game by asking too many questions.
// Dialogs outside of the Ability appear at the previous end of turn phase !!!
if (peek[0].isValidCard(shareTypes, k.getController(), k)) {
if (peek[0].isValid(shareTypes, k.getController(), k)) {
if (player.isHuman()) {
StringBuilder question = new StringBuilder();
question.append("Your top card is ").append(peek[0].getName());
@@ -1347,7 +1347,7 @@ public class Upkeep implements java.io.Serializable {
// We do not want to slow down the pace of the game by asking too many questions.
// Dialogs outside of the Ability appear at the previous end of turn phase !!!
if (peek[0].isValidCard(shareTypes, k.getController(), k)) {
if (peek[0].isValid(shareTypes, k.getController(), k)) {
if (player.isHuman()) {
StringBuilder question = new StringBuilder();
question.append("Your top card is ").append(peek[0].getName());
@@ -1433,7 +1433,7 @@ public class Upkeep implements java.io.Serializable {
// We do not want to slow down the pace of the game by asking too many questions.
// Dialogs outside of the Ability appear at the previous end of turn phase !!!
if (peek[0].isValidCard(shareTypes, k.getController(), k)) {
if (peek[0].isValid(shareTypes, k.getController(), k)) {
if (player.isHuman()) {
StringBuilder question = new StringBuilder();
question.append("Your top card is ").append(peek[0].getName());
@@ -1518,7 +1518,7 @@ public class Upkeep implements java.io.Serializable {
// We do not want to slow down the pace of the game by asking too many questions.
// Dialogs outside of the Ability appear at the previous end of turn phase !!!
if (peek[0].isValidCard(shareTypes, k.getController(), k)) {
if (peek[0].isValid(shareTypes, k.getController(), k)) {
if (player.isHuman()) {
StringBuilder question = new StringBuilder();
question.append("Your top card is ").append(peek[0].getName());
@@ -1597,7 +1597,7 @@ public class Upkeep implements java.io.Serializable {
// We do not want to slow down the pace of the game by asking too many questions.
// Dialogs outside of the Ability appear at the previous end of turn phase !!!
if (peek[0].isValidCard(shareTypes, k.getController(), k)) {
if (peek[0].isValid(shareTypes, k.getController(), k)) {
if (player.isHuman()) {
StringBuilder question = new StringBuilder();
question.append("Your top card is ").append(peek[0].getName());
@@ -1675,7 +1675,7 @@ public class Upkeep implements java.io.Serializable {
// We do not want to slow down the pace of the game by asking too many questions.
// Dialogs outside of the Ability appear at the previous end of turn phase !!!
if (peek[0].isValidCard(shareTypes, k.getController(), k)) {
if (peek[0].isValid(shareTypes, k.getController(), k)) {
if (player.isHuman()) {
StringBuilder question = new StringBuilder();
question.append("Your top card is ").append(peek[0].getName());
@@ -1773,7 +1773,7 @@ public class Upkeep implements java.io.Serializable {
// We do not want to slow down the pace of the game by asking too many questions.
// Dialogs outside of the Ability appear at the previous end of turn phase !!!
if (peek[0].isValidCard(shareTypes, k.getController(), k)) {
if (peek[0].isValid(shareTypes, k.getController(), k)) {
if (player.isHuman()) {
StringBuilder question = new StringBuilder();
question.append("Your top card is ").append(peek[0].getName());
@@ -1851,7 +1851,7 @@ public class Upkeep implements java.io.Serializable {
// We do not want to slow down the pace of the game by asking too many questions.
// Dialogs outside of the Ability appear at the previous end of turn phase !!!
if (peek[0].isValidCard(shareTypes, k.getController(), k)) {
if (peek[0].isValid(shareTypes, k.getController(), k)) {
if (player.isHuman()) {
StringBuilder question = new StringBuilder();
question.append("Your top card is ").append(peek[0].getName());

View File

@@ -2326,7 +2326,7 @@ public class CardFactoryUtil {
// Reconfirm the Validity of a TgtValid, or if the Creature is still
// a Creature
if (tgt.doesTarget()
&& !target.isValidCard(tgt.getValidTgts(), ability.getActivatingPlayer(), ability.getSourceCard()))
&& !target.isValid(tgt.getValidTgts(), ability.getActivatingPlayer(), ability.getSourceCard()))
{
return false;
}
@@ -2551,10 +2551,10 @@ public class CardFactoryUtil {
return true;
}
if (kw.startsWith("Protection:")) { // uses isValidCard
if (kw.startsWith("Protection:")) { // uses isValid
String characteristic = kw.split(":")[1];
String[] characteristics = characteristic.split(",");
if (card.isValidCard(characteristics, card.getController(), card)) {
if (card.isValid(characteristics, card.getController(), card)) {
return true;
}
}
@@ -3102,7 +3102,7 @@ public class CardFactoryUtil {
cl = cl.filter(new CardListFilter() {
public boolean addCard(final Card cdev) {
return cdev.isValidCard(validDevoured.split(","), csource.getController(), csource);
return cdev.isValid(validDevoured.split(","), csource.getController(), csource);
}
});
@@ -3750,7 +3750,7 @@ public class CardFactoryUtil {
String[] k = parse.split(":");
String[] restrictions = k[1].split(",");
if (!c.isValidCard(restrictions, card.getController(), card)) {
if (!c.isValid(restrictions, card.getController(), card)) {
continue;
}

View File

@@ -485,7 +485,7 @@ public class Target {
}
for (Card c : AllZoneUtil.getCardsIn(tgtZone)){
if (c.isValidCard(ValidTgts, srcCard.getController(), srcCard) && (!isTargeted || CardFactoryUtil.canTarget(srcCard, c))) {
if (c.isValid(ValidTgts, srcCard.getController(), srcCard) && (!isTargeted || CardFactoryUtil.canTarget(srcCard, c))) {
return true;
}
}

View File

@@ -465,7 +465,7 @@ public class Target_Selection {
Player activatingPlayer = sa.getActivatingPlayer();
if (o instanceof Card) {
Card c = (Card) o;
return c.isValidCard(valids, activatingPlayer, srcCard);
return c.isValid(valids, activatingPlayer, srcCard);
}
if (o instanceof Player) {
@@ -485,7 +485,7 @@ public class Target_Selection {
if (o instanceof SpellAbility) {
Card c = ((SpellAbility) o).getSourceCard();
return c.isValidCard(valids, activatingPlayer, srcCard);
return c.isValid(valids, activatingPlayer, srcCard);
}
return false;

View File

@@ -196,7 +196,7 @@ public class StaticAbility {
if (mapParams.containsKey("TopCardOfLibraryIs")) {
Card topCard = controller.getCardsIn(Zone.Library).get(0);
if (!topCard.isValidCard(mapParams.get("TopCardOfLibraryIs").split(","), controller, hostCard))
if (!topCard.isValid(mapParams.get("TopCardOfLibraryIs").split(","), controller, hostCard))
return false;
}

View File

@@ -458,7 +458,7 @@ public abstract class Trigger {
public boolean matchesValid(Object o, String[] valids, Card srcCard) {
if (o instanceof Card) {
Card c = (Card) o;
return c.isValidCard(valids, srcCard.getController(), srcCard);
return c.isValid(valids, srcCard.getController(), srcCard);
}
if (o instanceof Player) {

View File

@@ -30,7 +30,7 @@ public class Trigger_Championed extends Trigger {
Card championed = (Card) runParams2.get("Championed");
if (mapParams.containsKey("ValidCard")) {
if (!championed.isValidCard(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
if (!championed.isValid(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
return false;
}
}

View File

@@ -47,7 +47,7 @@ public class Trigger_ChangesZone extends Trigger {
if (mapParams.containsKey("ValidCard")) {
Card moved = (Card) runParams2.get("Card");
if (!moved.isValidCard(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
if (!moved.isValid(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
return false;
}
}

View File

@@ -31,7 +31,7 @@ public class Trigger_CounterAdded extends Trigger {
Counters addedType = (Counters) runParams2.get("CounterType");
if (mapParams.containsKey("ValidCard")) {
if (!addedTo.isValidCard(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
if (!addedTo.isValid(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
return false;
}
}

View File

@@ -31,7 +31,7 @@ public class Trigger_DamageDone extends Trigger {
Object tgt = runParams2.get("DamageTarget");
if (mapParams.containsKey("ValidSource")) {
if (!src.isValidCard(mapParams.get("ValidSource").split(","), hostCard.getController(), hostCard)) {
if (!src.isValid(mapParams.get("ValidSource").split(","), hostCard.getController(), hostCard)) {
return false;
}
}

View File

@@ -29,7 +29,7 @@ public class Trigger_Drawn extends Trigger {
Card draw = ((Card) runParams2.get("Card"));
if (mapParams.containsKey("ValidCard")) {
if (!draw.isValidCard(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
if (!draw.isValid(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
return false;
}
}

View File

@@ -33,7 +33,7 @@ public class Trigger_Sacrificed extends Trigger {
}
}
if (mapParams.containsKey("ValidCard")) {
if (!sac.isValidCard(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
if (!sac.isValid(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
return false;
}
}

View File

@@ -103,7 +103,7 @@ public class Trigger_SpellAbilityCast extends Trigger {
if (sa.getTarget().doesTarget()) {
boolean validTgtFound = false;
for (Card tgt : sa.getTarget().getTargetCards()) {
if (tgt.isValidCard(mapParams.get("TargetsValid").split(","), hostCard.getController(), hostCard)) {
if (tgt.isValid(mapParams.get("TargetsValid").split(","), hostCard.getController(), hostCard)) {
validTgtFound = true;
break;
}

View File

@@ -30,7 +30,7 @@ public class Trigger_Taps extends Trigger {
Card tapper = (Card) runParams2.get("Card");
if (mapParams.containsKey("ValidCard")) {
if (!tapper.isValidCard(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
if (!tapper.isValid(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
return false;
}
}

View File

@@ -29,7 +29,7 @@ public class Trigger_TapsForMana extends Trigger {
Card tapper = (Card) runParams2.get("Card");
if (mapParams.containsKey("ValidCard")) {
if (!tapper.isValidCard(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
if (!tapper.isValid(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
return false;
}
}

View File

@@ -30,13 +30,13 @@ public class Trigger_Unequip extends Trigger {
Card equipment = (Card) runParams2.get("Equipment");
if (mapParams.containsKey("ValidCard")) {
if (!equipped.isValidCard(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
if (!equipped.isValid(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
return false;
}
}
if (mapParams.containsKey("ValidEquipment")) {
if (!equipment.isValidCard(mapParams.get("ValidEquipment").split(","), hostCard.getController(), hostCard)) {
if (!equipment.isValid(mapParams.get("ValidEquipment").split(","), hostCard.getController(), hostCard)) {
return false;
}
}

View File

@@ -29,7 +29,7 @@ public class Trigger_Untaps extends Trigger {
Card untapper = (Card) runParams2.get("Card");
if (mapParams.containsKey("ValidCard")) {
if (!untapper.isValidCard(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
if (!untapper.isValid(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
return false;
}
}