mirror of
https://github.com/correl/mage.git
synced 2025-04-09 17:00:09 -09:00
* Ashcloud Phoenix - Fixed that the dies triggered abilitiy worked if he died face down.
This commit is contained in:
parent
4a051612d1
commit
b382865e8d
5 changed files with 49 additions and 15 deletions
Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords
Mage/src/mage/abilities
|
@ -116,7 +116,7 @@ public class MorphTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that the triggered "turned face up" ability of Pine Walker does not trigger
|
* Test that the triggered "turned face up" ability of Pine Walker does not trigger
|
||||||
* aas long as Pine Walker is not turned face up.
|
* as long as Pine Walker is not turned face up.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
|
@ -366,7 +366,7 @@ public class MorphTest extends CardTestPlayerBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that an effect like "arget creature and all other creatures with the same name" does
|
* Check that an effect like "Target creature and all other creatures with the same name" does
|
||||||
* only effect one face down creature, also if multiple on the battlefield. Because they have no
|
* only effect one face down creature, also if multiple on the battlefield. Because they have no
|
||||||
* name, they don't have the same name.
|
* name, they don't have the same name.
|
||||||
*
|
*
|
||||||
|
@ -469,4 +469,41 @@ public class MorphTest extends CardTestPlayerBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Check that a DiesTriggeredAbility of a creature does not trigger
|
||||||
|
* if the creature dies face down
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDiesTriggeredDoesNotTriggerIfFaceDown() {
|
||||||
|
addCard(Zone.HAND, playerA, "Ashcloud Phoenix", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
|
||||||
|
|
||||||
|
addCard(Zone.HAND, playerB, "Lightning Bolt", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 1);
|
||||||
|
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Ashcloud Phoenix");
|
||||||
|
setChoice(playerA, "Yes"); // cast it face down as 2/2 creature
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", "face down creature");
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertLife(playerA, 20);
|
||||||
|
assertLife(playerB, 20);
|
||||||
|
|
||||||
|
assertGraveyardCount(playerB, "Lightning Bolt", 1);
|
||||||
|
assertGraveyardCount(playerA, "Ashcloud Phoenix", 1);
|
||||||
|
|
||||||
|
|
||||||
|
for (Card card: playerA.getGraveyard().getCards(currentGame)) {
|
||||||
|
if (card.getName().equals("Ashcloud Phoenix")) {
|
||||||
|
Assert.assertEquals("Ashcloud Phoenix has to be face up in graveyard", false, card.isFaceDown(currentGame));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -895,14 +895,6 @@ public abstract class AbilityImpl implements Ability {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// else if (object instanceof PermanentCard) {
|
|
||||||
// this check prevents Flying to work if assigned to a face down creature
|
|
||||||
// Why is this neccessary??
|
|
||||||
// if (((PermanentCard)object).isFaceDown(game)&& !this.getWorksFaceDown()) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// check against current state
|
// check against current state
|
||||||
Zone test = game.getState().getZone(parameterSourceId);
|
Zone test = game.getState().getZone(parameterSourceId);
|
||||||
return test != null && zone.match(test);
|
return test != null && zone.match(test);
|
||||||
|
|
|
@ -70,7 +70,8 @@ public class TriggeredAbilities extends ConcurrentHashMap<String, TriggeredAbili
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// for effects like when leaves battlefield or destroyed use ShortLKI to check if permanent was in the correct zone before (e.g. Oblivion Ring or Karmic Justice)
|
// for effects like when leaves battlefield or destroyed use ShortLKI to check if permanent was in the correct zone before (e.g. Oblivion Ring or Karmic Justice)
|
||||||
if (ability.isInUseableZone(game, null, event.getType().equals(EventType.ZONE_CHANGE) || event.getType().equals(EventType.DESTROYED_PERMANENT))) {
|
if (ability.isInUseableZone(game, ability.getSourceObject(game), event.getType().equals(EventType.ZONE_CHANGE) || event.getType().equals(EventType.DESTROYED_PERMANENT))) {
|
||||||
|
|
||||||
if (!game.getContinuousEffects().preventedByRuleModification(event, ability, game, false)) {
|
if (!game.getContinuousEffects().preventedByRuleModification(event, ability, game, false)) {
|
||||||
MageObject object = null;
|
MageObject object = null;
|
||||||
if (!ability.getZone().equals(Zone.COMMAND) && !game.getState().getZone(ability.getSourceId()).equals(ability.getZone())) {
|
if (!ability.getZone().equals(Zone.COMMAND) && !game.getState().getZone(ability.getSourceId()).equals(ability.getZone())) {
|
||||||
|
@ -82,6 +83,9 @@ public class TriggeredAbilities extends ConcurrentHashMap<String, TriggeredAbili
|
||||||
|
|
||||||
if (object != null) {
|
if (object != null) {
|
||||||
if (object instanceof Permanent) {
|
if (object instanceof Permanent) {
|
||||||
|
if (((Permanent)object).isFaceDown(game) && !ability.getWorksFaceDown()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
ability.setControllerId(((Permanent) object).getControllerId());
|
ability.setControllerId(((Permanent) object).getControllerId());
|
||||||
}
|
}
|
||||||
ability.setSourceObject(object);
|
ability.setSourceObject(object);
|
||||||
|
|
|
@ -34,6 +34,7 @@ import mage.abilities.effects.Effect;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.events.ZoneChangeEvent;
|
import mage.game.events.ZoneChangeEvent;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -56,7 +57,7 @@ public class DiesTriggeredAbility extends ZoneChangeTriggeredAbility {
|
||||||
@Override
|
@Override
|
||||||
public boolean isInUseableZone(Game game, MageObject source, boolean checkLKI) {
|
public boolean isInUseableZone(Game game, MageObject source, boolean checkLKI) {
|
||||||
// check it was previously on battlefield
|
// check it was previously on battlefield
|
||||||
MageObject before = game.getLastKnownInformation(sourceId, Zone.BATTLEFIELD);
|
Permanent before = (Permanent) game.getLastKnownInformation(sourceId, Zone.BATTLEFIELD);
|
||||||
// check now it is in graveyard
|
// check now it is in graveyard
|
||||||
Zone after = game.getState().getZone(sourceId);
|
Zone after = game.getState().getZone(sourceId);
|
||||||
return before != null && after != null && Zone.GRAVEYARD.match(after);
|
return before != null && after != null && Zone.GRAVEYARD.match(after);
|
||||||
|
|
|
@ -158,7 +158,7 @@ public class BecomesFaceDownCreatureEffect extends ContinuousEffectImpl implemen
|
||||||
break;
|
break;
|
||||||
case AbilityAddingRemovingEffects_6:
|
case AbilityAddingRemovingEffects_6:
|
||||||
Card card = game.getCard(permanent.getId()); //
|
Card card = game.getCard(permanent.getId()); //
|
||||||
List<Ability> abilities = new ArrayList<>();
|
List<Ability> abilitiesToRemove = new ArrayList<>();
|
||||||
for (Ability ability : permanent.getAbilities()) {
|
for (Ability ability : permanent.getAbilities()) {
|
||||||
if (card != null && !card.getAbilities().contains(ability)) {
|
if (card != null && !card.getAbilities().contains(ability)) {
|
||||||
// gained abilities from other sources won't be removed
|
// gained abilities from other sources won't be removed
|
||||||
|
@ -174,9 +174,9 @@ public class BecomesFaceDownCreatureEffect extends ContinuousEffectImpl implemen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
abilities.add(ability);
|
abilitiesToRemove.add(ability);
|
||||||
}
|
}
|
||||||
permanent.getAbilities().removeAll(abilities);
|
permanent.getAbilities().removeAll(abilitiesToRemove);
|
||||||
if (turnFaceUpAbility != null) {
|
if (turnFaceUpAbility != null) {
|
||||||
permanent.addAbility(turnFaceUpAbility, source.getSourceId(), game);
|
permanent.addAbility(turnFaceUpAbility, source.getSourceId(), game);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue