// Code generated by "enumer -type=GameStatus -json"; DO NOT EDIT. // package tome_lib import ( "encoding/json" "fmt" ) const _GameStatusName = "StatusLobbyStatusReadyStatusPlayingStatusStopStatusSentinalWinStatusScourgeWinStatusDraw" var _GameStatusIndex = [...]uint8{0, 11, 22, 35, 45, 62, 78, 88} func (i GameStatus) String() string { if i < 0 || i >= GameStatus(len(_GameStatusIndex)-1) { return fmt.Sprintf("GameStatus(%d)", i) } return _GameStatusName[_GameStatusIndex[i]:_GameStatusIndex[i+1]] } var _GameStatusValues = []GameStatus{0, 1, 2, 3, 4, 5, 6} var _GameStatusNameToValueMap = map[string]GameStatus{ _GameStatusName[0:11]: 0, _GameStatusName[11:22]: 1, _GameStatusName[22:35]: 2, _GameStatusName[35:45]: 3, _GameStatusName[45:62]: 4, _GameStatusName[62:78]: 5, _GameStatusName[78:88]: 6, } // GameStatusString retrieves an enum value from the enum constants string name. // Throws an error if the param is not part of the enum. func GameStatusString(s string) (GameStatus, error) { if val, ok := _GameStatusNameToValueMap[s]; ok { return val, nil } return 0, fmt.Errorf("%s does not belong to GameStatus values", s) } // GameStatusValues returns all values of the enum func GameStatusValues() []GameStatus { return _GameStatusValues } // IsAGameStatus returns "true" if the value is listed in the enum definition. "false" otherwise func (i GameStatus) IsAGameStatus() bool { for _, v := range _GameStatusValues { if i == v { return true } } return false } // MarshalJSON implements the json.Marshaler interface for GameStatus func (i GameStatus) MarshalJSON() ([]byte, error) { return json.Marshal(i.String()) } // UnmarshalJSON implements the json.Unmarshaler interface for GameStatus func (i *GameStatus) UnmarshalJSON(data []byte) error { var s string if err := json.Unmarshal(data, &s); err != nil { return fmt.Errorf("GameStatus should be a string, got %s", data) } var err error *i, err = GameStatusString(s) return err }