From 349a0e4e815b6d5b49dedf47badc995b021b9ea5 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 16 Jun 2014 15:32:29 +0200 Subject: [PATCH] * Kuldotha Flamefiend - Fixed that sacrificing artifact did not work correctly. --- .../mirrodinbesieged/KuldothaFlamefiend.java | 42 +++---------------- .../mage/sets/theros/PyxisOfPandemonium.java | 14 ++++--- 2 files changed, 14 insertions(+), 42 deletions(-) diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/KuldothaFlamefiend.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/KuldothaFlamefiend.java index f253fa231b..667316013b 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/KuldothaFlamefiend.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/KuldothaFlamefiend.java @@ -29,17 +29,15 @@ package mage.sets.mirrodinbesieged; import java.util.UUID; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.Rarity; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.costs.common.SacrificeTargetCost; import mage.abilities.effects.common.DamageMultiEffect; +import mage.abilities.effects.common.DoIfCostPaid; import mage.cards.CardImpl; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.target.common.TargetArtifactPermanent; +import mage.filter.common.FilterControlledArtifactPermanent; +import mage.target.common.TargetControlledPermanent; import mage.target.common.TargetCreatureOrPlayerAmount; /** @@ -58,10 +56,9 @@ public class KuldothaFlamefiend extends CardImpl { this.toughness = new MageInt(4); // When Kuldotha Flamefiend enters the battlefield, you may sacrifice an artifact. If you do, Kuldotha Flamefiend deals 4 damage divided as you choose among any number of target creatures and/or players. - EntersBattlefieldTriggeredAbility ability = new EntersBattlefieldTriggeredAbility(new SacrificeArtifactEffect(), true); - ability.addEffect(new DamageMultiEffect(4)); + EntersBattlefieldTriggeredAbility ability = + new EntersBattlefieldTriggeredAbility(new DoIfCostPaid(new DamageMultiEffect(4), new SacrificeTargetCost(new TargetControlledPermanent(new FilterControlledArtifactPermanent("an artifact")))), false); ability.addTarget(new TargetCreatureOrPlayerAmount(4)); - ability.addTarget(new TargetArtifactPermanent()); this.addAbility(ability); } @@ -74,30 +71,3 @@ public class KuldothaFlamefiend extends CardImpl { return new KuldothaFlamefiend(this); } } - -class SacrificeArtifactEffect extends OneShotEffect { - - public SacrificeArtifactEffect() { - super(Outcome.Sacrifice); - this.staticText = "sacrifice an artifact"; - } - - public SacrificeArtifactEffect(final SacrificeArtifactEffect effect) { - super(effect); - } - - @Override - public SacrificeArtifactEffect copy() { - return new SacrificeArtifactEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanent(source.getTargets().get(1).getFirstTarget()); - if (permanent != null) { - permanent.sacrifice(source.getSourceId(), game); - return true; - } - return false; - } -} diff --git a/Mage.Sets/src/mage/sets/theros/PyxisOfPandemonium.java b/Mage.Sets/src/mage/sets/theros/PyxisOfPandemonium.java index 7247fe97de..077c1c46c8 100644 --- a/Mage.Sets/src/mage/sets/theros/PyxisOfPandemonium.java +++ b/Mage.Sets/src/mage/sets/theros/PyxisOfPandemonium.java @@ -29,7 +29,6 @@ package mage.sets.theros; import java.util.HashMap; import java.util.Map; -import java.util.Set; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -104,7 +103,7 @@ class PyxisOfPandemoniumExileEffect extends OneShotEffect { if (object != null && object instanceof Map) { exileIds = (Map) object; } else { - exileIds = new HashMap(); + exileIds = new HashMap<>(); game.getState().setValue(valueKey, exileIds); } @@ -114,14 +113,17 @@ class PyxisOfPandemoniumExileEffect extends OneShotEffect { if (player != null) { if (player.getLibrary().size() > 0) { Card card = player.getLibrary().removeFromTop(game); - String exileKey = new StringBuilder(playerId.toString()).append(source.getSourceId().toString()).toString(); + + String exileKey = new StringBuilder(playerId.toString()).append(CardUtil.getCardExileZoneId(game, source)).toString(); UUID exileId = exileIds.get(exileKey); if (exileId == null) { exileId = UUID.randomUUID(); exileIds.put(exileKey, exileId); } card.setFaceDown(true); - card.moveToExile(exileId, new StringBuilder("Pyxis of Pandemonium (").append(player.getName()).append(")").toString(), source.getSourceId(), game); + player.moveCardToExileWithInfo(card, exileId, + new StringBuilder("Pyxis of Pandemonium (").append(player.getName()).append(")").toString(), + source.getSourceId(), game, Zone.LIBRARY); } } } @@ -163,7 +165,7 @@ class PyxisOfPandemoniumPutOntoBattlefieldEffect extends OneShotEffect { for (UUID playerId : controller.getInRange()) { Player player = game.getPlayer(playerId); if (player != null) { - String exileKey = new StringBuilder(playerId.toString()).append(source.getSourceId().toString()).toString(); + String exileKey = new StringBuilder(playerId.toString()).append(CardUtil.getCardExileZoneId(game, source)).toString(); UUID exileId = exileIds.get(exileKey); if (exileId != null) { ExileZone exileZone = game.getState().getExile().getExileZone(exileId); @@ -171,7 +173,7 @@ class PyxisOfPandemoniumPutOntoBattlefieldEffect extends OneShotEffect { for(Card card: exileZone.getCards(game)) { card.setFaceDown(false); if (CardUtil.isPermanentCard(card)) { - card.putOntoBattlefield(game, Zone.EXILED, source.getSourceId(), playerId); + player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId()); } } }