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

35 lines
422 B
Go

package main
import (
"sync"
)
var gm *GameManager
func init() {
gm = &GameManager{
games: make(map[string]*Game, 32),
}
}
type GameManager struct {
games map[string]*Game
sync.Mutex
}
func (g *GameManager) NewGame() *Game {
g.Lock()
defer g.Unlock()
game := NewGame()
g.games[game.id] = game
return game
}
func (g *GameManager) Get(id string) *Game {
g.Lock()
defer g.Unlock()
return g.games[id]
}