From f3e085ceccd95899d8d705a28266003709ab87b7 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 4 Jul 2025 09:20:48 -0400 Subject: refactor playerControl Allow to propagate errors in order to handle them acordingly. Use playerNotifications by value to reduce the amount of allocations. Add session managment playerNotifications. Support marshalling notifications to plain text. --- go/activities/draft.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'go/activities') diff --git a/go/activities/draft.go b/go/activities/draft.go index 85389106..e326050d 100644 --- a/go/activities/draft.go +++ b/go/activities/draft.go @@ -109,7 +109,7 @@ func NewLocalDraft(width, height int, playerName string) *Draft { return d } -func StartNewRemoteDraft(width, height int, ctrl game.PlayerControl, firstPack *game.PlayerNotification) *Draft { +func StartNewRemoteDraft(width, height int, ctrl game.PlayerControl, firstPack game.PlayerNotification) *Draft { d := &Draft{ Collection: ui.Collection{Width: width, Height: height}, player: ctrl.Player(), @@ -121,7 +121,12 @@ func StartNewRemoteDraft(width, height int, ctrl game.PlayerControl, firstPack * } func (d *Draft) Update() error { - if n := d.ctrl.RecvNotification(); n != nil { + n, err := d.ctrl.RecvNotification() + if err != nil { + // FIXME + } + + if n.Valid() { log.Println("Received draft pick: %v\n", n) d.presentPack(n) } @@ -141,7 +146,7 @@ func (d *Draft) Update() error { return nil } -func (d *Draft) presentPack(n *game.PlayerNotification) { +func (d *Draft) presentPack(n game.PlayerNotification) { pack := n.Context.(game.PileOfCards) grid := ui.NewCardGrid(0, 0, d.Width-SEALED_DECK_STRIP_WIDTH, d.Height, 0.5, pack).Columns(3) selectCard := func(x, y int) { -- cgit v1.2.3