mirror of
https://github.com/correl/mage.git
synced 2024-12-25 19:25:41 +00:00
remove target hack from DealsCombatDamageToAPlayerTriggeredAbility, now you need to add flag to constructor to set target pointer to damaged player
This commit is contained in:
parent
a9e2bfe52a
commit
0633a2667f
3 changed files with 21 additions and 9 deletions
|
@ -28,7 +28,6 @@
|
||||||
|
|
||||||
package mage.sets.magic2011;
|
package mage.sets.magic2011;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
|
@ -43,6 +42,8 @@ import mage.cards.CardsImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -59,7 +60,7 @@ public class MerfolkSpy extends CardImpl<MerfolkSpy> {
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(1);
|
||||||
|
|
||||||
this.addAbility(new IslandwalkAbility());
|
this.addAbility(new IslandwalkAbility());
|
||||||
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new MerfolkSpyEffect(), false));
|
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new MerfolkSpyEffect(), false, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public MerfolkSpy(final MerfolkSpy card) {
|
public MerfolkSpy(final MerfolkSpy card) {
|
||||||
|
@ -86,7 +87,7 @@ class MerfolkSpyEffect extends OneShotEffect<MerfolkSpyEffect> {
|
||||||
|
|
||||||
@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 && player.getHand().size() > 0) {
|
if (player != null && player.getHand().size() > 0) {
|
||||||
Cards revealed = new CardsImpl();
|
Cards revealed = new CardsImpl();
|
||||||
revealed.add(player.getHand().getRandom(game));
|
revealed.add(player.getHand().getRandom(game));
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.sets.scarsofmirrodin;
|
package mage.sets.scarsofmirrodin;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
|
@ -39,6 +38,8 @@ import mage.abilities.effects.common.PutLibraryIntoGraveTargetEffect;
|
||||||
import mage.abilities.keyword.FlyingAbility;
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author ayratn
|
* @author ayratn
|
||||||
|
@ -59,7 +60,7 @@ public class ScreechingSilcaw extends CardImpl<ScreechingSilcaw> {
|
||||||
this.addAbility(FlyingAbility.getInstance());
|
this.addAbility(FlyingAbility.getInstance());
|
||||||
|
|
||||||
TriggeredAbility conditional = new ConditionalTriggeredAbility(
|
TriggeredAbility conditional = new ConditionalTriggeredAbility(
|
||||||
new DealsCombatDamageToAPlayerTriggeredAbility(new PutLibraryIntoGraveTargetEffect(4), false),
|
new DealsCombatDamageToAPlayerTriggeredAbility(new PutLibraryIntoGraveTargetEffect(4), false, true),
|
||||||
Metalcraft.getInstance(), text);
|
Metalcraft.getInstance(), text);
|
||||||
this.addAbility(conditional);
|
this.addAbility(conditional);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,19 +35,27 @@ import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.events.GameEvent.EventType;
|
import mage.game.events.GameEvent.EventType;
|
||||||
import mage.target.TargetPlayer;
|
import mage.target.TargetPlayer;
|
||||||
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class DealsCombatDamageToAPlayerTriggeredAbility extends TriggeredAbilityImpl<DealsCombatDamageToAPlayerTriggeredAbility> {
|
public class DealsCombatDamageToAPlayerTriggeredAbility extends TriggeredAbilityImpl<DealsCombatDamageToAPlayerTriggeredAbility> {
|
||||||
|
private boolean setTargetPointer;
|
||||||
|
|
||||||
public DealsCombatDamageToAPlayerTriggeredAbility(Effect effect, boolean optional) {
|
public DealsCombatDamageToAPlayerTriggeredAbility(Effect effect, boolean optional) {
|
||||||
|
this(effect, optional, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DealsCombatDamageToAPlayerTriggeredAbility(Effect effect, boolean optional, boolean setTargetPointer) {
|
||||||
super(Zone.BATTLEFIELD, effect, optional);
|
super(Zone.BATTLEFIELD, effect, optional);
|
||||||
|
this.setTargetPointer = setTargetPointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DealsCombatDamageToAPlayerTriggeredAbility(final DealsCombatDamageToAPlayerTriggeredAbility ability) {
|
public DealsCombatDamageToAPlayerTriggeredAbility(final DealsCombatDamageToAPlayerTriggeredAbility ability) {
|
||||||
super(ability);
|
super(ability);
|
||||||
|
this.setTargetPointer = ability.setTargetPointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,9 +66,11 @@ public class DealsCombatDamageToAPlayerTriggeredAbility extends TriggeredAbility
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getType() == EventType.DAMAGED_PLAYER && event.getSourceId().equals(this.sourceId)) {
|
if (event.getType() == EventType.DAMAGED_PLAYER && event.getSourceId().equals(this.sourceId)) {
|
||||||
getTargets().clear();
|
if (setTargetPointer) {
|
||||||
this.addTarget(new TargetPlayer());
|
for (Effect effect : this.getEffects()) {
|
||||||
getTargets().get(0).add(event.getPlayerId(), game);
|
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue