mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
* 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:
parent
bf3fa37e5d
commit
fb2d367992
5 changed files with 28 additions and 18 deletions
|
@ -124,6 +124,9 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
||||||
|
|
||||||
List<PermanentView> permanentsToAdd = new ArrayList<>();
|
List<PermanentView> permanentsToAdd = new ArrayList<>();
|
||||||
for (PermanentView permanent: battlefield.values()) {
|
for (PermanentView permanent: battlefield.values()) {
|
||||||
|
if (!permanent.isPhasedIn()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
MagePermanent oldMagePermanent = permanents.get(permanent.getId());
|
MagePermanent oldMagePermanent = permanents.get(permanent.getId());
|
||||||
if (oldMagePermanent == null) {
|
if (oldMagePermanent == null) {
|
||||||
permanentsToAdd.add(permanent);
|
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();) {
|
for (Iterator<Entry<UUID, MagePermanent>> iterator = permanents.entrySet().iterator(); iterator.hasNext();) {
|
||||||
Entry<UUID, MagePermanent> entry = iterator.next();
|
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);
|
removePermanent(entry.getKey(), 1);
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
changed = true;
|
changed = true;
|
||||||
|
|
|
@ -28,11 +28,10 @@
|
||||||
|
|
||||||
package mage.abilities.keyword;
|
package mage.abilities.keyword;
|
||||||
|
|
||||||
import mage.constants.Zone;
|
import java.io.ObjectStreamException;
|
||||||
import mage.abilities.MageSingleton;
|
import mage.abilities.MageSingleton;
|
||||||
import mage.abilities.StaticAbility;
|
import mage.abilities.StaticAbility;
|
||||||
|
import mage.constants.Zone;
|
||||||
import java.io.ObjectStreamException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -56,7 +55,7 @@ public class PhasingAbility extends StaticAbility implements MageSingleton {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
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
|
@Override
|
||||||
|
|
|
@ -29,15 +29,20 @@
|
||||||
package mage.game.permanent;
|
package mage.game.permanent;
|
||||||
|
|
||||||
import java.io.Serializable;
|
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.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.abilities.keyword.PhasingAbility;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.RangeOfInfluence;
|
import mage.constants.RangeOfInfluence;
|
||||||
import mage.abilities.keyword.PhasingAbility;
|
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -82,7 +87,7 @@ public class Battlefield implements Serializable {
|
||||||
public int countAll(FilterPermanent filter, UUID controllerId, Game game) {
|
public int countAll(FilterPermanent filter, UUID controllerId, Game game) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (Permanent permanent: field.values()) {
|
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++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +109,7 @@ public class Battlefield implements Serializable {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
if (game.getRangeOfInfluence() == RangeOfInfluence.ALL) {
|
if (game.getRangeOfInfluence() == RangeOfInfluence.ALL) {
|
||||||
for (Permanent permanent: field.values()) {
|
for (Permanent permanent: field.values()) {
|
||||||
if (filter.match(permanent, sourceId, sourcePlayerId, game)) {
|
if (filter.match(permanent, sourceId, sourcePlayerId, game) && permanent.isPhasedIn()) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +117,7 @@ public class Battlefield implements Serializable {
|
||||||
else {
|
else {
|
||||||
Set<UUID> range = game.getPlayer(sourcePlayerId).getInRange();
|
Set<UUID> range = game.getPlayer(sourcePlayerId).getInRange();
|
||||||
for (Permanent permanent: field.values()) {
|
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++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +138,7 @@ public class Battlefield implements Serializable {
|
||||||
public boolean contains(FilterPermanent filter, int num, Game game) {
|
public boolean contains(FilterPermanent filter, int num, Game game) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (Permanent permanent: field.values()) {
|
for (Permanent permanent: field.values()) {
|
||||||
if (filter.match(permanent, game)) {
|
if (filter.match(permanent, game) && permanent.isPhasedIn()) {
|
||||||
count++;
|
count++;
|
||||||
if (num == count) {
|
if (num == count) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -157,7 +162,7 @@ public class Battlefield implements Serializable {
|
||||||
public boolean contains(FilterPermanent filter, UUID controllerId, int num, Game game) {
|
public boolean contains(FilterPermanent filter, UUID controllerId, int num, Game game) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (Permanent permanent: field.values()) {
|
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++;
|
count++;
|
||||||
if (num == count) {
|
if (num == count) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -182,7 +187,7 @@ public class Battlefield implements Serializable {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
if (game.getRangeOfInfluence() == RangeOfInfluence.ALL) {
|
if (game.getRangeOfInfluence() == RangeOfInfluence.ALL) {
|
||||||
for (Permanent permanent: field.values()) {
|
for (Permanent permanent: field.values()) {
|
||||||
if (filter.match(permanent, null, sourcePlayerId, game)) {
|
if (filter.match(permanent, null, sourcePlayerId, game) && permanent.isPhasedIn()) {
|
||||||
count++;
|
count++;
|
||||||
if (num == count) {
|
if (num == count) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -193,7 +198,7 @@ public class Battlefield implements Serializable {
|
||||||
else {
|
else {
|
||||||
Set<UUID> range = game.getPlayer(sourcePlayerId).getInRange();
|
Set<UUID> range = game.getPlayer(sourcePlayerId).getInRange();
|
||||||
for (Permanent permanent: field.values()) {
|
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++;
|
count++;
|
||||||
if (num == count) {
|
if (num == count) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -401,6 +401,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
||||||
if (!phasedIn) {
|
if (!phasedIn) {
|
||||||
if (!replaceEvent(EventType.PHASE_IN, game)) {
|
if (!replaceEvent(EventType.PHASE_IN, game)) {
|
||||||
this.phasedIn = true;
|
this.phasedIn = true;
|
||||||
|
game.informPlayers(getLogName() + " phased in");
|
||||||
fireEvent(EventType.PHASED_IN, game);
|
fireEvent(EventType.PHASED_IN, game);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -413,6 +414,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
||||||
if (phasedIn) {
|
if (phasedIn) {
|
||||||
if (!replaceEvent(EventType.PHASE_OUT, game)) {
|
if (!replaceEvent(EventType.PHASE_OUT, game)) {
|
||||||
this.phasedIn = false;
|
this.phasedIn = false;
|
||||||
|
game.informPlayers(getLogName() + " phased out");
|
||||||
fireEvent(EventType.PHASED_OUT, game);
|
fireEvent(EventType.PHASED_OUT, game);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1247,10 +1247,11 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
@Override
|
@Override
|
||||||
public void phasing(Game game) {
|
public void phasing(Game game) {
|
||||||
//20091005 - 502.1
|
//20091005 - 502.1
|
||||||
|
List<Permanent> phasedOut = game.getBattlefield().getPhasedOut(playerId);
|
||||||
for (Permanent permanent: game.getBattlefield().getPhasedIn(playerId)) {
|
for (Permanent permanent: game.getBattlefield().getPhasedIn(playerId)) {
|
||||||
permanent.phaseOut(game);
|
permanent.phaseOut(game);
|
||||||
}
|
}
|
||||||
for (Permanent permanent: game.getBattlefield().getPhasedOut(playerId)) {
|
for (Permanent permanent: phasedOut) {
|
||||||
permanent.phaseIn(game);
|
permanent.phaseIn(game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue