mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
* Elite Scaleguard - Fixed not working triggered ability (fixes #6689).
This commit is contained in:
parent
3f2a5fc362
commit
313829c826
2 changed files with 115 additions and 29 deletions
|
@ -1,10 +1,11 @@
|
||||||
|
|
||||||
package mage.cards.e;
|
package mage.cards.e;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.AttacksCreatureYouControlTriggeredAbility;
|
import mage.abilities.common.AttacksCreatureYouControlTriggeredAbility;
|
||||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||||
|
import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.effects.common.TapTargetEffect;
|
import mage.abilities.effects.common.TapTargetEffect;
|
||||||
import mage.abilities.effects.keyword.BolsterEffect;
|
import mage.abilities.effects.keyword.BolsterEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
@ -14,13 +15,12 @@ import mage.constants.SubType;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
|
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||||
import mage.filter.predicate.permanent.CounterPredicate;
|
import mage.filter.predicate.permanent.CounterPredicate;
|
||||||
import mage.filter.predicate.permanent.DefendingPlayerControlsPredicate;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
import mage.target.targetadjustment.TargetAdjuster;
|
||||||
import java.util.UUID;
|
import mage.target.targetpointer.FirstTargetPointer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author emerald000
|
* @author emerald000
|
||||||
|
@ -28,11 +28,9 @@ import java.util.UUID;
|
||||||
public final class EliteScaleguard extends CardImpl {
|
public final class EliteScaleguard extends CardImpl {
|
||||||
|
|
||||||
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creature you control with a +1/+1 counter on it");
|
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creature you control with a +1/+1 counter on it");
|
||||||
private static final FilterCreaturePermanent filter2 = new FilterCreaturePermanent("creature defending player controls");
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
filter.add(new CounterPredicate(CounterType.P1P1));
|
filter.add(new CounterPredicate(CounterType.P1P1));
|
||||||
filter2.add(DefendingPlayerControlsPredicate.instance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public EliteScaleguard(UUID ownerId, CardSetInfo setInfo) {
|
public EliteScaleguard(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
@ -46,8 +44,9 @@ public final class EliteScaleguard extends CardImpl {
|
||||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new BolsterEffect(2)));
|
this.addAbility(new EntersBattlefieldTriggeredAbility(new BolsterEffect(2)));
|
||||||
|
|
||||||
// Whenever a creature you control with a +1/+1 counter on it attacks, tap target creature defending player controls.
|
// Whenever a creature you control with a +1/+1 counter on it attacks, tap target creature defending player controls.
|
||||||
Ability ability = new AttacksCreatureYouControlTriggeredAbility(new EliteScaleguardTapEffect(), false, filter, true);
|
Ability ability = new AttacksCreatureYouControlTriggeredAbility(new TapTargetEffect(), false, filter, true);
|
||||||
ability.addTarget(new TargetCreaturePermanent(filter2));
|
ability.addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("creature defending player controls")));
|
||||||
|
ability.setTargetAdjuster(EliteScaleguardTargetAdjuster.instance);
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,28 +60,21 @@ public final class EliteScaleguard extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class EliteScaleguardTapEffect extends TapTargetEffect {
|
enum EliteScaleguardTargetAdjuster implements TargetAdjuster {
|
||||||
|
instance;
|
||||||
EliteScaleguardTapEffect() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
EliteScaleguardTapEffect(final EliteScaleguardTapEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EliteScaleguardTapEffect copy() {
|
public void adjustTargets(Ability ability, Game game) {
|
||||||
return new EliteScaleguardTapEffect(this);
|
FilterCreaturePermanent filterDefender = new FilterCreaturePermanent("creature defending player controls");
|
||||||
}
|
for (Effect effect : ability.getEffects()) {
|
||||||
|
if (effect instanceof TapTargetEffect) {
|
||||||
@Override
|
filterDefender.add(new ControllerIdPredicate(game.getCombat().getDefendingPlayerId(effect.getTargetPointer().getFirst(game, ability), game)));
|
||||||
public boolean apply(Game game, Ability source) {
|
effect.setTargetPointer(new FirstTargetPointer());// reset target pointer to first target to tap correct target
|
||||||
Permanent permanent = game.getPermanent(source.getFirstTarget());
|
break;
|
||||||
if (permanent != null) {
|
}
|
||||||
permanent.tap(game);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
ability.getTargets().clear();
|
||||||
|
TargetCreaturePermanent target = new TargetCreaturePermanent(filterDefender);
|
||||||
|
ability.addTarget(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
package org.mage.test.cards.abilities.keywords;
|
||||||
|
|
||||||
|
import mage.constants.PhaseStep;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import mage.counters.CounterType;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author LevelX2
|
||||||
|
*/
|
||||||
|
public class BolsterTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests keyword bolster
|
||||||
|
*
|
||||||
|
* 701.32. Bolster <br>
|
||||||
|
* 701.32a "Bolster N" means “Choose a creature you control with the least
|
||||||
|
* toughness or tied for least toughness among creatures you control. Put N
|
||||||
|
* +1/+1 counters on that creature.”
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void Basic1Test() {
|
||||||
|
// When Elite Scaleguard enters the battlefield, bolster 2.
|
||||||
|
// Whenever a creature you control with a +1/+1 counter on it attacks, tap target creature defending player controls.
|
||||||
|
addCard(Zone.HAND, playerA, "Elite Scaleguard"); // Creature 2/3 {4}{W}
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Elite Scaleguard");
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
|
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
execute();
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
|
||||||
|
assertCounterCount("Elite Scaleguard", CounterType.P1P1, 2);
|
||||||
|
assertPowerToughness(playerA, "Elite Scaleguard", 4, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void Basic2Test() {
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
// When Elite Scaleguard enters the battlefield, bolster 2.
|
||||||
|
// Whenever a creature you control with a +1/+1 counter on it attacks, tap target creature defending player controls.
|
||||||
|
addCard(Zone.HAND, playerA, "Elite Scaleguard"); // Creature 2/3 {4}{W}
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1);
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Elite Scaleguard");
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
|
|
||||||
|
execute();
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
|
||||||
|
assertPowerToughness(playerA, "Elite Scaleguard", 2, 3);
|
||||||
|
assertCounterCount("Silvercoat Lion", CounterType.P1P1, 2);
|
||||||
|
assertPowerToughness(playerA, "Silvercoat Lion", 4, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void EliteScaleguardTriggerTest() {
|
||||||
|
// When Elite Scaleguard enters the battlefield, bolster 2.
|
||||||
|
// Whenever a creature you control with a +1/+1 counter on it attacks, tap target creature defending player controls.
|
||||||
|
addCard(Zone.HAND, playerA, "Elite Scaleguard"); // Creature 2/3 {4}{W}
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1);
|
||||||
|
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Pillarfield Ox", 1);
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Elite Scaleguard");
|
||||||
|
|
||||||
|
attack(3, playerA, "Silvercoat Lion");
|
||||||
|
addTarget(playerA, "Pillarfield Ox"); // Tap from triggered ability of Elite Scaleguard
|
||||||
|
|
||||||
|
setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
|
||||||
|
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
execute();
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
|
||||||
|
assertPowerToughness(playerA, "Elite Scaleguard", 2, 3);
|
||||||
|
assertCounterCount("Silvercoat Lion", CounterType.P1P1, 2);
|
||||||
|
assertPowerToughness(playerA, "Silvercoat Lion", 4, 4);
|
||||||
|
assertTapped("Silvercoat Lion", true);
|
||||||
|
|
||||||
|
assertPermanentCount(playerB, "Pillarfield Ox", 1);
|
||||||
|
assertTapped("Pillarfield Ox", true);
|
||||||
|
|
||||||
|
assertLife(playerB, 16);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue