diff --git a/Mage.Sets/src/mage/cards/k/KaerveksSpite.java b/Mage.Sets/src/mage/cards/k/KaerveksSpite.java index bc0c37007de..349fa1ccf82 100644 --- a/Mage.Sets/src/mage/cards/k/KaerveksSpite.java +++ b/Mage.Sets/src/mage/cards/k/KaerveksSpite.java @@ -12,25 +12,24 @@ import mage.filter.common.FilterControlledPermanent; public class KaerveksSpite extends CardImpl { - private FilterControlledPermanent permanentsYouControl = new FilterControlledPermanent("all permanents you control"); - public KaerveksSpite(UUID ownerId, CardSetInfo cardSetInfo) { super(ownerId, cardSetInfo, new CardType[]{CardType.INSTANT}, "{B}{B}{B}"); - //As an additional cost to cast Kaervek's Spite, sacrifice all permanents you control and discard your hand. - this.getSpellAbility().addCost(new SacrificeAllCost(permanentsYouControl)); + // As an additional cost to cast Kaervek's Spite, sacrifice all permanents you control and discard your hand. + this.getSpellAbility().addCost(new SacrificeAllCost(new FilterControlledPermanent("all permanents you control"))); this.getSpellAbility().addCost(new DiscardHandCost()); - //Target player loses 5 life. + // Target player loses 5 life. Effect effect = new LoseLifeTargetEffect(5); this.getSpellAbility().addEffect(effect); } - public KaerveksSpite(final KaerveksSpite other){ + public KaerveksSpite(final KaerveksSpite other) { super(other); } - public KaerveksSpite copy(){ + @Override + public KaerveksSpite copy() { return new KaerveksSpite(this); } } diff --git a/Mage.Sets/src/mage/cards/s/Soulblast.java b/Mage.Sets/src/mage/cards/s/Soulblast.java index 1c9d495fcab..c6391096b60 100644 --- a/Mage.Sets/src/mage/cards/s/Soulblast.java +++ b/Mage.Sets/src/mage/cards/s/Soulblast.java @@ -36,7 +36,7 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Outcome; -import mage.filter.common.FilterCreaturePermanent; +import mage.filter.StaticFilters; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -48,14 +48,12 @@ import mage.target.common.TargetCreatureOrPlayer; */ public class Soulblast extends CardImpl { - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures you control"); - public Soulblast(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{3}{R}{R}{R}"); - + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{R}{R}{R}"); // As an additional cost to cast Soulblast, sacrifice all creatures you control. - this.getSpellAbility().addCost(new SacrificeAllCost(filter)); + this.getSpellAbility().addCost(new SacrificeAllCost(StaticFilters.FILTER_PERMANENT_CREATURES_CONTROLLED)); + // Soulblast deals damage to target creature or player equal to the total power of the sacrificed creatures. this.getSpellAbility().addEffect(new SoulblastEffect()); this.getSpellAbility().addTarget(new TargetCreatureOrPlayer()); @@ -90,7 +88,7 @@ class SoulblastEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { int power = 0; - for (Cost cost :source.getCosts()) { + for (Cost cost : source.getCosts()) { if (cost instanceof SacrificeAllCost) { for (Permanent permanent : ((SacrificeAllCost) cost).getPermanents()) { power += permanent.getPower().getValue(); diff --git a/Mage/src/main/java/mage/abilities/costs/common/SacrificeAllCost.java b/Mage/src/main/java/mage/abilities/costs/common/SacrificeAllCost.java index 88f5d8af975..a784838b8c9 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/SacrificeAllCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/SacrificeAllCost.java @@ -55,19 +55,19 @@ public class SacrificeAllCost extends CostImpl { public SacrificeAllCost(final SacrificeAllCost cost) { super(cost); - for (Permanent permanent: cost.permanents) { - this.permanents.add(permanent.copy()); - } + this.permanents.addAll(cost.permanents); // because this are already copied permanents, they can't change, so no copy again is needed this.filter = cost.filter.copy(); } @Override public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, controllerId, game)) { - permanents.add(permanent.copy()); - permanent.sacrifice(sourceId, game); + if (permanent.sacrifice(sourceId, game)) { + permanents.add(permanent.copy()); + } } - return true; + paid = true; + return paid; } @Override @@ -81,13 +81,13 @@ public class SacrificeAllCost extends CostImpl { activator = controllerId; } } - - for (Permanent permanent :game.getBattlefield().getAllActivePermanents(filter, controllerId, game)) { - if(!game.getPlayer(activator).canPaySacrificeCost(permanent, sourceId, controllerId, game)) { - return false; - } + + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, controllerId, game)) { + if (!game.getPlayer(activator).canPaySacrificeCost(permanent, sourceId, controllerId, game)) { + return false; + } } - + return true; }