diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-08-03 20:48:29 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:57:08 +0200 |
| commit | 34f56972535b8122e7d86762d532a601e917982b (patch) | |
| tree | 002c38d56cd13c84e37d544cc17d99217ad9fbb9 /go | |
| parent | 14d194fdefe3d11de89e02f1c5994b67e9855ec2 (diff) | |
| download | muhqs-game-34f56972535b8122e7d86762d532a601e917982b.tar.gz muhqs-game-34f56972535b8122e7d86762d532a601e917982b.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() |
