[MH2] Implemented Suspend

This commit is contained in:
Evan Kranzler 2021-06-06 18:32:19 -04:00
parent 9a3daa683f
commit 0410cb5343
2 changed files with 89 additions and 0 deletions

View file

@ -0,0 +1,88 @@
package mage.cards.s;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.GainSuspendEffect;
import mage.abilities.keyword.SuspendAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class Suspend extends CardImpl {
public Suspend(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{U}");
// Exile target creature and put two time counters on it. If it doesn't have suspend, it gains suspend.
this.getSpellAbility().addEffect(new SuspendEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
}
private Suspend(final Suspend card) {
super(card);
}
@Override
public Suspend copy() {
return new Suspend(this);
}
}
class SuspendEffect extends OneShotEffect {
SuspendEffect() {
super(Outcome.Benefit);
staticText = "exile target creature and put two time counters on it. " +
"If it doesn't have suspend, it gains suspend";
}
private SuspendEffect(final SuspendEffect effect) {
super(effect);
}
@Override
public SuspendEffect copy() {
return new SuspendEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (controller == null || permanent == null) {
return false;
}
Card card = permanent.getMainCard();
if (!controller.moveCards(permanent, Zone.EXILED, source, game)
|| game.getState().getZone(card.getId()) != Zone.EXILED) {
return true;
}
UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game);
if (!controller.moveCardToExileWithInfo(
card, exileId, "Suspended cards of " + controller.getLogName(),
source, game, Zone.HAND, true
)) {
return true;
}
card.addCounters(CounterType.TIME.createInstance(2), source.getControllerId(), source, game);
if (!card.getAbilities(game).containsClass(SuspendAbility.class)) {
game.addEffect(new GainSuspendEffect(new MageObjectReference(card, game)), source);
}
game.informPlayers(controller.getLogName() + " suspends 2 - " + card.getName());
return true;
}
}

View file

@ -271,6 +271,7 @@ public final class ModernHorizons2 extends ExpansionSet {
cards.add(new SetCardInfo("Strike It Rich", 143, Rarity.UNCOMMON, mage.cards.s.StrikeItRich.class));
cards.add(new SetCardInfo("Subtlety", 67, Rarity.MYTHIC, mage.cards.s.Subtlety.class));
cards.add(new SetCardInfo("Sudden Edict", 100, Rarity.UNCOMMON, mage.cards.s.SuddenEdict.class));
cards.add(new SetCardInfo("Suspend", 68, Rarity.RARE, mage.cards.s.Suspend.class));
cards.add(new SetCardInfo("Svyelun of Sea and Sky", 69, Rarity.MYTHIC, mage.cards.s.SvyelunOfSeaAndSky.class));
cards.add(new SetCardInfo("Swamp", 485, Rarity.LAND, mage.cards.basiclands.Swamp.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Sweep the Skies", 70, Rarity.UNCOMMON, mage.cards.s.SweepTheSkies.class));