mirror of
https://github.com/correl/mage.git
synced 2024-12-27 03:00:13 +00:00
* Sacrificed a bug of SacrificeAllCost (fixing a problem with Soulblast looping forever).
This commit is contained in:
parent
a6644b0eb2
commit
4d4b0d145e
3 changed files with 23 additions and 26 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
@ -82,10 +82,10 @@ public class SacrificeAllCost extends CostImpl {
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue