* Kuldotha Flamefiend - Fixed that sacrificing artifact did not work correctly.

This commit is contained in:
LevelX2 2014-06-16 15:32:29 +02:00
parent b360bb1528
commit 349a0e4e81
2 changed files with 14 additions and 42 deletions

View file

@ -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;
}
}

View file

@ -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<String, UUID>) object;
} else {
exileIds = new HashMap<String, UUID>();
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());
}
}
}