forked from External/mage
new DamageTargetAndAllControlledEffect
This commit is contained in:
parent
03100a932e
commit
b8394f99e2
2 changed files with 79 additions and 8 deletions
|
|
@ -1,14 +1,14 @@
|
||||||
|
|
||||||
package mage.cards.c;
|
package mage.cards.c;
|
||||||
|
|
||||||
import java.util.UUID;
|
import mage.abilities.effects.common.DamageTargetAndAllControlledEffect;
|
||||||
import mage.abilities.effects.common.DamageAllControlledTargetEffect;
|
|
||||||
import mage.abilities.effects.common.DamageTargetEffect;
|
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
|
import mage.filter.StaticFilters;
|
||||||
import mage.target.common.TargetPlayerOrPlaneswalker;
|
import mage.target.common.TargetPlayerOrPlaneswalker;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author North
|
* @author North
|
||||||
|
|
@ -19,10 +19,8 @@ public final class ChandrasFury extends CardImpl {
|
||||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{4}{R}");
|
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{4}{R}");
|
||||||
|
|
||||||
// Chandra's Fury deals 4 damage to target player and 1 damage to each creature that player controls.
|
// Chandra's Fury deals 4 damage to target player and 1 damage to each creature that player controls.
|
||||||
this.getSpellAbility().addEffect(new DamageTargetEffect(4));
|
this.getSpellAbility().addEffect(new DamageTargetAndAllControlledEffect(4, 1,
|
||||||
this.getSpellAbility().addEffect(new DamageAllControlledTargetEffect(1)
|
StaticFilters.FILTER_PERMANENT_CREATURE));
|
||||||
.setText("and 1 damage to each creature that player or that planeswalker's controller controls")
|
|
||||||
);
|
|
||||||
this.getSpellAbility().addTarget(new TargetPlayerOrPlaneswalker());
|
this.getSpellAbility().addTarget(new TargetPlayerOrPlaneswalker());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
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.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 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, false, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 each " + filter.getMessage() +
|
||||||
|
" that player or that planeswalker's controller controls";
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue