mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
* Pine Walker - Fixed that the turned face up ability did also trigger for other creatures if Pine Walker was face down (fixes #581).
This commit is contained in:
parent
87b1b64d80
commit
6a9a7d11e8
5 changed files with 61 additions and 6 deletions
|
@ -70,7 +70,7 @@ public class IcefeatherAven extends CardImpl {
|
|||
// Morph {1}{G}{U}
|
||||
this.addAbility(new MorphAbility(this, new ManaCostsImpl("{1}{G}{U}")));
|
||||
// When Icefeather Aven is turned face up, you may return another target creature to its owner's hand.
|
||||
Ability ability = new TurnedFaceUpSourceTriggeredAbility(new ReturnToHandTargetEffect());
|
||||
Ability ability = new TurnedFaceUpSourceTriggeredAbility(new ReturnToHandTargetEffect(), false, true);
|
||||
ability.addTarget(new TargetCreaturePermanent(filter));
|
||||
this.addAbility(ability);
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ public class MorphTest extends CardTestPlayerBase {
|
|||
* Test triggered turn face up ability of Pine Walker
|
||||
*/
|
||||
@Test
|
||||
public void testCopyFaceDwonMorphCreature() {
|
||||
public void testTurnFaceUpTrigger() {
|
||||
addCard(Zone.HAND, playerA, "Pine Walker");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Forest", 5);
|
||||
|
||||
|
@ -110,6 +110,42 @@ public class MorphTest extends CardTestPlayerBase {
|
|||
assertTapped("Pine Walker", false);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test triggered turn face up ability of Pine Walker did not trigger as
|
||||
* long as Pine Walker is not turned face up.
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testDoesNotTriggerFaceDown() {
|
||||
addCard(Zone.HAND, playerA, "Pine Walker");
|
||||
addCard(Zone.HAND, playerA, "Icefeather Aven");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Island", 3);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Pine Walker");
|
||||
setChoice(playerA, "Yes"); // cast it face down as 2/2 creature
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Icefeather Aven");
|
||||
setChoice(playerA, "Yes"); // cast it face down as 2/2 creature
|
||||
|
||||
attack(3, playerA, "");
|
||||
attack(3, playerA, "");
|
||||
activateAbility(3, PhaseStep.DECLARE_BLOCKERS, playerA, "{1}{G}{U}: Turn this face-down permanent face up.");
|
||||
setChoice(playerA, "No"); // Don't use return permanent to hand effect
|
||||
|
||||
setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertLife(playerB, 16);
|
||||
|
||||
assertHandCount(playerA, "Pine Walker", 0);
|
||||
assertHandCount(playerA, "Icefeather Aven", 0);
|
||||
assertPermanentCount(playerA, "", 1);
|
||||
assertPermanentCount(playerA, "Icefeather Aven", 1);
|
||||
assertTapped("Icefeather Aven", true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that Morph creature do not trigger abilities with their face up attributes
|
||||
*
|
||||
|
|
|
@ -30,9 +30,11 @@ package mage.abilities.common;
|
|||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.ActivatedAbilityImpl;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.Costs;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
|
@ -46,9 +48,10 @@ import mage.players.Player;
|
|||
|
||||
public class TurnFaceUpAbility extends ActivatedAbilityImpl {
|
||||
|
||||
public TurnFaceUpAbility(Costs costs) {
|
||||
public TurnFaceUpAbility(Costs<Cost> costs) {
|
||||
super(Zone.BATTLEFIELD, new TurnFaceUpEffect(), costs);
|
||||
this.usesStack = false;
|
||||
this.abilityType = AbilityType.SPECIAL_ACTION;
|
||||
this.setRuleVisible(false); // will be made visible only to controller in CardView
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public class TurnedFaceUpAllTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
public TurnedFaceUpAllTriggeredAbility(Effect effect, FilterPermanent filter, boolean setTargetPointer) {
|
||||
super(Zone.BATTLEFIELD, effect);
|
||||
// has to be set so the ability triggers if card is turn faced up
|
||||
// has to be set so the ability triggers if card itself is turn faced up
|
||||
this.setWorksFaceDown(true);
|
||||
this.filter = filter;
|
||||
this.setTargetPointer = setTargetPointer;
|
||||
|
@ -75,6 +75,18 @@ public class TurnedFaceUpAllTriggeredAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (EventType.TURNEDFACEUP.equals(event.getType())) {
|
||||
if (!event.getTargetId().equals(getSourceId())) {
|
||||
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(getSourceId());
|
||||
if (sourcePermanent != null) {
|
||||
if (sourcePermanent.isFaceDown()) {
|
||||
// if face down and it's not itself that is turned face up, it does not trigger
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Permanent is and was not on the battlefield
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (filter.match(permanent, getSourceId(), getControllerId(), game)) {
|
||||
if (setTargetPointer) {
|
||||
|
|
|
@ -28,7 +28,11 @@ public class TurnedFaceUpSourceTriggeredAbility extends TriggeredAbilityImpl {
|
|||
}
|
||||
|
||||
public TurnedFaceUpSourceTriggeredAbility(Effect effect, boolean setTargetPointer) {
|
||||
super(Zone.BATTLEFIELD, effect);
|
||||
this(effect, setTargetPointer, false);
|
||||
}
|
||||
|
||||
public TurnedFaceUpSourceTriggeredAbility(Effect effect, boolean setTargetPointer, boolean optional) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
// has to be set so the ability triggers if card is turn faced up
|
||||
this.setWorksFaceDown(true);
|
||||
this.setTargetPointer = setTargetPointer;
|
||||
|
|
Loading…
Reference in a new issue