From d5deca8993f40ea1475d80579c0aa090fd98f8f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=AEittaG=20ordnasselA?= Date: Mon, 17 Jun 2019 18:08:17 +0200 Subject: [PATCH] Add chan notifying when all picks have been done --- pod.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pod.go b/pod.go index f955d9a..25c226f 100644 --- a/pod.go +++ b/pod.go @@ -21,6 +21,8 @@ var ( type Pod struct { Players []*Player Direction PodDirection + + NextRound chan bool } // Player is a single player partecipating in a pod @@ -94,6 +96,17 @@ func (p *Pod) flipDirection() { } } +func (p *Pod) checkRound() { + for _, player := range p.Players { + if len(player.newpack) < 1 { + // Someone still hasn't passed a pack + return + } + } + // Everyone has new packs to draft + p.NextRound <- true +} + // OpenPack opens the next pack the player has func (p *Player) OpenPack() error { if len(p.Packs) < 1 { @@ -129,5 +142,7 @@ func (p *Player) Pick(pick Card) error { p.right.newpack <- p.CurrentPack } + p.pod.checkRound() + return nil }