mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10:18:01 +00:00
- Fixed possible min > max error.
This commit is contained in:
@@ -572,6 +572,8 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
*/
|
||||
@Override
|
||||
public List<Card> chooseCardsToRevealFromHand(int min, int max, List<Card> valid) {
|
||||
max = Math.min(max, valid.size());
|
||||
min = Math.min(min, max);
|
||||
InputSelectCardsFromList inp = new InputSelectCardsFromList(min, max, valid);
|
||||
inp.setMessage("Choose Which Cards to Reveal");
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
|
||||
@@ -10,11 +10,11 @@ public class InputSelectCardsFromList extends InputSelectCards {
|
||||
private final List<Card> validChoices;
|
||||
|
||||
public InputSelectCardsFromList(int min, int max, List<Card> validCards) {
|
||||
super(min, Math.min(max, validCards.size())); // to avoid hangs
|
||||
super(Math.min(min, validCards.size()), Math.min(max, validCards.size())); // to avoid hangs
|
||||
this.validChoices = validCards;
|
||||
|
||||
if ( min > validCards.size() )
|
||||
throw new RuntimeException(String.format("Trying to choose at least %d cards from a list with only %d cards!", min, validCards.size()));
|
||||
System.out.println(String.format("Trying to choose at least %d cards from a list with only %d cards!", min, validCards.size()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user