Skip to content

Commit 17f0ba1

Browse files
committed
TibiaCharactersCharacter: use switch case for containsCreaturesWithOf
1 parent 37eeae4 commit 17f0ba1

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

src/TibiaCharactersCharacter.go

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -580,9 +580,11 @@ func TibiaDataParseKiller(data string) (string, bool, bool, string) {
580580

581581
// containsCreaturesWithOf checks if creature is present in special creatures list
582582
func containsCreaturesWithOf(str string) bool {
583-
// this list should be based on the https://assets.tibiadata.com/data.json creatures name and plural_name field (currently only singular version)
584-
creaturesWithOf := []string{
585-
"acolyte of darkness",
583+
// trim away "an " and "a "
584+
str = strings.TrimPrefix(strings.TrimPrefix(str, "an "), "a ")
585+
586+
switch str {
587+
case "acolyte of darkness",
586588
"acolyte of the cult",
587589
"adept of the cult",
588590
"ancient spawn of morgathla",
@@ -712,16 +714,9 @@ func containsCreaturesWithOf(str string) bool {
712714
"wildness of urmahlullu",
713715
"wisdom of urmahlullu",
714716
"wrath of the emperor",
715-
"zarcorix of yalahar",
716-
}
717-
718-
// trim away "an " and "a "
719-
str = strings.TrimPrefix(strings.TrimPrefix(str, "an "), "a ")
720-
721-
for _, v := range creaturesWithOf {
722-
if v == str {
723-
return true
724-
}
717+
"zarcorix of yalahar":
718+
return true
719+
default:
720+
return false
725721
}
726-
return false
727722
}

0 commit comments

Comments
 (0)