Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/TibiaCharactersCharacter.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ func TibiaDataParseKiller(data string) (string, bool, bool, string) {
// containsCreaturesWithOf checks if creature is present in special creatures list
func containsCreaturesWithOf(str string) bool {
// trim away "an " and "a "
str = strings.TrimPrefix(strings.TrimPrefix(str, "an "), "a ")
str = strings.ToLower(strings.TrimPrefix(strings.TrimPrefix(str, "an "), "a "))

switch str {
case "acolyte of darkness",
Expand Down
90 changes: 90 additions & 0 deletions src/TibiaCharactersCharacter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4075,6 +4075,96 @@ func TestNumber17(t *testing.T) {
}
}

func TestNumber18(t *testing.T) {
file, err := static.TestFiles.Open("testdata/characters/Tirador Azteca.html")
if err != nil {
t.Fatalf("file opening error: %s", err)
}
defer file.Close()

data, err := io.ReadAll(file)
if err != nil {
t.Fatalf("File reading error: %s", err)
}

characterJson, err := TibiaCharactersCharacterImpl(string(data), "")
if err != nil {
t.Fatal(err)
}

assert := assert.New(t)
character := characterJson.Character.CharacterInfo

assert.Equal("Tirador Azteca", character.Name)
assert.False(characterJson.Character.DeathsTruncated)

// validate death data
assert.Equal(3, len(characterJson.Character.Deaths))
deaths := characterJson.Character.Deaths

for idx, tc := range []struct {
Assists []Killers
Killers []Killers
Level int
Reason string
Time string
}{
{
Assists: []Killers{},
Killers: []Killers{
{Name: "retainer of Baeloc", Player: false, Traded: false, Summon: ""},
},
Level: 500,
Reason: "Died at Level 500 by retainer of Baeloc.",
Time: "2025-09-14T20:29:01Z",
},
{
Assists: []Killers{},
Killers: []Killers{
{Name: "terrorsleep", Player: false, Traded: false, Summon: ""},
},
Level: 494,
Reason: "Died at Level 494 by terrorsleep.",
Time: "2025-09-07T02:39:55Z",
},
{
Assists: []Killers{},
Killers: []Killers{
{Name: "headwalker", Player: false, Traded: false, Summon: ""},
},
Level: 487,
Reason: "Died at Level 487 by headwalker.",
Time: "2025-08-29T19:09:51Z",
},
} {
assert.True(
reflect.DeepEqual(deaths[idx].Assists, tc.Assists),
"Wrong assists\nidx: %d\nwant: %#v\n\ngot: %#v",
idx, tc.Assists, deaths[idx].Assists,
)
assert.True(
reflect.DeepEqual(deaths[idx].Killers, tc.Killers),
"Wrong killers\nidx: %d\nwant: %#v\n\ngot: %#v",
idx, tc.Killers, deaths[idx].Killers,
)
assert.Equal(
deaths[idx].Level, tc.Level,
"Wrong Level\nidx: %d\nwant: %d\n\ngot: %d",
idx, tc.Level, deaths[idx].Level,
)
assert.Equal(
deaths[idx].Reason, tc.Reason,
"Wrong Reason\nidx: %d\nwant: %s\n\ngot: %s",
idx, tc.Reason, deaths[idx].Reason,
)
assert.Equal(
tc.Time, deaths[idx].Time,
"Wrong Time\nidx: %d\nwant: %s\n\ngot: %s",
idx, tc.Time, deaths[idx].Time,
)
}
}

func BenchmarkNumber1(b *testing.B) {
file, err := static.TestFiles.Open("testdata/characters/Darkside Rafa.html")
if err != nil {
Expand Down
Loading