|
7 | 7 | "net/http" |
8 | 8 | "reflect" |
9 | 9 | "strings" |
| 10 | + "unicode" |
| 11 | + "unicode/utf8" |
10 | 12 |
|
11 | 13 | "github.com/PuerkitoBio/goquery" |
12 | 14 | "github.com/TibiaData/tibiadata-api-go/src/validation" |
@@ -777,19 +779,19 @@ func TibiaDataParseKiller(data string) (string, bool, bool, string) { |
777 | 779 | data = RemoveHtmlTag(data) |
778 | 780 | } |
779 | 781 |
|
780 | | - // remove htlm, spaces and dots from data-string |
| 782 | + // remove htlm, spaces, dots and prefixes from data-string |
781 | 783 | data = strings.TrimSpace(strings.TrimSuffix(strings.TrimSuffix(data, "</td>"), ".")) |
| 784 | + data = strings.TrimPrefix(strings.TrimPrefix(data, "a "), "an ") |
782 | 785 |
|
| 786 | + firstRune, _ := utf8.DecodeRuneInString(data) |
783 | 787 | // get summon information |
784 | | - if strings.HasPrefix(data, "a ") || strings.HasPrefix(data, "an ") { |
785 | | - if containsCreaturesWithOf(data) { |
786 | | - // this is not a summon, since it is a creature with a of in the middle |
787 | | - } else { |
788 | | - ofIdx := strings.Index(data, "of") |
789 | | - if ofIdx != -1 { |
790 | | - theSummon = data[:ofIdx-1] |
791 | | - data = data[ofIdx+3:] |
792 | | - } |
| 788 | + if containsCreaturesWithOf(data) { |
| 789 | + // this is not a summon, since it is a creature with a of in the middle |
| 790 | + } else if unicode.IsLower(firstRune) { |
| 791 | + ofIdx := strings.Index(data, "of") |
| 792 | + if ofIdx != -1 { |
| 793 | + theSummon = data[:ofIdx-1] |
| 794 | + data = data[ofIdx+3:] |
793 | 795 | } |
794 | 796 | } |
795 | 797 |
|
|
0 commit comments