mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- AF NameCard will now present a complete list of card names to the player. He needs to chose until a valid card is chosen (for nonland or other restrictions).
This commit is contained in:
@@ -2,6 +2,7 @@ package forge.card.abilityfactory;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@@ -25,6 +26,9 @@ import forge.card.spellability.Spell;
|
|||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.card.spellability.Target;
|
import forge.card.spellability.Target;
|
||||||
import forge.gui.GuiUtils;
|
import forge.gui.GuiUtils;
|
||||||
|
import forge.gui.ListChooser;
|
||||||
|
import forge.item.CardDb;
|
||||||
|
import forge.item.CardPrinted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -1380,7 +1384,7 @@ public final class AbilityFactoryChoose {
|
|||||||
if (sa.getActivatingPlayer().isHuman()) {
|
if (sa.getActivatingPlayer().isHuman()) {
|
||||||
final String message = validDesc.equals("card") ? "Name a card" : "Name a " + validDesc
|
final String message = validDesc.equals("card") ? "Name a card" : "Name a " + validDesc
|
||||||
+ " card. (Case sensitive)";
|
+ " card. (Case sensitive)";
|
||||||
name = JOptionPane.showInputDialog(null, message, host.getName(), JOptionPane.QUESTION_MESSAGE);
|
/*name = JOptionPane.showInputDialog(null, message, host.getName(), JOptionPane.QUESTION_MESSAGE);
|
||||||
if (!valid.equals("Card") && !(null == name)) {
|
if (!valid.equals("Card") && !(null == name)) {
|
||||||
try {
|
try {
|
||||||
final Card temp = AllZone.getCardFactory().getCard(name, p);
|
final Card temp = AllZone.getCardFactory().getCard(name, p);
|
||||||
@@ -1393,8 +1397,24 @@ public final class AbilityFactoryChoose {
|
|||||||
}
|
}
|
||||||
if (ok) {
|
if (ok) {
|
||||||
host.setNamedCard(null == name ? "" : name);
|
host.setNamedCard(null == name ? "" : name);
|
||||||
|
}*/
|
||||||
|
final List<String> cards = new ArrayList<String>();
|
||||||
|
for (final CardPrinted c : CardDb.instance().getAllUniqueCards()) {
|
||||||
|
cards.add(c.getName());
|
||||||
}
|
}
|
||||||
|
Collections.sort(cards);
|
||||||
|
|
||||||
|
// use standard forge's list selection dialog
|
||||||
|
final ListChooser<String> choice = new ListChooser<String>(
|
||||||
|
message, 1, 1, cards);
|
||||||
|
choice.show();
|
||||||
|
// still missing a listener to display the card preview
|
||||||
|
// in the right
|
||||||
|
name = choice.getSelectedValue();
|
||||||
|
if(AllZone.getCardFactory().getCard(name, p).isValid(valid, host.getController(), host)) {
|
||||||
|
host.setNamedCard(choice.getSelectedValue());
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
CardList list = AllZoneUtil.getCardsInGame().getController(AllZone.getHumanPlayer());
|
CardList list = AllZoneUtil.getCardsInGame().getController(AllZone.getHumanPlayer());
|
||||||
list = list.filter(new CardListFilter() {
|
list = list.filter(new CardListFilter() {
|
||||||
|
|||||||
Reference in New Issue
Block a user