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.
30 lines
600 B
30 lines
600 B
3 years ago
|
package state
|
||
|
|
||
3 years ago
|
import (
|
||
|
"go.uber.org/zap/zapcore"
|
||
|
)
|
||
|
|
||
3 years ago
|
// Synced contains all state that is synced between the server and its clients.
|
||
|
type Synced struct {
|
||
3 years ago
|
Map HexMap `json:"map"`
|
||
|
User UserState `json:"user"`
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
func (s *Synced) MarshalLogObject(encoder zapcore.ObjectEncoder) error {
|
||
3 years ago
|
mapErr := encoder.AddObject("map", s.Map)
|
||
|
userErr := encoder.AddObject("user", s.User)
|
||
|
if mapErr != nil {
|
||
|
return mapErr
|
||
|
} else {
|
||
|
return userErr
|
||
|
}
|
||
|
}
|
||
|
|
||
3 years ago
|
// Copy creates a deep copy of this Synced instance.
|
||
3 years ago
|
func (s *Synced) Copy() Synced {
|
||
3 years ago
|
return Synced{
|
||
|
Map: s.Map.Copy(),
|
||
|
User: s.User.Copy(),
|
||
|
}
|
||
|
}
|