Skip to content

Commit

Permalink
fix: character death parsings with creatures
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasehlert committed Mar 3, 2025
1 parent 71ffb4e commit ab30a38
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/TibiaCharactersCharacter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"net/http"
"reflect"
"strings"
"unicode"
"unicode/utf8"

"github.com/PuerkitoBio/goquery"
"github.com/TibiaData/tibiadata-api-go/src/validation"
Expand Down Expand Up @@ -777,19 +779,19 @@ func TibiaDataParseKiller(data string) (string, bool, bool, string) {
data = RemoveHtmlTag(data)
}

// remove htlm, spaces and dots from data-string
// remove htlm, spaces, dots and prefixes from data-string
data = strings.TrimSpace(strings.TrimSuffix(strings.TrimSuffix(data, "</td>"), "."))
data = strings.TrimPrefix(strings.TrimPrefix(data, "a "), "an ")

firstRune, _ := utf8.DecodeRuneInString(data)
// get summon information
if strings.HasPrefix(data, "a ") || strings.HasPrefix(data, "an ") {
if containsCreaturesWithOf(data) {
// this is not a summon, since it is a creature with a of in the middle
} else {
ofIdx := strings.Index(data, "of")
if ofIdx != -1 {
theSummon = data[:ofIdx-1]
data = data[ofIdx+3:]
}
if containsCreaturesWithOf(data) {
// this is not a summon, since it is a creature with a of in the middle
} else if unicode.IsLower(firstRune) {
ofIdx := strings.Index(data, "of")
if ofIdx != -1 {
theSummon = data[:ofIdx-1]
data = data[ofIdx+3:]
}
}

Expand Down

0 comments on commit ab30a38

Please sign in to comment.