[ARB] fixed Sen Triplets (fixes #7068, fixes #7116)

This commit is contained in:
Evan Kranzler 2021-06-30 22:16:00 -04:00
parent a0be37922e
commit a76d6e8c24
2 changed files with 96 additions and 19 deletions

View file

@ -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());
@ -59,7 +62,7 @@ class SenTripletsRuleModifyingEffect extends ContinuousRuleModifyingEffectImpl {
staticText = "choose target opponent. This turn, that player can't cast spells or activate abilities";
}
public SenTripletsRuleModifyingEffect(final SenTripletsRuleModifyingEffect effect) {
private SenTripletsRuleModifyingEffect(final SenTripletsRuleModifyingEffect effect) {
super(effect);
}
@ -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);
}
}

View file

@ -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);
}
}