mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
other: added getAmount testable dialogs in cheat menu (part of #13638)
This commit is contained in:
parent
e320bf241c
commit
832ff8a4ac
2 changed files with 62 additions and 1 deletions
|
|
@ -0,0 +1,60 @@
|
|||
package mage.utils.testers;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Part of testable game dialogs
|
||||
* <p>
|
||||
* Supported methods:
|
||||
* - player.getAmount()
|
||||
*
|
||||
* @author JayDi85
|
||||
*/
|
||||
class GetAmountTestableDialog extends BaseTestableDialog {
|
||||
|
||||
boolean isYou; // who choose - you or opponent
|
||||
int min;
|
||||
int max;
|
||||
|
||||
public GetAmountTestableDialog(boolean isYou, int min, int max) {
|
||||
super(String.format("player.getAmount(%s)", isYou ? "you" : "AI"),
|
||||
String.format("from %d to %d", min, max), "");
|
||||
this.isYou = isYou;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> showDialog(Player player, Ability source, Game game, Player opponent) {
|
||||
Player choosingPlayer = this.isYou ? player : opponent;
|
||||
String message = "<font color=green>message</font> with html";
|
||||
int chooseRes;
|
||||
chooseRes = choosingPlayer.getAmount(this.min, this.max, message, source, game);
|
||||
List<String> result = new ArrayList<>();
|
||||
result.add(getGroup() + " - " + this.getName() + " selected " + chooseRes);
|
||||
return result;
|
||||
}
|
||||
|
||||
static public void register(TestableDialogsRunner runner) {
|
||||
List<Boolean> isYous = Arrays.asList(false, true);
|
||||
for (boolean isYou : isYous) {
|
||||
runner.registerDialog(new GetAmountTestableDialog(isYou, 0, 0));
|
||||
runner.registerDialog(new GetAmountTestableDialog(isYou, 0, 1));
|
||||
runner.registerDialog(new GetAmountTestableDialog(isYou, 0, 3));
|
||||
runner.registerDialog(new GetAmountTestableDialog(isYou, 0, 50));
|
||||
runner.registerDialog(new GetAmountTestableDialog(isYou, 0, 500));
|
||||
runner.registerDialog(new GetAmountTestableDialog(isYou, 1, 1));
|
||||
runner.registerDialog(new GetAmountTestableDialog(isYou, 1, 3));
|
||||
runner.registerDialog(new GetAmountTestableDialog(isYou, 1, 50));
|
||||
runner.registerDialog(new GetAmountTestableDialog(isYou, 3, 3));
|
||||
runner.registerDialog(new GetAmountTestableDialog(isYou, 3, 10));
|
||||
runner.registerDialog(new GetAmountTestableDialog(isYou, 10, 10));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -30,7 +30,7 @@ import java.util.stream.Collectors;
|
|||
* [x] chooseUse
|
||||
* [x] choosePile
|
||||
* [x] announceX
|
||||
* [ ] getAmount // TODO: implement
|
||||
* [x] getAmount
|
||||
* [ ] getMultiAmountWithIndividualConstraints // TODO: implement
|
||||
* <p>
|
||||
* Support of priority dialogs (can be called by game engine, some can be implemented in theory):
|
||||
|
|
@ -74,6 +74,7 @@ public class TestableDialogsRunner {
|
|||
ChoosePileTestableDialog.register(this);
|
||||
ChooseAmountTestableDialog.register(this);
|
||||
AnnounceXTestableDialog.register(this);
|
||||
GetAmountTestableDialog.register(this);
|
||||
}
|
||||
|
||||
void registerDialog(TestableDialog dialog) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue