// Code generated by "enumer -type=CardType -json"; DO NOT EDIT. // package tome_lib import ( "encoding/json" "fmt" ) const _CardTypeName = "EmptyValueValkSpeedsterCommanderPaladinScholarWarriorFighterSevenShieldWallHealthPotionTreeGoblinChupacabraAllyEnemyDuelistBureaucratVanguardStudentLibrarianElephantMesmeristDivinerHologramGoblinSpawnDudClog" var _CardTypeIndex = [...]uint8{0, 10, 14, 23, 32, 39, 46, 53, 60, 65, 75, 87, 91, 97, 107, 111, 116, 123, 133, 141, 148, 157, 165, 174, 181, 189, 200, 203, 207} func (i CardType) String() string { i -= -1 if i < 0 || i >= CardType(len(_CardTypeIndex)-1) { return fmt.Sprintf("CardType(%d)", i+-1) } return _CardTypeName[_CardTypeIndex[i]:_CardTypeIndex[i+1]] } var _CardTypeValues = []CardType{-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26} var _CardTypeNameToValueMap = map[string]CardType{ _CardTypeName[0:10]: -1, _CardTypeName[10:14]: 0, _CardTypeName[14:23]: 1, _CardTypeName[23:32]: 2, _CardTypeName[32:39]: 3, _CardTypeName[39:46]: 4, _CardTypeName[46:53]: 5, _CardTypeName[53:60]: 6, _CardTypeName[60:65]: 7, _CardTypeName[65:75]: 8, _CardTypeName[75:87]: 9, _CardTypeName[87:91]: 10, _CardTypeName[91:97]: 11, _CardTypeName[97:107]: 12, _CardTypeName[107:111]: 13, _CardTypeName[111:116]: 14, _CardTypeName[116:123]: 15, _CardTypeName[123:133]: 16, _CardTypeName[133:141]: 17, _CardTypeName[141:148]: 18, _CardTypeName[148:157]: 19, _CardTypeName[157:165]: 20, _CardTypeName[165:174]: 21, _CardTypeName[174:181]: 22, _CardTypeName[181:189]: 23, _CardTypeName[189:200]: 24, _CardTypeName[200:203]: 25, _CardTypeName[203:207]: 26, } // CardTypeString retrieves an enum value from the enum constants string name. // Throws an error if the param is not part of the enum. func CardTypeString(s string) (CardType, error) { if val, ok := _CardTypeNameToValueMap[s]; ok { return val, nil } return 0, fmt.Errorf("%s does not belong to CardType values", s) } // CardTypeValues returns all values of the enum func CardTypeValues() []CardType { return _CardTypeValues } // IsACardType returns "true" if the value is listed in the enum definition. "false" otherwise func (i CardType) IsACardType() bool { for _, v := range _CardTypeValues { if i == v { return true } } return false } // MarshalJSON implements the json.Marshaler interface for CardType func (i CardType) MarshalJSON() ([]byte, error) { return json.Marshal(i.String()) } // UnmarshalJSON implements the json.Unmarshaler interface for CardType func (i *CardType) UnmarshalJSON(data []byte) error { var s string if err := json.Unmarshal(data, &s); err != nil { return fmt.Errorf("CardType should be a string, got %s", data) } var err error *i, err = CardTypeString(s) return err }