aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-08-03 20:48:29 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2025-01-27 16:43:53 +0100
commit833534b5a58bf1abfad4101dd264ff760382067f (patch)
treeba25a9e40586bed46cf1d5aad3c5773d4b978811
parent2d487b385ffa772e0213c37c0ed0794b045db27e (diff)
downloadmuhqs-game-833534b5a58bf1abfad4101dd264ff760382067f.tar.gz
muhqs-game-833534b5a58bf1abfad4101dd264ff760382067f.zip
client: remove active prompt or choice before adding a new one
-rw-r--r--go/client/game.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/go/client/game.go b/go/client/game.go
index c328ddf7..9f440ceb 100644
--- a/go/client/game.go
+++ b/go/client/game.go
@@ -111,12 +111,6 @@ func (g *Game) addActivePlayer(name string, deckList string) *Game {
return g.initPlayerUi(p)
}
-func (g *Game) addPrompt(action game.Action, prompt string) {
- g.prompt = ui.NewPrompt(g.Height/2, g.Width, action, prompt)
- g.AddWidget(g.prompt)
- g.updateHighlight()
-}
-
func (g *Game) getPlayer(name string) *game.Player {
for _, p := range g.gameState.Players {
if p.Name == name {
@@ -282,6 +276,9 @@ func (g *Game) addActionChoice(perm game.Permanent, x, y int) {
}
func (g *Game) addChoice(choice *ui.Choice) {
+ if g.choice != nil {
+ g.removeChoice()
+ }
g.choice = choice
g.AddWidget(choice)
}
@@ -291,6 +288,15 @@ func (g *Game) removeChoice() {
g.choice = nil
}
+func (g *Game) addPrompt(action game.Action, prompt string) {
+ if g.prompt != nil {
+ g.removePrompt()
+ }
+ g.prompt = ui.NewPrompt(g.Height/2, g.Width, action, prompt)
+ g.AddWidget(g.prompt)
+ g.updateHighlight()
+}
+
func (g *Game) progressPrompt() {
a := g.prompt.Action()
targets := a.Targets()