Fixed Powder Keg sac ability cost

This commit is contained in:
Evan Kranzler 2017-08-03 14:45:44 -04:00
parent e6eb415236
commit d6586cd103

View file

@ -32,6 +32,7 @@ import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -51,13 +52,14 @@ import mage.game.permanent.Permanent;
public class PowderKeg extends CardImpl { public class PowderKeg extends CardImpl {
public PowderKeg(UUID ownerId, CardSetInfo setInfo) { public PowderKeg(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{2}"); super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}");
// At the beginning of your upkeep, you may put a fuse counter on Powder Keg. // At the beginning of your upkeep, you may put a fuse counter on Powder Keg.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.FUSE.createInstance(), true), TargetController.YOU, true)); this.addAbility(new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.FUSE.createInstance(), true), TargetController.YOU, true));
// {T}, Sacrifice Powder Keg: Destroy each artifact and creature with converted mana cost equal to the number of fuse counters on Powder Keg. // {T}, Sacrifice Powder Keg: Destroy each artifact and creature with converted mana cost equal to the number of fuse counters on Powder Keg.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PowderKegEffect(), new SacrificeSourceCost()); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PowderKegEffect(), new SacrificeSourceCost());
ability.addCost(new TapSourceCost());
this.addAbility(ability); this.addAbility(ability);
} }
@ -73,39 +75,39 @@ public class PowderKeg extends CardImpl {
class PowderKegEffect extends OneShotEffect { class PowderKegEffect extends OneShotEffect {
public PowderKegEffect() { public PowderKegEffect() {
super(Outcome.DestroyPermanent); super(Outcome.DestroyPermanent);
staticText = "Destroy each artifact and creature with converted mana cost equal to the number of fuse counters on Powder Keg {this}"; staticText = "Destroy each artifact and creature with converted mana cost equal to the number of fuse counters on Powder Keg {this}";
} }
public PowderKegEffect(final PowderKegEffect effect) { public PowderKegEffect(final PowderKegEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent p = game.getBattlefield().getPermanent(source.getSourceId()); Permanent p = game.getBattlefield().getPermanent(source.getSourceId());
if (p == null) {
p = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if (p == null) { if (p == null) {
p = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); return false;
if (p == null) {
return false;
}
} }
int count = p.getCounters(game).getCount(CounterType.FUSE);
for (Permanent perm: game.getBattlefield().getAllActivePermanents()) {
if (perm.getConvertedManaCost() == count && ((perm.isArtifact())
|| (perm.isCreature()))) {
perm.destroy(source.getSourceId(), game, false);
}
}
return true;
} }
@Override int count = p.getCounters(game).getCount(CounterType.FUSE);
public PowderKegEffect copy() { for (Permanent perm : game.getBattlefield().getAllActivePermanents()) {
return new PowderKegEffect(this); if (perm.getConvertedManaCost() == count && ((perm.isArtifact())
|| (perm.isCreature()))) {
perm.destroy(source.getSourceId(), game, false);
}
} }
} return true;
}
@Override
public PowderKegEffect copy() {
return new PowderKegEffect(this);
}
}