diff --git a/Mage.Sets/src/mage/cards/t/TinderWall.java b/Mage.Sets/src/mage/cards/t/TinderWall.java index db670850d16..948a334c794 100644 --- a/Mage.Sets/src/mage/cards/t/TinderWall.java +++ b/Mage.Sets/src/mage/cards/t/TinderWall.java @@ -1,8 +1,5 @@ - package mage.cards.t; -import java.util.ArrayList; -import java.util.List; import java.util.UUID; import mage.MageInt; import mage.Mana; @@ -17,14 +14,10 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; -import mage.constants.WatcherScope; import mage.constants.Zone; import mage.filter.common.FilterAttackingCreature; import mage.filter.predicate.permanent.BlockedByIdPredicate; -import mage.game.Game; -import mage.game.events.GameEvent; import mage.target.common.TargetCreaturePermanent; -import mage.watchers.Watcher; /** * @@ -33,7 +26,7 @@ import mage.watchers.Watcher; public final class TinderWall extends CardImpl { public TinderWall(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{G}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{G}"); this.subtype.add(SubType.PLANT); this.subtype.add(SubType.WALL); @@ -50,7 +43,7 @@ public final class TinderWall extends CardImpl { Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(2), new ManaCostsImpl("{R}")); ability.addTarget(new TargetCreaturePermanent(filter)); ability.addCost(new SacrificeSourceCost()); - this.addAbility(ability, new BlockedByWatcher()); + this.addAbility(ability); } public TinderWall(final TinderWall card) { @@ -62,38 +55,3 @@ public final class TinderWall extends CardImpl { return new TinderWall(this); } } - -class BlockedByWatcher extends Watcher { - - public List blockedByWatcher = new ArrayList<>(); - - public BlockedByWatcher() { - super("BlockedByWatcher", WatcherScope.CARD); - } - - public BlockedByWatcher(final BlockedByWatcher watcher) { - super(watcher); - this.blockedByWatcher.addAll(watcher.blockedByWatcher); - } - - @Override - public BlockedByWatcher copy() { - return new BlockedByWatcher(this); - } - - @Override - public void watch(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.BLOCKER_DECLARED) { - if (sourceId.equals(event.getSourceId()) && !blockedByWatcher.contains(event.getTargetId())) { - blockedByWatcher.add(event.getTargetId()); - } - } - } - - @Override - public void reset() { - super.reset(); - blockedByWatcher.clear(); - } - -} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/TinderWallTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/TinderWallTest.java new file mode 100644 index 00000000000..42d9b2adf92 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/damage/TinderWallTest.java @@ -0,0 +1,40 @@ +package org.mage.test.cards.abilities.oneshot.damage; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class TinderWallTest extends CardTestPlayerBase { + + /** + * This test fails because the target is no longer seen as valid during + * resolution, because the source is no longer on the battlefield + * (sacrificed as cost) and therefore it's no longer blocking the target. + */ + @Test + public void testDamageFromInstantToPlayer() { + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1); + // Defender + // Sacrifice Tinder Wall: Add {R}{R}. + // {R}, Sacrifice Tinder Wall: Tinder Wall deals 2 damage to target creature it's blocking. + addCard(Zone.BATTLEFIELD, playerA, "Tinder Wall"); // Creature 0/3 + + addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion"); + + attack(2, playerB, "Silvercoat Lion"); + block(2, playerA, "Tinder Wall", "Silvercoat Lion"); + activateAbility(2, PhaseStep.DECLARE_BLOCKERS, playerA, "{R}, Sacrifice", "Silvercoat Lion"); + + setStopAt(2, PhaseStep.END_COMBAT); + execute(); + + assertGraveyardCount(playerA, "Tinder Wall", 1); + assertGraveyardCount(playerB, "Silvercoat Lion", 1); + } + +} diff --git a/Mage/src/main/java/mage/filter/predicate/permanent/BlockedByIdPredicate.java b/Mage/src/main/java/mage/filter/predicate/permanent/BlockedByIdPredicate.java index 949f6a20a59..b1ba27d4005 100644 --- a/Mage/src/main/java/mage/filter/predicate/permanent/BlockedByIdPredicate.java +++ b/Mage/src/main/java/mage/filter/predicate/permanent/BlockedByIdPredicate.java @@ -1,4 +1,3 @@ - package mage.filter.predicate.permanent; import java.util.UUID; @@ -6,6 +5,7 @@ import mage.filter.predicate.Predicate; import mage.game.Game; import mage.game.combat.CombatGroup; import mage.game.permanent.Permanent; +import mage.watchers.common.BlockedAttackerWatcher; /** * @@ -25,6 +25,13 @@ public class BlockedByIdPredicate implements Predicate { if (combatGroup.getBlockers().contains(blockerId) && combatGroup.getAttackers().contains(input.getId())) { return true; } + } // Check if the blockerId was blocked before, if it does no longer exists now but so the target attacking is still valid + Permanent blocker = game.getPermanentOrLKIBattlefield(blockerId); + if (blocker != null) { + BlockedAttackerWatcher watcher = (BlockedAttackerWatcher) game.getState().getWatchers().get(BlockedAttackerWatcher.class.getSimpleName()); + if (watcher != null) { + return watcher.creatureHasBlockedAttacker(input, blocker, game); + } } return false; }