mirror of
https://github.com/correl/mage.git
synced 2024-11-25 03:00:11 +00:00
[M21] fixed Hooded Blightfang triggered ability (fixes #7935)
This commit is contained in:
parent
9a4489b47f
commit
f27f59603c
2 changed files with 81 additions and 11 deletions
|
@ -2,8 +2,9 @@ package mage.cards.h;
|
||||||
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
import mage.abilities.common.AttacksCreatureYouControlTriggeredAbility;
|
import mage.abilities.common.AttacksCreatureYouControlTriggeredAbility;
|
||||||
import mage.abilities.common.DestroyPlaneswalkerWhenDamagedTriggeredAbility;
|
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||||
import mage.abilities.effects.common.GainLifeEffect;
|
import mage.abilities.effects.common.GainLifeEffect;
|
||||||
import mage.abilities.effects.common.LoseLifeOpponentsEffect;
|
import mage.abilities.effects.common.LoseLifeOpponentsEffect;
|
||||||
import mage.abilities.keyword.DeathtouchAbility;
|
import mage.abilities.keyword.DeathtouchAbility;
|
||||||
|
@ -11,18 +12,24 @@ import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import mage.filter.StaticFilters;
|
||||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||||
import mage.filter.predicate.mageobject.AbilityPredicate;
|
import mage.filter.predicate.mageobject.AbilityPredicate;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author htrajan
|
* @author htrajan
|
||||||
*/
|
*/
|
||||||
public final class HoodedBlightfang extends CardImpl {
|
public final class HoodedBlightfang extends CardImpl {
|
||||||
|
|
||||||
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("a creature you control with deathtouch");
|
static final FilterControlledCreaturePermanent filter
|
||||||
|
= new FilterControlledCreaturePermanent("a creature you control with deathtouch");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
filter.add(new AbilityPredicate(DeathtouchAbility.class));
|
filter.add(new AbilityPredicate(DeathtouchAbility.class));
|
||||||
|
@ -39,12 +46,14 @@ public final class HoodedBlightfang extends CardImpl {
|
||||||
this.addAbility(DeathtouchAbility.getInstance());
|
this.addAbility(DeathtouchAbility.getInstance());
|
||||||
|
|
||||||
// Whenever a creature you control with deathtouch attacks, each opponent loses 1 life and you gain 1 life.
|
// Whenever a creature you control with deathtouch attacks, each opponent loses 1 life and you gain 1 life.
|
||||||
Ability ability = new AttacksCreatureYouControlTriggeredAbility(new LoseLifeOpponentsEffect(1), false, filter);
|
Ability ability = new AttacksCreatureYouControlTriggeredAbility(
|
||||||
ability.addEffect(new GainLifeEffect(1).setText("and you gain 1 life"));
|
new LoseLifeOpponentsEffect(1), false, filter
|
||||||
|
);
|
||||||
|
ability.addEffect(new GainLifeEffect(1).concatBy("and"));
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
||||||
// Whenever a creature you control with deathtouch deals damage to a planeswalker, destroy that planeswalker.
|
// Whenever a creature you control with deathtouch deals damage to a planeswalker, destroy that planeswalker.
|
||||||
this.addAbility(new DestroyPlaneswalkerWhenDamagedTriggeredAbility(filter));
|
this.addAbility(new HoodedBlightfangTriggeredAbility());
|
||||||
}
|
}
|
||||||
|
|
||||||
private HoodedBlightfang(final HoodedBlightfang card) {
|
private HoodedBlightfang(final HoodedBlightfang card) {
|
||||||
|
@ -56,3 +65,43 @@ public final class HoodedBlightfang extends CardImpl {
|
||||||
return new HoodedBlightfang(this);
|
return new HoodedBlightfang(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class HoodedBlightfangTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
|
HoodedBlightfangTriggeredAbility() {
|
||||||
|
super(Zone.BATTLEFIELD, new DestroyTargetEffect(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private HoodedBlightfangTriggeredAbility(final HoodedBlightfangTriggeredAbility ability) {
|
||||||
|
super(ability);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkEventType(GameEvent event, Game game) {
|
||||||
|
return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
|
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
|
||||||
|
Permanent damaged = game.getPermanentOrLKIBattlefield(event.getTargetId());
|
||||||
|
if (permanent == null
|
||||||
|
|| damaged == null
|
||||||
|
|| !StaticFilters.FILTER_PERMANENT_PLANESWALKER.match(damaged, game)
|
||||||
|
|| !HoodedBlightfang.filter.match(permanent, this.getSourceId(), this.getControllerId(), game)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.getEffects().setTargetPointer(new FixedTarget(damaged.getId(), damaged.getZoneChangeCounter(game)));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HoodedBlightfangTriggeredAbility copy() {
|
||||||
|
return new HoodedBlightfangTriggeredAbility(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRule() {
|
||||||
|
return "Whenever a creature you control with deathtouch deals damage to a planeswalker, destroy that planeswalker.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -7,13 +7,18 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
public class HoodedBlightfangTest extends CardTestPlayerBase {
|
public class HoodedBlightfangTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
|
private static final String blightfang = "Hooded Blightfang";
|
||||||
|
private static final String goblin = "Raging Goblin";
|
||||||
|
private static final String bow = "Bow of Nylea";
|
||||||
|
private static final String jace = "Jace Beleren";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBowOfNylea() {
|
public void testBowOfNylea() {
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Hooded Blightfang");
|
addCard(Zone.BATTLEFIELD, playerA, blightfang);
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Raging Goblin");
|
addCard(Zone.BATTLEFIELD, playerA, goblin);
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Bow of Nylea");
|
addCard(Zone.BATTLEFIELD, playerA, bow);
|
||||||
|
|
||||||
attack(1, playerA, "Raging Goblin");
|
attack(1, playerA, goblin);
|
||||||
setStopAt(2, PhaseStep.END_TURN);
|
setStopAt(2, PhaseStep.END_TURN);
|
||||||
execute();
|
execute();
|
||||||
assertAllCommandsUsed();
|
assertAllCommandsUsed();
|
||||||
|
@ -21,4 +26,20 @@ public class HoodedBlightfangTest extends CardTestPlayerBase {
|
||||||
assertLife(playerA, 20 + 1);
|
assertLife(playerA, 20 + 1);
|
||||||
assertLife(playerB, 20 - 1 - 1);
|
assertLife(playerB, 20 - 1 - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeathtouchPlaneswalker() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, blightfang);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, goblin);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, bow);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, jace);
|
||||||
|
|
||||||
|
attack(1, playerA, goblin, jace);
|
||||||
|
setStopAt(2, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
|
||||||
|
assertPermanentCount(playerB, jace, 0);
|
||||||
|
assertGraveyardCount(playerB, jace, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue