forked from External/mage
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:
parent
00c7b3753c
commit
2906f86324
22 changed files with 106 additions and 47 deletions
|
|
@ -48,8 +48,32 @@ import java.util.*;
|
|||
*/
|
||||
public interface Player extends MageItem, Copyable<Player> {
|
||||
|
||||
/**
|
||||
* Current player is real life player (human). Try to use in GUI and network engine only.
|
||||
*
|
||||
* WARNING, you must use isComputer instead isHuman in card's code (for good Human/AI logic testing in unit tests)
|
||||
* TODO: check combat code and other and replace isHuman to isComputer usage if possible (if AI support that actions)
|
||||
* @return
|
||||
*/
|
||||
boolean isHuman();
|
||||
|
||||
boolean isTestsMode();
|
||||
|
||||
/**
|
||||
* Current player is AI. Use it in card's code and all other places.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
default boolean isComputer() {
|
||||
return !isHuman();
|
||||
}
|
||||
|
||||
String getName();
|
||||
|
||||
String getLogName();
|
||||
|
|
@ -314,8 +338,6 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
|
||||
void setGameUnderYourControl(boolean value, boolean fullRestore);
|
||||
|
||||
boolean isTestMode();
|
||||
|
||||
void setTestMode(boolean value);
|
||||
|
||||
void addAction(String action);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue