* Powder Keg - Fixed that the destroy ability did not work.

This commit is contained in:
LevelX2 2017-09-05 12:00:13 +02:00
parent b459e590ad
commit 5bef2a4eeb

View file

@ -38,10 +38,15 @@ import mage.abilities.effects.common.counter.AddCountersSourceEffect;
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.constants.ComparisonType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -58,8 +63,8 @@ public class PowderKeg extends CardImpl {
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 TapSourceCost());
ability.addCost(new TapSourceCost()); ability.addCost(new SacrificeSourceCost());
this.addAbility(ability); this.addAbility(ability);
} }
@ -77,7 +82,7 @@ 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 {this}";
} }
public PowderKegEffect(final PowderKegEffect effect) { public PowderKegEffect(final PowderKegEffect effect) {
@ -86,22 +91,17 @@ class PowderKegEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent p = game.getBattlefield().getPermanent(source.getSourceId()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (p == null) { if (sourcePermanent == null) {
p = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if (p == null) {
return false; return false;
} }
} int count = sourcePermanent.getCounters(game).getCount(CounterType.FUSE);
FilterPermanent filter = new FilterPermanent();
int count = p.getCounters(game).getCount(CounterType.FUSE); filter.add(Predicates.or(new CardTypePredicate(CardType.ARTIFACT), new CardTypePredicate(CardType.CREATURE)));
for (Permanent perm : game.getBattlefield().getAllActivePermanents()) { filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, count));
if (perm.getConvertedManaCost() == count && ((perm.isArtifact()) for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|| (perm.isCreature()))) {
perm.destroy(source.getSourceId(), game, false); perm.destroy(source.getSourceId(), game, false);
} }
}
return true; return true;
} }