package action import "git.reya.zone/reya/hexmap/server/state" func (x *ServerActionPB) ToGo() (Server, error) { if x == nil { return nil, nil } switch action := x.Action.(type) { case *ServerActionPB_Client: return action.Client.ToGo() default: panic("A case was missed in ServerActionPB.ToGo!") } } func (x *ClientActionPB) ToGo() (Client, error) { if x == nil { return nil, nil } switch action := x.Action.(type) { case *ClientActionPB_CellSetColor: return action.CellSetColor.ToGo() case *ClientActionPB_UserSetActiveColor: return action.UserSetActiveColor.ToGo(), nil default: panic("A case was missed in ClientActionPB.ToGo!") } } func (x *CellSetColorPB) ToGo() (*CellColor, error) { at, err := x.At.ToGo() if err != nil { return nil, err } return &CellColor{ At: at, Color: state.ColorFromInt(x.Color), }, nil } func (c CellColor) ToServerPB() *ServerActionPB { return serverPBFromClient(c) } func (c CellColor) ToClientPB() *ClientActionPB { return &ClientActionPB{ Action: &ClientActionPB_CellSetColor{ CellSetColor: &CellSetColorPB{ Color: c.Color.ToInt(), At: c.At.ToPB(), }, }, } } func (x *UserSetActiveColorPB) ToGo() *UserActiveColor { return &UserActiveColor{ Color: state.ColorFromInt(x.Color), } } func (c UserActiveColor) ToServerPB() *ServerActionPB { return serverPBFromClient(c) } func (c UserActiveColor) ToClientPB() *ClientActionPB { return &ClientActionPB{ Action: &ClientActionPB_UserSetActiveColor{ UserSetActiveColor: &UserSetActiveColorPB{ Color: c.Color.ToInt(), }, }, } }