Address issue #1311 (cards with multiple different targets). More work

will need to be done for cards that target a creature or player (rather
than creature only).
This commit is contained in:
Skyler Sell 2016-01-22 16:15:22 -08:00
parent 67d78f19ee
commit ed5361cbd6
10 changed files with 182 additions and 41 deletions

View file

@ -37,6 +37,8 @@ import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.AnotherTargetPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
@ -54,8 +56,17 @@ public class ConsumeStrength extends CardImpl {
// Target creature gets +2/+2 until end of turn. Another target creature gets -2/-2 until end of turn.
this.getSpellAbility().addEffect(new ConsumeStrengthEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent(2));
FilterCreaturePermanent filter1 = new FilterCreaturePermanent("creature to get +2/+2");
TargetCreaturePermanent target1 = new TargetCreaturePermanent(filter1);
target1.setTargetTag(1);
this.getSpellAbility().addTarget(target1);
FilterCreaturePermanent filter2 = new FilterCreaturePermanent("another creature to get -2/-2");
filter2.add(new AnotherTargetPredicate(2));
TargetCreaturePermanent target2 = new TargetCreaturePermanent(filter2);
target2.setTargetTag(2);
this.getSpellAbility().addTarget(target2);
}
public ConsumeStrength(final ConsumeStrength card) {
@ -91,7 +102,7 @@ class ConsumeStrengthEffect extends ContinuousEffectImpl {
permanent.addPower(2);
permanent.addToughness(2);
}
permanent = game.getPermanent(source.getTargets().get(0).getTargets().get(1));
permanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (permanent != null) {
permanent.addPower(-2);
permanent.addToughness(-2);

View file

@ -56,7 +56,7 @@ public class Bioshift extends CardImpl {
// Move any number of +1/+1 counters from target creature onto another target creature with the same controller.
getSpellAbility().addEffect(new MoveCounterFromTargetToTargetEffect());
getSpellAbility().addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("creature (you take counters from)")));
getSpellAbility().addTarget(new BioshiftSecondTargetPermanent());
getSpellAbility().addTarget(new BioshiftSecondTargetCreaturePermanent());
}
@ -113,14 +113,15 @@ class MoveCounterFromTargetToTargetEffect extends OneShotEffect {
}
}
class BioshiftSecondTargetPermanent extends TargetPermanent {
class BioshiftSecondTargetCreaturePermanent extends TargetCreaturePermanent {
BioshiftSecondTargetPermanent() {
super();
this.filter = new FilterCreaturePermanent("another target creature with the same controller (counters go to)");
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("another target creature with the same controller (counters go to)");
BioshiftSecondTargetCreaturePermanent() {
super(filter);
}
BioshiftSecondTargetPermanent(final BioshiftSecondTargetPermanent target) {
BioshiftSecondTargetCreaturePermanent(final BioshiftSecondTargetCreaturePermanent target) {
super(target);
}
@ -137,7 +138,7 @@ class BioshiftSecondTargetPermanent extends TargetPermanent {
}
@Override
public BioshiftSecondTargetPermanent copy() {
return new BioshiftSecondTargetPermanent(this);
public BioshiftSecondTargetCreaturePermanent copy() {
return new BioshiftSecondTargetCreaturePermanent(this);
}
}

View file

@ -37,6 +37,8 @@ import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.AnotherTargetPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
@ -53,7 +55,17 @@ public class Schismotivate extends CardImpl {
// Target creature gets +4/+0 until end of turn. Another target creature gets -4/-0 until end of turn.
this.getSpellAbility().addEffect(new SchismotivateEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent(2));
FilterCreaturePermanent filter1 = new FilterCreaturePermanent("creature (gets +4/+0 until end of turn)");
TargetCreaturePermanent target1 = new TargetCreaturePermanent(filter1);
target1.setTargetTag(1);
this.getSpellAbility().addTarget(target1);
FilterCreaturePermanent filter2 = new FilterCreaturePermanent("another creature (gets -4/-0 until end of turn)");
filter2.add(new AnotherTargetPredicate(2));
TargetCreaturePermanent target2 = new TargetCreaturePermanent(filter2);
target2.setTargetTag(2);
this.getSpellAbility().addTarget(target2);
}
public Schismotivate(final Schismotivate card) {
@ -88,7 +100,7 @@ class SchismotivateEffect extends ContinuousEffectImpl {
if (permanent != null) {
permanent.addPower(4);
}
permanent = game.getPermanent(source.getTargets().get(0).getTargets().get(1));
permanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (permanent != null) {
permanent.addPower(-4);
}

View file

@ -35,6 +35,8 @@ import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.counters.CounterType;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.AnotherTargetPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.Target;
@ -53,8 +55,23 @@ public class IncrementalGrowth extends CardImpl {
// Put a +1/+1 counter on target creature, two +1/+1 counters on another target creature, and three +1/+1 counters on a third target creature.
this.getSpellAbility().addEffect(new IncrementalGrowthEffect());
Target target = new TargetCreaturePermanent(3,3);
this.getSpellAbility().addTarget(target);
FilterCreaturePermanent filter1 = new FilterCreaturePermanent("creature (gets a +1/+1 counter)");
TargetCreaturePermanent target1 = new TargetCreaturePermanent(filter1);
target1.setTargetTag(1);
this.getSpellAbility().addTarget(target1);
FilterCreaturePermanent filter2 = new FilterCreaturePermanent("another creature (gets two +1/+1 counter)");
filter2.add(new AnotherTargetPredicate(2));
TargetCreaturePermanent target2 = new TargetCreaturePermanent(filter2);
target2.setTargetTag(2);
this.getSpellAbility().addTarget(target2);
FilterCreaturePermanent filter3 = new FilterCreaturePermanent("another creature (gets three +1/+1 counters)");
filter3.add(new AnotherTargetPredicate(3));
TargetCreaturePermanent target3 = new TargetCreaturePermanent(filter3);
target3.setTargetTag(3);
this.getSpellAbility().addTarget(target3);
}
public IncrementalGrowth(final IncrementalGrowth card) {
@ -86,9 +103,9 @@ class IncrementalGrowthEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
int i = 0;
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
for (Target target : source.getTargets()) {
i++;
Permanent creature = game.getPermanent(targetId);
Permanent creature = game.getPermanent(target.getFirstTarget());
if (creature != null) {
creature.addCounters(CounterType.P1P1.createInstance(i), game);
}

View file

@ -28,15 +28,20 @@
package mage.sets.newphyrexia;
import java.util.UUID;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.AnotherTargetPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.SecondTargetPointer;
/**
*
@ -48,16 +53,20 @@ public class LeechingBite extends CardImpl {
super(ownerId, 113, "Leeching Bite", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{G}");
this.expansionSetCode = "NPH";
// Target creature gets +1/+1 until end of turn. Another target creature gets -1/-1 until end of turn.
Effect effect = new BoostTargetEffect(1, 1, Duration.EndOfTurn);
effect.setText("Target creature gets +1/+1 until end of turn");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("creature (getting the +1/+1 counter)")));
effect = new BoostTargetEffect(-1, -1, Duration.EndOfTurn);
effect.setText("Another target creature gets -1/-1 until end of turn");
effect.setTargetPointer(new SecondTargetPointer());
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("creature (getting the -1/-1 counter)")));
this.getSpellAbility().addEffect(new LeechingBiteEffect());
FilterCreaturePermanent filter1 = new FilterCreaturePermanent("creature to get +1/+1");
TargetCreaturePermanent target1 = new TargetCreaturePermanent(filter1);
target1.setTargetTag(1);
this.getSpellAbility().addTarget(target1);
FilterCreaturePermanent filter2 = new FilterCreaturePermanent("another creature to get -1/-1");
filter2.add(new AnotherTargetPredicate(2));
TargetCreaturePermanent target2 = new TargetCreaturePermanent(filter2);
target2.setTargetTag(2);
this.getSpellAbility().addTarget(target2);
}
public LeechingBite(final LeechingBite card) {
@ -69,3 +78,35 @@ public class LeechingBite extends CardImpl {
return new LeechingBite(this);
}
}
class LeechingBiteEffect extends ContinuousEffectImpl {
public LeechingBiteEffect() {
super(Duration.EndOfTurn, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature);
this.staticText = "Target creature gets +1/+1 until end of turn. Another target creature gets -1/-1 until end of turn";
}
public LeechingBiteEffect(final LeechingBiteEffect effect) {
super(effect);
}
@Override
public LeechingBiteEffect copy() {
return new LeechingBiteEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
permanent.addPower(1);
permanent.addToughness(1);
}
permanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (permanent != null) {
permanent.addPower(-1);
permanent.addToughness(-1);
}
return true;
}
}

View file

@ -37,6 +37,8 @@ import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.AnotherTargetPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
@ -53,7 +55,17 @@ public class StealStrength extends CardImpl {
// Target creature gets +1/+1 until end of turn. Another target creature gets -1/-1 until end of turn.
this.getSpellAbility().addEffect(new StealStrengthEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent(2));
FilterCreaturePermanent filter1 = new FilterCreaturePermanent("creature (gets +1/+1 until end of turn)");
TargetCreaturePermanent target1 = new TargetCreaturePermanent(filter1);
target1.setTargetTag(1);
this.getSpellAbility().addTarget(target1);
FilterCreaturePermanent filter2 = new FilterCreaturePermanent("another creature (gets -1/-1 until end of turn)");
filter2.add(new AnotherTargetPredicate(2));
TargetCreaturePermanent target2 = new TargetCreaturePermanent(filter2);
target2.setTargetTag(2);
this.getSpellAbility().addTarget(target2);
}
public StealStrength(final StealStrength card) {
@ -89,7 +101,7 @@ class StealStrengthEffect extends ContinuousEffectImpl {
permanent.addPower(1);
permanent.addToughness(1);
}
permanent = game.getPermanent(source.getTargets().get(0).getTargets().get(1));
permanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (permanent != null) {
permanent.addPower(-1);
permanent.addToughness(-1);

View file

@ -37,6 +37,8 @@ import mage.constants.SubLayer;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.cards.CardImpl;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.AnotherTargetPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
@ -54,7 +56,17 @@ public class RitesOfReaping extends CardImpl {
// Target creature gets +3/+3 until end of turn. Another target creature gets -3/-3 until end of turn.
this.getSpellAbility().addEffect(new RitesOfReapingEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent(2));
FilterCreaturePermanent filter1 = new FilterCreaturePermanent("creature (gets +3/+3 until end of turn)");
TargetCreaturePermanent target1 = new TargetCreaturePermanent(filter1);
target1.setTargetTag(1);
this.getSpellAbility().addTarget(target1);
FilterCreaturePermanent filter2 = new FilterCreaturePermanent("another creature (gets -3/-3 until end of turn)");
filter2.add(new AnotherTargetPredicate(2));
TargetCreaturePermanent target2 = new TargetCreaturePermanent(filter2);
target2.setTargetTag(2);
this.getSpellAbility().addTarget(target2);
}
public RitesOfReaping(final RitesOfReaping card) {
@ -90,7 +102,7 @@ class RitesOfReapingEffect extends ContinuousEffectImpl {
permanent.addPower(3);
permanent.addToughness(3);
}
permanent = game.getPermanent(source.getTargets().get(0).getTargets().get(1));
permanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (permanent != null) {
permanent.addPower(-3);
permanent.addToughness(-3);

View file

@ -36,6 +36,7 @@ import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.counters.Counter;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.AnotherTargetPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
@ -47,7 +48,7 @@ import mage.target.common.TargetCreaturePermanent;
public class FateTransfer extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("target creature to move all counters from");
private static final FilterCreaturePermanent filter2 = new FilterCreaturePermanent("target creature to move all counters to");
private static final FilterCreaturePermanent filter2 = new FilterCreaturePermanent("another target creature to move all counters to");
public FateTransfer(UUID ownerId) {
super(ownerId, 161, "Fate Transfer", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{U/B}");
@ -55,8 +56,15 @@ public class FateTransfer extends CardImpl {
// Move all counters from target creature onto another target creature.
this.getSpellAbility().addEffect(new FateTransferEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter));
this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter2));
TargetCreaturePermanent fromTarget = new TargetCreaturePermanent(filter);
fromTarget.setTargetTag(1);
this.getSpellAbility().addTarget(fromTarget);
TargetCreaturePermanent toTarget = new TargetCreaturePermanent(filter2);
filter2.add(new AnotherTargetPredicate(2));
toTarget.setTargetTag(2);
this.getSpellAbility().addTarget(toTarget);
}

View file

@ -35,6 +35,8 @@ import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.counters.CounterType;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.AnotherTargetPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.Target;
@ -53,8 +55,23 @@ public class IncrementalBlight extends CardImpl {
// Put a -1/-1 counter on target creature, two -1/-1 counters on another target creature, and three -1/-1 counters on a third target creature.
this.getSpellAbility().addEffect(new IncrementalBlightEffect());
Target target = new TargetCreaturePermanent(3,3);
this.getSpellAbility().addTarget(target);
FilterCreaturePermanent filter1 = new FilterCreaturePermanent("creature (gets a -1/-1 counter)");
TargetCreaturePermanent target1 = new TargetCreaturePermanent(filter1);
target1.setTargetTag(1);
this.getSpellAbility().addTarget(target1);
FilterCreaturePermanent filter2 = new FilterCreaturePermanent("another creature (gets two -1/-1 counters)");
filter2.add(new AnotherTargetPredicate(2));
TargetCreaturePermanent target2 = new TargetCreaturePermanent(filter2);
target2.setTargetTag(2);
this.getSpellAbility().addTarget(target2);
FilterCreaturePermanent filter3 = new FilterCreaturePermanent("another creature (gets three -1/-1 counters)");
filter3.add(new AnotherTargetPredicate(3));
TargetCreaturePermanent target3 = new TargetCreaturePermanent(filter3);
target3.setTargetTag(3);
this.getSpellAbility().addTarget(target3);
}
public IncrementalBlight(final IncrementalBlight card) {
@ -85,9 +102,9 @@ class IncrementalBlightEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
int i = 0;
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
for (Target target : source.getTargets()) {
i++;
Permanent creature = game.getPermanent(targetId);
Permanent creature = game.getPermanent(target.getFirstTarget());
if (creature != null) {
creature.addCounters(CounterType.M1M1.createInstance(i), game);
}

View file

@ -37,6 +37,8 @@ import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.cards.CardImpl;
import mage.constants.Duration;
import mage.counters.CounterType;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.AnotherTargetPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetControlledCreaturePermanent;
@ -54,10 +56,18 @@ public class FeralContest extends CardImpl {
// Put a +1/+1 counter on target creature you control.
this.getSpellAbility().addEffect(new AddCountersTargetEffect(CounterType.P1P1.createInstance()));
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
TargetControlledCreaturePermanent target1 = new TargetControlledCreaturePermanent();
target1.setTargetTag(1);
this.getSpellAbility().addTarget(target1);
// Another target creature blocks it this turn if able.
this.getSpellAbility().addEffect(new FeralContestEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature (must block this turn)");
filter.add(new AnotherTargetPredicate(2));
TargetCreaturePermanent target2 = new TargetCreaturePermanent(filter);
target2.setTargetTag(2);
this.getSpellAbility().addTarget(target2);
}
public FeralContest(final FeralContest card) {