forked from External/mage
Merge pull request #14078 from xenohedron/damagemulti
Rework effects that deal damage to multiple specific objects
This commit is contained in:
commit
1cb72d0efb
86 changed files with 1200 additions and 844 deletions
|
|
@ -29,8 +29,7 @@ public class DealsDamageAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT
|
||||
|| event.getType() == GameEvent.EventType.DAMAGED_PLAYER;
|
||||
return event.getType() == GameEvent.EventType.DAMAGED_BATCH_BY_SOURCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -0,0 +1,83 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
* @author xenohedron
|
||||
*/
|
||||
public class DamageTargetAndAllControlledEffect extends OneShotEffect {
|
||||
|
||||
private final int firstAmount;
|
||||
private final int secondAmount;
|
||||
private final FilterPermanent filter;
|
||||
|
||||
/**
|
||||
* Deals simultaneous damage to the target and to each creature the target controls
|
||||
*/
|
||||
public DamageTargetAndAllControlledEffect(int amount) {
|
||||
this(amount, amount, StaticFilters.FILTER_PERMANENT_CREATURE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deals simultaneous damage to the target and to each creature the target controls
|
||||
*/
|
||||
public DamageTargetAndAllControlledEffect(int firstAmount, int secondAmount, FilterPermanent filter) {
|
||||
super(Outcome.Damage);
|
||||
this.firstAmount = firstAmount;
|
||||
this.secondAmount = secondAmount;
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
protected DamageTargetAndAllControlledEffect(final DamageTargetAndAllControlledEffect effect) {
|
||||
super(effect);
|
||||
this.firstAmount = effect.firstAmount;
|
||||
this.secondAmount = effect.secondAmount;
|
||||
this.filter = effect.filter.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DamageTargetAndAllControlledEffect copy() {
|
||||
return new DamageTargetAndAllControlledEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (permanent != null) {
|
||||
permanent.damage(firstAmount, source.getSourceId(), source, game);
|
||||
} else {
|
||||
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||
if (player != null) {
|
||||
player.damage(firstAmount, source.getSourceId(), source, game);
|
||||
}
|
||||
}
|
||||
Player controller = game.getPlayerOrPlaneswalkerController(getTargetPointer().getFirst(game, source));
|
||||
if (controller != null) {
|
||||
for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game)) {
|
||||
perm.damage(secondAmount, source.getSourceId(), source, game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
String description = getTargetPointer().describeTargets(mode.getTargets(), "that player");
|
||||
return "{this} deals " + firstAmount + "damage to " + description +
|
||||
" and " + secondAmount + " damage to each " + filter.getMessage() +
|
||||
" that player" +
|
||||
(description.contains("planeswalker") ? " or that planeswalker's controller" : "") +
|
||||
" controls";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author xenohedron
|
||||
*/
|
||||
public class DamageTargetAndSelfEffect extends OneShotEffect {
|
||||
|
||||
private final int firstAmount;
|
||||
private final int secondAmount;
|
||||
|
||||
/**
|
||||
* Deals simultaneous damage to the target and to itself
|
||||
*/
|
||||
public DamageTargetAndSelfEffect(int amount) {
|
||||
this(amount, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deals simultaneous damage to the target and to itself
|
||||
*/
|
||||
public DamageTargetAndSelfEffect(int firstAmount, int secondAmount) {
|
||||
super(Outcome.Damage);
|
||||
this.firstAmount = firstAmount;
|
||||
this.secondAmount = secondAmount;
|
||||
}
|
||||
|
||||
protected DamageTargetAndSelfEffect(final DamageTargetAndSelfEffect effect) {
|
||||
super(effect);
|
||||
this.firstAmount = effect.firstAmount;
|
||||
this.secondAmount = effect.secondAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DamageTargetAndSelfEffect copy() {
|
||||
return new DamageTargetAndSelfEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (UUID targetId : this.getTargetPointer().getTargets(game, source)) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent != null) {
|
||||
permanent.damage(firstAmount, source.getSourceId(), source, game);
|
||||
} else {
|
||||
Player player = game.getPlayer(targetId);
|
||||
if (player != null) {
|
||||
player.damage(firstAmount, source.getSourceId(), source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
Permanent itself = source.getSourcePermanentIfItStillExists(game);
|
||||
if (itself != null) {
|
||||
itself.damage(secondAmount, source.getSourceId(), source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
return "{this} deals " + firstAmount + "damage to " +
|
||||
getTargetPointer().describeTargets(mode.getTargets(), "that creature") +
|
||||
" and " + secondAmount + "damage to itself";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author xenohedron
|
||||
*/
|
||||
public class DamageTargetAndTargetControllerEffect extends OneShotEffect {
|
||||
|
||||
private final int firstAmount;
|
||||
private final int secondAmount;
|
||||
|
||||
/**
|
||||
* Deals simultaneous damage to the target and to the controller of the target
|
||||
*/
|
||||
public DamageTargetAndTargetControllerEffect(int firstAmount, int secondAmount) {
|
||||
super(Outcome.Damage);
|
||||
this.firstAmount = firstAmount;
|
||||
this.secondAmount = secondAmount;
|
||||
}
|
||||
|
||||
protected DamageTargetAndTargetControllerEffect(final DamageTargetAndTargetControllerEffect effect) {
|
||||
super(effect);
|
||||
this.firstAmount = effect.firstAmount;
|
||||
this.secondAmount = effect.secondAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DamageTargetAndTargetControllerEffect copy() {
|
||||
return new DamageTargetAndTargetControllerEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (UUID targetId : this.getTargetPointer().getTargets(game, source)) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent != null) {
|
||||
permanent.damage(firstAmount, source.getSourceId(), source, game);
|
||||
}
|
||||
Permanent lki = game.getPermanentOrLKIBattlefield(targetId);
|
||||
if (lki != null) {
|
||||
Player player = game.getPlayer(lki.getControllerId());
|
||||
if (player != null) {
|
||||
player.damage(secondAmount, source.getSourceId(), source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
String description = getTargetPointer().describeTargets(mode.getTargets(), "that creature");
|
||||
return "{this} deals " + firstAmount + "damage to " + description +
|
||||
" and " + secondAmount + "damage to that " +
|
||||
(description.contains(" or ") ? "permanent's" : "creature's") + " controller";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author xenohedron
|
||||
*/
|
||||
public class DamageTargetAndTargetEffect extends OneShotEffect {
|
||||
|
||||
private final int firstAmount;
|
||||
private final int secondAmount;
|
||||
|
||||
/**
|
||||
* Deals simultaneous damage to two targets. Must set target tag 1 and 2
|
||||
*/
|
||||
public DamageTargetAndTargetEffect(int firstAmount, int secondAmount) {
|
||||
super(Outcome.Damage);
|
||||
this.firstAmount = firstAmount;
|
||||
this.secondAmount = secondAmount;
|
||||
}
|
||||
|
||||
protected DamageTargetAndTargetEffect(final DamageTargetAndTargetEffect effect) {
|
||||
super(effect);
|
||||
this.firstAmount = effect.firstAmount;
|
||||
this.secondAmount = effect.secondAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DamageTargetAndTargetEffect copy() {
|
||||
return new DamageTargetAndTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
source.getTargets().getTargetsByTag(1).forEach(uuid -> damageTarget(uuid, firstAmount, source, game));
|
||||
source.getTargets().getTargetsByTag(2).forEach(uuid -> damageTarget(uuid, secondAmount, source, game));
|
||||
return true;
|
||||
}
|
||||
|
||||
private void damageTarget(UUID targetId, int amount, Ability source, Game game) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent != null) {
|
||||
permanent.damage(amount, source.getSourceId(), source, game) ;
|
||||
} else {
|
||||
Player player = game.getPlayer(targetId);
|
||||
if (player != null) {
|
||||
player.damage(amount, source.getSourceId(), source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
// verify check that target tags are properly setup
|
||||
if (mode.getTargets().getByTag(1) == null || mode.getTargets().getByTag(2) == null) {
|
||||
throw new IllegalArgumentException("Wrong code usage: need to add tags to targets");
|
||||
}
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
return "{this} deals " + firstAmount + "damage to " + mode.getTargets().getByTag(1).getDescription() +
|
||||
" and " + secondAmount + "damage to " + mode.getTargets().getByTag(2).getDescription();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author xenohedron
|
||||
*/
|
||||
public class DamageTargetAndYouEffect extends OneShotEffect {
|
||||
|
||||
private final int firstAmount;
|
||||
private final int secondAmount;
|
||||
|
||||
/**
|
||||
* Deals simultaneous damage to the target and the controller of the source
|
||||
*/
|
||||
public DamageTargetAndYouEffect(int amount) {
|
||||
this(amount, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deals simultaneous damage to the target and the controller of the source
|
||||
*/
|
||||
public DamageTargetAndYouEffect(int firstAmount, int secondAmount) {
|
||||
super(Outcome.Damage);
|
||||
this.firstAmount = firstAmount;
|
||||
this.secondAmount = secondAmount;
|
||||
}
|
||||
|
||||
protected DamageTargetAndYouEffect(final DamageTargetAndYouEffect effect) {
|
||||
super(effect);
|
||||
this.firstAmount = effect.firstAmount;
|
||||
this.secondAmount = effect.secondAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DamageTargetAndYouEffect copy() {
|
||||
return new DamageTargetAndYouEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (UUID targetId : this.getTargetPointer().getTargets(game, source)) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent != null) {
|
||||
permanent.damage(firstAmount, source.getSourceId(), source, game);
|
||||
} else {
|
||||
Player player = game.getPlayer(targetId);
|
||||
if (player != null) {
|
||||
player.damage(firstAmount, source.getSourceId(), source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
controller.damage(secondAmount, source.getSourceId(), source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
return "{this} deals " + firstAmount + "damage to " +
|
||||
getTargetPointer().describeTargets(mode.getTargets(), "that creature") +
|
||||
" and " + secondAmount + "damage to you";
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.Mode;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
|
|
@ -24,7 +23,6 @@ public class DamageTargetEffect extends OneShotEffect {
|
|||
protected DynamicValue amount;
|
||||
protected boolean preventable;
|
||||
protected String targetDescription;
|
||||
protected boolean useOnlyTargetPointer; // TODO: investigate why do we ignore targetPointer by default??
|
||||
protected String sourceName = "{this}";
|
||||
|
||||
public DamageTargetEffect(int amount) {
|
||||
|
|
@ -44,10 +42,6 @@ public class DamageTargetEffect extends OneShotEffect {
|
|||
this(StaticValue.get(amount), preventable, targetDescription);
|
||||
}
|
||||
|
||||
public DamageTargetEffect(int amount, boolean preventable, String targetDescription, boolean useOnlyTargetPointer) {
|
||||
this(StaticValue.get(amount), preventable, targetDescription, useOnlyTargetPointer);
|
||||
}
|
||||
|
||||
public DamageTargetEffect(int amount, boolean preventable, String targetDescription, String whoDealDamageName) {
|
||||
this(StaticValue.get(amount), preventable, targetDescription);
|
||||
this.sourceName = whoDealDamageName;
|
||||
|
|
@ -67,15 +61,10 @@ public class DamageTargetEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
public DamageTargetEffect(DynamicValue amount, boolean preventable, String targetDescription) {
|
||||
this(amount, preventable, targetDescription, false);
|
||||
}
|
||||
|
||||
public DamageTargetEffect(DynamicValue amount, boolean preventable, String targetDescription, boolean useOnlyTargetPointer) {
|
||||
super(Outcome.Damage);
|
||||
this.amount = amount;
|
||||
this.preventable = preventable;
|
||||
this.targetDescription = targetDescription;
|
||||
this.useOnlyTargetPointer = useOnlyTargetPointer;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
|
|
@ -95,21 +84,15 @@ public class DamageTargetEffect extends OneShotEffect {
|
|||
this.amount = effect.amount.copy();
|
||||
this.preventable = effect.preventable;
|
||||
this.targetDescription = effect.targetDescription;
|
||||
this.useOnlyTargetPointer = effect.useOnlyTargetPointer;
|
||||
this.sourceName = effect.sourceName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DamageTargetEffect withTargetDescription(String targetDescription) {
|
||||
this.targetDescription = targetDescription;
|
||||
return this;
|
||||
}
|
||||
|
||||
// TODO: this should most likely be refactored to not be needed and always use target pointer.
|
||||
public Effect setUseOnlyTargetPointer(boolean useOnlyTargetPointer) {
|
||||
this.useOnlyTargetPointer = useOnlyTargetPointer;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DamageTargetEffect copy() {
|
||||
return new DamageTargetEffect(this);
|
||||
|
|
@ -117,21 +100,6 @@ public class DamageTargetEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (!useOnlyTargetPointer && source.getTargets().size() > 1) {
|
||||
for (Target target : source.getTargets()) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent != null) {
|
||||
permanent.damage(amount.calculate(game, source, this), source.getSourceId(), source, game, false, preventable);
|
||||
}
|
||||
Player player = game.getPlayer(targetId);
|
||||
if (player != null) {
|
||||
player.damage(amount.calculate(game, source, this), source.getSourceId(), source, game, false, preventable);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
for (UUID targetId : this.getTargetPointer().getTargets(game, source)) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent != null) {
|
||||
|
|
@ -154,7 +122,7 @@ public class DamageTargetEffect extends OneShotEffect {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
String message = amount.getMessage();
|
||||
sb.append(this.sourceName).append(" deals ");
|
||||
if (message.isEmpty() || !message.equals("1")) {
|
||||
if (!message.equals("1")) {
|
||||
sb.append(amount);
|
||||
}
|
||||
if (!sb.toString().endsWith(" ")) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import mage.abilities.effects.OneShotEffect;
|
|||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.Target;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -42,37 +41,26 @@ public class TargetsDamageTargetsEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (source.getTargets().size() < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Target damageTarget = source.getTargets().getByTag(1);
|
||||
Target additionalDamageTarget = source.getTargets().getByTag(2);
|
||||
Target destTarget = source.getTargets().getByTag(3);
|
||||
|
||||
List<Permanent> damagingPermanents = new ArrayList<>();
|
||||
List<Permanent> receivingPermanents = new ArrayList<>();
|
||||
for (UUID id : damageTarget.getTargets()) {
|
||||
for (UUID id : source.getTargets().getTargetsByTag(1)) { // dealing damage
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
if (permanent != null) {
|
||||
damagingPermanents.add(permanent);
|
||||
}
|
||||
}
|
||||
if (additionalDamageTarget != null) {
|
||||
for (UUID id : additionalDamageTarget.getTargets()) {
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
if (permanent != null) {
|
||||
damagingPermanents.add(permanent);
|
||||
}
|
||||
for (UUID id : source.getTargets().getTargetsByTag(2)) { // additional dealing damage, if applicable
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
if (permanent != null) {
|
||||
damagingPermanents.add(permanent);
|
||||
}
|
||||
}
|
||||
for (UUID id : destTarget.getTargets()) {
|
||||
for (UUID id : source.getTargets().getTargetsByTag(3)) { // receiving damage
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
if (permanent != null) {
|
||||
receivingPermanents.add(permanent);
|
||||
}
|
||||
}
|
||||
|
||||
if (receivingPermanents.isEmpty() || damagingPermanents.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -86,6 +74,10 @@ public class TargetsDamageTargetsEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
// verify check that target tags are properly setup
|
||||
if (mode.getTargets().getByTag(1) == null || mode.getTargets().getByTag(3) == null) {
|
||||
throw new IllegalArgumentException("Wrong code usage: need to add tags to targets");
|
||||
}
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
|
|
@ -102,4 +94,4 @@ public class TargetsDamageTargetsEffect extends OneShotEffect {
|
|||
sb.append(mode.getTargets().getByTag(3).getDescription());
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,10 @@
|
|||
package mage.game.permanent.token;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.DealsCombatDamageTriggeredAbility;
|
||||
import mage.abilities.effects.common.SacrificeSourceEffect;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
public final class VrondissRageOfAncientsToken extends TokenImpl {
|
||||
|
||||
|
|
@ -21,7 +18,7 @@ public final class VrondissRageOfAncientsToken extends TokenImpl {
|
|||
power = new MageInt(5);
|
||||
toughness = new MageInt(4);
|
||||
|
||||
this.addAbility(new VrondissRageOfAncientsTokenTriggeredAbility());
|
||||
this.addAbility(new DealsCombatDamageTriggeredAbility(new SacrificeSourceEffect(), false));
|
||||
}
|
||||
|
||||
private VrondissRageOfAncientsToken(final VrondissRageOfAncientsToken token) {
|
||||
|
|
@ -32,35 +29,3 @@ public final class VrondissRageOfAncientsToken extends TokenImpl {
|
|||
return new VrondissRageOfAncientsToken(this);
|
||||
}
|
||||
}
|
||||
|
||||
class VrondissRageOfAncientsTokenTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public VrondissRageOfAncientsTokenTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new SacrificeSourceEffect(), false);
|
||||
}
|
||||
|
||||
protected VrondissRageOfAncientsTokenTriggeredAbility(final VrondissRageOfAncientsTokenTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VrondissRageOfAncientsTokenTriggeredAbility copy() {
|
||||
return new VrondissRageOfAncientsTokenTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DAMAGED_PLAYER
|
||||
|| event.getType() == GameEvent.EventType.DAMAGED_PERMANENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return event.getSourceId().equals(this.getSourceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "When this creature deals damage, sacrifice it.";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue