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
11
pod.go
11
pod.go
|
@ -36,6 +36,9 @@ type Player struct {
|
||||||
|
|
||||||
// Pod the player is in
|
// Pod the player is in
|
||||||
pod *Pod
|
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
|
// MakePod creates a pod with a specified number of players and a given set of packs
|
||||||
|
@ -55,6 +58,7 @@ func MakePod(playerCount int, provider PackProvider) *Pod {
|
||||||
Packs: provider(),
|
Packs: provider(),
|
||||||
Picks: []Card{},
|
Picks: []Card{},
|
||||||
pod: pod,
|
pod: pod,
|
||||||
|
newpack: make(chan Pack, playerCount-1),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Second loop to fill nearby players
|
// 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[id] = p.CurrentPack[len(p.CurrentPack)-1]
|
||||||
p.CurrentPack = 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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue