mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
fix Do or Die (related to #12245)
This commit is contained in:
parent
a0c3c7a7de
commit
614be8e928
1 changed files with 37 additions and 35 deletions
|
|
@ -1,9 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.d;
|
package mage.cards.d;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
|
@ -12,12 +8,17 @@ import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.filter.StaticFilters;
|
import mage.filter.StaticFilters;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
|
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||||
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;
|
||||||
import mage.target.TargetPlayer;
|
import mage.target.TargetPlayer;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author fireshoes
|
* @author fireshoes
|
||||||
|
|
@ -62,38 +63,39 @@ class DoOrDieEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
Player targetPlayer = game.getPlayer(source.getFirstTarget());
|
Player targetPlayer = game.getPlayer(source.getFirstTarget());
|
||||||
if (player != null && targetPlayer != null) {
|
if (player == null || targetPlayer == null) {
|
||||||
int count = game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURES, targetPlayer.getId(), game);
|
return false;
|
||||||
TargetCreaturePermanent creatures = new TargetCreaturePermanent(0, count, new FilterCreaturePermanent("creatures to put in the first pile"), true);
|
|
||||||
List<Permanent> pile1 = new ArrayList<>();
|
|
||||||
creatures.setRequired(false);
|
|
||||||
if (player.choose(Outcome.Neutral, creatures, source, game)) {
|
|
||||||
List<UUID> targets = creatures.getTargets();
|
|
||||||
for (UUID targetId : targets) {
|
|
||||||
Permanent p = game.getPermanent(targetId);
|
|
||||||
if (p != null) {
|
|
||||||
pile1.add(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<Permanent> pile2 = new ArrayList<>();
|
|
||||||
for (Permanent p : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, targetPlayer.getId(), game)) {
|
|
||||||
if (!pile1.contains(p)) {
|
|
||||||
pile2.add(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean choice = targetPlayer.choosePile(Outcome.DestroyPermanent, "Choose a pile to destroy.", pile1, pile2, game);
|
|
||||||
|
|
||||||
if (choice) {
|
|
||||||
destroyPermanents(pile1, game, source);
|
|
||||||
} else {
|
|
||||||
destroyPermanents(pile2, game, source);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures to put in the first pile");
|
||||||
|
filter.add(new ControllerIdPredicate(targetPlayer.getId()));
|
||||||
|
TargetCreaturePermanent creatures = new TargetCreaturePermanent(0, Integer.MAX_VALUE, filter, true);
|
||||||
|
List<Permanent> pile1 = new ArrayList<>();
|
||||||
|
creatures.setRequired(false);
|
||||||
|
if (player.choose(Outcome.Neutral, creatures, source, game)) {
|
||||||
|
List<UUID> targets = creatures.getTargets();
|
||||||
|
for (UUID targetId : targets) {
|
||||||
|
Permanent p = game.getPermanent(targetId);
|
||||||
|
if (p != null) {
|
||||||
|
pile1.add(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<Permanent> pile2 = new ArrayList<>();
|
||||||
|
for (Permanent p : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, targetPlayer.getId(), game)) {
|
||||||
|
if (!pile1.contains(p)) {
|
||||||
|
pile2.add(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean choice = targetPlayer.choosePile(Outcome.DestroyPermanent, "Choose a pile to destroy.", pile1, pile2, game);
|
||||||
|
|
||||||
|
if (choice) {
|
||||||
|
destroyPermanents(pile1, game, source);
|
||||||
|
} else {
|
||||||
|
destroyPermanents(pile2, game, source);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void destroyPermanents(List<Permanent> pile, Game game, Ability source) {
|
private void destroyPermanents(List<Permanent> pile, Game game, Ability source) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue