diff options
Diffstat (limited to 'go/client/game.go')
| -rw-r--r-- | go/client/game.go | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/go/client/game.go b/go/client/game.go index 0870450e..c0724547 100644 --- a/go/client/game.go +++ b/go/client/game.go @@ -7,7 +7,6 @@ import ( "github.com/hajimehoshi/ebiten/v2" "github.com/hajimehoshi/ebiten/v2/ebitenutil" - "github.com/hajimehoshi/ebiten/v2/inpututil" "muhq.space/muhqs-game/go/game" "muhq.space/muhqs-game/go/ui" @@ -75,10 +74,11 @@ func newGame(app *app, gameState game.State) *Game { } // default key bindings - g.keyBindings[ebiten.MouseButtonLeft] = clickSelection - g.keyBindings[ui.TouchTypes.Tap] = touchSelection + g.keyBindings[ebiten.MouseButtonLeft] = selection + g.keyBindings[ui.Tap] = selection g.keyBindings[ebiten.KeySpace] = pass g.keyBindings[ebiten.KeyEscape] = reset + g.keyBindings[ebiten.KeyQ] = func(ui.InputEvent, *Game) (bool, error) { return false, ebiten.Termination } g.passButton = ui.NewSimpleButton(g.Width-PASS_BUTTON_WIDTH, g.Height-DEFAULT_BUTTON_HEIGHT, @@ -427,6 +427,23 @@ func (g *Game) updateButtons() { g.passButton.UpdateLabel(passButtonLabel) } +func (g *Game) reset() { + g.removeChoice() + g.selectedObject = nil + g.ResetHover() + g.clearHighlights() + g.hideStore() + g.RemoveWidget(g.discardPileView) + g.RemoveWidget(g.resetButton) + if g.prompt != nil { + if g.prompt.Action().Targets().NoSelections() { + g.removePrompt() + } else { + g.prompt.ClearSelections() + } + } +} + func (g *Game) passPriority() { g.declareAction(game.NewPassPriority(g.activePlayer())) } @@ -585,11 +602,7 @@ func (g *Game) updateHighlight() { } func (g *Game) Update() error { - if inpututil.IsKeyJustPressed(ebiten.KeyQ) { - return ebiten.Termination - } - - if err := ui.TouchManager.Update(); err != nil { + if err := ui.Update(); err != nil { return err } @@ -598,7 +611,10 @@ func (g *Game) Update() error { } g.handlePlayerNotifications() - g.handleKeyBindings(g.keyBindings) + + if err := g.handleKeyBindings(g.keyBindings); err != nil { + return err + } g.updateButtons() return nil |
