aboutsummaryrefslogtreecommitdiff
path: root/go/client/game.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-02-08 17:50:10 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2025-01-27 16:43:49 +0100
commit805cbf397589e5cb861f866713c2eb4bec9ce40b (patch)
tree084ef7d136f33b87efe5aa02c7401bde50c9d251 /go/client/game.go
parent05de94b9d97079ca9a7b23e011516f55056472b3 (diff)
downloadmuhqs-game-805cbf397589e5cb861f866713c2eb4bec9ce40b.tar.gz
muhqs-game-805cbf397589e5cb861f866713c2eb4bec9ce40b.zip
intermediate commit
Diffstat (limited to 'go/client/game.go')
-rw-r--r--go/client/game.go30
1 files changed, 12 insertions, 18 deletions
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)
}