mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
Improved Doubling Chant.
This commit is contained in:
parent
3a88168bdd
commit
a2ae384960
1 changed files with 19 additions and 10 deletions
|
@ -89,20 +89,29 @@ class DoublingChantEffect extends OneShotEffect<DoublingChantEffect> {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
List<Card> chosenCards = new ArrayList<Card>();
|
List<Card> chosenCards = new ArrayList<Card>();
|
||||||
|
List<String> namesFiltered = new ArrayList<String>();
|
||||||
|
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(FilterCreaturePermanent.getDefault(), source.getControllerId());
|
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(FilterCreaturePermanent.getDefault(), source.getControllerId());
|
||||||
for (Permanent creature : creatures) {
|
for (Permanent creature : creatures) {
|
||||||
StringBuilder sb = new StringBuilder();
|
final String creatureName = creature.getName();
|
||||||
sb.append("Search for ").append(creature.getName()).append(" in your library?");
|
if (!namesFiltered.contains(creatureName)) {
|
||||||
if (player.chooseUse(Outcome.PutCreatureInPlay, sb.toString(), game)) {
|
StringBuilder sb = new StringBuilder();
|
||||||
FilterCreatureCard filter = new FilterCreatureCard(creature.getName());
|
sb.append("Search for ").append(creatureName).append(" in your library?");
|
||||||
filter.getName().add(creature.getName());
|
|
||||||
TargetCardInLibrary target = new TargetCardInLibrary(filter);
|
if (player.chooseUse(Outcome.PutCreatureInPlay, sb.toString(), game)) {
|
||||||
if (player.searchLibrary(target, game)) {
|
FilterCreatureCard filter = new FilterCreatureCard(creatureName);
|
||||||
Card card = player.getLibrary().remove(target.getFirstTarget(), game);
|
filter.getName().add(creatureName);
|
||||||
if (card != null) {
|
TargetCardInLibrary target = new TargetCardInLibrary(filter);
|
||||||
chosenCards.add(card);
|
|
||||||
|
if (player.searchLibrary(target, game)) {
|
||||||
|
Card card = player.getLibrary().remove(target.getFirstTarget(), game);
|
||||||
|
if (card != null) {
|
||||||
|
chosenCards.add(card);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
namesFiltered.add(creatureName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue