Add Ask AI button

This commit is contained in:
tool4EvEr
2021-06-11 23:04:39 +02:00
parent dbe1683ba9
commit 828d4e17c9
10 changed files with 43 additions and 0 deletions

View File

@@ -59,6 +59,8 @@ public interface IDevModeCheats {
void planeswalkTo();
void askAI();
/**
* Implementation of {@link IDevModeCheats} that disallows cheating by
* performing no action whatsoever when any of its methods is called.
@@ -141,6 +143,9 @@ public interface IDevModeCheats {
@Override
public void removeCardsFromGame() {
}
@Override
public void askAI() {
}
};
}

View File

@@ -36,6 +36,7 @@ import com.google.common.collect.Multimap;
import forge.LobbyPlayer;
import forge.StaticData;
import forge.ai.GameState;
import forge.ai.PlayerControllerAi;
import forge.card.CardDb;
import forge.card.CardStateName;
import forge.card.CardType;
@@ -2942,6 +2943,18 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
}
});
}
public void askAI() {
PlayerControllerAi ai = new PlayerControllerAi(player.getGame(), player, player.getOriginalLobbyPlayer());
player.runWithController(new Runnable() {
@Override
public void run() {
List<SpellAbility> sas = ai.chooseSpellAbilityToPlay();
SpellAbility chosen = sas == null ? null : sas.get(0);
getGui().message(chosen == null ? "AI doesn't want to play anything right now" : chosen.getHostCard().toString(), "AI Play Suggestion");
}
}, ai);
}
}
private IMacroSystem macros;