tome_lib/cardtype_enumer.go

92 lines
2.6 KiB
Go
Raw Normal View History

// Code generated by "enumer -type=CardType -json"; DO NOT EDIT.
//
package tome_lib
import (
"encoding/json"
"fmt"
)
const _CardTypeName = "EmptyValueValkSpeedsterCommanderPaladinScholarWarriorFighterSevenShieldWallHealthPotionTreeGoblinChupacabraAllyEnemyDuelistVanguardElephantMesmeristDivinerHologramGoblinSpawnDud"
var _CardTypeIndex = [...]uint8{0, 10, 14, 23, 32, 39, 46, 53, 60, 65, 75, 87, 91, 97, 107, 111, 116, 123, 131, 139, 148, 155, 163, 174, 177}
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}
var _CardTypeNameToValueMap = map[string]CardType{
2021-11-10 17:44:42 -05:00
_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:131]: 16,
_CardTypeName[131:139]: 17,
_CardTypeName[139:148]: 18,
_CardTypeName[148:155]: 19,
_CardTypeName[155:163]: 20,
_CardTypeName[163:174]: 21,
_CardTypeName[174:177]: 22,
}
// 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
}