forked from External/mage
other: reworked target selection: (#13638)
- WIP: AI and multi targets, human and X=0 use cases, human and impossible targets use cases;
- improved stability and shared logic (related to #13606, #11134, #11666, continue from a53eb66b58, close #13617, close #13613);
- improved test logs and debug info to show more target info on errors;
- improved test framework to support multiple addTarget calls;
- improved test framework to find bad commands order for targets (related to #11666);
- fixed game freezes on auto-choice usages with disconnected or under control players (related to #11285);
- gui, game: fixed that player doesn't mark avatar as selected/green in "up to" targeting;
- gui, game: fixed small font in some popup messages on big screens (related to #969);
- gui, game: added min targets info for target selection dialog;
- for devs: added new cheat option to call and test any game dialog (define own dialogs, targets, etc in HumanDialogsTester);
- for devs: now tests require complete an any or up to target selection by addTarget + TestPlayer.TARGET_SKIP or setChoice + TestPlayer.CHOICE_SKIP (if not all max/possible targets used);
- for devs: added detail targets info for activate/trigger/cast, can be useful to debug unit tests, auto-choose or AI (see DebugUtil.GAME_SHOW_CHOOSE_TARGET_LOGS)
This commit is contained in:
parent
80d62727e1
commit
133e4fe425
84 changed files with 2737 additions and 743 deletions
|
|
@ -0,0 +1,77 @@
|
|||
package mage.utils.testers;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Part of testable game dialogs
|
||||
* <p>
|
||||
* Supported methods:
|
||||
* - player.chooseUse()
|
||||
*
|
||||
* @author JayDi85
|
||||
*/
|
||||
class ChooseUseTestableDialog extends BaseTestableDialog {
|
||||
|
||||
boolean isYou; // who choose - you or opponent
|
||||
String trueText;
|
||||
String falseText;
|
||||
String messageMain;
|
||||
String messageAdditional;
|
||||
|
||||
public ChooseUseTestableDialog(boolean isYou, String name, String trueText, String falseText, String messageMain, String messageAdditional) {
|
||||
super(String.format("player.chooseUse(%s)", isYou ? "you" : "AI"), name + buildName(trueText, falseText, messageMain, messageAdditional), "");
|
||||
this.isYou = isYou;
|
||||
this.trueText = trueText;
|
||||
this.falseText = falseText;
|
||||
this.messageMain = messageMain;
|
||||
this.messageAdditional = messageAdditional;
|
||||
}
|
||||
|
||||
private static String buildName(String trueText, String falseText, String messageMain, String messageAdditional) {
|
||||
String buttonsInfo = (trueText == null ? "default" : "custom") + "/" + (falseText == null ? "default" : "custom");
|
||||
String messagesInfo = (messageMain == null ? "-" : "main") + "/" + (messageAdditional == null ? "-" : "additional");
|
||||
return String.format("buttons: %s, messages: %s", buttonsInfo, messagesInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> showDialog(Player player, Ability source, Game game, Player opponent) {
|
||||
Player choosingPlayer = this.isYou ? player : opponent;
|
||||
boolean chooseRes = choosingPlayer.chooseUse(
|
||||
Outcome.Benefit,
|
||||
messageMain,
|
||||
messageAdditional == null ? null : messageAdditional + CardUtil.getSourceLogName(game, source),
|
||||
trueText,
|
||||
falseText,
|
||||
source,
|
||||
game
|
||||
);
|
||||
List<String> result = new ArrayList<>();
|
||||
result.add(chooseRes ? "TRUE" : "FALSE");
|
||||
return result;
|
||||
}
|
||||
|
||||
static public void register(TestableDialogsRunner runner) {
|
||||
List<Boolean> isYous = Arrays.asList(false, true);
|
||||
String trueButton = "true button";
|
||||
String falseButton = "false button";
|
||||
String mainMessage = "main <font color=green>message</font> with html";
|
||||
String additionalMessage = "additional main <font color=red>message</font> with html";
|
||||
for (boolean isYou : isYous) {
|
||||
runner.registerDialog(new ChooseUseTestableDialog(isYou, "", null, null, mainMessage, additionalMessage));
|
||||
runner.registerDialog(new ChooseUseTestableDialog(isYou, "", trueButton, falseButton, mainMessage, additionalMessage));
|
||||
runner.registerDialog(new ChooseUseTestableDialog(isYou, "", null, falseButton, mainMessage, additionalMessage));
|
||||
runner.registerDialog(new ChooseUseTestableDialog(isYou, "", trueButton, null, mainMessage, additionalMessage));
|
||||
runner.registerDialog(new ChooseUseTestableDialog(isYou, "error ", trueButton, falseButton, null, additionalMessage));
|
||||
runner.registerDialog(new ChooseUseTestableDialog(isYou, "", trueButton, falseButton, mainMessage, null));
|
||||
runner.registerDialog(new ChooseUseTestableDialog(isYou, "error ", trueButton, falseButton, null, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue