diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2024-12-26 19:15:24 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:57:12 +0200 |
| commit | 2cf04db7c532bc756716e356a348f11f572b331f (patch) | |
| tree | 31207cea26889e9a7a767cbebda14d420e426851 | |
| parent | 53e1912c7464cf49e527045aa4fffbbdc322d0b9 (diff) | |
| download | muhqs-game-2cf04db7c532bc756716e356a348f11f572b331f.tar.gz muhqs-game-2cf04db7c532bc756716e356a348f11f572b331f.zip | |
support choosing a value for X when playing cards with variadic costs
| -rw-r--r-- | go/client/game.go | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/go/client/game.go b/go/client/game.go index 8c7d50ad..38a2971c 100644 --- a/go/client/game.go +++ b/go/client/game.go @@ -42,7 +42,7 @@ type Game struct { handLayer *ui.HandView stateBar *ui.StateBar mapView *ui.MapView - choice *ui.Choice + choice ui.Widget passButton *ui.SimpleButton discardPileView *ui.PocList discardPileButton *ui.SimpleButton @@ -282,7 +282,7 @@ func (g *Game) addActionChoice(perm game.Permanent, x, y int) { } } -func (g *Game) addChoice(choice *ui.Choice) { +func (g *Game) addChoice(choice ui.Widget) { if g.choice != nil { g.removeChoice() } @@ -475,9 +475,19 @@ func (g *Game) findObjectAt(x, y int) interface{} { return nil } +func (g *Game) progressPlayAction(a *game.PlayAction) { + targets := a.Targets() + if targets != nil && targets.AllowSelection() { + g.addPrompt(a, fmt.Sprintf("Select targets to play %v", a.Card.Name)) + g.handLayer.HighlightCard(a.Card, ui.HighlightSelectionColor) + } else { + g.declareAction(a) + } +} + func (g *Game) handleSelection(obj interface{}, x, y int) { if obj == nil { - fmt.Printf("No object found at cursor position (%d, %d)\n", x, y) + log.Printf("No object found at cursor position (%d, %d)\n", x, y) return } @@ -499,13 +509,21 @@ func (g *Game) handleSelection(obj interface{}, x, y int) { g.addPermActionChoice(perm, x, y) case ui.HandCard: - a := game.NewPlayAction(g.activePlayer, obj.C) - targets := a.Targets() - if targets != nil && targets.AllowSelection() { - g.addPrompt(a, fmt.Sprintf("Select targets to play %v", obj.C.Name)) - g.handLayer.HighlightCard(obj.C, ui.HighlightSelectionColor) + if obj.C.PlayCosts.IsVariadic() { + g.addChoice(ui.NewNumberChoice( + g.Width-ui.NUMBER_CHOICE_WIDTH, + g.Height-ui.NUMBER_CHOICE_HEIGHT, + 0, + func(nc *ui.NumberChoice) { + a := game.NewPlayActionVariadicCosts( + g.activePlayer, + obj.C, + nc.GetChoosen()) + g.progressPlayAction(a) + })) } else { - g.declareAction(a) + a := game.NewPlayAction(g.activePlayer, obj.C) + g.progressPlayAction(a) } default: |
