From dad15915b62e1a06771af7c6ed5bf04c6cb32b25 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Tue, 26 Aug 2025 18:27:01 +0200 Subject: show number of cards in PoCs on their buttons --- go/client/game.go | 57 ++++++++++++++++++++++++++++++++++++------------------- 1 file 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() -- cgit v1.2.3