diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2024-12-26 19:15:24 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-01-27 16:43:58 +0100 |
| commit | 6405dfcea2e3ca46d92444dfd72a251057fb4ae2 (patch) | |
| tree | 28e8a105c8a168b13ed5917682eae90f0212d613 /go/client | |
| parent | 4275eea579aec664763e8c8ad74ced5b8033461f (diff) | |
| download | muhqs-game-6405dfcea2e3ca46d92444dfd72a251057fb4ae2.tar.gz muhqs-game-6405dfcea2e3ca46d92444dfd72a251057fb4ae2.zip | |
support choosing a value for X when playing cards with variadic costs
Diffstat (limited to 'go/client')
| -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: |
