diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-08-26 18:27:01 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-26 18:27:01 +0200 |
| commit | dad15915b62e1a06771af7c6ed5bf04c6cb32b25 (patch) | |
| tree | 167c02209315c3fca066b3d5ec7e22f087b297f9 | |
| parent | 1d7a26ff27a3197150a038d311a410096e02b108 (diff) | |
| download | muhqs-game-dad15915b62e1a06771af7c6ed5bf04c6cb32b25.tar.gz muhqs-game-dad15915b62e1a06771af7c6ed5bf04c6cb32b25.zip | |
show number of cards in PoCs on their buttons
| -rw-r--r-- | go/client/game.go | 57 |
1 files changed, 37 insertions, 20 deletions
diff --git a/go/client/game.go b/go/client/game.go index 5689c88c..308095a4 100644 --- a/go/client/game.go +++ b/go/client/game.go @@ -33,7 +33,7 @@ const ( STATE_BAR_WIDTH = 300 - POC_BUTTON_WIDTH = 150 + POC_BUTTON_WIDTH = 175 ) type Game struct { @@ -44,23 +44,28 @@ type Game struct { selectedObject any - menuButton *ui.ImageButton - handLayer *ui.HandView - discardBtn *ui.ImageButton - stateBar *ui.StateBar - mapView *ui.MapView - choice ui.Widget - passButton *ui.SimpleButton - resetButton *ui.SimpleButton - discardPileView *ui.PocList - discardPileButton *ui.SimpleButton - storeVisible bool - storeView *ui.PocList - storeButton *ui.SimpleButton - stackBuffer *ui.Buffer - prompt *ui.Prompt - messageBuffer *ui.Buffer - triggers []*game.TriggeredAction + menuButton *ui.ImageButton + handLayer *ui.HandView + discardBtn *ui.ImageButton + stateBar *ui.StateBar + mapView *ui.MapView + choice ui.Widget + passButton *ui.SimpleButton + resetButton *ui.SimpleButton + + discardPileView *ui.PocList + discardPileButton *ui.SimpleButton + cardsInDiscardPile int + + storeVisible bool + storeView *ui.PocList + storeButton *ui.SimpleButton + cardsInStore int + + stackBuffer *ui.Buffer + prompt *ui.Prompt + messageBuffer *ui.Buffer + triggers []*game.TriggeredAction ui.Collection activePlayerId int @@ -206,7 +211,7 @@ func (g *Game) initPlayerUi(player *game.Player) *Game { g.Height-DEFAULT_BUTTON_HEIGHT, POC_BUTTON_WIDTH, DEFAULT_BUTTON_HEIGHT, - "DiscardPile", + "Discard Pile [0]", func(*ui.SimpleButton) { if !g.visible(g.discardPileView) { g.discardPileView.ForceRedraw() @@ -227,7 +232,7 @@ func (g *Game) initPlayerUi(player *game.Player) *Game { g.storeButton = ui.NewSimpleButton(x, y, POC_BUTTON_WIDTH, DEFAULT_BUTTON_HEIGHT, - "Store", + fmt.Sprintf("Store [%d]", g.activePlayer().Store.Size()), func(*ui.SimpleButton) { if !g.storeVisible { g.showStore() @@ -501,6 +506,18 @@ func (g *Game) updateButtons() { g.show(g.discardBtn) } + if nCards := g.activePlayer().DiscardPile.Size(); nCards != g.cardsInDiscardPile { + g.cardsInDiscardPile = nCards + g.discardPileButton.UpdateLabel(fmt.Sprintf("discard pile [%d]", nCards)) + g.discardPileButton.ForceRedraw() + } + + if nCards := g.activePlayer().Store.Size(); nCards != g.cardsInStore { + g.cardsInStore = nCards + g.discardPileButton.UpdateLabel(fmt.Sprintf("store [%d]", nCards)) + g.storeButton.ForceRedraw() + } + passButtonLabel := "pass" if g.prompt != nil { targets := g.prompt.Action().Targets() |
