now Massacre Wurm not used direct targets

This commit is contained in:
Loki 2011-06-07 23:19:37 +03:00
parent 0b10a3a121
commit b7c7290e6f
4 changed files with 52 additions and 4 deletions

View file

@ -36,6 +36,7 @@ import mage.Constants.Rarity;
import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.LoseLifeTargetEffect;
import mage.abilities.effects.common.continious.BoostOpponentsEffect;
@ -45,6 +46,7 @@ import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import mage.target.TargetPlayer;
import mage.target.targetpointer.FixedTarget;
/**
*
@ -77,7 +79,6 @@ public class MassacreWurm extends CardImpl<MassacreWurm> {
class MassacreWurmTriggeredAbility extends TriggeredAbilityImpl<MassacreWurmTriggeredAbility> {
MassacreWurmTriggeredAbility() {
super(Constants.Zone.BATTLEFIELD, new LoseLifeTargetEffect(2));
this.addTarget(new TargetPlayer());
}
MassacreWurmTriggeredAbility(final MassacreWurmTriggeredAbility ability) {
@ -96,7 +97,9 @@ class MassacreWurmTriggeredAbility extends TriggeredAbilityImpl<MassacreWurmTrig
if (zEvent.getFromZone() == Constants.Zone.BATTLEFIELD && zEvent.getToZone() == Constants.Zone.GRAVEYARD) {
Permanent p = (Permanent) game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
if (p != null && p.getCardType().contains(CardType.CREATURE) && game.getOpponents(this.getControllerId()).contains(p.getControllerId())) {
targets.get(0).add(p.getControllerId(), game);
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(p.getControllerId()));
}
return true;
}
}

View file

@ -34,6 +34,7 @@ import mage.Constants.EffectType;
import mage.Constants.Outcome;
import mage.abilities.Ability;
import mage.game.Game;
import mage.target.targetpointer.TargetPointer;
/**
*
@ -46,6 +47,7 @@ public interface Effect<T extends Effect<T>> extends Serializable {
public boolean apply(Game game, Ability source);
public Outcome getOutcome();
public EffectType getEffectType();
public void setTargetPointer(TargetPointer targetPointer);
public T copy();

View file

@ -63,7 +63,7 @@ public class LoseLifeTargetEffect extends OneShotEffect<LoseLifeTargetEffect> {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget());
Player player = game.getPlayer(targetPointer.getFirst(source));
if (player != null) {
player.loseLife(amount, game);
return true;
@ -73,7 +73,14 @@ public class LoseLifeTargetEffect extends OneShotEffect<LoseLifeTargetEffect> {
@Override
public String getText(Ability source) {
return "Target " + source.getTargets().get(0).getTargetName() + " loses " + Integer.toString(amount) + " life";
StringBuffer result = new StringBuffer();
if (source.getTargets().size() > 0) {
result.append("Target " + source.getTargets().get(0).getTargetName());
} else {
result.append("that player");
}
result.append(" loses ").append(amount).append(" life");
return result.toString();
}

View file

@ -0,0 +1,36 @@
package mage.target.targetpointer;
import mage.abilities.Ability;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class FixedTarget implements TargetPointer {
private UUID target;
public FixedTarget(UUID target) {
this.target = target;
}
public FixedTarget(final FixedTarget fixedTarget) {
this.target = fixedTarget.target;
}
@Override
public List<UUID> getTargets(Ability source) {
ArrayList<UUID> list = new ArrayList<UUID>(1);
list.add(target);
return list;
}
@Override
public UUID getFirst(Ability source) {
return target;
}
@Override
public TargetPointer copy() {
return new FixedTarget(this);
}
}