From a76d6e8c24a9f948ae5afc6dcc5851673412b599 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 30 Jun 2021 22:16:00 -0400 Subject: [PATCH] [ARB] fixed Sen Triplets (fixes #7068, fixes #7116) --- Mage.Sets/src/mage/cards/s/SenTriplets.java | 45 +++++++----- .../cards/single/arb/SenTripletsTest.java | 70 +++++++++++++++++++ 2 files changed, 96 insertions(+), 19 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/arb/SenTripletsTest.java diff --git a/Mage.Sets/src/mage/cards/s/SenTriplets.java b/Mage.Sets/src/mage/cards/s/SenTriplets.java index 6d5d28d940..2a84343b02 100644 --- a/Mage.Sets/src/mage/cards/s/SenTriplets.java +++ b/Mage.Sets/src/mage/cards/s/SenTriplets.java @@ -1,7 +1,5 @@ - package mage.cards.s; -import java.util.UUID; import mage.MageInt; import mage.MageObject; import mage.abilities.Ability; @@ -15,17 +13,19 @@ import mage.cards.CardSetInfo; import mage.constants.*; import mage.game.Game; import mage.game.events.GameEvent; +import mage.game.stack.Spell; import mage.players.Player; import mage.target.common.TargetOpponent; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class SenTriplets extends CardImpl { public SenTriplets(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{2}{W}{U}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{2}{W}{U}{B}"); addSuperType(SuperType.LEGENDARY); this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.WIZARD); @@ -35,7 +35,10 @@ public final class SenTriplets extends CardImpl { // At the beginning of your upkeep, choose target opponent. // This turn, that player can't cast spells or activate abilities and plays with their hand revealed. // You may play cards from that player's hand this turn. - Ability ability = new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new SenTripletsRuleModifyingEffect(), TargetController.YOU, false, false); + Ability ability = new BeginningOfUpkeepTriggeredAbility( + Zone.BATTLEFIELD, new SenTripletsRuleModifyingEffect(), + TargetController.YOU, false, false + ); ability.addEffect(new SenTripletsOpponentRevealsHandEffect()); ability.addEffect(new SenTripletsPlayFromOpponentsHandEffect()); ability.addTarget(new TargetOpponent()); @@ -56,11 +59,11 @@ class SenTripletsRuleModifyingEffect extends ContinuousRuleModifyingEffectImpl { public SenTripletsRuleModifyingEffect() { super(Duration.EndOfTurn, Outcome.Benefit); - staticText = "choose target opponent. This turn, that player can't cast spells or activate abilities"; + staticText = "choose target opponent. This turn, that player can't cast spells or activate abilities"; } - public SenTripletsRuleModifyingEffect(final SenTripletsRuleModifyingEffect effect) { - super(effect); + private SenTripletsRuleModifyingEffect(final SenTripletsRuleModifyingEffect effect) { + super(effect); } @Override @@ -86,7 +89,8 @@ class SenTripletsRuleModifyingEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.CAST_SPELL || event.getType() == GameEvent.EventType.ACTIVATE_ABILITY; + return event.getType() == GameEvent.EventType.CAST_SPELL + || event.getType() == GameEvent.EventType.ACTIVATE_ABILITY; } @Override @@ -102,7 +106,7 @@ class SenTripletsOpponentRevealsHandEffect extends ContinuousEffectImpl { staticText = "and plays with their hand revealed"; } - public SenTripletsOpponentRevealsHandEffect(final SenTripletsOpponentRevealsHandEffect effect) { + private SenTripletsOpponentRevealsHandEffect(final SenTripletsOpponentRevealsHandEffect effect) { super(effect); } @@ -123,10 +127,9 @@ class SenTripletsOpponentRevealsHandEffect extends ContinuousEffectImpl { class SenTripletsPlayFromOpponentsHandEffect extends AsThoughEffectImpl { - public SenTripletsPlayFromOpponentsHandEffect() { super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfTurn, Outcome.Benefit); - staticText = "You may play cards from that player's hand this turn"; + staticText = "You may play cards from that player's hand this turn"; } public SenTripletsPlayFromOpponentsHandEffect(final SenTripletsPlayFromOpponentsHandEffect effect) { @@ -146,12 +149,16 @@ class SenTripletsPlayFromOpponentsHandEffect extends AsThoughEffectImpl { @Override public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { Card card = game.getCard(objectId); - return card != null && - card.isOwnedBy(getTargetPointer().getFirst(game, source)) && - game.getState().getZone(objectId) == Zone.HAND && - affectedControllerId.equals(source.getControllerId()); + Zone zone; + if (card instanceof Spell) { + zone = ((Spell) card).getFromZone(); + } else if (card != null) { + zone = game.getState().getZone(card.getMainCard().getId()); + } else { + return false; + } + return card.isOwnedBy(getTargetPointer().getFirst(game, source)) + && zone == Zone.HAND + && source.isControlledBy(affectedControllerId); } - } - - diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/arb/SenTripletsTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/arb/SenTripletsTest.java new file mode 100644 index 0000000000..1c12a2e96f --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/arb/SenTripletsTest.java @@ -0,0 +1,70 @@ +package org.mage.test.cards.single.arb; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * @author TheElk801 + */ +public class SenTripletsTest extends CardTestPlayerBase { + + private static final String triplets = "Sen Triplets"; + private static final String bolt = "Lightning Bolt"; + private static final String relic = "Darksteel Relic"; + + private void initTriplets() { + addCard(Zone.BATTLEFIELD, playerA, triplets); + addCard(Zone.BATTLEFIELD, playerA, "Mountain"); + addCard(Zone.BATTLEFIELD, playerB, "Taiga"); + addCard(Zone.HAND, playerB, bolt); + addCard(Zone.HAND, playerB, relic); + addCard(Zone.HAND, playerB, "Island"); + } + + @Test + public void testCastSpell() { + initTriplets(); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bolt, playerB); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, relic); + playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Island"); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + assertPermanentCount(playerA, triplets, 1); + assertPermanentCount(playerA, relic, 1); + assertPermanentCount(playerA, "Island", 1); + assertHandCount(playerB, bolt, 0); + assertHandCount(playerB, relic, 0); + assertGraveyardCount(playerB, 1); + assertLife(playerB, 20 - 3); + } + + @Test + public void testCantActivate() { + initTriplets(); + + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, "{T}"); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertTapped("Taiga", false); + } + + @Test + public void testCantCast() { + initTriplets(); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, bolt, playerA); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertHandCount(playerB, bolt, 1); + assertLife(playerA, 20); + } +}