mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
updated damage triggers to include planeswalker damage
This commit is contained in:
parent
dc67f2f49c
commit
e0ce04c436
3 changed files with 30 additions and 14 deletions
|
@ -39,6 +39,7 @@ public final class VraskaSwarmsEminence extends CardImpl {
|
|||
this.addAbility(new PlaneswalkerEntersWithLoyaltyCountersAbility(5));
|
||||
|
||||
// Whenever a creature you control with deathtouch deals damage to a player or planeswalker, put a +1/+1 counter on that creature.
|
||||
// TODO: make this trigger on planeswalkers
|
||||
this.addAbility(new DealsDamageToAPlayerAllTriggeredAbility(
|
||||
new AddCountersTargetEffect(
|
||||
CounterType.P1P1.createInstance()
|
||||
|
|
|
@ -5,20 +5,20 @@ import mage.abilities.TriggeredAbilityImpl;
|
|||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.DamagedPlayerEvent;
|
||||
import mage.game.events.DamagedEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class DealsCombatDamageToAPlayerTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
protected boolean setTargetPointer;
|
||||
protected final boolean setTargetPointer;
|
||||
protected String text;
|
||||
protected boolean onlyOpponents;
|
||||
private boolean orPlaneswalker = false;
|
||||
|
||||
public DealsCombatDamageToAPlayerTriggeredAbility(Effect effect, boolean optional) {
|
||||
this(effect, optional, false);
|
||||
|
@ -47,6 +47,10 @@ public class DealsCombatDamageToAPlayerTriggeredAbility extends TriggeredAbility
|
|||
this.onlyOpponents = ability.onlyOpponents;
|
||||
}
|
||||
|
||||
public void setOrPlaneswalker(boolean orPlaneswalker) {
|
||||
this.orPlaneswalker = orPlaneswalker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DealsCombatDamageToAPlayerTriggeredAbility copy() {
|
||||
return new DealsCombatDamageToAPlayerTriggeredAbility(this);
|
||||
|
@ -54,14 +58,15 @@ public class DealsCombatDamageToAPlayerTriggeredAbility extends TriggeredAbility
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DAMAGED_PLAYER;
|
||||
return event.getType() == GameEvent.EventType.DAMAGED_PLAYER
|
||||
|| (orPlaneswalker && event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getSourceId().equals(getSourceId())
|
||||
&& ((DamagedPlayerEvent) event).isCombatDamage()) {
|
||||
if (onlyOpponents) {
|
||||
&& ((DamagedEvent) event).isCombatDamage()) {
|
||||
if (onlyOpponents && event.getType() == GameEvent.EventType.DAMAGED_PLAYER) {
|
||||
Player controller = game.getPlayer(getControllerId());
|
||||
if (controller == null || !controller.hasOpponent(event.getPlayerId(), game)) {
|
||||
return false;
|
||||
|
@ -81,7 +86,10 @@ public class DealsCombatDamageToAPlayerTriggeredAbility extends TriggeredAbility
|
|||
@Override
|
||||
public String getRule() {
|
||||
if (text == null || text.isEmpty()) {
|
||||
return "Whenever {this} deals combat damage to " + (onlyOpponents ? "an opponent, " : "a player, ") + super.getRule();
|
||||
return "Whenever {this} deals combat damage to "
|
||||
+ (onlyOpponents ? "an opponent" : "a player")
|
||||
+ (orPlaneswalker ? " or planeswalker" : "")
|
||||
+ ", " + super.getRule();
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
|
|
@ -2,32 +2,38 @@
|
|||
|
||||
package mage.abilities.common;
|
||||
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeff
|
||||
*/
|
||||
public class DealsDamageToAPlayerTriggeredAbility extends TriggeredAbilityImpl {
|
||||
private boolean setTargetPointer;
|
||||
private final boolean setTargetPointer;
|
||||
private final boolean orPlaneswalker;
|
||||
|
||||
public DealsDamageToAPlayerTriggeredAbility(Effect effect, boolean optional) {
|
||||
this(effect, optional, false);
|
||||
}
|
||||
|
||||
public DealsDamageToAPlayerTriggeredAbility(Effect effect, boolean optional, boolean setTargetPointer) {
|
||||
this(effect, optional, setTargetPointer, false);
|
||||
}
|
||||
|
||||
public DealsDamageToAPlayerTriggeredAbility(Effect effect, boolean optional, boolean setTargetPointer, boolean orPlaneswalker) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
this.setTargetPointer = setTargetPointer;
|
||||
this.orPlaneswalker = orPlaneswalker;
|
||||
}
|
||||
|
||||
public DealsDamageToAPlayerTriggeredAbility(final DealsDamageToAPlayerTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.setTargetPointer = ability.setTargetPointer;
|
||||
this.orPlaneswalker = ability.orPlaneswalker;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,7 +43,8 @@ public class DealsDamageToAPlayerTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DAMAGED_PLAYER;
|
||||
return event.getType() == GameEvent.EventType.DAMAGED_PLAYER
|
||||
|| (orPlaneswalker && event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,8 +52,8 @@ public class DealsDamageToAPlayerTriggeredAbility extends TriggeredAbilityImpl {
|
|||
if (event.getSourceId().equals(this.sourceId)) {
|
||||
if (setTargetPointer) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||
effect.setValue("damage", event.getAmount());
|
||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||
effect.setValue("damage", event.getAmount());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -56,7 +63,7 @@ public class DealsDamageToAPlayerTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever {this} deals damage to a player, " + super.getRule();
|
||||
return "Whenever {this} deals damage to a player" + (orPlaneswalker ? " or planeswalker" : "") + ", " + super.getRule();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue