From 17f0ba143625d33cca352bd11be41a126f8f2432 Mon Sep 17 00:00:00 2001 From: phenpessoa Date: Mon, 3 Jul 2023 18:25:46 -0300 Subject: [PATCH] TibiaCharactersCharacter: use switch case for containsCreaturesWithOf --- src/TibiaCharactersCharacter.go | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/TibiaCharactersCharacter.go b/src/TibiaCharactersCharacter.go index 1e229d56..2cf92b38 100644 --- a/src/TibiaCharactersCharacter.go +++ b/src/TibiaCharactersCharacter.go @@ -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", @@ -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 }