mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
* Megrim - Fixed target handling (using always the target from first time the ability triggered).
This commit is contained in:
parent
cc9f036c89
commit
91482964dc
2 changed files with 29 additions and 48 deletions
|
@ -25,20 +25,15 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.sets.tenthedition;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.DiscardsACardOpponentTriggeredAbility;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.target.common.TargetOpponent;
|
||||
import mage.constants.SetTargetPointer;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -46,14 +41,15 @@ import mage.target.common.TargetOpponent;
|
|||
*/
|
||||
public class Megrim extends CardImpl {
|
||||
|
||||
public Megrim (UUID ownerId) {
|
||||
public Megrim(UUID ownerId) {
|
||||
super(ownerId, 157, "Megrim", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}");
|
||||
this.expansionSetCode = "10E";
|
||||
|
||||
this.addAbility(new MergimTriggeredAbility());
|
||||
// Whenever an opponent discards a card, Megrim deals 2 damage to that player.
|
||||
this.addAbility(new DiscardsACardOpponentTriggeredAbility(new DamageTargetEffect(2, true, "that player"), false, SetTargetPointer.PLAYER));
|
||||
}
|
||||
|
||||
public Megrim (final Megrim card) {
|
||||
public Megrim(final Megrim card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
|
@ -63,39 +59,3 @@ public class Megrim extends CardImpl {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
class MergimTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
MergimTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new DamageTargetEffect(2));
|
||||
this.addTarget(new TargetOpponent());
|
||||
}
|
||||
|
||||
MergimTriggeredAbility(final MergimTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MergimTriggeredAbility copy() {
|
||||
return new MergimTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.DISCARDED_CARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (game.getOpponents(this.getControllerId()).contains(event.getPlayerId())) {
|
||||
this.getTargets().get(0).add(event.getPlayerId(), game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever an opponent discards a card, {this} deals 2 damage to that player.";
|
||||
}
|
||||
}
|
|
@ -6,10 +6,11 @@ package mage.abilities.common;
|
|||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.SetTargetPointer;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -17,12 +18,20 @@ import mage.game.events.GameEvent.EventType;
|
|||
*/
|
||||
public class DiscardsACardOpponentTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private SetTargetPointer setTargetPointer;
|
||||
|
||||
public DiscardsACardOpponentTriggeredAbility(Effect effect, Boolean isOptional) {
|
||||
this(effect, isOptional, SetTargetPointer.NONE);
|
||||
}
|
||||
|
||||
public DiscardsACardOpponentTriggeredAbility(Effect effect, Boolean isOptional, SetTargetPointer setTargetPointer) {
|
||||
super(Zone.BATTLEFIELD, effect, isOptional);
|
||||
this.setTargetPointer = setTargetPointer;
|
||||
}
|
||||
|
||||
public DiscardsACardOpponentTriggeredAbility(final DiscardsACardOpponentTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.setTargetPointer = ability.setTargetPointer;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,7 +46,19 @@ public class DiscardsACardOpponentTriggeredAbility extends TriggeredAbilityImpl
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return game.getOpponents(controllerId).contains(event.getPlayerId());
|
||||
if (game.getOpponents(controllerId).contains(event.getPlayerId())) {
|
||||
switch (setTargetPointer) {
|
||||
case PLAYER:
|
||||
for (Effect effect : getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException(setTargetPointer.toString() + " not supported for this ability.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue