[PIP] Implement Sentinel Sarah Lyons; The Prydwen, Steel Flagship; add common watcher + condition (#12250)

* [PIP] Implement Sentinel Sarah Lyons

* Create common watcher and condition for artifacts entering

* [PIP] Implement The Prydwen, Steel Flagship

* Use common classes in Akal Pakal, First Among Equals; string correction

* Add warning about watcher to ArtifactEnteredUnderYourControlCondition

* Add tests

* Move test file

* Test with opponent casting artifact during your turn

* Use checkPT(), don't call execute() multiple times

* Check final assertion at upkeep instead of untap step
This commit is contained in:
Cameron Merkel 2024-05-20 23:33:11 -05:00 committed by GitHub
parent 08f48be745
commit 0f858fe3c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 355 additions and 107 deletions

View file

@ -3,19 +3,14 @@ package mage.cards.a;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfEndStepTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.ArtifactEnteredUnderYourControlCondition;
import mage.abilities.effects.common.LookLibraryAndPickControllerEffect;
import mage.abilities.hint.ConditionHint;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.watchers.Watcher;
import mage.watchers.common.ArtifactEnteredControllerWatcher;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
@ -36,11 +31,11 @@ public final class AkalPakalFirstAmongEquals extends CardImpl {
Ability ability = new BeginningOfEndStepTriggeredAbility(
new LookLibraryAndPickControllerEffect(2, 1, PutCards.HAND, PutCards.GRAVEYARD),
TargetController.EACH_PLAYER,
AkalPakalCondition.instance,
ArtifactEnteredUnderYourControlCondition.instance,
false
);
ability.addHint(new ConditionHint(AkalPakalCondition.instance));
this.addAbility(ability, new AkalPakalWatcher());
ability.addHint(new ConditionHint(ArtifactEnteredUnderYourControlCondition.instance));
this.addAbility(ability, new ArtifactEnteredControllerWatcher());
}
private AkalPakalFirstAmongEquals(final AkalPakalFirstAmongEquals card) {
@ -52,50 +47,3 @@ public final class AkalPakalFirstAmongEquals extends CardImpl {
return new AkalPakalFirstAmongEquals(this);
}
}
enum AkalPakalCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {
return AkalPakalWatcher.checkPlayer(source.getControllerId(), game);
}
@Override
public String toString() {
return "an artifact entered the battlefield under your control this turn";
}
}
class AkalPakalWatcher extends Watcher {
// Set of the players that had an artifact enter this turn.
private final Set<UUID> playerSet = new HashSet<>();
AkalPakalWatcher() {
super(WatcherScope.GAME);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() != GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
return;
}
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && permanent.isArtifact(game)) {
playerSet.add(event.getPlayerId());
}
}
@Override
public void reset() {
super.reset();
playerSet.clear();
}
static boolean checkPlayer(UUID playerId, Game game) {
AkalPakalWatcher watcher = game.getState().getWatcher(AkalPakalWatcher.class);
return watcher != null && watcher.playerSet.contains(playerId);
}
}

View file

@ -0,0 +1,66 @@
package mage.cards.s;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.ArtifactEnteredUnderYourControlCondition;
import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.dynamicvalue.common.ArtifactYouControlCount;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.continuous.BoostControlledEffect;
import mage.abilities.hint.ConditionHint;
import mage.abilities.hint.common.ArtifactYouControlHint;
import mage.abilities.keyword.BattalionAbility;
import mage.constants.*;
import mage.abilities.keyword.HasteAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.target.TargetPlayer;
import mage.watchers.common.ArtifactEnteredControllerWatcher;
/**
* @author Cguy7777
*/
public final class SentinelSarahLyons extends CardImpl {
public SentinelSarahLyons(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}{W}");
this.supertype.add(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.KNIGHT);
this.power = new MageInt(4);
this.toughness = new MageInt(4);
// Haste
this.addAbility(HasteAbility.getInstance());
// As long as an artifact entered the battlefield under your control this turn, creatures you control get +2/+2.
this.addAbility(new SimpleStaticAbility(new ConditionalContinuousEffect(
new BoostControlledEffect(2, 2, Duration.WhileOnBattlefield),
ArtifactEnteredUnderYourControlCondition.instance,
"as long as an artifact entered the battlefield under your control this turn, " +
"creatures you control get +2/+2"))
.addHint(new ConditionHint(ArtifactEnteredUnderYourControlCondition.instance)),
new ArtifactEnteredControllerWatcher());
// Battalion -- Whenever Sentinel Sarah Lyons and at least two other creatures attack,
// Sentinel Sarah Lyons deals damage equal to the number of artifacts you control to target player.
Ability ability = new BattalionAbility(new DamageTargetEffect(ArtifactYouControlCount.instance)
.setText("{this} deals damage equal to the number of artifacts you control to target player"));
ability.addTarget(new TargetPlayer());
ability.addHint(ArtifactYouControlHint.instance);
this.addAbility(ability);
}
private SentinelSarahLyons(final SentinelSarahLyons card) {
super(card);
}
@Override
public SentinelSarahLyons copy() {
return new SentinelSarahLyons(this);
}
}

View file

@ -1,26 +1,19 @@
package mage.cards.s;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.ArtifactEnteredUnderYourControlCondition;
import mage.abilities.decorator.ConditionalAsThoughEffect;
import mage.abilities.effects.common.combat.CanAttackAsThoughItDidntHaveDefenderSourceEffect;
import mage.abilities.hint.ConditionHint;
import mage.abilities.hint.Hint;
import mage.abilities.keyword.DefenderAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.constants.WatcherScope;
import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent;
import mage.watchers.Watcher;
import mage.watchers.common.ArtifactEnteredControllerWatcher;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
@ -28,11 +21,6 @@ import java.util.UUID;
*/
public final class ShipwreckSentry extends CardImpl {
private static final Hint hint = new ConditionHint(
ShipwreckSentryWatcher::checkPlayer,
"An artifact entered under your control this turn"
);
public ShipwreckSentry(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}");
@ -47,9 +35,11 @@ public final class ShipwreckSentry extends CardImpl {
// As long as an artifact entered the battlefield under your control this turn, Shipwreck Sentry can attack as though it didn't have defender.
this.addAbility(new SimpleStaticAbility(new ConditionalAsThoughEffect(
new CanAttackAsThoughItDidntHaveDefenderSourceEffect(Duration.WhileOnBattlefield),
ShipwreckSentryWatcher::checkPlayer
ArtifactEnteredUnderYourControlCondition.instance
).setText("as long as an artifact entered the battlefield under your control this turn, " +
"{this} can attack as though it didn't have defender")).addHint(hint), new ShipwreckSentryWatcher());
"{this} can attack as though it didn't have defender"))
.addHint(new ConditionHint(ArtifactEnteredUnderYourControlCondition.instance)),
new ArtifactEnteredControllerWatcher());
}
private ShipwreckSentry(final ShipwreckSentry card) {
@ -61,37 +51,3 @@ public final class ShipwreckSentry extends CardImpl {
return new ShipwreckSentry(this);
}
}
class ShipwreckSentryWatcher extends Watcher {
private final Set<UUID> playerSet = new HashSet<>();
ShipwreckSentryWatcher() {
super(WatcherScope.GAME);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() != GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
return;
}
EntersTheBattlefieldEvent eEvent = (EntersTheBattlefieldEvent) event;
if (eEvent.getTarget() != null && eEvent.getTarget().isArtifact(game)) {
playerSet.add(eEvent.getTarget().getControllerId());
}
}
@Override
public void reset() {
super.reset();
playerSet.clear();
}
static boolean checkPlayer(Game game, Ability source) {
return game
.getState()
.getWatcher(ShipwreckSentryWatcher.class)
.playerSet
.contains(source.getControllerId());
}
}

View file

@ -0,0 +1,65 @@
package mage.cards.t;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.CrewAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.common.FilterArtifactPermanent;
import mage.filter.predicate.mageobject.AnotherPredicate;
import mage.filter.predicate.permanent.TokenPredicate;
import mage.game.permanent.token.ThePrydwenSteelFlagshipHumanKnightToken;
import mage.watchers.common.ArtifactEnteredControllerWatcher;
/**
* @author Cguy7777
*/
public final class ThePrydwenSteelFlagship extends CardImpl {
private static final FilterArtifactPermanent filter = new FilterArtifactPermanent("another nontoken artifact");
static {
filter.add(AnotherPredicate.instance);
filter.add(TokenPredicate.FALSE);
}
public ThePrydwenSteelFlagship(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}{W}{W}");
this.supertype.add(SuperType.LEGENDARY);
this.subtype.add(SubType.VEHICLE);
this.power = new MageInt(6);
this.toughness = new MageInt(6);
// Flying
this.addAbility(FlyingAbility.getInstance());
// Whenever another nontoken artifact enters the battlefield under your control,
// create a 2/2 white Human Knight creature token with
// "This creature gets +2/+2 as long as an artifact entered the battlefield under your control this turn."
this.addAbility(
new EntersBattlefieldControlledTriggeredAbility(
new CreateTokenEffect(new ThePrydwenSteelFlagshipHumanKnightToken()), filter),
new ArtifactEnteredControllerWatcher());
// Crew 2
this.addAbility(new CrewAbility(2));
}
private ThePrydwenSteelFlagship(final ThePrydwenSteelFlagship card) {
super(card);
}
@Override
public ThePrydwenSteelFlagship copy() {
return new ThePrydwenSteelFlagship(this);
}
}

