- Added the boolean function "isInZone" to the card class. It should be a performance upgrade to "AllZone.getZoneOf(c).equals(zone)".

This commit is contained in:
Sloth
2011-11-01 15:58:05 +00:00
parent 7530ddcc30
commit 311af14ac9
3 changed files with 24 additions and 2 deletions

View File

@@ -496,6 +496,25 @@ public final class AllZone implements NewConstants {
return null;
}
public static boolean isCardInZone(final Card c, Constant.Zone zone) {
final FGameState gameState = Singletons.getModel().getGameState();
if (gameState == null) {
return false;
}
if (zone.equals(Constant.Zone.Stack) && gameState.getStackZone().contains(c)) {
return true;
}
else for (Player p : gameState.getPlayers()) {
if(p.getZone(zone).contains(c)) {
return true;
}
}
return false;
}
/**
* <p>
* resetZoneMoveTracking.

View File

@@ -8092,4 +8092,8 @@ public class Card extends GameEntity implements Comparable<Card> {
return false;
}
public boolean isInZone(final Constant.Zone zone) {
return AllZone.isCardInZone(this, zone);
}
} // end Card class

View File

@@ -303,8 +303,7 @@ public class StaticAbility {
effectZone = Zone.smartValueOf(this.mapParams.get("EffectZone"));
}
if ((effectZone != null)
&& (!AllZone.getZoneOf(this.hostCard).getZoneType().equals(effectZone) || this.hostCard.isPhasedOut())) {
if ((effectZone != null) && (!this.hostCard.isInZone(effectZone) || this.hostCard.isPhasedOut())) {
return false;
}