mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
* Fixed a bug that replacemet effects did not work if the source object of the replacemet effect also changed zone (fixes #759).
This commit is contained in:
parent
6bd17716cd
commit
01ef3f9354
3 changed files with 37 additions and 5 deletions
|
@ -146,5 +146,39 @@ public class UndyingTest extends CardTestPlayerBase {
|
|||
assertExileCount("Butcher Ghoul", 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests "Target creature with Undying will be exiled by Anafenza before it returns to battlefield
|
||||
* if both leave the battlefield at the same time
|
||||
*
|
||||
* Anafenza the foremost doesn't exile an undying creature when dying at the same time as
|
||||
* that undying one. The undying comes back to the field when he shouldn't.
|
||||
*/
|
||||
@Test
|
||||
public void testReplacementEffectPreventsReturnOfUndyingWrath() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
|
||||
// Butcher Ghoul
|
||||
// Creature - Zombie, 1/1 {1}{B}
|
||||
// Undying (When this creature dies, if it had no +1/+1 counters on it, return it to the battlefield under its owner's control with a +1/+1 counter on it.)
|
||||
addCard(Zone.HAND, playerA, "Butcher Ghoul");
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Plains", 4);
|
||||
// Destroy all creatures. They can't be regenerated.
|
||||
addCard(Zone.HAND, playerB, "Wrath of God");
|
||||
// Anafenza, the Foremost
|
||||
// Whenever Anafenza, the Foremost attacks, put a +1/+1 counter on another target tapped creature you control.
|
||||
// If a creature card would be put into an opponent's graveyard from anywhere, exile it instead.
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Anafenza, the Foremost");
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Butcher Ghoul");
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Wrath of God");
|
||||
|
||||
setStopAt(2, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertGraveyardCount(playerB, "Anafenza, the Foremost", 1);
|
||||
assertGraveyardCount(playerB, "Wrath of God", 1);
|
||||
|
||||
assertPermanentCount(playerA, "Butcher Ghoul", 0);
|
||||
assertExileCount("Butcher Ghoul", 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -331,6 +331,7 @@ public class ContinuousEffects implements Serializable {
|
|||
if(auraReplacementEffect.checksEventType(event, game) && auraReplacementEffect.applies(event, null, game)){
|
||||
replaceEffects.put(auraReplacementEffect, null);
|
||||
}
|
||||
boolean checkLKI = event.getType().equals(EventType.ZONE_CHANGE) || event.getType().equals(EventType.DESTROYED_PERMANENT);
|
||||
//get all applicable transient Replacement effects
|
||||
for (ReplacementEffect effect: replacementEffects) {
|
||||
if (!effect.checksEventType(event, game)) {
|
||||
|
@ -344,7 +345,7 @@ public class ContinuousEffects implements Serializable {
|
|||
HashSet<Ability> abilities = replacementEffects.getAbility(effect.getId());
|
||||
HashSet<Ability> applicableAbilities = new HashSet<>();
|
||||
for (Ability ability : abilities) {
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, false)) {
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, checkLKI)) {
|
||||
if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
|
||||
if (!game.getScopeRelevant() || effect.hasSelfScope() || !event.getTargetId().equals(ability.getSourceId())) {
|
||||
if (checkAbilityStillExists(ability, effect, event, game)) {
|
||||
|
|
|
@ -40,7 +40,6 @@ public class UndyingAbility extends DiesTriggeredAbility {
|
|||
if (super.checkTrigger(event, game)) {
|
||||
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
||||
if (!permanent.getCounters().containsKey(CounterType.P1P1) || permanent.getCounters().getCount(CounterType.P1P1) == 0) {
|
||||
Logger.getLogger(UndyingAbility.class).info("Undying trigger: " + getSourceId());
|
||||
game.getState().setValue("undying" + getSourceId(),permanent.getId());
|
||||
return true;
|
||||
}
|
||||
|
@ -115,8 +114,6 @@ class UndyingReplacementEffect extends ReplacementEffectImpl {
|
|||
if (event.getTargetId().equals(source.getSourceId())) {
|
||||
// Check if undying condition is true
|
||||
UUID targetId = (UUID) game.getState().getValue("undying" + source.getSourceId());
|
||||
Logger.getLogger(UndyingReplacementEffect.class).info("Undying replacement applies: " + targetId + " eventSourceId " + event.getTargetId());
|
||||
|
||||
if (targetId != null && targetId.equals(source.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue