* Non basic mana abilities - fixed rollback errors in AI games (#6300);

This commit is contained in:
Oleg Agafonov 2020-02-25 12:41:45 +04:00
parent 28169b5271
commit 169d9bf761
62 changed files with 692 additions and 509 deletions

View file

@ -14,7 +14,7 @@ public class ManaChoice {
for (int i = 0; i < amount; i++) {
ChoiceColor choiceColor = new ChoiceColor();
if (amount > 1) {
choiceColor.setMessage("Choose color " + (i+1));
choiceColor.setMessage("Choose color " + (i + 1));
}
if (!player.choose(Outcome.Benefit, choiceColor, game)) {
return null;
@ -25,27 +25,28 @@ public class ManaChoice {
}
public static Mana chooseTwoDifferentColors(Player player, Game game) {
if (player == null) {
return null;
Mana mana = new Mana();
if (game == null || player == null) {
return mana;
}
ChoiceColor color1 = new ChoiceColor(true, "Choose color 1");
if (!player.choose(Outcome.PutManaInPool, color1, game) || color1.getColor() == null) {
return null;
return mana;
}
ChoiceColor color2 = new ChoiceColor(true, "Choose color 2");
color2.removeColorFromChoices(color1.getChoice());
if (!player.choose(Outcome.PutManaInPool, color2, game) || color2.getColor() == null) {
return null;
return mana;
}
if (color1.getColor().equals(color2.getColor())) {
game.informPlayers("Player " + player.getName() + " is cheating with mana choices.");
return null;
return mana;
}
Mana mana = new Mana();
mana.add(color1.getMana(1));
mana.add(color2.getMana(1));
return mana;