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.effects.common.FightTargetsEffect;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.target.common.TargetControlledCreaturePermanent;
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.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new FightTargetsEffect(), new ManaCostsImpl("{1}{G}"));
ability.addCost(new TapSourceCost());
ability.addTarget(new TargetControlledCreaturePermanent());
ability.addTarget(new TargetCreaturePermanent());
ability.addTarget(new TargetControlledCreaturePermanent(true));
ability.addTarget(new TargetOtherCreaturePermanent(true));
this.addAbility(ability);
}
@ -74,3 +75,27 @@ public class UlvenwaldTracker extends CardImpl<UlvenwaldTracker> {
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 mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.effects.common.FightTargetsEffect;
import mage.cards.CardImpl;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.target.common.TargetCreaturePermanent;
/**
@ -48,8 +51,8 @@ public class BloodFeud extends CardImpl<BloodFeud> {
// Target creature fights another target creature.
this.getSpellAbility().addEffect(new FightTargetsEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
this.getSpellAbility().addTarget(new TargetCreaturePermanent(true));
this.getSpellAbility().addTarget(new TargetOtherCreaturePermanent(true));
}
public BloodFeud(final BloodFeud card) {
@ -61,3 +64,28 @@ public class BloodFeud extends CardImpl<BloodFeud> {
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.players.Player;
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.
LoyaltyAbility ability2 = new LoyaltyAbility(new FightTargetsEffect(), -2);
ability2.addTarget(new TargetControlledCreaturePermanent());
ability2.addTarget(new TargetCreaturePermanent());
ability2.addTarget(new TargetControlledCreaturePermanent(true));
ability2.addTarget(new TargetOtherCreaturePermanent(true));
this.addAbility(ability2);
// -7: You get an emblem with "Creatures you control have double strike, trample, hexproof and haste."

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.
Ability ability = new GruulRagebeastTriggeredAbility();
ability.addTarget(new TargetCreaturePermanent(filter2));
this.addAbility(ability);
}

View file

@ -30,8 +30,10 @@ package mage.sets.gatecrash;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.effects.common.FightTargetsEffect;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetCreaturePermanent;
@ -50,8 +52,8 @@ public class PitFight extends CardImpl<PitFight> {
// Target creature you control fights another target creature.
this.getSpellAbility().addEffect(new FightTargetsEffect());
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent(true));
this.getSpellAbility().addTarget(new TargetOtherCreaturePermanent(true));
}
public PitFight(final PitFight card) {
@ -63,3 +65,29 @@ public class PitFight extends CardImpl<PitFight> {
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.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.target.Target;
import mage.target.common.TargetControlledCreaturePermanent;
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.
this.getSpellAbility().addEffect(new FightTargetsEffect());
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter));
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent(true));
Target target = new TargetCreaturePermanent(filter);
target.setRequired(true);
this.getSpellAbility().addTarget(target);
}
public PreyUpon(final PreyUpon card) {

View file

@ -32,6 +32,7 @@ import mage.Constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -51,6 +52,10 @@ public class FightTargetsEffect extends OneShotEffect<FightTargetsEffect> {
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(source.getSourceId());
if (card != null) {
// only if both targets are legal the effect will be applied
if (source.getTargets().get(0).isLegal(source, game) && source.getTargets().get(1).isLegal(source, game)) {
Permanent creature1 = game.getPermanent(source.getTargets().get(0).getFirstTarget());
Permanent creature2 = game.getPermanent(source.getTargets().get(1).getFirstTarget());
// 20110930 - 701.10
@ -61,6 +66,9 @@ public class FightTargetsEffect extends OneShotEffect<FightTargetsEffect> {
return true;
}
}
}
game.informPlayers(card.getName() + " has been fizzled.");
}
return false;
}
@ -71,7 +79,8 @@ public class FightTargetsEffect extends OneShotEffect<FightTargetsEffect> {
@Override
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();
}
}