diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-07-04 09:20:48 -0400 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-07-06 11:49:19 -0400 |
| commit | f3e085ceccd95899d8d705a28266003709ab87b7 (patch) | |
| tree | 30869054b059b2484d44e8caf60d4755fd244318 /go/activities | |
| parent | 53ba6a1c0cd020f26d501912320a41e8dc736976 (diff) | |
| download | muhqs-game-f3e085ceccd95899d8d705a28266003709ab87b7.tar.gz muhqs-game-f3e085ceccd95899d8d705a28266003709ab87b7.zip | |
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.
Diffstat (limited to 'go/activities')
| -rw-r--r-- | go/activities/draft.go | 11 |
1 files changed, 8 insertions, 3 deletions
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) { |
