package mage.utils.testers; import mage.abilities.Ability; import mage.choices.Choice; import mage.choices.ChoiceHintType; import mage.choices.ChoiceImpl; import mage.constants.Outcome; import mage.game.Game; import mage.players.Player; import java.util.*; import java.util.stream.Collectors; /** * Part of testable game dialogs *
* Helper class to create additional options in cheat menu - allow to test any game dialogs with any settings * Allow to call game dialogs from you or from your opponent, e.g. from AI player *
* All existing human's choose dialogs (search by waitForResponse): *
* Support of single dialogs (can be called inside effects): * [x] choose(target) * [x] choose(cards) * [x] choose(choice) * [x] chooseTarget(target) * [x] chooseTarget(cards) * [x] chooseTargetAmount * [x] chooseUse * [x] choosePile * [x] announceX * [x] getAmount * [x] getMultiAmountWithIndividualConstraints *
* Support of priority dialogs (can be called by game engine, some can be implemented in theory): * --- priority * --- playManaHandling * --- activateSpecialAction * --- activateAbility * --- chooseAbilityForCast * --- chooseLandOrSpellAbility * --- chooseMode * --- chooseMulligan * --- chooseReplacementEffect * --- chooseTriggeredAbility * --- selectAttackers * --- selectBlockers * --- selectCombatGroup (part of selectBlockers) *
* Support of outdated dialogs (not used anymore)
* --- announceRepetitions (part of removed macro feature)
*
* @author JayDi85
*/
public class TestableDialogsRunner {
private final Map
", group)
);
}
// fast link to last group
String lastGroupInfo = String.format(" -> last group: %s", lastSelectedGroup == null ? "not used" : lastSelectedGroup);
choice.withItem(
String.valueOf(LAST_SELECTED_GROUP_ID),
lastGroupInfo,
-2,
ChoiceHintType.TEXT,
lastGroupInfo
);
// fast link to last dialog
String lastDialogName = (lastSelectedDialog == null ? "not used" : String.format("%s - %s",
lastSelectedDialog.getName(), lastSelectedDialog.getDescription()));
String lastDialogInfo = String.format(" -> last dialog: %s", lastDialogName);
choice.withItem(
String.valueOf(LAST_SELECTED_DIALOG_ID),
lastDialogInfo,
-1,
ChoiceHintType.TEXT,
lastDialogInfo
);
return choice;
}
private Choice prepareSelectDialogChoice(String needGroup) {
Choice choice = new ChoiceImpl(false);
choice.setMessage("Choose game dialog to run from " + needGroup);
for (TestableDialog dialog : this.dialogs.values()) {
if (!dialog.getGroup().equals(needGroup)) {
continue;
}
String info = String.format("%s - %s - %s", dialog.getGroup(), dialog.getName(), dialog.getDescription());
choice.withItem(
String.valueOf(dialog.getRegNumber()),
String.format("%02d. %s", dialog.getRegNumber(), info),
dialog.getRegNumber(),
ChoiceHintType.TEXT,
String.join("
", info)
);
}
return choice;
}
public Collection