implement [BLB] Early Winter

This commit is contained in:
Susucre 2024-06-29 16:49:13 +02:00
parent f4ebb67abf
commit 65828866ec
3 changed files with 176 additions and 0 deletions

View file

@ -0,0 +1,90 @@
package mage.cards.e;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.common.FilterControlledPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetControlledPermanent;
import mage.target.common.TargetCreaturePermanent;
import mage.target.common.TargetOpponent;
import java.util.UUID;
/**
* @author Susucr
*/
public final class EarlyWinter extends CardImpl {
public EarlyWinter(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{4}{B}");
// Choose one
// * Exile target creature.
this.getSpellAbility().addEffect(new ExileTargetEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
// * Target opponent exiles an enchantment they control.
Mode mode = new Mode(new EarlyWinterTargetEffect());
mode.addTarget(new TargetOpponent());
this.getSpellAbility().addMode(mode);
}
private EarlyWinter(final EarlyWinter card) {
super(card);
}
@Override
public EarlyWinter copy() {
return new EarlyWinter(this);
}
}
class EarlyWinterTargetEffect extends OneShotEffect {
private static final FilterControlledPermanent filter = new FilterControlledPermanent("enchantment you control");
static {
filter.add(CardType.ENCHANTMENT.getPredicate());
}
public EarlyWinterTargetEffect() {
super(Outcome.Exile);
this.staticText = "Target opponent exiles an enchantment they control";
}
private EarlyWinterTargetEffect(final EarlyWinterTargetEffect effect) {
super(effect);
}
@Override
public EarlyWinterTargetEffect copy() {
return new EarlyWinterTargetEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget());
if (player == null) {
return false;
}
Target target = new TargetControlledPermanent(filter);
target.withNotTarget(true);
player.choose(outcome, target, source, game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent == null) {
return false;
}
return player.moveCards(permanent, Zone.EXILED, source, game);
}
}

View file

@ -23,6 +23,7 @@ public final class Bloomburrow extends ExpansionSet {
cards.add(new SetCardInfo("Bria, Riptide Rogue", 379, Rarity.MYTHIC, mage.cards.b.BriaRiptideRogue.class)); cards.add(new SetCardInfo("Bria, Riptide Rogue", 379, Rarity.MYTHIC, mage.cards.b.BriaRiptideRogue.class));
cards.add(new SetCardInfo("Byrke, Long Ear of the Law", 380, Rarity.MYTHIC, mage.cards.b.ByrkeLongEarOfTheLaw.class)); cards.add(new SetCardInfo("Byrke, Long Ear of the Law", 380, Rarity.MYTHIC, mage.cards.b.ByrkeLongEarOfTheLaw.class));
cards.add(new SetCardInfo("Early Winter", 93, Rarity.COMMON, mage.cards.e.EarlyWinter.class));
cards.add(new SetCardInfo("Lilypad Village", 255, Rarity.UNCOMMON, mage.cards.l.LilypadVillage.class)); cards.add(new SetCardInfo("Lilypad Village", 255, Rarity.UNCOMMON, mage.cards.l.LilypadVillage.class));
cards.add(new SetCardInfo("Lumra, Bellow of the Woods", 183, Rarity.MYTHIC, mage.cards.l.LumraBellowOfTheWoods.class)); cards.add(new SetCardInfo("Lumra, Bellow of the Woods", 183, Rarity.MYTHIC, mage.cards.l.LumraBellowOfTheWoods.class));
cards.add(new SetCardInfo("Lupinflower Village", 256, Rarity.UNCOMMON, mage.cards.l.LupinflowerVillage.class)); cards.add(new SetCardInfo("Lupinflower Village", 256, Rarity.UNCOMMON, mage.cards.l.LupinflowerVillage.class));

View file

@ -0,0 +1,85 @@
package org.mage.test.cards.single.blb;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author Susucr
*/
public class EarlyWinterTest extends CardTestPlayerBase {
/**
* {@link mage.cards.e.EarlyWinter Early Winter} {4}{B}
* Instant
* Choose one
* Exile target creature.
* Target opponent exiles an enchantment they control.
*/
private static final String winter = "Early Winter";
@Test
public void test_ExileEnchantment() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 5);
addCard(Zone.BATTLEFIELD, playerB, "Glorious Anthem");
addCard(Zone.HAND, playerA, winter);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, winter);
setModeChoice(playerA, "2"); // Target opponent exiles an enchantment they control
addTarget(playerA, playerB);
setChoice(playerB, "Glorious Anthem");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerB, "Glorious Anthem", 0);
assertExileCount(playerB, "Glorious Anthem", 1);
assertGraveyardCount(playerA, winter, 1);
}
@Test
public void test_ExileEnchantment_WorksOnShroud() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 5);
addCard(Zone.BATTLEFIELD, playerB, "Helix Pinnacle"); // Shroud
addCard(Zone.HAND, playerA, winter);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, winter);
setModeChoice(playerA, "2"); // Target opponent exiles an enchantment they control
addTarget(playerA, playerB);
setChoice(playerB, "Helix Pinnacle");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerB, "Helix Pinnacle", 0);
assertExileCount(playerB, "Helix Pinnacle", 1);
assertGraveyardCount(playerA, winter, 1);
}
@Test
public void test_ExileEnchantment_CheckControlled() {
//setStrictChooseMode(true); // enable once the choice for enchantment can be tested when no choice possible
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 5);
addCard(Zone.BATTLEFIELD, playerA, "Glorious Anthem");
addCard(Zone.HAND, playerA, winter);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, winter);
setModeChoice(playerA, "2"); // Target opponent exiles an enchantment they control
//addTarget(playerA, playerB);
// playerB has no enchantment to choose from.
//setChoice(playerB, TestPlayer.CHOICE_SKIP);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerA, "Glorious Anthem", 1);
assertGraveyardCount(playerA, winter, 1);
}
}