diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-08-03 20:48:29 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-01-27 16:43:53 +0100 |
| commit | 833534b5a58bf1abfad4101dd264ff760382067f (patch) | |
| tree | ba25a9e40586bed46cf1d5aad3c5773d4b978811 /go | |
| parent | 2d487b385ffa772e0213c37c0ed0794b045db27e (diff) | |
| download | muhqs-game-833534b5a58bf1abfad4101dd264ff760382067f.tar.gz muhqs-game-833534b5a58bf1abfad4101dd264ff760382067f.zip | |
client: remove active prompt or choice before adding a new one
Diffstat (limited to 'go')
| -rw-r--r-- | go/client/game.go | 18 |
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() |
