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/game/draft.go | |
| 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/game/draft.go')
| -rw-r--r-- | go/game/draft.go | 20 |
1 files changed, 10 insertions, 10 deletions
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() { |
