changed how phasing is handled

This commit is contained in:
Evan Kranzler 2017-10-10 13:35:41 -04:00
parent 51f0e92103
commit 3d20e4dbef
5 changed files with 41 additions and 17 deletions

View file

@ -57,7 +57,6 @@ public class Equipoise extends CardImpl {
public Equipoise(UUID ownerId, CardSetInfo setInfo) { public Equipoise(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}");
// At the beginning of your upkeep, for each land target player controls in excess of the number you control, choose a land he or she controls, then the chosen permanents phase out. Repeat this process for artifacts and creatures. // At the beginning of your upkeep, for each land target player controls in excess of the number you control, choose a land he or she controls, then the chosen permanents phase out. Repeat this process for artifacts and creatures.
Ability ability = new BeginningOfUpkeepTriggeredAbility(new EquipoiseEffect(), TargetController.YOU, false); Ability ability = new BeginningOfUpkeepTriggeredAbility(new EquipoiseEffect(), TargetController.YOU, false);
ability.addTarget(new TargetPlayer()); ability.addTarget(new TargetPlayer());

View file

@ -171,8 +171,12 @@ class TeferisProtectionPhaseOutEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_PERMANENT, controller.getId(), game)) { for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_PERMANENT, controller.getId(), game)) {
Permanent attachedTo = game.getPermanent(permanent.getAttachedTo());
// don't phase out auras directly if they're attached to your stuff
if (!(attachedTo != null && attachedTo.getControllerId().equals(controller.getId()))) {
permanent.phaseOut(game); permanent.phaseOut(game);
} }
}
return true; return true;
} }
return false; return false;

View file

@ -78,9 +78,11 @@ public interface Permanent extends Card, Controllable {
boolean isPhasedIn(); boolean isPhasedIn();
boolean isPhasedOutIndirectly();
boolean phaseIn(Game game); boolean phaseIn(Game game);
boolean phaseIn(Game game, boolean indirectPhase); boolean phaseIn(Game game, boolean onlyDirect);
boolean phaseOut(Game game); boolean phaseOut(Game game);

View file

@ -464,18 +464,31 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
} }
@Override @Override
public boolean phaseIn(Game game) { public boolean isPhasedOutIndirectly() {
return phaseIn(game, false); return !phasedIn && indirectPhase;
} }
@Override @Override
public boolean phaseIn(Game game, boolean indirectPhase) { public boolean phaseIn(Game game) {
return phaseIn(game, true);
}
@Override
public boolean phaseIn(Game game, boolean onlyDirect) {
if (!phasedIn) { if (!phasedIn) {
if (!replaceEvent(EventType.PHASE_IN, game)) { if (!replaceEvent(EventType.PHASE_IN, game)
&& ((onlyDirect && !indirectPhase) || (!onlyDirect))) {
this.phasedIn = true; this.phasedIn = true;
this.indirectPhase = false;
if (!game.isSimulation()) { if (!game.isSimulation()) {
game.informPlayers(getLogName() + " phased in"); game.informPlayers(getLogName() + " phased in");
} }
for (UUID attachedId : this.getAttachments()) {
Permanent attachedPerm = game.getPermanent(attachedId);
if (attachedPerm != null) {
attachedPerm.phaseIn(game, false);
}
}
fireEvent(EventType.PHASED_IN, game); fireEvent(EventType.PHASED_IN, game);
return true; return true;
} }
@ -492,7 +505,14 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
public boolean phaseOut(Game game, boolean indirectPhase) { public boolean phaseOut(Game game, boolean indirectPhase) {
if (phasedIn) { if (phasedIn) {
if (!replaceEvent(EventType.PHASE_OUT, game)) { if (!replaceEvent(EventType.PHASE_OUT, game)) {
for (UUID attachedId : this.getAttachments()) {
Permanent attachedPerm = game.getPermanent(attachedId);
if (attachedPerm != null) {
attachedPerm.phaseOut(game, true);
}
}
this.phasedIn = false; this.phasedIn = false;
this.indirectPhase = indirectPhase;
if (!game.isSimulation()) { if (!game.isSimulation()) {
game.informPlayers(getLogName() + " phased out"); game.informPlayers(getLogName() + " phased out");
} }

View file

@ -1484,18 +1484,17 @@ public abstract class PlayerImpl implements Player, Serializable {
// phasing out is known as phasing out "indirectly." An enchantment or Equipment // phasing out is known as phasing out "indirectly." An enchantment or Equipment
// that phased out indirectly won't phase in by itself, but instead phases in // that phased out indirectly won't phase in by itself, but instead phases in
// along with the card it's attached to. // along with the card it's attached to.
for (UUID attachmentId : permanent.getAttachments()) { Permanent attachedTo = game.getPermanent(permanent.getAttachedTo());
Permanent attachment = game.getPermanent(attachmentId); if (!(attachedTo != null && attachedTo.getControllerId().equals(this.getId()))) {
if (attachment != null) { permanent.phaseOut(game, false);
attachment.phaseOut(game);
} }
} }
permanent.phaseOut(game);
}
for (Permanent permanent : phasedOut) { for (Permanent permanent : phasedOut) {
if (!permanent.isPhasedOutIndirectly()) {
permanent.phaseIn(game); permanent.phaseIn(game);
} }
} }
}
@Override @Override
public void untap(Game game) { public void untap(Game game) {