mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
now Massacre Wurm not used direct targets
This commit is contained in:
parent
0b10a3a121
commit
b7c7290e6f
4 changed files with 52 additions and 4 deletions
|
@ -36,6 +36,7 @@ import mage.Constants.Rarity;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||||
|
import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.effects.common.DamageTargetEffect;
|
import mage.abilities.effects.common.DamageTargetEffect;
|
||||||
import mage.abilities.effects.common.LoseLifeTargetEffect;
|
import mage.abilities.effects.common.LoseLifeTargetEffect;
|
||||||
import mage.abilities.effects.common.continious.BoostOpponentsEffect;
|
import mage.abilities.effects.common.continious.BoostOpponentsEffect;
|
||||||
|
@ -45,6 +46,7 @@ import mage.game.events.GameEvent;
|
||||||
import mage.game.events.ZoneChangeEvent;
|
import mage.game.events.ZoneChangeEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.target.TargetPlayer;
|
import mage.target.TargetPlayer;
|
||||||
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -77,7 +79,6 @@ public class MassacreWurm extends CardImpl<MassacreWurm> {
|
||||||
class MassacreWurmTriggeredAbility extends TriggeredAbilityImpl<MassacreWurmTriggeredAbility> {
|
class MassacreWurmTriggeredAbility extends TriggeredAbilityImpl<MassacreWurmTriggeredAbility> {
|
||||||
MassacreWurmTriggeredAbility() {
|
MassacreWurmTriggeredAbility() {
|
||||||
super(Constants.Zone.BATTLEFIELD, new LoseLifeTargetEffect(2));
|
super(Constants.Zone.BATTLEFIELD, new LoseLifeTargetEffect(2));
|
||||||
this.addTarget(new TargetPlayer());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MassacreWurmTriggeredAbility(final MassacreWurmTriggeredAbility ability) {
|
MassacreWurmTriggeredAbility(final MassacreWurmTriggeredAbility ability) {
|
||||||
|
@ -96,7 +97,9 @@ class MassacreWurmTriggeredAbility extends TriggeredAbilityImpl<MassacreWurmTrig
|
||||||
if (zEvent.getFromZone() == Constants.Zone.BATTLEFIELD && zEvent.getToZone() == Constants.Zone.GRAVEYARD) {
|
if (zEvent.getFromZone() == Constants.Zone.BATTLEFIELD && zEvent.getToZone() == Constants.Zone.GRAVEYARD) {
|
||||||
Permanent p = (Permanent) game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
|
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())) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ import mage.Constants.EffectType;
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.game.Game;
|
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 boolean apply(Game game, Ability source);
|
||||||
public Outcome getOutcome();
|
public Outcome getOutcome();
|
||||||
public EffectType getEffectType();
|
public EffectType getEffectType();
|
||||||
|
public void setTargetPointer(TargetPointer targetPointer);
|
||||||
|
|
||||||
public T copy();
|
public T copy();
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class LoseLifeTargetEffect extends OneShotEffect<LoseLifeTargetEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player player = game.getPlayer(source.getFirstTarget());
|
Player player = game.getPlayer(targetPointer.getFirst(source));
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.loseLife(amount, game);
|
player.loseLife(amount, game);
|
||||||
return true;
|
return true;
|
||||||
|
@ -73,7 +73,14 @@ public class LoseLifeTargetEffect extends OneShotEffect<LoseLifeTargetEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getText(Ability source) {
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
36
Mage/src/mage/target/targetpointer/FixedTarget.java
Normal file
36
Mage/src/mage/target/targetpointer/FixedTarget.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue