From 805cbf397589e5cb861f866713c2eb4bec9ce40b Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Wed, 8 Feb 2023 17:50:10 +0100 Subject: intermediate commit --- go/client/game.go | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'go/client') diff --git a/go/client/game.go b/go/client/game.go index 76b04fa7..f954362a 100644 --- a/go/client/game.go +++ b/go/client/game.go @@ -153,7 +153,7 @@ func (g *Game) getPlayer(name string) *game.Player { func (g *Game) initPlayerUi(player *game.Player) *Game { g.activePlayer = player - g.playerCtrl = game.NewChanPlayerControl() + g.playerCtrl = game.NewChanPlayerControl(player) player.Ctrl = g.playerCtrl var x, y int @@ -338,6 +338,7 @@ func (g *Game) passPriority() { func (g *Game) handlePlayerNotifications() { n := g.playerCtrl.RecvNotification() for n != nil { + log.Println("Received notification", n) switch n.Notification { case game.PriorityNotification: g.showPassButton() @@ -355,16 +356,15 @@ func (g *Game) handlePlayerNotifications() { g.stackBuffer.RemoveLast() g.mapView.ForceRedraw() - case game.BuyPrompt: - if !g.storesOnMap { - g.showStore() + case game.TargetSelectionPrompt: + ctx := n.Context.(game.TargetSelectionCtx) + if _, ok := ctx.Action.(*game.BuyAction); ok { + if !g.storesOnMap { + g.showStore() + } } - case game.HandCardSelectionPrompt: - ctx := n.Context.([]int) - min, max := ctx[0], ctx[1] - promptTxt := fmt.Sprintf("Select between %d and %d hand cards", min, max) - g.prompt = ui.NewHandCardPrompt(g.height/2, g.width, promptTxt) + g.prompt = ui.NewPrompt(g.height/2, g.width, ctx.Action, ctx.Prompt) g.addWidget(g.prompt) g.showPassButton() } @@ -394,9 +394,9 @@ func (g *Game) findObjectAt(x, y int) interface{} { func (g *Game) handleTargetSelection(obj interface{}) { a := g.selectedObject.(game.Action) - a.Targets().AddTarget(obj) + a.Targets().AddSelection(obj) - if !a.Targets().RequireTargets() { + if !a.Targets().RequireSelection() { g.declareAction(a) g.selectedObject = nil } @@ -426,12 +426,6 @@ func (g *Game) handleSelection(obj interface{}, x, y int) { g.selectedObject = game.NewPlayAction(g.activePlayer, obj.C) g.handLayer.HighlightCard(obj.C) - case *game.Card: - if g.gameState.IsActivePlayer(g.activePlayer) && - g.gameState.ActivePhase == game.Phases.BuyPhase { - g.declareAction(game.NewBuyAction(g.activePlayer, obj)) - } - default: log.Fatalf("Object of type %T not handled", obj) } @@ -444,7 +438,7 @@ func (g *Game) highlightTargets() { return } - options := a.Targets().NextOptions() + options := a.Targets().Options() for _, option := range options { g.AddHighlight(option) } -- cgit v1.2.3