mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- Cleanup and performance updates in AllZoneUtil.
This commit is contained in:
@@ -178,7 +178,12 @@ public abstract class AllZoneUtil {
|
||||
* @return true is the card is in play, false otherwise
|
||||
*/
|
||||
public static boolean isCardInPlay(final String cardName) {
|
||||
return AllZoneUtil.getCardsIn(Zone.Battlefield, cardName).size() > 0;
|
||||
for (Card card : AllZoneUtil.getCardsIn(Zone.Battlefield)) {
|
||||
if (card.getName() == cardName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,7 +196,12 @@ public abstract class AllZoneUtil {
|
||||
* @return true if that player has that card in play, false otherwise
|
||||
*/
|
||||
public static boolean isCardInPlay(final String cardName, final Player player) {
|
||||
return player.getCardsIn(Zone.Battlefield, cardName).size() > 0;
|
||||
for (Card card : player.getCardsIn(Zone.Battlefield)) {
|
||||
if (card.getName() == cardName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ////////////// getting all cards of a given color
|
||||
@@ -300,15 +310,9 @@ public abstract class AllZoneUtil {
|
||||
for (final Player player : AllZone.getPlayersInGame()) {
|
||||
all.addAll(player.getZone(Zone.Graveyard).getCards());
|
||||
all.addAll(player.getZone(Zone.Hand).getCards());
|
||||
all.addAll(player.getZone(Zone.Library).getCards()); // not sure if
|
||||
// library
|
||||
// should be
|
||||
// included.
|
||||
all.addAll(player.getZone(Zone.Library).getCards());
|
||||
all.addAll(player.getZone(Zone.Battlefield).getCards(false));
|
||||
all.addAll(player.getZone(Zone.Exile).getCards()); // Spawnsire of
|
||||
// Ulamog plays
|
||||
// spells from
|
||||
// here?
|
||||
all.addAll(player.getZone(Zone.Exile).getCards());
|
||||
}
|
||||
all.addAll(AllZone.getStackZone().getCards());
|
||||
return all;
|
||||
@@ -411,13 +415,13 @@ public abstract class AllZoneUtil {
|
||||
* a {@link forge.Card} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public static boolean matchesValid(final Object o, final String[] valids, final Card srcCard) {
|
||||
/*public static boolean matchesValid(final Object o, final String[] valids, final Card srcCard) {
|
||||
if (o instanceof GameEntity) {
|
||||
final GameEntity c = (GameEntity) o;
|
||||
return c.isValid(valids, srcCard.getController(), srcCard);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
} // end class AllZoneUtil
|
||||
|
||||
@@ -49,12 +49,12 @@ public class ReplaceDamage extends ReplacementEffect {
|
||||
return false;
|
||||
}
|
||||
if (getMapParams().containsKey("ValidSource")) {
|
||||
if (!AllZoneUtil.matchesValid(runParams.get("DamageSource"), getMapParams().get("ValidSource").split(","), getHostCard())) {
|
||||
if (!matchesValid(runParams.get("DamageSource"), getMapParams().get("ValidSource").split(","), getHostCard())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (getMapParams().containsKey("ValidTarget")) {
|
||||
if (!AllZoneUtil.matchesValid(runParams.get("Affected"), getMapParams().get("ValidTarget").split(","), getHostCard())) {
|
||||
if (!matchesValid(runParams.get("Affected"), getMapParams().get("ValidTarget").split(","), getHostCard())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package forge.card.replacement;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
|
||||
/**
|
||||
@@ -47,7 +46,7 @@ public class ReplaceDraw extends ReplacementEffect {
|
||||
return false;
|
||||
}
|
||||
if (this.getMapParams().containsKey("ValidPlayer")) {
|
||||
if (!AllZoneUtil.matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidPlayer").split(","), this.getHostCard())) {
|
||||
if (!matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidPlayer").split(","), this.getHostCard())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package forge.card.replacement;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
|
||||
@@ -48,7 +47,7 @@ public class ReplaceGainLife extends ReplacementEffect {
|
||||
return false;
|
||||
}
|
||||
if (this.getMapParams().containsKey("ValidPlayer")) {
|
||||
if (!AllZoneUtil.matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidPlayer").split(","), this.getHostCard())) {
|
||||
if (!matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidPlayer").split(","), this.getHostCard())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package forge.card.replacement;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
|
||||
@@ -31,7 +30,7 @@ public class ReplaceGameLoss extends ReplacementEffect {
|
||||
return false;
|
||||
}
|
||||
if (this.getMapParams().containsKey("ValidPlayer")) {
|
||||
if (!AllZoneUtil.matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidPlayer").split(","), this.getHostCard())) {
|
||||
if (!matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidPlayer").split(","), this.getHostCard())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package forge.card.replacement;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import forge.AllZoneUtil;
|
||||
import forge.Card;
|
||||
import forge.Constant.Zone;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -32,7 +31,7 @@ public class ReplaceMoved extends ReplacementEffect {
|
||||
return false;
|
||||
}
|
||||
if (this.getMapParams().containsKey("ValidCard")) {
|
||||
if (!AllZoneUtil.matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidCard").split(","), this.getHostCard())) {
|
||||
if (!matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidCard").split(","), this.getHostCard())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user