added startGame side band

This commit is contained in:
sm
2013-08-28 23:46:12 -07:00
parent aaaff34448
commit a1470c102a
3 changed files with 36 additions and 7 deletions
+5 -3
View File
@@ -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()
}