mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
changed how phasing is handled
This commit is contained in:
parent
51f0e92103
commit
3d20e4dbef
5 changed files with 41 additions and 17 deletions
|
@ -55,8 +55,7 @@ import mage.target.TargetPlayer;
|
|||
public class Equipoise extends CardImpl {
|
||||
|
||||
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.
|
||||
Ability ability = new BeginningOfUpkeepTriggeredAbility(new EquipoiseEffect(), TargetController.YOU, false);
|
||||
|
@ -112,12 +111,12 @@ class EquipoiseEffect extends OneShotEffect {
|
|||
int numberTargetPlayer = game.getBattlefield().count(filter, source.getSourceId(), targetPlayer.getId(), game);
|
||||
int excess = numberTargetPlayer - numberController;
|
||||
if (excess > 0) {
|
||||
FilterPermanent filterChoose = new FilterPermanent(cardType.toString().toLowerCase() + (excess > 1 ? "s":"") +" of target player");
|
||||
FilterPermanent filterChoose = new FilterPermanent(cardType.toString().toLowerCase() + (excess > 1 ? "s" : "") + " of target player");
|
||||
filterChoose.add(new ControllerIdPredicate(targetPlayer.getId()));
|
||||
filterChoose.add(new CardTypePredicate(cardType));
|
||||
Target target = new TargetPermanent(excess, excess, filterChoose, true);
|
||||
controller.chooseTarget(outcome, target, source, game);
|
||||
for (UUID permanentId:target.getTargets()) {
|
||||
for (UUID permanentId : target.getTargets()) {
|
||||
Permanent permanent = game.getPermanent(permanentId);
|
||||
if (permanent != null) {
|
||||
permanent.phaseOut(game);
|
||||
|
|
|
@ -171,7 +171,11 @@ class TeferisProtectionPhaseOutEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_PERMANENT, controller.getId(), game)) {
|
||||
permanent.phaseOut(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);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -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…
Reference in a new issue