From fb2d36799237ea7065fb2773eeb87ee16b7d4ec4 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 23 Nov 2014 13:00:58 +0100 Subject: [PATCH] * Phasing- Fixed that permanets with phasing did not phase out at controllers untap step and phased out permanents where count as on the battlefield. --- .../mage/client/game/BattlefieldPanel.java | 5 +++- .../abilities/keyword/PhasingAbility.java | 7 +++--- Mage/src/mage/game/permanent/Battlefield.java | 25 +++++++++++-------- .../mage/game/permanent/PermanentImpl.java | 6 +++-- Mage/src/mage/players/PlayerImpl.java | 3 ++- 5 files changed, 28 insertions(+), 18 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/game/BattlefieldPanel.java b/Mage.Client/src/main/java/mage/client/game/BattlefieldPanel.java index d5ac6cebfb..393f15d814 100644 --- a/Mage.Client/src/main/java/mage/client/game/BattlefieldPanel.java +++ b/Mage.Client/src/main/java/mage/client/game/BattlefieldPanel.java @@ -124,6 +124,9 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane { List permanentsToAdd = new ArrayList<>(); for (PermanentView permanent: battlefield.values()) { + if (!permanent.isPhasedIn()) { + continue; + } MagePermanent oldMagePermanent = permanents.get(permanent.getId()); if (oldMagePermanent == null) { permanentsToAdd.add(permanent); @@ -193,7 +196,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane { for (Iterator> iterator = permanents.entrySet().iterator(); iterator.hasNext();) { Entry entry = iterator.next(); - if (!battlefield.containsKey(entry.getKey())) { + if (!battlefield.containsKey(entry.getKey()) || !battlefield.get(entry.getKey()).isPhasedIn()) { removePermanent(entry.getKey(), 1); iterator.remove(); changed = true; diff --git a/Mage/src/mage/abilities/keyword/PhasingAbility.java b/Mage/src/mage/abilities/keyword/PhasingAbility.java index 52342fc55c..7dbb750975 100644 --- a/Mage/src/mage/abilities/keyword/PhasingAbility.java +++ b/Mage/src/mage/abilities/keyword/PhasingAbility.java @@ -28,11 +28,10 @@ package mage.abilities.keyword; -import mage.constants.Zone; +import java.io.ObjectStreamException; import mage.abilities.MageSingleton; import mage.abilities.StaticAbility; - -import java.io.ObjectStreamException; +import mage.constants.Zone; /** * @@ -56,7 +55,7 @@ public class PhasingAbility extends StaticAbility implements MageSingleton { @Override public String getRule() { - return "Phasing"; + return "Phasing (This phases in or out before you untap during each of your untap steps. While it's phased out, it's treated as though it doesn't exist.)"; } @Override diff --git a/Mage/src/mage/game/permanent/Battlefield.java b/Mage/src/mage/game/permanent/Battlefield.java index c8f24c097d..e44a9c59f7 100644 --- a/Mage/src/mage/game/permanent/Battlefield.java +++ b/Mage/src/mage/game/permanent/Battlefield.java @@ -29,15 +29,20 @@ package mage.game.permanent; import java.io.Serializable; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; +import java.util.Set; +import java.util.UUID; +import mage.abilities.keyword.PhasingAbility; import mage.constants.CardType; import mage.constants.RangeOfInfluence; -import mage.abilities.keyword.PhasingAbility; import mage.filter.FilterPermanent; import mage.game.Game; - /** * * @author BetaSteward_at_googlemail.com @@ -82,7 +87,7 @@ public class Battlefield implements Serializable { public int countAll(FilterPermanent filter, UUID controllerId, Game game) { int count = 0; for (Permanent permanent: field.values()) { - if (permanent.getControllerId().equals(controllerId) && filter.match(permanent, game)) { + if (permanent.getControllerId().equals(controllerId) && filter.match(permanent, game) && permanent.isPhasedIn()) { count++; } } @@ -104,7 +109,7 @@ public class Battlefield implements Serializable { int count = 0; if (game.getRangeOfInfluence() == RangeOfInfluence.ALL) { for (Permanent permanent: field.values()) { - if (filter.match(permanent, sourceId, sourcePlayerId, game)) { + if (filter.match(permanent, sourceId, sourcePlayerId, game) && permanent.isPhasedIn()) { count++; } } @@ -112,7 +117,7 @@ public class Battlefield implements Serializable { else { Set range = game.getPlayer(sourcePlayerId).getInRange(); for (Permanent permanent: field.values()) { - if (range.contains(permanent.getControllerId()) && filter.match(permanent, sourceId, sourcePlayerId, game)) { + if (range.contains(permanent.getControllerId()) && filter.match(permanent, sourceId, sourcePlayerId, game) && permanent.isPhasedIn()) { count++; } } @@ -133,7 +138,7 @@ public class Battlefield implements Serializable { public boolean contains(FilterPermanent filter, int num, Game game) { int count = 0; for (Permanent permanent: field.values()) { - if (filter.match(permanent, game)) { + if (filter.match(permanent, game) && permanent.isPhasedIn()) { count++; if (num == count) { return true; @@ -157,7 +162,7 @@ public class Battlefield implements Serializable { public boolean contains(FilterPermanent filter, UUID controllerId, int num, Game game) { int count = 0; for (Permanent permanent: field.values()) { - if (permanent.getControllerId().equals(controllerId) && filter.match(permanent, game)) { + if (permanent.getControllerId().equals(controllerId) && filter.match(permanent, game) && permanent.isPhasedIn()) { count++; if (num == count) { return true; @@ -182,7 +187,7 @@ public class Battlefield implements Serializable { int count = 0; if (game.getRangeOfInfluence() == RangeOfInfluence.ALL) { for (Permanent permanent: field.values()) { - if (filter.match(permanent, null, sourcePlayerId, game)) { + if (filter.match(permanent, null, sourcePlayerId, game) && permanent.isPhasedIn()) { count++; if (num == count) { return true; @@ -193,7 +198,7 @@ public class Battlefield implements Serializable { else { Set range = game.getPlayer(sourcePlayerId).getInRange(); for (Permanent permanent: field.values()) { - if (range.contains(permanent.getControllerId()) && filter.match(permanent, null, sourcePlayerId, game)) { + if (range.contains(permanent.getControllerId()) && filter.match(permanent, null, sourcePlayerId, game) && permanent.isPhasedIn()) { count++; if (num == count) { return true; diff --git a/Mage/src/mage/game/permanent/PermanentImpl.java b/Mage/src/mage/game/permanent/PermanentImpl.java index fc48828b4c..1512e5b4d1 100644 --- a/Mage/src/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/mage/game/permanent/PermanentImpl.java @@ -401,7 +401,8 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { if (!phasedIn) { if (!replaceEvent(EventType.PHASE_IN, game)) { this.phasedIn = true; - fireEvent(EventType.PHASED_IN, game); + game.informPlayers(getLogName() + " phased in"); + fireEvent(EventType.PHASED_IN, game); return true; } } @@ -413,7 +414,8 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { if (phasedIn) { if (!replaceEvent(EventType.PHASE_OUT, game)) { this.phasedIn = false; - fireEvent(EventType.PHASED_OUT, game); + game.informPlayers(getLogName() + " phased out"); + fireEvent(EventType.PHASED_OUT, game); return true; } } diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index 2cef90f5bc..a4ec9a05e3 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -1247,10 +1247,11 @@ public abstract class PlayerImpl implements Player, Serializable { @Override public void phasing(Game game) { //20091005 - 502.1 + List phasedOut = game.getBattlefield().getPhasedOut(playerId); for (Permanent permanent: game.getBattlefield().getPhasedIn(playerId)) { permanent.phaseOut(game); } - for (Permanent permanent: game.getBattlefield().getPhasedOut(playerId)) { + for (Permanent permanent: phasedOut) { permanent.phaseIn(game); } }