aboutsummaryrefslogtreecommitdiff
path: root/go/client
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-02-25 23:08:47 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:57:06 +0200
commit3d36d1d0254b8aeecc889a2a49cbcced458cbe9c (patch)
tree38dd0851d8eaa6535d05b97f29f65fc35655a5ef /go/client
parent19fb1a7e5c5883f49e944b6499fa1ced207a3e39 (diff)
downloadmuhqs-game-3d36d1d0254b8aeecc889a2a49cbcced458cbe9c.tar.gz
muhqs-game-3d36d1d0254b8aeecc889a2a49cbcced458cbe9c.zip
intermediate commit
* Implement move artifact action * Fix widget update memory leak * update the highlights not during on each frame * do not update the unchanged label of a button * Allow to exit the game by pressing 'q' * Implement some cards from the magic set * Improve permanent formatting * Some tweaks to UnitAI code
Diffstat (limited to 'go/client')
-rw-r--r--go/client/game.go14
-rw-r--r--go/client/main.go4
2 files changed, 15 insertions, 3 deletions
diff --git a/go/client/game.go b/go/client/game.go
index 8dc69b25..0e516815 100644
--- a/go/client/game.go
+++ b/go/client/game.go
@@ -32,6 +32,8 @@ const (
)
type Game struct {
+ app *app
+
selectedObject interface{}
handLayer *ui.HandView
@@ -58,6 +60,7 @@ type Game struct {
func newGame(app *app) *Game {
g := &Game{
+ app: app,
Collection: ui.Collection{
Width: app.windowWidth,
Height: app.windowHeight,
@@ -110,6 +113,7 @@ func (g *Game) addActivePlayer(name string, deckList string) *Game {
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 {
@@ -202,9 +206,11 @@ func (g *Game) addPermActionChoice(perm game.Permanent, x, y int) {
}
perms := []game.Permanent{perm}
+ labels := []string{perm.Card().Name}
for _, p := range perm.Pile() {
if len(p.CurrentlyAvailActions()) > 0 {
perms = append(perms, p)
+ labels = append(labels, p.Card().Name)
}
}
@@ -215,7 +221,7 @@ func (g *Game) addPermActionChoice(perm game.Permanent, x, y int) {
p := perms[c.GetChoosen(x, y)]
g.addActionChoice(p, x, y)
}
- g.addChoice(ui.NewPermChoice(x, y, perms, onClick))
+ g.addChoice(ui.NewChoice(x, y, utils.TypedSliceToInterfaceSlice(labels), onClick))
} else {
g.selectedObject = perms[0]
g.addActionChoice(perms[0], x, y)
@@ -289,6 +295,7 @@ func (g *Game) progressPrompt() {
targets := a.Targets()
if targets.RequireSelection() {
targets.Next()
+ g.updateHighlight()
} else {
g.declareAction(a)
g.removePrompt()
@@ -515,12 +522,16 @@ func (g *Game) Update() error {
if err := g.prompt.Add(obj); err != nil {
log.Println("Not added", obj, "to active prompt:", err)
g.handleSelection(obj, x, y)
+ } else {
+ g.updateHighlight()
}
} else {
g.handleSelection(obj, x, y)
}
} else if inpututil.IsKeyJustPressed(ebiten.KeySpace) {
g.passButton.Click(0, 0)
+ } else if inpututil.IsKeyJustPressed(ebiten.KeyQ) {
+ return fmt.Errorf("Exit")
} else if inpututil.IsKeyJustPressed(ebiten.KeyEscape) {
g.removeChoice()
g.selectedObject = nil
@@ -541,7 +552,6 @@ func (g *Game) Update() error {
return err
}
- g.updateHighlight()
g.updatePassButton()
return nil
}
diff --git a/go/client/main.go b/go/client/main.go
index 82b60a40..86491a4d 100644
--- a/go/client/main.go
+++ b/go/client/main.go
@@ -94,6 +94,8 @@ func main() {
app.pushActivity(startMenu)
if err := ebiten.RunGame(app); err != nil {
- log.Fatal(err)
+ if err.Error() != "Exit" {
+ log.Fatal(err)
+ }
}
}