Fixed Pit Fight (issue #151) and other fight cards that both targets must be valid when the effect resolves. Fixed also that the second target must be another target than the first.

This commit is contained in:
LevelX2 2013-03-04 22:54:27 +01:00
parent 5b1de89159
commit 8718a1de8e
7 changed files with 114 additions and 21 deletions

View file

@ -38,6 +38,7 @@ import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.FightTargetsEffect; import mage.abilities.effects.common.FightTargetsEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.game.Game;
import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
@ -60,8 +61,8 @@ public class UlvenwaldTracker extends CardImpl<UlvenwaldTracker> {
// {1}{G}, {tap}: Target creature you control fights another target creature. // {1}{G}, {tap}: Target creature you control fights another target creature.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new FightTargetsEffect(), new ManaCostsImpl("{1}{G}")); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new FightTargetsEffect(), new ManaCostsImpl("{1}{G}"));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
ability.addTarget(new TargetControlledCreaturePermanent()); ability.addTarget(new TargetControlledCreaturePermanent(true));
ability.addTarget(new TargetCreaturePermanent()); ability.addTarget(new TargetOtherCreaturePermanent(true));
this.addAbility(ability); this.addAbility(ability);
} }
@ -74,3 +75,27 @@ public class UlvenwaldTracker extends CardImpl<UlvenwaldTracker> {
return new UlvenwaldTracker(this); return new UlvenwaldTracker(this);
} }
} }
class TargetOtherCreaturePermanent extends TargetCreaturePermanent {
public TargetOtherCreaturePermanent(boolean required) {
super(true);
}
public TargetOtherCreaturePermanent(final TargetOtherCreaturePermanent target) {
super(target);
}
@Override
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
if (source.getTargets().get(0).getTargets().contains(id)) {
return false;
}
return super.canTarget(controllerId, id, source, game);
}
@Override
public TargetOtherCreaturePermanent copy() {
return new TargetOtherCreaturePermanent(this);
}
}

View file

