forked from External/mage
[TDC] fix Parapet Thrasher triggered Ability
This commit is contained in:
parent
8656548676
commit
693a6f2213
2 changed files with 143 additions and 10 deletions
|
|
@ -1,7 +1,5 @@
|
||||||
package mage.cards.p;
|
package mage.cards.p;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
|
@ -12,17 +10,27 @@ import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.DestroyTargetEffect;
|
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||||
import mage.abilities.effects.common.ExileTopXMayPlayUntilEffect;
|
import mage.abilities.effects.common.ExileTopXMayPlayUntilEffect;
|
||||||
import mage.abilities.hint.common.ModesAlreadyUsedHint;
|
import mage.abilities.hint.common.ModesAlreadyUsedHint;
|
||||||
import mage.constants.*;
|
|
||||||
import mage.abilities.keyword.FlyingAbility;
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.*;
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
import mage.filter.common.FilterArtifactPermanent;
|
import mage.filter.common.FilterArtifactPermanent;
|
||||||
import mage.filter.common.FilterControlledPermanent;
|
import mage.filter.common.FilterControlledPermanent;
|
||||||
|
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamagedBatchForOnePlayerEvent;
|
||||||
|
import mage.game.events.DamagedEvent;
|
||||||
|
import mage.game.events.DamagedPlayerEvent;
|
||||||
|
import mage.game.events.GameEvent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.targetadjustment.ThatPlayerControlsTargetAdjuster;
|
import mage.target.targetadjustment.DefineByTriggerTargetAdjuster;
|
||||||
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -31,7 +39,6 @@ import mage.target.targetadjustment.ThatPlayerControlsTargetAdjuster;
|
||||||
public final class ParapetThrasher extends CardImpl {
|
public final class ParapetThrasher extends CardImpl {
|
||||||
|
|
||||||
private static final FilterControlledPermanent filter = new FilterControlledPermanent(SubType.DRAGON, "Dragons you control");
|
private static final FilterControlledPermanent filter = new FilterControlledPermanent(SubType.DRAGON, "Dragons you control");
|
||||||
private static final FilterPermanent artifactFilter = new FilterArtifactPermanent("artifact that opponent controls");
|
|
||||||
|
|
||||||
public ParapetThrasher(UUID ownerId, CardSetInfo setInfo) {
|
public ParapetThrasher(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}{R}");
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}{R}");
|
||||||
|
|
@ -45,11 +52,7 @@ public final class ParapetThrasher extends CardImpl {
|
||||||
|
|
||||||
// Whenever one or more Dragons you control deal combat damage to an opponent, choose one that hasn't been chosen this turn --
|
// Whenever one or more Dragons you control deal combat damage to an opponent, choose one that hasn't been chosen this turn --
|
||||||
// * Destroy target artifact that opponent controls.
|
// * Destroy target artifact that opponent controls.
|
||||||
Ability ability = new OneOrMoreDamagePlayerTriggeredAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(),
|
Ability ability = new ParapetThrasherTriggeredAbility(new DestroyTargetEffect(), filter);
|
||||||
filter, true, true, SetTargetPointer.PLAYER, false)
|
|
||||||
.setTriggerPhrase("Whenever one or more Dragons you control deal combat damage to an opponent, ");
|
|
||||||
ability.addTarget(new TargetPermanent(artifactFilter));
|
|
||||||
ability.setTargetAdjuster(new ThatPlayerControlsTargetAdjuster());
|
|
||||||
ability.setModeTag("destroy artifact");
|
ability.setModeTag("destroy artifact");
|
||||||
ability.getModes().setLimitUsageByOnce(true);
|
ability.getModes().setLimitUsageByOnce(true);
|
||||||
|
|
||||||
|
|
@ -78,6 +81,47 @@ public final class ParapetThrasher extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ParapetThrasherTriggeredAbility extends OneOrMoreDamagePlayerTriggeredAbility {
|
||||||
|
|
||||||
|
|
||||||
|
public ParapetThrasherTriggeredAbility(Effect effect, FilterPermanent filter) {
|
||||||
|
super(Zone.BATTLEFIELD, effect,
|
||||||
|
filter, true, true, SetTargetPointer.PLAYER, false);
|
||||||
|
setTargetAdjuster(DefineByTriggerTargetAdjuster.instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ParapetThrasherTriggeredAbility(final ParapetThrasherTriggeredAbility ability) {
|
||||||
|
super(ability);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ParapetThrasherTriggeredAbility copy() {
|
||||||
|
return new ParapetThrasherTriggeredAbility(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
|
List<DamagedPlayerEvent> events = getFilteredEvents((DamagedBatchForOnePlayerEvent) event, game);
|
||||||
|
if (events.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.getAllEffects().setValue("damage", events.stream().mapToInt(DamagedEvent::getAmount).sum());
|
||||||
|
Player damagedPlayer = game.getPlayer(event.getTargetId());
|
||||||
|
|
||||||
|
FilterPermanent artifactFilter = new FilterArtifactPermanent("artifact " + damagedPlayer.getLogName() + " controls");
|
||||||
|
artifactFilter.add(new ControllerIdPredicate(damagedPlayer.getId()));
|
||||||
|
this.getTargets().clear();
|
||||||
|
this.addTarget(new TargetPermanent(artifactFilter));
|
||||||
|
|
||||||
|
for (Effect effect : this.getAllEffects()) {
|
||||||
|
if (effect instanceof ParapetThrasherDamageEffect) {
|
||||||
|
effect.setTargetPointer(new FixedTarget(damagedPlayer.getId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class ParapetThrasherDamageEffect extends OneShotEffect {
|
class ParapetThrasherDamageEffect extends OneShotEffect {
|
||||||
|
|
||||||
ParapetThrasherDamageEffect() {
|
ParapetThrasherDamageEffect() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,89 @@
|
||||||
|
package org.mage.test.cards.single.tdc;
|
||||||
|
|
||||||
|
import mage.constants.PhaseStep;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mage.test.serverside.base.CardTestCommander4Players;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jmlundeen
|
||||||
|
*/
|
||||||
|
public class ParapetThrasherTest extends CardTestCommander4Players {
|
||||||
|
|
||||||
|
/*
|
||||||
|
Parapet Thrasher
|
||||||
|
{2}{R}{R}
|
||||||
|
Creature - Dragon
|
||||||
|
Flying
|
||||||
|
Whenever one or more Dragons you control deal combat damage to an opponent, choose one that hasn't been chosen this turn --
|
||||||
|
* Destroy target artifact that opponent controls.
|
||||||
|
* This creature deals 4 damage to each other opponent.
|
||||||
|
* Exile the top card of your library. You may play it this turn.
|
||||||
|
4/3
|
||||||
|
*/
|
||||||
|
private static final String parapetThrasher = "Parapet Thrasher";
|
||||||
|
|
||||||
|
/*
|
||||||
|
Fountain of Youth
|
||||||
|
{0}
|
||||||
|
Artifact
|
||||||
|
{2}, {tap}: You gain 1 life.
|
||||||
|
*/
|
||||||
|
private static final String fountainOfYouth = "Fountain of Youth";
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testParapetThrasherMode1() {
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, parapetThrasher);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, fountainOfYouth);
|
||||||
|
|
||||||
|
attack(1, playerA, parapetThrasher, playerB);
|
||||||
|
setModeChoice(playerA, "1");
|
||||||
|
addTarget(playerA, fountainOfYouth);
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertGraveyardCount(playerB, fountainOfYouth, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testParapetThrasherMode2() {
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, parapetThrasher);
|
||||||
|
|
||||||
|
attack(1, playerA, parapetThrasher);
|
||||||
|
setModeChoice(playerA, "2");
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertLife(playerB, 20 - 4);
|
||||||
|
assertLife(playerC, 20 - 4);
|
||||||
|
assertLife(playerD, 20 - 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testParapetThrasherMode3() {
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
skipInitShuffling();
|
||||||
|
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, parapetThrasher);
|
||||||
|
addCard(Zone.LIBRARY, playerA, "Island");
|
||||||
|
addCard(Zone.LIBRARY, playerA, "Mountain");
|
||||||
|
|
||||||
|
attack(1, playerA, parapetThrasher);
|
||||||
|
setModeChoice(playerA, "3");
|
||||||
|
|
||||||
|
playLand(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Island");
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertExileCount(playerA, 0);
|
||||||
|
assertPermanentCount(playerA, "Island", 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue