forked from External/mage
Changed computer choose choice to prevent for NPE and choose a random choice instead always the first.
This commit is contained in:
parent
8d210edaac
commit
250bb8a705
1 changed files with 5 additions and 1 deletions
|
|
@ -935,13 +935,17 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
|
|||
public boolean choose(Outcome outcome, Choice choice, Game game) {
|
||||
log.debug("choose 3");
|
||||
//TODO: improve this
|
||||
if (choice.getMessage().equals("Choose creature type")) {
|
||||
if (choice.getMessage() != null && choice.getMessage().equals("Choose creature type")) {
|
||||
chooseCreatureType(outcome, choice, game);
|
||||
}
|
||||
if (!choice.isChosen()) {
|
||||
int choiceIdx = (int) (Math.random()*choice.getChoices().size()+1);
|
||||
Iterator iterator = choice.getChoices().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
String next = (String) iterator.next();
|
||||
if (--choiceIdx > 0) {
|
||||
continue;
|
||||
}
|
||||
if (!next.isEmpty()) {
|
||||
choice.setChoice(next);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue