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
|
|
@ -319,7 +319,7 @@ public abstract class AbilityImpl implements Ability {
|
|||
// unit tests only: it allows to add targets/choices by two ways:
|
||||
// 1. From cast/activate command params (process it here)
|
||||
// 2. From single addTarget/setChoice, it's a preffered method for tests (process it in normal choose dialogs like human player)
|
||||
if (controller.isTestMode()) {
|
||||
if (controller.isTestsMode()) {
|
||||
if (!controller.addTargets(this, game)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,8 +94,9 @@ public class AssistAbility extends SimpleStaticAbility implements AlternateManaP
|
|||
}
|
||||
|
||||
// AI can't use assist (can't ask another player to help), maybe in teammode it can be enabled, but tests must works all the time
|
||||
// Outcome.AIDontUseIt
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null && !controller.isTestMode() && !controller.isHuman()) {
|
||||
if (controller != null && controller.isComputer()) {
|
||||
return options;
|
||||
}
|
||||
|
||||
|
|
@ -170,7 +171,7 @@ class AssistEffect extends OneShotEffect {
|
|||
if (controller != null && spell != null && targetPlayer != null) {
|
||||
// AI can't assist other players, maybe for teammates only (but tests must work as normal)
|
||||
int amountToPay = 0;
|
||||
if (targetPlayer.isHuman() || targetPlayer.isTestMode()) {
|
||||
if (!targetPlayer.isComputer()) {
|
||||
amountToPay = targetPlayer.announceXMana(0, unpaid.getMana().getGeneric(),
|
||||
"How much mana to pay as assist for " + controller.getName() + "?", game, source);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue