mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
changed how phasing is handled
This commit is contained in:
parent
51f0e92103
commit
3d20e4dbef
5 changed files with 41 additions and 17 deletions
|
|
@ -78,9 +78,11 @@ public interface Permanent extends Card, Controllable {
|
|||
|
||||
boolean isPhasedIn();
|
||||
|
||||
boolean isPhasedOutIndirectly();
|
||||
|
||||
boolean phaseIn(Game game);
|
||||
|
||||
boolean phaseIn(Game game, boolean indirectPhase);
|
||||
boolean phaseIn(Game game, boolean onlyDirect);
|
||||
|
||||
boolean phaseOut(Game game);
|
||||
|
||||
|
|
|
|||
|
|
@ -464,18 +464,31 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean phaseIn(Game game) {
|
||||
return phaseIn(game, false);
|
||||
public boolean isPhasedOutIndirectly() {
|
||||
return !phasedIn && indirectPhase;
|
||||
}
|
||||
|
||||
@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 (!replaceEvent(EventType.PHASE_IN, game)) {
|
||||
if (!replaceEvent(EventType.PHASE_IN, game)
|
||||
&& ((onlyDirect && !indirectPhase) || (!onlyDirect))) {
|
||||
this.phasedIn = true;
|
||||
this.indirectPhase = false;
|
||||
if (!game.isSimulation()) {
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -492,7 +505,14 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
public boolean phaseOut(Game game, boolean indirectPhase) {
|
||||
if (phasedIn) {
|
||||
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.indirectPhase = indirectPhase;
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(getLogName() + " phased out");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1484,16 +1484,15 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
// 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
|
||||
// along with the card it's attached to.
|
||||
for (UUID attachmentId : permanent.getAttachments()) {
|
||||
Permanent attachment = game.getPermanent(attachmentId);
|
||||
if (attachment != null) {
|
||||
attachment.phaseOut(game);
|
||||
}
|
||||
Permanent attachedTo = game.getPermanent(permanent.getAttachedTo());
|
||||
if (!(attachedTo != null && attachedTo.getControllerId().equals(this.getId()))) {
|
||||
permanent.phaseOut(game, false);
|
||||
}
|
||||
permanent.phaseOut(game);
|
||||
}
|
||||
for (Permanent permanent : phasedOut) {
|
||||
permanent.phaseIn(game);
|
||||
if (!permanent.isPhasedOutIndirectly()) {
|
||||
permanent.phaseIn(game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue