mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
AI: fixed not working choice with key-value dialogs, random refactor
This commit is contained in:
parent
ec50a123ec
commit
3dda5712db
8 changed files with 77 additions and 64 deletions
|
|
@ -1301,9 +1301,13 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
public boolean choose(Outcome outcome, Choice choice, Game game) {
|
||||
log.debug("choose 3");
|
||||
//TODO: improve this
|
||||
if (choice.getMessage() != null && choice.getMessage().equals("Choose creature type")) {
|
||||
|
||||
// choose creature type
|
||||
// TODO: WTF?! Creature types dialog text can changes, need to replace that code
|
||||
if (choice.getMessage() != null && (choice.getMessage().equals("Choose creature type") || choice.getMessage().equals("Choose a creature type"))) {
|
||||
chooseCreatureType(outcome, choice, game);
|
||||
}
|
||||
|
||||
// choose the correct color to pay a spell
|
||||
if (outcome == Outcome.PutManaInPool && choice instanceof ChoiceColor && currentUnpaidMana != null) {
|
||||
if (currentUnpaidMana.containsColor(ColoredManaSymbol.W) && choice.getChoices().contains("White")) {
|
||||
|
|
@ -1331,19 +1335,12 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// choose by random
|
||||
if (!choice.isChosen()) {
|
||||
int choiceIdx = (int) (Math.random() * choice.getChoices().size() + 1);
|
||||
for (String next : choice.getChoices()) {
|
||||
if (--choiceIdx > 0) {
|
||||
continue;
|
||||
}
|
||||
if (!next.isEmpty()) {
|
||||
choice.setChoice(next);
|
||||
break;
|
||||
}
|
||||
}
|
||||
choice.setRandomChoice();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue