- Replaced some unnecessary uses of getZoneOf.

This commit is contained in:
Sloth
2011-11-01 16:17:35 +00:00
parent 8d8dd1361e
commit 3040891eb8
7 changed files with 17 additions and 13 deletions

View File

@@ -59,8 +59,9 @@ public class DefaultPlayerZone extends PlayerZone implements java.io.Serializabl
// don't want to log those. // don't want to log those.
if (!c.isImmutable()) { if (!c.isImmutable()) {
this.cardsAddedThisTurn.add(c); this.cardsAddedThisTurn.add(c);
if (AllZone.getZoneOf(c) != null) { PlayerZone zone = AllZone.getZoneOf(c);
this.cardsAddedThisTurnSource.add(AllZone.getZoneOf(c).getZoneType()); if (zone != null) {
this.cardsAddedThisTurnSource.add(zone.getZoneType());
} else { } else {
this.cardsAddedThisTurnSource.add(null); this.cardsAddedThisTurnSource.add(null);
} }
@@ -117,8 +118,9 @@ public class DefaultPlayerZone extends PlayerZone implements java.io.Serializabl
// don't want to log those. // don't want to log those.
if (!c.isImmutable()) { if (!c.isImmutable()) {
this.cardsAddedThisTurn.add(c); this.cardsAddedThisTurn.add(c);
if (AllZone.getZoneOf(c) != null) { PlayerZone zone = AllZone.getZoneOf(c);
this.cardsAddedThisTurnSource.add(AllZone.getZoneOf(c).getZoneType()); if (zone != null) {
this.cardsAddedThisTurnSource.add(zone.getZoneType());
} else { } else {
this.cardsAddedThisTurnSource.add(null); this.cardsAddedThisTurnSource.add(null);
} }

View File

@@ -160,8 +160,8 @@ public class MagicStack extends MyObservable {
// on the stack zone, move there // on the stack zone, move there
if (ability.isSpell()) { if (ability.isSpell()) {
final Card source = ability.getSourceCard(); final Card source = ability.getSourceCard();
if (!source.isCopiedSpell() && !AllZone.getZoneOf(source).is(Constant.Zone.Stack)) { if (!source.isCopiedSpell() && !source.isInZone(Constant.Zone.Stack)) {
//ability.setSourceCard(AllZone.getGameAction().moveToStack(source)); ability.setSourceCard(AllZone.getGameAction().moveToStack(source));
} }
} }
@@ -957,7 +957,7 @@ public class MagicStack extends MyObservable {
// If Spell and still on the Stack then let it goto the graveyard or // If Spell and still on the Stack then let it goto the graveyard or
// replace its own movement // replace its own movement
else if (!source.isCopiedSpell() && (source.isInstant() || source.isSorcery() || fizzle) else if (!source.isCopiedSpell() && (source.isInstant() || source.isSorcery() || fizzle)
&& AllZone.getZoneOf(source).is(Constant.Zone.Stack)) { && source.isInZone(Constant.Zone.Stack)) {
AllZone.getGameAction().moveToGraveyard(source); AllZone.getGameAction().moveToGraveyard(source);
} }
} }

View File

@@ -2386,7 +2386,7 @@ public class CardFactoryUtil {
} else { } else {
// If an Aura's target is removed before it resolves, the Aura // If an Aura's target is removed before it resolves, the Aura
// fizzles // fizzles
if (source.isAura() && !AllZone.getZoneOf(target).is(Constant.Zone.Battlefield)) { if (source.isAura() && !target.isInZone(Constant.Zone.Battlefield)) {
return false; return false;
} }
} }

View File

@@ -96,7 +96,7 @@ public class CostDiscard extends CostPartWithList {
final Integer amount = this.convertAmount(); final Integer amount = this.convertAmount();
if (this.getThis()) { if (this.getThis()) {
if (!AllZone.getZoneOf(source).is(Constant.Zone.Hand)) { if (!source.isInZone(Constant.Zone.Hand)) {
return false; return false;
} }
} else if (type.equals("Hand")) { } else if (type.equals("Hand")) {

View File

@@ -48,7 +48,7 @@ public class CostReveal extends CostPartWithList {
final Integer amount = this.convertAmount(); final Integer amount = this.convertAmount();
if (this.getThis()) { if (this.getThis()) {
if (!AllZone.getZoneOf(source).is(Constant.Zone.Hand)) { if (!source.isInZone(Constant.Zone.Hand)) {
return false; return false;
} }
} else { } else {

View File

@@ -286,7 +286,7 @@ public class Spell_Permanent extends Spell {
} }
final CardList cl = (CardList) this.championGetCreature.execute(); final CardList cl = (CardList) this.championGetCreature.execute();
if ((o == null) || !(cl.size() > 0) || !AllZone.getZoneOf(this.getSourceCard()).is(Constant.Zone.Hand)) { if ((o == null) || !(cl.size() > 0) || !this.getSourceCard().isInZone(Constant.Zone.Hand)) {
return false; return false;
} }
} }

View File

@@ -12,6 +12,7 @@ import forge.CardList;
import forge.CardUtil; import forge.CardUtil;
import forge.Constant.Zone; import forge.Constant.Zone;
import forge.Player; import forge.Player;
import forge.PlayerZone;
import forge.card.abilityFactory.AbilityFactory; import forge.card.abilityFactory.AbilityFactory;
import forge.card.cardFactory.CardFactoryUtil; import forge.card.cardFactory.CardFactoryUtil;
import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbility;
@@ -292,13 +293,14 @@ public abstract class Trigger {
public final boolean zonesCheck() { public final boolean zonesCheck() {
if (mapParams.containsKey("TriggerZones")) { if (mapParams.containsKey("TriggerZones")) {
List<Zone> triggerZones = new ArrayList<Zone>(); List<Zone> triggerZones = new ArrayList<Zone>();
PlayerZone zone = AllZone.getZoneOf(hostCard);
for (String s : mapParams.get("TriggerZones").split(",")) { for (String s : mapParams.get("TriggerZones").split(",")) {
triggerZones.add(Zone.smartValueOf(s)); triggerZones.add(Zone.smartValueOf(s));
} }
if (AllZone.getZoneOf(hostCard) == null) { if (zone == null) {
return false; return false;
} }
if (!triggerZones.contains(AllZone.getZoneOf(hostCard).getZoneType()) || hostCard.isPhasedOut()) { if (!triggerZones.contains(zone.getZoneType()) || hostCard.isPhasedOut()) {
return false; return false;
} }
} }