This commit is contained in:
Jeff 2019-03-04 17:38:52 -06:00
parent 9a1edf7689
commit 26fd9f6088
3 changed files with 37 additions and 41 deletions

View file

@ -2,26 +2,26 @@ package mage.cards.p;
import mage.MageInt; import mage.MageInt;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.LoseLifeTargetEffect;
import mage.abilities.effects.common.SacrificeEffect;
import mage.abilities.effects.mana.BasicManaEffect; import mage.abilities.effects.mana.BasicManaEffect;
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.SubType; import mage.constants.SubType;
import mage.filter.StaticFilters;
import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterControlledPermanent; import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.permanent.AnotherPredicate; import mage.filter.predicate.permanent.AnotherPredicate;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
import mage.target.common.TargetControlledPermanent;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.LoseLifeTargetEffect;
import mage.abilities.effects.common.SacrificeEffect;
import mage.filter.StaticFilters;
import mage.target.common.TargetControlledPermanent;
/** /**
* @author TheElk801 * @author TheElk801
@ -53,9 +53,9 @@ public final class PriestOfForgottenGods extends CardImpl {
new SacrificeEffect(StaticFilters.FILTER_PERMANENT_CREATURE, 1, "") new SacrificeEffect(StaticFilters.FILTER_PERMANENT_CREATURE, 1, "")
.setText("and sacrifice a creature") .setText("and sacrifice a creature")
); );
ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(2, 2, filter, true)));
ability.addEffect(new BasicManaEffect(Mana.BlackMana(2)).setText("You add {B}{B}")); ability.addEffect(new BasicManaEffect(Mana.BlackMana(2)).setText("You add {B}{B}"));
ability.addEffect(new DrawCardSourceControllerEffect(1).setText("and draw a card")); ability.addEffect(new DrawCardSourceControllerEffect(1).setText("and draw a card"));
ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(2, 2, filter, true)));
ability.addTarget(new TargetPlayer(0, Integer.MAX_VALUE, false)); ability.addTarget(new TargetPlayer(0, Integer.MAX_VALUE, false));
this.addAbility(ability); this.addAbility(ability);
} }
@ -68,4 +68,4 @@ public final class PriestOfForgottenGods extends CardImpl {
public PriestOfForgottenGods copy() { public PriestOfForgottenGods copy() {
return new PriestOfForgottenGods(this); return new PriestOfForgottenGods(this);
} }
} }

View file

@ -1,6 +1,6 @@
package mage.abilities.effects.common; package mage.abilities.effects.common;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode; import mage.abilities.Mode;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
@ -39,12 +39,13 @@ public class LoseLifeTargetEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source)); for (UUID playerId : targetPointer.getTargets(game, source)) {
if (player != null) { Player player = game.getPlayer(playerId);
player.loseLife(amount.calculate(game, source, this), game, false); if (player != null) {
return true; player.loseLife(amount.calculate(game, source, this), game, false);
}
} }
return false; return true;
} }
@Override @Override

View file

@ -1,6 +1,6 @@
package mage.abilities.effects.common; package mage.abilities.effects.common;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.dynamicvalue.common.StaticValue;
@ -46,30 +46,25 @@ public class SacrificeEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source)); for (UUID playerId : targetPointer.getTargets(game, source)) {
if (player == null) { Player player = game.getPlayer(playerId);
return false; if (player != null) {
} FilterPermanent newFilter = filter.copy(); // filter can be static, so it's important to copy here
newFilter.add(new ControllerIdPredicate(player.getId()));
FilterPermanent newFilter = filter.copy(); // filter can be static, so it's important to copy here int amount = count.calculate(game, source, this);
newFilter.add(new ControllerIdPredicate(player.getId())); int realCount = game.getBattlefield().countAll(newFilter, player.getId(), game);
amount = Math.min(amount, realCount);
int amount = count.calculate(game, source, this); Target target = new TargetPermanent(amount, amount, newFilter, true);
int realCount = game.getBattlefield().countAll(newFilter, player.getId(), game); if (amount > 0 && target.canChoose(source.getSourceId(), player.getId(), game)) {
amount = Math.min(amount, realCount); while (!target.isChosen() && target.canChoose(player.getId(), game) && player.canRespond()) {
player.chooseTarget(Outcome.Sacrifice, target, source, game);
Target target = new TargetPermanent(amount, amount, newFilter, true); }
for (int idx = 0; idx < target.getTargets().size(); idx++) {
if (amount > 0 && target.canChoose(source.getSourceId(), player.getId(), game)) { Permanent permanent = game.getPermanent(target.getTargets().get(idx));
while (!target.isChosen() && target.canChoose(player.getId(), game) && player.canRespond()) { if (permanent != null) {
player.chooseTarget(Outcome.Sacrifice, target, source, game); permanent.sacrifice(source.getSourceId(), game);
} }
}
for (int idx = 0; idx < target.getTargets().size(); idx++) {
Permanent permanent = game.getPermanent(target.getTargets().get(idx));
if (permanent != null) {
permanent.sacrifice(source.getSourceId(), game);
} }
} }
} }