View file

@ -289,6 +289,10 @@ public final class Fallout extends ExpansionSet {
cards.add(new SetCardInfo("Screeching Scorchbeast", 49, Rarity.RARE, mage.cards.s.ScreechingScorchbeast.class));
cards.add(new SetCardInfo("Secure the Wastes", 171, Rarity.RARE, mage.cards.s.SecureTheWastes.class));
cards.add(new SetCardInfo("Securitron Squadron", 23, Rarity.RARE, mage.cards.s.SecuritronSquadron.class));
cards.add(new SetCardInfo("Sentinel Sarah Lyons", 118, Rarity.RARE, mage.cards.s.SentinelSarahLyons.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Sentinel Sarah Lyons", 428, Rarity.RARE, mage.cards.s.SentinelSarahLyons.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Sentinel Sarah Lyons", 646, Rarity.RARE, mage.cards.s.SentinelSarahLyons.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Sentinel Sarah Lyons", 956, Rarity.RARE, mage.cards.s.SentinelSarahLyons.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Sentry Bot", 24, Rarity.RARE, mage.cards.s.SentryBot.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Sentry Bot", 371, Rarity.RARE, mage.cards.s.SentryBot.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Sentry Bot", 552, Rarity.RARE, mage.cards.s.SentryBot.class, NON_FULL_USE_VARIOUS));
@ -361,6 +365,10 @@ public final class Fallout extends ExpansionSet {
cards.add(new SetCardInfo("The Nipton Lottery", 423, Rarity.RARE, mage.cards.t.TheNiptonLottery.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("The Nipton Lottery", 641, Rarity.RARE, mage.cards.t.TheNiptonLottery.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("The Nipton Lottery", 951, Rarity.RARE, mage.cards.t.TheNiptonLottery.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("The Prydwen, Steel Flagship", 22, Rarity.RARE, mage.cards.t.ThePrydwenSteelFlagship.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("The Prydwen, Steel Flagship", 370, Rarity.RARE, mage.cards.t.ThePrydwenSteelFlagship.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("The Prydwen, Steel Flagship", 550, Rarity.RARE, mage.cards.t.ThePrydwenSteelFlagship.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("The Prydwen, Steel Flagship", 898, Rarity.RARE, mage.cards.t.ThePrydwenSteelFlagship.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("The Wise Mothman", 4, Rarity.MYTHIC, mage.cards.t.TheWiseMothman.class));
cards.add(new SetCardInfo("Thirst for Knowledge", 180, Rarity.UNCOMMON, mage.cards.t.ThirstForKnowledge.class));
cards.add(new SetCardInfo("Thought Vessel", 251, Rarity.COMMON, mage.cards.t.ThoughtVessel.class));

View file

@ -0,0 +1,86 @@
package org.mage.test.cards.single.pip;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
public class SentinelSarahLyonsTest extends CardTestPlayerBase {
/*
* Sentinel Sarah Lyons {3}{R}{W}
* Legendary Creature - Human Knight (4/4)
* Haste
* As long as an artifact entered the battlefield under your control this turn, creatures you control get +2/+2.
* Battalion - Whenever Sentinel Sarah Lyons and at least two other creatures attack,
* Sentinel Sarah Lyons deals damage equal to the number of artifacts you control to target player.
*/
@Test
public void test_ArtifactEntersUnderYourControlBeforeAndAfter() {
addCard(Zone.BATTLEFIELD, playerA, "Sentinel Sarah Lyons", 1);
addCard(Zone.HAND, playerA, "Darksteel Relic", 1); // Artifact w/ Indestructible
// Before casting an artifact (4/4)
checkPT("1: before casting Relic", 1, PhaseStep.UPKEEP, playerA, "Sentinel Sarah Lyons", 4, 4);
// Casting the artifact (should become a 6/6 until end of turn)
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Darksteel Relic");
checkPT("1: after casting Relic", 1, PhaseStep.END_TURN, playerA, "Sentinel Sarah Lyons", 6, 6);
// Turn after casting the artifact (should return to 4/4)
setStrictChooseMode(true);
setStopAt(2, PhaseStep.UPKEEP);
execute();
assertPowerToughness(playerA, "Sentinel Sarah Lyons", 4, 4);
}
@Test
public void test_ArtifactEntersUnderOpponentsControl() {
addCard(Zone.BATTLEFIELD, playerA, "Sentinel Sarah Lyons", 1);
addCard(Zone.HAND, playerB, "Darksteel Relic", 1);
// Artifact w/ "You may cast spells as though they had flash."
addCard(Zone.BATTLEFIELD, playerB, "Vedalken Orrery", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Darksteel Relic");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPowerToughness(playerA, "Sentinel Sarah Lyons", 4, 4);
}
@Test
public void test_NonartifactEntersUnderYourControl() {
addCard(Zone.BATTLEFIELD, playerA, "Forest", 2);
addCard(Zone.BATTLEFIELD, playerA, "Sentinel Sarah Lyons", 1);
addCard(Zone.HAND, playerA, "Grizzly Bears", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Grizzly Bears");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPowerToughness(playerA, "Sentinel Sarah Lyons", 4, 4);
}
@Test
public void test_ArtifactEntersBeforeSarahLyons() {
addCard(Zone.BATTLEFIELD, playerA, "Plateau", 5);
addCard(Zone.HAND, playerA, "Sentinel Sarah Lyons", 1);
addCard(Zone.HAND, playerA, "Darksteel Relic", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Darksteel Relic", true);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Sentinel Sarah Lyons");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPowerToughness(playerA, "Sentinel Sarah Lyons", 6, 6);
}
}

View file

@ -0,0 +1,25 @@
package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.game.Game;
import mage.watchers.common.ArtifactEnteredControllerWatcher;
/**
* /!\ You need to add ArtifactEnteredControllerWatcher to any card using this condition
*
* @author Cguy7777
*/
public enum ArtifactEnteredUnderYourControlCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {
return ArtifactEnteredControllerWatcher.enteredArtifactForPlayer(source.getControllerId(), game);
}
@Override
public String toString() {
return "an artifact entered the battlefield under your control this turn";
}
}

View file

@ -0,0 +1,45 @@
package mage.game.permanent.token;
import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.ArtifactEnteredUnderYourControlCondition;
import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.abilities.hint.ConditionHint;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
/**
* @author Cguy7777
*/
public class ThePrydwenSteelFlagshipHumanKnightToken extends TokenImpl {
/**
* /!\ You need to add ArtifactEnteredControllerWatcher to any card using this token
*/
public ThePrydwenSteelFlagshipHumanKnightToken() {
super("Human Knight Token", "2/2 white Human Knight creature token with \"This creature " +
"gets +2/+2 as long as an artifact entered the battlefield under your control this turn.\"");
cardType.add(CardType.CREATURE);
color.setWhite(true);
subtype.add(SubType.HUMAN, SubType.KNIGHT);
power = new MageInt(2);
toughness = new MageInt(2);
this.addAbility(new SimpleStaticAbility(new ConditionalContinuousEffect(
new BoostSourceEffect(2, 2, Duration.WhileOnBattlefield),
ArtifactEnteredUnderYourControlCondition.instance,
"This creature gets +2/+2 as long as an artifact entered the battlefield under your control this turn"))
.addHint(new ConditionHint(ArtifactEnteredUnderYourControlCondition.instance)));
}
private ThePrydwenSteelFlagshipHumanKnightToken(final ThePrydwenSteelFlagshipHumanKnightToken token) {
super(token);
}
@Override
public ThePrydwenSteelFlagshipHumanKnightToken copy() {
return new ThePrydwenSteelFlagshipHumanKnightToken(this);
}
}

View file

@ -0,0 +1,49 @@
package mage.watchers.common;
import mage.constants.WatcherScope;
import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent;
import mage.watchers.Watcher;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
* @author Cguy7777
*/
public class ArtifactEnteredControllerWatcher extends Watcher {
private final Set<UUID> players = new HashSet<>();
public ArtifactEnteredControllerWatcher() {
super(WatcherScope.GAME);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() != GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
return;
}
EntersTheBattlefieldEvent eEvent = (EntersTheBattlefieldEvent) event;
if (eEvent.getTarget() != null && eEvent.getTarget().isArtifact(game)) {
players.add(eEvent.getTarget().getControllerId());
}
}
@Override
public void reset() {
super.reset();
players.clear();
}
public static boolean enteredArtifactForPlayer(UUID playerId, Game game) {
return game
.getState()
.getWatcher(ArtifactEnteredControllerWatcher.class)
.players
.contains(playerId);
}
}