refactoring
This commit is contained in:
parent
91d3fc9265
commit
cbc7369b8d
@ -15,13 +15,16 @@ func NewGameFromFile(id, fileName string) (*Game, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var gm Game
|
||||
if err := json.Unmarshal(jsonBytes, &gm); err != nil {
|
||||
var gmJson GameJson
|
||||
if err := json.Unmarshal(jsonBytes, &gmJson); err != nil {
|
||||
return nil, fmt.Errorf("%s: %v\n", fileName, err)
|
||||
} else {
|
||||
gm.id = id
|
||||
gm.eng = engine.NewEngine(id)
|
||||
gm.playerTimestamp = make(map[string]time.Time)
|
||||
gm := Game{
|
||||
id: id,
|
||||
name: gmJson.Name,
|
||||
eng: engine.NewEngine(id),
|
||||
playerTimestamp: make(map[string]time.Time),
|
||||
}
|
||||
|
||||
go gm.eng.Run()
|
||||
|
||||
|
@ -7,7 +7,11 @@ import (
|
||||
|
||||
type Game struct {
|
||||
id string
|
||||
Name string `json:"name"`
|
||||
name string
|
||||
eng *engine.Engine
|
||||
playerTimestamp map[string]time.Time
|
||||
}
|
||||
|
||||
type GameJson struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
@ -6,6 +6,5 @@ type Gameinfo struct {
|
||||
|
||||
type SyncData struct {
|
||||
VersionRef int `json:"version"`
|
||||
Players []string `json:"players"`
|
||||
Gameinfo *Gameinfo `json:"game"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user