Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TibiaCharactersCharacter: use switch case for containsCreaturesWithOf #229

Merged
merged 1 commit into from
Jul 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions src/TibiaCharactersCharacter.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,9 +580,11 @@ func TibiaDataParseKiller(data string) (string, bool, bool, string) {

// containsCreaturesWithOf checks if creature is present in special creatures list
func containsCreaturesWithOf(str string) bool {
// this list should be based on the https://assets.tibiadata.com/data.json creatures name and plural_name field (currently only singular version)
creaturesWithOf := []string{
"acolyte of darkness",
// trim away "an " and "a "
str = strings.TrimPrefix(strings.TrimPrefix(str, "an "), "a ")

switch str {
case "acolyte of darkness",
"acolyte of the cult",
"adept of the cult",
"ancient spawn of morgathla",
Expand Down Expand Up @@ -712,16 +714,9 @@ func containsCreaturesWithOf(str string) bool {
"wildness of urmahlullu",
"wisdom of urmahlullu",
"wrath of the emperor",
"zarcorix of yalahar",
}

// trim away "an " and "a "
str = strings.TrimPrefix(strings.TrimPrefix(str, "an "), "a ")

for _, v := range creaturesWithOf {
if v == str {
return true
}
"zarcorix of yalahar":
return true
default:
return false
}
return false
}
Loading