1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-10 17:00:08 -09:00

Fixed some cards that did not correctly retrieve target object if it was not destroyed (fixes ) .

This commit is contained in:
LevelX2 2016-01-22 12:56:58 +01:00
parent fb7d05e82a
commit ecedc360e9
12 changed files with 135 additions and 74 deletions
Mage.Sets/src/mage/sets
Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/destroy

View file

@ -39,7 +39,6 @@ import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.filter.FilterSpell;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
@ -165,7 +164,7 @@ class SoulReapEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent creature = (Permanent) game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
Permanent creature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
if (creature != null) {
Player controller = game.getPlayer(creature.getControllerId());
if (controller != null) {

View file

@ -53,15 +53,15 @@ import mage.target.targetpointer.FixedTarget;
public class GrislySpectacle extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("nonartifact creature");
static {
filter.add(Predicates.not(new CardTypePredicate(CardType.ARTIFACT)));
}
public GrislySpectacle (UUID ownerId) {
public GrislySpectacle(UUID ownerId) {
super(ownerId, 66, "Grisly Spectacle", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{2}{B}{B}");
this.expansionSetCode = "GTC";
// Destroy target nonartifact creature. Its controller puts a number of cards equal to that creature's power from the top of his or her library into his or her graveyard.
this.getSpellAbility().addEffect(new DestroyTargetEffect());
this.getSpellAbility().addEffect(new GrislySpectacleEffect());
@ -73,7 +73,7 @@ public class GrislySpectacle extends CardImpl {
}
@Override
public GrislySpectacle copy() {
public GrislySpectacle copy() {
return new GrislySpectacle(this);
}
}
@ -96,7 +96,6 @@ class GrislySpectacleEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
// the mill effect works also if creature is indestructible or regenerated
Permanent creature = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source));
if (creature != null) {
Player controller = game.getPlayer(creature.getControllerId());

View file

@ -96,7 +96,7 @@ class GhostQuarterEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = (Permanent) game.getPermanentOrLKIBattlefield(source.getFirstTarget()); // if indestructible effect should work also
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getFirstTarget());
if (permanent != null) {
Player controller = game.getPlayer(permanent.getControllerId());
if (controller.chooseUse(Outcome.PutLandInPlay, "Do you wish to search for a basic land, put it onto the battlefield and then shuffle your library?", source, game)) {

View file

@ -56,7 +56,6 @@ public class Polymorph extends CardImpl {
super(ownerId, 67, "Polymorph", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{3}{U}");
this.expansionSetCode = "M10";
// Destroy target creature. It can't be regenerated.
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
this.getSpellAbility().addEffect(new DestroyTargetEffect(true));
@ -93,11 +92,7 @@ class PolymorphEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent == null) {
permanent = (Permanent) game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
}
Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
if (permanent != null) {
Player player = game.getPlayer(permanent.getControllerId());
if (player != null) {

View file

@ -28,15 +28,13 @@
package mage.sets.mirage;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl;
import mage.constants.Zone;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.SpiritWhiteToken;
@ -52,7 +50,6 @@ public class Afterlife extends CardImpl {
super(ownerId, 205, "Afterlife", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{2}{W}");
this.expansionSetCode = "MIR";
// Destroy target creature. It can't be regenerated. Its controller puts a
// 1/1 white Spirit creature token with flying onto the battlefield.
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
@ -96,4 +93,4 @@ class AfterlifeEffect extends OneShotEffect {
return true;
}
}
}

View file

@ -1,16 +1,16 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,19 +20,17 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.mirrodinbesieged;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
@ -62,7 +60,6 @@ public class PistusStrike extends CardImpl {
super(ownerId, 86, "Pistus Strike", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{2}{G}");
this.expansionSetCode = "MBS";
this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter));
this.getSpellAbility().addEffect(new DestroyTargetEffect());
this.getSpellAbility().addEffect(new PoisonControllerTargetCreatureEffect());
@ -96,15 +93,13 @@ class PoisonControllerTargetCreatureEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent p = game.getBattlefield().getPermanent(source.getFirstTarget());
if (p == null) {
p = (Permanent) game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
}
if (p != null) {
Player player = game.getPlayer(p.getControllerId());
Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
if (permanent != null) {
Player player = game.getPlayer(permanent.getControllerId());
if (player != null) {
player.addCounters(CounterType.POISON.createInstance(), game);
}
return true;
}
return false;
}

View file

@ -28,15 +28,13 @@
package mage.sets.newphyrexia;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl;
import mage.constants.Zone;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.BeastToken;
@ -52,7 +50,7 @@ public class BeastWithin extends CardImpl {
super(ownerId, 103, "Beast Within", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{2}{G}");
this.expansionSetCode = "NPH";
// Destroy target permanent. Its controller puts a 3/3 green Beast creature token onto the battlefield.
this.getSpellAbility().addTarget(new TargetPermanent());
this.getSpellAbility().addEffect(new DestroyTargetEffect());
this.getSpellAbility().addEffect(new BeastWithinEffect());
@ -86,12 +84,11 @@ class BeastWithinEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD);
Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
if (permanent != null) {
BeastToken token = new BeastToken();
token.putOntoBattlefield(1, game, source.getSourceId(), permanent.getControllerId());
new BeastToken().putOntoBattlefield(1, game, source.getSourceId(), permanent.getControllerId());
}
return true;
}
}
}

View file

@ -25,22 +25,20 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.scarsofmirrodin;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
@ -57,10 +55,12 @@ import mage.watchers.Watcher;
*/
public class FleshAllergy extends CardImpl {
public FleshAllergy (UUID ownerId) {
public FleshAllergy(UUID ownerId) {
super(ownerId, 62, "Flesh Allergy", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{2}{B}{B}");
this.expansionSetCode = "SOM";
// As an additional cost to cast Flesh Allergy, sacrifice a creature.
// Destroy target creature. Its controller loses life equal to the number of creatures that died this turn.
this.getSpellAbility().addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent()));
this.getSpellAbility().addEffect(new DestroyTargetEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
@ -68,7 +68,7 @@ public class FleshAllergy extends CardImpl {
this.getSpellAbility().addWatcher(new FleshAllergyWatcher());
}
public FleshAllergy (final FleshAllergy card) {
public FleshAllergy(final FleshAllergy card) {
super(card);
}
@ -97,7 +97,7 @@ class FleshAllergyWatcher extends Watcher {
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).isDiesEvent()) {
MageObject card = game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
if (card != null && card.getCardType().contains(CardType.CREATURE)) {
creaturesDiedThisTurn++;
@ -132,9 +132,9 @@ class FleshAllergyEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
FleshAllergyWatcher watcher = (FleshAllergyWatcher) game.getState().getWatchers().get("CreaturesDied");
MageObject card = game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
if (card != null && watcher != null) {
Player player = game.getPlayer(((Permanent)card).getControllerId());
Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
if (permanent != null && watcher != null) {
Player player = game.getPlayer(permanent.getControllerId());
if (player != null) {
int amount = watcher.creaturesDiedThisTurn;
if (amount > 0) {

View file

@ -28,7 +28,6 @@
package mage.sets.shadowmoor;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
@ -50,7 +49,6 @@ public class Gloomlance extends CardImpl {
super(ownerId, 67, "Gloomlance", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{3}{B}{B}");
this.expansionSetCode = "SHM";
// Destroy target creature. If that creature was green or white, its controller discards a card.
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
this.getSpellAbility().addEffect(new GloomlanceEffect());
@ -85,7 +83,7 @@ class GloomlanceEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent targetCreature = game.getPermanent(source.getFirstTarget());
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetCreature != null) {
Player targetController = game.getPlayer(targetCreature.getControllerId());
targetCreature.destroy(source.getSourceId(), game, false);

View file

@ -28,14 +28,13 @@
package mage.sets.worldwake;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.constants.Rarity;
import mage.filter.common.FilterArtifactOrEnchantmentPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -48,7 +47,7 @@ import mage.target.TargetPermanent;
*/
public class NaturesClaim extends CardImpl {
public NaturesClaim (UUID ownerId) {
public NaturesClaim(UUID ownerId) {
super(ownerId, 108, "Nature's Claim", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{G}");
this.expansionSetCode = "WWK";
@ -58,7 +57,7 @@ public class NaturesClaim extends CardImpl {
this.getSpellAbility().addTarget(new TargetPermanent(new FilterArtifactOrEnchantmentPermanent()));
}
public NaturesClaim (final NaturesClaim card) {
public NaturesClaim(final NaturesClaim card) {
super(card);
}
@ -69,6 +68,7 @@ public class NaturesClaim extends CardImpl {
}
class NaturesClaimEffect extends OneShotEffect {
NaturesClaimEffect() {
super(Outcome.GainLife);
staticText = "Its controller gains 4 life";
@ -80,7 +80,7 @@ class NaturesClaimEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent target = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD);
Permanent target = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
if (target != null) {
Player player = game.getPlayer(target.getControllerId());
if (player != null) {
@ -95,4 +95,4 @@ class NaturesClaimEffect extends OneShotEffect {
public NaturesClaimEffect copy() {
return new NaturesClaimEffect(this);
}
}
}

View file

@ -28,14 +28,13 @@
package mage.sets.zendikar;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -51,7 +50,6 @@ public class DesecratedEarth extends CardImpl {
super(ownerId, 86, "Desecrated Earth", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{4}{B}");
this.expansionSetCode = "ZEN";
// Destroy target land. Its controller discards a card.
this.getSpellAbility().addTarget(new TargetLandPermanent());
this.getSpellAbility().addEffect(new DestroyTargetEffect());
@ -87,11 +85,11 @@ class DesecratedEarthEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = (Permanent) game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
if (permanent != null) {
Player player = game.getPlayer(permanent.getControllerId());
if (player != null) {
player.discard(1, source, game);
player.discard(1, false, source, game);
return true;
}
}

View file

@ -0,0 +1,83 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package org.mage.test.cards.abilities.oneshot.destroy;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class NaturesClaimTest extends CardTestPlayerBase {
@Test
public void testTargetDestroyable() {
addCard(Zone.BATTLEFIELD, playerA, "Forest", 1);
// Destroy target artifact or enchantment. Its controller gains 4 life.
addCard(Zone.HAND, playerA, "Nature's Claim");
// Flying
addCard(Zone.BATTLEFIELD, playerA, "Gold-Forged Sentinel"); // 4/4
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Nature's Claim", "Gold-Forged Sentinel");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, "Nature's Claim", 1);
assertGraveyardCount(playerA, "Gold-Forged Sentinel", 1);
assertLife(playerA, 24);
assertLife(playerB, 20);
}
@Test
public void testTargetUndestroyable() {
addCard(Zone.BATTLEFIELD, playerA, "Forest", 1);
// Destroy target artifact or enchantment. Its controller gains 4 life.
addCard(Zone.HAND, playerA, "Nature's Claim");
// Flying
// Darksteel Gargoyle is indestructible. ("Destroy" effects and lethal damage don't destroy it.)
addCard(Zone.BATTLEFIELD, playerA, "Darksteel Gargoyle");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Nature's Claim", "Darksteel Gargoyle");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, "Nature's Claim", 1);
assertPermanentCount(playerA, "Darksteel Gargoyle", 1);
assertLife(playerA, 24);
assertLife(playerB, 20);
}
}