mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
- Fixed possible min > max error.
This commit is contained in:
@@ -572,6 +572,8 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Card> chooseCardsToRevealFromHand(int min, int max, List<Card> valid) {
|
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);
|
InputSelectCardsFromList inp = new InputSelectCardsFromList(min, max, valid);
|
||||||
inp.setMessage("Choose Which Cards to Reveal");
|
inp.setMessage("Choose Which Cards to Reveal");
|
||||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ public class InputSelectCardsFromList extends InputSelectCards {
|
|||||||
private final List<Card> validChoices;
|
private final List<Card> validChoices;
|
||||||
|
|
||||||
public InputSelectCardsFromList(int min, int max, List<Card> validCards) {
|
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;
|
this.validChoices = validCards;
|
||||||
|
|
||||||
if ( min > validCards.size() )
|
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
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user