aboutsummaryrefslogtreecommitdiff
path: root/go/activities
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-07-04 09:20:48 -0400
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:57:23 +0200
commite4ec9266c205120a51dc8d5c4ac956f2b8792f1b (patch)
tree89456898db852153785cc11a161f1feb57d3d84a /go/activities
parent507f09757ca751c5dc7a1e5ca7ab17ee4715e719 (diff)
downloadmuhqs-game-e4ec9266c205120a51dc8d5c4ac956f2b8792f1b.tar.gz
muhqs-game-e4ec9266c205120a51dc8d5c4ac956f2b8792f1b.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.go11
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) {