[READY FOR REVIEW] Implement a "multi-amount" dialog (#7528)

* Implemented chooseTargetAmount and new GUI dialog (distribute damage, distribute mana)
* Added tests and AI support;
* Test framework: added aliases support in TargetAmount dialogs;

Co-authored-by: Oleg Agafonov <jaydi85@gmail.com>
This commit is contained in:
Daniel Bomar 2021-04-17 05:28:01 -05:00 committed by GitHub
parent 042aa61ad4
commit 600cac6fc7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 1209 additions and 232 deletions

View file

@ -2028,6 +2028,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
}
@Override
// TODO: add AI support with outcome and replace random with min/max
public int getAmount(int min, int max, String message, Game game) {
log.debug("getAmount");
if (message.startsWith("Assign damage to ")) {
@ -2039,6 +2040,29 @@ public class ComputerPlayer extends PlayerImpl implements Player {
return min;
}
@Override
public List<Integer> getMultiAmount(Outcome outcome, List<String> messages, int min, int max, MultiAmountType type, Game game) {
log.debug("getMultiAmount");
int needCount = messages.size();
List<Integer> defaultList = MultiAmountType.prepareDefaltValues(needCount, min, max);
if (needCount == 0) {
return defaultList;
}
// BAD effect
// default list uses minimum possible values, so return it on bad effect
// TODO: need something for damage target and mana logic here, current version is useless but better than random
if (!outcome.isGood()) {
return defaultList;
}
// GOOD effect
// values must be stable, so AI must able to simulate it and choose correct actions
// fill max values as much as possible
return MultiAmountType.prepareMaxValues(needCount, min, max);
}
@Override
public UUID chooseAttackerOrder(List<Permanent> attackers, Game game) {
//TODO: improve this