Test framework: simplified AI logic and tests, added usage comments. Devs recommendations:

* in card's code use player.isComputer instead player.isHuman (it help to split Human/AI logic and test both by unit tests);
* usage example: AI hint to skip or auto-calculate choices instead call of real choose dialogs;
* unit tests for Human logic: call normal commands;
* unit tests for AI logic: call aiXXX commands;
This commit is contained in:
Oleg Agafonov 2021-03-07 22:51:58 +04:00
parent 00c7b3753c
commit 2906f86324
22 changed files with 106 additions and 47 deletions

View file

@ -109,8 +109,9 @@ public class ComputerPlayer extends PlayerImpl implements Player {
public boolean chooseMulligan(Game game) {
log.debug("chooseMulligan");
if (hand.size() < 6
|| isTestMode()
|| game.getClass().getName().contains("Momir")) {
|| isTestsMode() // ignore mulligan in tests
|| game.getClass().getName().contains("Momir") // ignore mulligan in Momir games
) {
return false;
}
Set<Card> lands = hand.getCards(new FilterLandCard(), game);
@ -2880,9 +2881,10 @@ public class ComputerPlayer extends PlayerImpl implements Player {
@Override
public boolean isHuman() {
if (human) {
log.error("computer must be not human", new Throwable());
throw new IllegalStateException("Computer player can't be Human");
} else {
return false;
}
return human;
}
@Override