Add chan notifying when all picks have been done
This commit is contained in:
parent
1bd0a11db0
commit
d5deca8993
1 changed files with 15 additions and 0 deletions
15
pod.go
15
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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue