- Fixed possible min > max error.

This commit is contained in:
Sloth
2013-06-14 11:42:30 +00:00
parent 7298cbbe0d
commit dea4a38a6c
2 changed files with 4 additions and 2 deletions

View File

@@ -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);

View File

@@ -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