freego/gamestate_enumer.go

55 lines
1.4 KiB
Go

// Code generated by "enumer -type=GameState"; DO NOT EDIT.
//
package freego
import (
"fmt"
)
const _GameStateName = "gameLobbygameSetupgameTurnRedgameTurnBluegameWinRedgameWinBlue"
var _GameStateIndex = [...]uint8{0, 9, 18, 29, 41, 51, 62}
func (i GameState) String() string {
if i < 0 || i >= GameState(len(_GameStateIndex)-1) {
return fmt.Sprintf("GameState(%d)", i)
}
return _GameStateName[_GameStateIndex[i]:_GameStateIndex[i+1]]
}
var _GameStateValues = []GameState{0, 1, 2, 3, 4, 5}
var _GameStateNameToValueMap = map[string]GameState{
_GameStateName[0:9]: 0,
_GameStateName[9:18]: 1,
_GameStateName[18:29]: 2,
_GameStateName[29:41]: 3,
_GameStateName[41:51]: 4,
_GameStateName[51:62]: 5,
}
// GameStateString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func GameStateString(s string) (GameState, error) {
if val, ok := _GameStateNameToValueMap[s]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to GameState values", s)
}
// GameStateValues returns all values of the enum
func GameStateValues() []GameState {
return _GameStateValues
}
// IsAGameState returns "true" if the value is listed in the enum definition. "false" otherwise
func (i GameState) IsAGameState() bool {
for _, v := range _GameStateValues {
if i == v {
return true
}
}
return false
}