You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
513 B

package main
import (
"math/rand"
"time"
)
const (
// time until next flip
GAME_TIME = 180
)
func (h *Hub) runGameClock() {
var msg string
for {
for i := GAME_TIME; i >= 0; i-- {
h.tick(i)
time.Sleep(time.Second)
}
HorT := rand.Int() % 2
if HorT == 1 {
msg = "{\"type\":\"flip\",\"value\":\"heads\"}"
} else {
msg = "{\"type\":\"flip\",\"value\":\"tails\"}"
}
h.broadcast <- []byte(msg)
time.Sleep(4 * time.Second)
h.broadcastPoolUpdate()
time.Sleep(1 * time.Second)
}
}