* Emerge Ability - Fixed that the creature to sacrifice had to be selcted twice.

This commit is contained in:
LevelX2 2020-05-27 10:24:21 +02:00
parent 42ed2f64e7
commit 9933420f57

View file

@ -2,7 +2,6 @@ package mage.abilities.keyword;
import mage.Mana; import mage.Mana;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.costs.mana.ManaCost; import mage.abilities.costs.mana.ManaCost;
import mage.abilities.costs.mana.ManaCosts; import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.mana.ManaOptions; import mage.abilities.mana.ManaOptions;
@ -11,7 +10,6 @@ import mage.constants.Outcome;
import mage.constants.SpellAbilityType; import mage.constants.SpellAbilityType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.mageobject.CardIdPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
@ -92,11 +90,16 @@ public class EmergeAbility extends SpellAbility {
TargetPermanent target = new TargetControlledCreaturePermanent(new FilterControlledCreaturePermanent("creature to sacrifice for emerge")); TargetPermanent target = new TargetControlledCreaturePermanent(new FilterControlledCreaturePermanent("creature to sacrifice for emerge"));
if (controller.choose(Outcome.Sacrifice, target, this.getSourceId(), game)) { if (controller.choose(Outcome.Sacrifice, target, this.getSourceId(), game)) {
Permanent creature = game.getPermanent(target.getFirstTarget()); Permanent creature = game.getPermanent(target.getFirstTarget());
if (creature != null) {
CardUtil.reduceCost(this, creature.getConvertedManaCost()); CardUtil.reduceCost(this, creature.getConvertedManaCost());
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(creature.getLogName()); if (super.activate(game, false)) {
filter.add(new CardIdPredicate(creature.getId())); if (creature.sacrifice(getSourceId(), game)) {
this.addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent(filter))); return true;
return super.activate(game, false); } else {
activated = false;
}
}
}
} }
} }
return false; return false;