@ -30,8 +30,11 @@ package mage.sets.darkascension;
import java.util.UUID; import java.util.UUID;
import mage.Constants.CardType; import mage.Constants.CardType;
import mage.Constants.Rarity; import mage.Constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.effects.common.FightTargetsEffect; import mage.abilities.effects.common.FightTargetsEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
/** /**
@ -48,8 +51,8 @@ public class BloodFeud extends CardImpl<BloodFeud> {
// Target creature fights another target creature. // Target creature fights another target creature.
this.getSpellAbility().addEffect(new FightTargetsEffect()); this.getSpellAbility().addEffect(new FightTargetsEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent()); this.getSpellAbility().addTarget(new TargetCreaturePermanent(true));
this.getSpellAbility().addTarget(new TargetCreaturePermanent()); this.getSpellAbility().addTarget(new TargetOtherCreaturePermanent(true));
} }
public BloodFeud(final BloodFeud card) { public BloodFeud(final BloodFeud card) {
@ -61,3 +64,28 @@ public class BloodFeud extends CardImpl<BloodFeud> {
return new BloodFeud(this); return new BloodFeud(this);
} }
} }
class TargetOtherCreaturePermanent extends TargetCreaturePermanent {
public TargetOtherCreaturePermanent(boolean required) {
super(true);
}
public TargetOtherCreaturePermanent(final TargetOtherCreaturePermanent target) {
super(target);
}
@Override
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
if (source.getTargets().get(0).getTargets().contains(id)) {
return false;
}
return super.canTarget(controllerId, id, source, game);
}
@Override
public TargetOtherCreaturePermanent copy() {
return new TargetOtherCreaturePermanent(this);
}
}

View file

@ -56,7 +56,6 @@ import mage.game.Game;
import mage.game.command.Emblem; import mage.game.command.Emblem;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetCreaturePermanent;
/** /**
* *
@ -78,8 +77,8 @@ public class DomriRade extends CardImpl<DomriRade> {
// -2: Target creature you control fights another target creature. // -2: Target creature you control fights another target creature.
LoyaltyAbility ability2 = new LoyaltyAbility(new FightTargetsEffect(), -2); LoyaltyAbility ability2 = new LoyaltyAbility(new FightTargetsEffect(), -2);
ability2.addTarget(new TargetControlledCreaturePermanent()); ability2.addTarget(new TargetControlledCreaturePermanent(true));
ability2.addTarget(new TargetCreaturePermanent()); ability2.addTarget(new TargetOtherCreaturePermanent(true));
this.addAbility(ability2); this.addAbility(ability2);
// -7: You get an emblem with "Creatures you control have double strike, trample, hexproof and haste." // -7: You get an emblem with "Creatures you control have double strike, trample, hexproof and haste."
@ -150,4 +149,4 @@ class DomriRadeEmblem extends Emblem {
ability.addEffect(effect); ability.addEffect(effect);
this.getAbilities().add(ability); this.getAbilities().add(ability);
} }
} }

View file

@ -74,6 +74,7 @@ public class GruulRagebeast extends CardImpl<GruulRagebeast> {
// Whenever Gruul Ragebeast or another creature enters the battlefield under your control, that creature fights target creature an opponent controls. // Whenever Gruul Ragebeast or another creature enters the battlefield under your control, that creature fights target creature an opponent controls.
Ability ability = new GruulRagebeastTriggeredAbility(); Ability ability = new GruulRagebeastTriggeredAbility();
ability.addTarget(new TargetCreaturePermanent(filter2)); ability.addTarget(new TargetCreaturePermanent(filter2));
this.addAbility(ability); this.addAbility(ability);
} }

View file

@ -30,8 +30,10 @@ package mage.sets.gatecrash;
import java.util.UUID; import java.util.UUID;
import mage.Constants.CardType; import mage.Constants.CardType;
import mage.Constants.Rarity; import mage.Constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.effects.common.FightTargetsEffect; import mage.abilities.effects.common.FightTargetsEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.game.Game;
import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
@ -50,8 +52,8 @@ public class PitFight extends CardImpl<PitFight> {
// Target creature you control fights another target creature. // Target creature you control fights another target creature.
this.getSpellAbility().addEffect(new FightTargetsEffect()); this.getSpellAbility().addEffect(new FightTargetsEffect());
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent(true));
this.getSpellAbility().addTarget(new TargetCreaturePermanent()); this.getSpellAbility().addTarget(new TargetOtherCreaturePermanent(true));
} }
public PitFight(final PitFight card) { public PitFight(final PitFight card) {
@ -63,3 +65,29 @@ public class PitFight extends CardImpl<PitFight> {
return new PitFight(this); return new PitFight(this);
} }
} }
class TargetOtherCreaturePermanent extends TargetCreaturePermanent {
public TargetOtherCreaturePermanent(boolean required) {
super(required);
}
public TargetOtherCreaturePermanent(final TargetOtherCreaturePermanent target) {
super(target);
}
@Override
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
if (source.getTargets().get(0).getTargets().contains(id)) {
return false;
}
return super.canTarget(controllerId, id, source, game);
}
@Override
public TargetOtherCreaturePermanent copy() {
return new TargetOtherCreaturePermanent(this);
}
}

View file

@ -35,6 +35,7 @@ import mage.abilities.effects.common.FightTargetsEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerPredicate; import mage.filter.predicate.permanent.ControllerPredicate;
import mage.target.Target;
import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
@ -58,8 +59,10 @@ public class PreyUpon extends CardImpl<PreyUpon> {
// Target creature you control fights target creature you don't control. // Target creature you control fights target creature you don't control.
this.getSpellAbility().addEffect(new FightTargetsEffect()); this.getSpellAbility().addEffect(new FightTargetsEffect());
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent(true));
this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter)); Target target = new TargetCreaturePermanent(filter);
target.setRequired(true);
this.getSpellAbility().addTarget(target);
} }
public PreyUpon(final PreyUpon card) { public PreyUpon(final PreyUpon card) {

View file

@ -32,6 +32,7 @@ import mage.Constants.Outcome;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode; import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -51,15 +52,22 @@ public class FightTargetsEffect extends OneShotEffect<FightTargetsEffect> {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent creature1 = game.getPermanent(source.getTargets().get(0).getFirstTarget()); Card card = game.getCard(source.getSourceId());
Permanent creature2 = game.getPermanent(source.getTargets().get(1).getFirstTarget()); if (card != null) {
// 20110930 - 701.10 // only if both targets are legal the effect will be applied
if (creature1 != null && creature2 != null) { if (source.getTargets().get(0).isLegal(source, game) && source.getTargets().get(1).isLegal(source, game)) {
if (creature1.getCardType().contains(CardType.CREATURE) && creature2.getCardType().contains(CardType.CREATURE)) { Permanent creature1 = game.getPermanent(source.getTargets().get(0).getFirstTarget());
creature1.damage(creature2.getPower().getValue(), creature2.getId(), game, true, false); Permanent creature2 = game.getPermanent(source.getTargets().get(1).getFirstTarget());
creature2.damage(creature1.getPower().getValue(), creature1.getId(), game, true, false); // 20110930 - 701.10
return true; if (creature1 != null && creature2 != null) {
if (creature1.getCardType().contains(CardType.CREATURE) && creature2.getCardType().contains(CardType.CREATURE)) {
creature1.damage(creature2.getPower().getValue(), creature2.getId(), game, true, false);
creature2.damage(creature1.getPower().getValue(), creature1.getId(), game, true, false);
return true;
}
}
} }
game.informPlayers(card.getName() + " has been fizzled.");
} }
return false; return false;
} }
@ -71,7 +79,8 @@ public class FightTargetsEffect extends OneShotEffect<FightTargetsEffect> {
@Override @Override
public String getText(Mode mode) { public String getText(Mode mode) {
return "Target " + mode.getTargets().get(0).getTargetName() + " fights target " + mode.getTargets().get(1).getTargetName(); return "Target " + mode.getTargets().get(0).getTargetName() + " fights another target " + mode.getTargets().get(1).getTargetName();
} }
} }