added startGame side band
This commit is contained in:
@@ -12,7 +12,7 @@ type game struct {
|
||||
splosions map[*splosion]bool
|
||||
register chan *player
|
||||
unregister chan *player
|
||||
id chan int
|
||||
robot_id chan int
|
||||
turn int
|
||||
spectators map[*Spectator]bool
|
||||
sregister chan *Spectator
|
||||
@@ -59,10 +59,10 @@ func NewBoardstate(id int) *boardstate {
|
||||
}
|
||||
|
||||
func (g *game) run() {
|
||||
g.id = make(chan int)
|
||||
g.robot_id = make(chan int)
|
||||
go func() {
|
||||
for i := 0; ; i++ {
|
||||
g.id <- i
|
||||
g.robot_id <- i
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -120,6 +120,8 @@ func (g *game) run() {
|
||||
for p := range g.players {
|
||||
if p.Robot.Health > 0 {
|
||||
log.Printf("Robot %v Wins", p.Robot.Id)
|
||||
log.Printf("game over: %+v", g)
|
||||
return
|
||||
}
|
||||
p.reset()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user