diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-06-06 21:04:09 -0500 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:57:18 +0200 |
| commit | 2bc941c548c7249fe122fbdf43963b798cb2b14f (patch) | |
| tree | 36777711333636c03de1f0dbe3a9e9139b7054b6 | |
| parent | 79e0374f7eab4f0f3ee48315b27bdc879b43be47 (diff) | |
| download | muhqs-game-2bc941c548c7249fe122fbdf43963b798cb2b14f.tar.gz muhqs-game-2bc941c548c7249fe122fbdf43963b798cb2b14f.zip | |
make PlayerControl a Closer
| -rw-r--r-- | go/game/draft.go | 2 | ||||
| -rw-r--r-- | go/game/kraken.go | 4 | ||||
| -rw-r--r-- | go/game/playerControl.go | 7 |
3 files changed, 12 insertions, 1 deletions
diff --git a/go/game/draft.go b/go/game/draft.go index 74091f5a..e2056d86 100644 --- a/go/game/draft.go +++ b/go/game/draft.go @@ -94,6 +94,8 @@ type randomDraftAiCtrl struct { func (ctrl *randomDraftAiCtrl) Player() *Player { return ctrl.ai } +func (ctrl *randomDraftAiCtrl) Close() { +} func (ctrl *randomDraftAiCtrl) SendNotification(n PlayerNotification) { ctrl.pack = n.Context.(PileOfCards) diff --git a/go/game/kraken.go b/go/game/kraken.go index fccaa6df..82ae6ccd 100644 --- a/go/game/kraken.go +++ b/go/game/kraken.go @@ -81,6 +81,10 @@ func (c *KrakenControl) Player() *Player { return c.kraken } +func (c *KrakenControl) Close() { + close(c.actions) +} + func (ctrl *KrakenControl) awaitGameStateSync() { ctrl.syncGameState.Wait() ctrl.syncGameState.Add(1) diff --git a/go/game/playerControl.go b/go/game/playerControl.go index bad1a13a..c472f4f0 100644 --- a/go/game/playerControl.go +++ b/go/game/playerControl.go @@ -42,7 +42,7 @@ func (n PlayerNotification) IsPriorityNotification() bool { type PlayerNotification struct { Notification PlayerNotificationType - Context interface{} + Context any Error error } @@ -104,6 +104,7 @@ type PlayerControl interface { Player() *Player RecvAction() Action SendNotification(PlayerNotification) + Close() } type ChanPlayerControl struct { @@ -124,6 +125,10 @@ func (c *ChanPlayerControl) RecvNotification() *PlayerNotification { return nil } } +func (c *ChanPlayerControl) Close() { + close(c.actions) + close(c.notifications) +} func NewChanPlayerControl(p *Player) *ChanPlayerControl { a := make(chan Action) |
