Add bot to play against.

This commit is contained in:
Greyson Parrelli
2026-07-23 15:58:12 -04:00
parent 3825dbacec
commit db1a6ef290
23 changed files with 1852 additions and 23 deletions
+4 -2
View File
@@ -73,6 +73,9 @@ func (s *Server) handleWS(w http.ResponseWriter, req *http.Request) {
r.conns[c] = struct{}{}
p.Connected = true
r.broadcastLocked()
// Safety net: if a scheduled bot move was ever lost (crash between
// persist and timer), a player connecting re-arms it.
s.scheduleBotsLocked(r)
r.mu.Unlock()
defer func() {
@@ -147,8 +150,7 @@ func (s *Server) apply(r *room, c *client, msg clientMessage) {
c.sendError(err.Error())
return
}
s.persist(r)
r.broadcastLocked()
s.commitLocked(r)
}
// broadcastLocked sends each connected client its own view of the game.