Add chan notifying when all picks have been done

This commit is contained in:
Hamcha 2019-06-17 18:08:17 +02:00
parent 1bd0a11db0
commit d5deca8993
Signed by: hamcha
GPG key ID: A40413D21021EAEE

15
pod.go
View file

@ -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
}