diff --git a/Mage.Sets/src/mage/cards/s/SphinxOfTheSecondSun.java b/Mage.Sets/src/mage/cards/s/SphinxOfTheSecondSun.java new file mode 100644 index 0000000000..b0c9183803 --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/SphinxOfTheSecondSun.java @@ -0,0 +1,101 @@ +package mage.cards.s; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfPostCombatMainTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.turn.TurnMod; +import mage.watchers.Watcher; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class SphinxOfTheSecondSun extends CardImpl { + + public SphinxOfTheSecondSun(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{6}{U}{U}"); + + this.subtype.add(SubType.SPHINX); + this.power = new MageInt(6); + this.toughness = new MageInt(6); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // At the beginning of your postcombat main phase, you get an additional beginning phase after this phase. + this.addAbility(new BeginningOfPostCombatMainTriggeredAbility( + new SphinxOfTheSecondSunEffect(), TargetController.YOU, false + ), new SphinxOfTheSecondSunWatcher()); + } + + private SphinxOfTheSecondSun(final SphinxOfTheSecondSun card) { + super(card); + } + + @Override + public SphinxOfTheSecondSun copy() { + return new SphinxOfTheSecondSun(this); + } +} + +class SphinxOfTheSecondSunEffect extends OneShotEffect { + + SphinxOfTheSecondSunEffect() { + super(Outcome.Benefit); + staticText = "you get an additional beginning phase after this phase"; + } + + private SphinxOfTheSecondSunEffect(final SphinxOfTheSecondSunEffect effect) { + super(effect); + } + + @Override + public SphinxOfTheSecondSunEffect copy() { + return new SphinxOfTheSecondSunEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + TurnPhase turnPhase = game.getPhase().getType(); + for (TurnMod turnMod : game.getState().getTurnMods()) { + if ("sphinxSecondSun".equals(turnMod.getNote()) + && turnMod.getPlayerId().equals(source.getControllerId()) + && turnMod.getAfterPhase() == turnPhase) { + turnPhase = TurnPhase.BEGINNING; + turnMod.setNote("sphinxSecondSunIgnore"); + break; + } + } + TurnMod combat = new TurnMod(source.getControllerId(), TurnPhase.POSTCOMBAT_MAIN, turnPhase, false); + combat.setNote("sphinxSecondSun"); + game.getState().getTurnMods().add(combat); + return true; + } +} + +class SphinxOfTheSecondSunWatcher extends Watcher { + + SphinxOfTheSecondSunWatcher() { + super(WatcherScope.GAME); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() != GameEvent.EventType.POSTCOMBAT_MAIN_PHASE_PRE) { + return; + } + for (TurnMod turnMod : game.getState().getTurnMods()) { + if ("sphinxSecondSun".equals(turnMod.getNote())) { + turnMod.setNote("sphinxSecondSunIgnore"); + } + } + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegends.java b/Mage.Sets/src/mage/sets/CommanderLegends.java index 3f5b1f1204..f2e9fcba1b 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegends.java +++ b/Mage.Sets/src/mage/sets/CommanderLegends.java @@ -453,6 +453,7 @@ public final class CommanderLegends extends ExpansionSet { cards.add(new SetCardInfo("Spectator Seating", 356, Rarity.RARE, mage.cards.s.SpectatorSeating.class)); cards.add(new SetCardInfo("Spectral Searchlight", 342, Rarity.COMMON, mage.cards.s.SpectralSearchlight.class)); cards.add(new SetCardInfo("Sphinx of Uthuun", 406, Rarity.RARE, mage.cards.s.SphinxOfUthuun.class)); + cards.add(new SetCardInfo("Sphinx of the Second Sun", 99, Rarity.MYTHIC, mage.cards.s.SphinxOfTheSecondSun.class)); cards.add(new SetCardInfo("Spirit Mantle", 385, Rarity.UNCOMMON, mage.cards.s.SpiritMantle.class)); cards.add(new SetCardInfo("Spitting Image", 453, Rarity.RARE, mage.cards.s.SpittingImage.class)); cards.add(new SetCardInfo("Spontaneous Mutation", 100, Rarity.COMMON, mage.cards.s.SpontaneousMutation.class));