网络游戏初步接入

This commit is contained in:
2024-10-18 15:11:40 +08:00
parent 263a57f636
commit b27d2b80f7
12 changed files with 306 additions and 67 deletions
+33
View File
@@ -0,0 +1,33 @@
package global
import "sync"
type RunGameInfo struct {
Uuid string
Type TyGameType
Obj any
}
var RunGames = make(map[string]*RunGameInfo)
var lock = sync.Mutex{}
func GetGameInfo(uuid string) *RunGameInfo {
return RunGames[uuid]
}
func CreateGame(game *RunGameInfo) {
lock.Lock()
defer lock.Unlock()
RunGames[game.Uuid] = game
}
func DeleteGame(uuid string) {
lock.Lock()
defer lock.Unlock()
delete(RunGames, uuid)
}
type TyGameType = int
const (
GameType1 TyGameType = iota
)