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/game/draft.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'go/game/draft.go') diff --git a/go/game/draft.go b/go/game/draft.go index 2b554a82..f180e0ca 100644 --- a/go/game/draft.go +++ b/go/game/draft.go @@ -105,19 +105,19 @@ func (ctrl *randomDraftAiCtrl) Player() *Player { func (ctrl *randomDraftAiCtrl) Close() { } -func (ctrl *randomDraftAiCtrl) SendNotification(n PlayerNotification) { +func (ctrl *randomDraftAiCtrl) SendNotification(n PlayerNotification) error { ctrl.pack = n.Context.(PileOfCards) + return nil } -func (ctrl *randomDraftAiCtrl) RecvAction() Action { - availCards := ctrl.pack.Cards() - var pick int - if n := len(availCards); n > 1 { - pick = rand.Intn(n - 1) - } else { - pick = 0 - } - return NewDraftPick(ctrl.ai, ctrl.pack, availCards[pick]) +func (ctrl *randomDraftAiCtrl) RecvNotification() (n PlayerNotification, err error) { return } + +func (ctrl *randomDraftAiCtrl) SendAction(Action) error { + return nil +} + +func (ctrl *randomDraftAiCtrl) RecvAction() (Action, error) { + return NewDraftPick(ctrl.ai, ctrl.pack, ctrl.pack.RandomCard()), nil } func (d *Draft) AddRandomAi() { -- cgit v1.2.3