* Phasing- Fixed that permanets with phasing did not phase out at controllers untap step and phased out permanents where count as on the battlefield.

This commit is contained in:
LevelX2 2014-11-23 13:00:58 +01:00
parent bf3fa37e5d
commit fb2d367992
5 changed files with 28 additions and 18 deletions

View file

@ -124,6 +124,9 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
List<PermanentView> 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<Entry<UUID, MagePermanent>> iterator = permanents.entrySet().iterator(); iterator.hasNext();) {
Entry<UUID, MagePermanent> 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;

View file

@ -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 <i>(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.)</i>";
}
@Override

View file

@ -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<UUID> 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<UUID> 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;

View file

@ -401,6 +401,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
if (!phasedIn) {
if (!replaceEvent(EventType.PHASE_IN, game)) {
this.phasedIn = true;
game.informPlayers(getLogName() + " phased in");
fireEvent(EventType.PHASED_IN, game);
return true;
}
@ -413,6 +414,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
if (phasedIn) {
if (!replaceEvent(EventType.PHASE_OUT, game)) {
this.phasedIn = false;
game.informPlayers(getLogName() + " phased out");
fireEvent(EventType.PHASED_OUT, game);
return true;
}

View file

@ -1247,10 +1247,11 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override
public void phasing(Game game) {
//20091005 - 502.1
List<Permanent> 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);
}
}