Add channel, even though I need to figure out how to make them work
This commit is contained in:
parent
3eac6aaa61
commit
1bd0a11db0
1 changed files with 14 additions and 3 deletions
17
pod.go
17
pod.go
|
@ -36,6 +36,9 @@ type Player struct {
|
|||
|
||||
// Pod the player is in
|
||||
pod *Pod
|
||||
|
||||
// Channels for passing stuff around
|
||||
newpack chan Pack
|
||||
}
|
||||
|
||||
// MakePod creates a pod with a specified number of players and a given set of packs
|
||||
|
@ -52,9 +55,10 @@ func MakePod(playerCount int, provider PackProvider) *Pod {
|
|||
// Fill players
|
||||
for i := range players {
|
||||
players[i] = &Player{
|
||||
Packs: provider(),
|
||||
Picks: []Card{},
|
||||
pod: pod,
|
||||
Packs: provider(),
|
||||
Picks: []Card{},
|
||||
pod: pod,
|
||||
newpack: make(chan Pack, playerCount-1),
|
||||
}
|
||||
}
|
||||
// Second loop to fill nearby players
|
||||
|
@ -118,5 +122,12 @@ func (p *Player) Pick(pick Card) error {
|
|||
p.CurrentPack[id] = p.CurrentPack[len(p.CurrentPack)-1]
|
||||
p.CurrentPack = p.CurrentPack[:len(p.CurrentPack)-1]
|
||||
|
||||
// Send pack to next player
|
||||
if p.pod.Direction == PRClockwise {
|
||||
p.left.newpack <- p.CurrentPack
|
||||
} else {
|
||||
p.right.newpack <- p.CurrentPack
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue