2020-10-22 16:53:18 -04:00
|
|
|
package d2enum
|
|
|
|
|
|
|
|
import "log"
|
|
|
|
|
2020-10-25 19:23:55 -04:00
|
|
|
// SkillClass represents the skills for a character class
|
2020-10-22 16:53:18 -04:00
|
|
|
type SkillClass int
|
|
|
|
|
2020-10-25 19:23:55 -04:00
|
|
|
// Skill classes
|
2020-10-22 16:53:18 -04:00
|
|
|
const (
|
|
|
|
SkillClassGeneric SkillClass = iota
|
|
|
|
SkillClassBarbarian
|
|
|
|
SkillClassNecromancer
|
|
|
|
SkillClassPaladin
|
|
|
|
SkillClassAssassin
|
|
|
|
SkillClassSorceress
|
|
|
|
SkillClassAmazon
|
|
|
|
SkillClassDruid
|
|
|
|
)
|
|
|
|
|
2020-10-26 05:04:50 -04:00
|
|
|
// Skill class tokens
|
|
|
|
const (
|
|
|
|
SkillClassTokenGeneric = ""
|
|
|
|
SkillClassTokenBarbarian = "bar"
|
|
|
|
SkillClassTokenNecromancer = "nec"
|
|
|
|
SkillClassTokenPaladin = "pal"
|
|
|
|
SkillClassTokenAssassin = "ass"
|
|
|
|
SkillClassTokenSorceress = "sor"
|
|
|
|
SkillClassTokenAmazon = "ama"
|
|
|
|
SkillClassTokenDruid = "dru"
|
|
|
|
)
|
|
|
|
|
2020-10-22 16:53:18 -04:00
|
|
|
// FromToken returns the enum which corresponds to the given class token
|
|
|
|
func (sc *SkillClass) FromToken(classToken string) SkillClass {
|
|
|
|
resource := SkillClassGeneric
|
|
|
|
|
|
|
|
switch classToken {
|
2020-10-26 05:04:50 -04:00
|
|
|
case SkillClassTokenGeneric:
|
2020-10-22 16:53:18 -04:00
|
|
|
return SkillClassGeneric
|
2020-10-26 05:04:50 -04:00
|
|
|
case SkillClassTokenBarbarian:
|
2020-10-22 16:53:18 -04:00
|
|
|
return SkillClassBarbarian
|
2020-10-26 05:04:50 -04:00
|
|
|
case SkillClassTokenNecromancer:
|
2020-10-22 16:53:18 -04:00
|
|
|
return SkillClassNecromancer
|
2020-10-26 05:04:50 -04:00
|
|
|
case SkillClassTokenPaladin:
|
2020-10-22 16:53:18 -04:00
|
|
|
return SkillClassPaladin
|
2020-10-26 05:04:50 -04:00
|
|
|
case SkillClassTokenAssassin:
|
2020-10-22 16:53:18 -04:00
|
|
|
return SkillClassAssassin
|
2020-10-26 05:04:50 -04:00
|
|
|
case SkillClassTokenSorceress:
|
2020-10-22 16:53:18 -04:00
|
|
|
return SkillClassSorceress
|
2020-10-26 05:04:50 -04:00
|
|
|
case SkillClassTokenAmazon:
|
2020-10-22 16:53:18 -04:00
|
|
|
return SkillClassAmazon
|
2020-10-26 05:04:50 -04:00
|
|
|
case SkillClassTokenDruid:
|
2020-10-22 16:53:18 -04:00
|
|
|
return SkillClassDruid
|
|
|
|
default:
|
|
|
|
log.Fatalf("Unknown skill class token: '%s'", classToken)
|
|
|
|
}
|
|
|
|
|
|
|
|
// should not be reached
|
|
|
|
return resource
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetToken returns a string token for the enum
|
|
|
|
func (sc SkillClass) GetToken() string {
|
|
|
|
switch sc {
|
|
|
|
case SkillClassGeneric:
|
|
|
|
return ""
|
|
|
|
case SkillClassBarbarian:
|
|
|
|
return "bar"
|
|
|
|
case SkillClassNecromancer:
|
|
|
|
return "nec"
|
|
|
|
case SkillClassPaladin:
|
|
|
|
return "pal"
|
|
|
|
case SkillClassAssassin:
|
|
|
|
return "ass"
|
|
|
|
case SkillClassSorceress:
|
|
|
|
return "sor"
|
|
|
|
case SkillClassAmazon:
|
|
|
|
return "ama"
|
|
|
|
case SkillClassDruid:
|
|
|
|
return "dru"
|
|
|
|
default:
|
|
|
|
log.Fatalf("Unknown skill class token: %v", sc)
|
|
|
|
}
|
|
|
|
|
|
|
|
// should not be reached
|
|
|
|
return ""
|
|
|
|
}
|