Skip to content

Commit c3d5b0f

Browse files
authored
Cleanup of characters deathlist (#75)
1 parent 0064541 commit c3d5b0f

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

src/TibiaCharactersCharacterV3.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,29 +60,23 @@ type Achievements struct {
6060
Secret bool `json:"secret"`
6161
}
6262

63-
// Child of DeathEntries
63+
// Child of Deaths
6464
type Killers struct {
6565
Name string `json:"name"`
6666
Player bool `json:"player"`
6767
Traded bool `json:"traded"`
6868
Summon string `json:"summon"`
6969
}
7070

71-
// Child of Deaths
72-
type DeathEntries struct {
71+
// Child of Characters
72+
type Deaths struct {
7373
Time string `json:"time"`
7474
Level int `json:"level"`
7575
Killers []Killers `json:"killers"`
7676
Assists []Killers `json:"assists"`
7777
Reason string `json:"reason"`
7878
}
7979

80-
// Child of Characters
81-
type Deaths struct {
82-
DeathEntries []DeathEntries `json:"death_entries,omitempty"`
83-
TruncatedDeaths bool `json:"truncated,omitempty"` // deathlist can be truncated.. but we don't have logic for that atm
84-
}
85-
8680
// Child of Characters
8781
type AccountInformation struct {
8882
Position string `json:"position,omitempty"`
@@ -105,7 +99,7 @@ type Characters struct {
10599
Character Character `json:"character"`
106100
AccountBadges []AccountBadges `json:"account_badges,omitempty"`
107101
Achievements []Achievements `json:"achievements,omitempty"`
108-
Deaths Deaths `json:"deaths,omitempty"`
102+
Deaths []Deaths `json:"deaths,omitempty"`
109103
AccountInformation AccountInformation `json:"account_information,omitempty"`
110104
OtherCharacters []OtherCharacters `json:"other_characters,omitempty"`
111105
}
@@ -144,7 +138,7 @@ func TibiaCharactersCharacterV3Impl(BoxContentHTML string) CharacterResponse {
144138
CharacterInformationData Character
145139
AccountBadgesData []AccountBadges
146140
AchievementsData []Achievements
147-
DeathsData Deaths
141+
DeathsData []Deaths
148142
AccountInformationData AccountInformation
149143
OtherCharactersData []OtherCharacters
150144
)
@@ -320,7 +314,6 @@ func TibiaCharactersCharacterV3Impl(BoxContentHTML string) CharacterResponse {
320314

321315
// Removing line breaks
322316
CharacterListHTML = TibiadataHTMLRemoveLinebreaksV3(CharacterListHTML)
323-
//log.Println(CharacterListHTML)
324317
CharacterListHTML = strings.ReplaceAll(CharacterListHTML, ".<br/>Assisted by", ". Assisted by")
325318

326319
// Regex to get data for deaths
@@ -388,7 +381,7 @@ func TibiaCharactersCharacterV3Impl(BoxContentHTML string) CharacterResponse {
388381
}
389382

390383
// append deadentry to death list
391-
DeathsData.DeathEntries = append(DeathsData.DeathEntries, DeathEntries{
384+
DeathsData = append(DeathsData, Deaths{
392385
Time: TibiadataDatetimeV3(subma1[0][1]),
393386
Level: TibiadataStringToIntegerV3(subma1[0][3]),
394387
Killers: DeathKillers,

src/TibiaCharactersCharacterV3_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ func TestNumber4(t *testing.T) {
129129
assert.Equal("Nataraya Soldrac", characterJson.Characters.Character.FormerNames[3])
130130

131131
//validate death data
132-
assert.Equal(79, len(characterJson.Characters.Deaths.DeathEntries))
132+
assert.Equal(79, len(characterJson.Characters.Deaths))
133133

134-
firstDeath := characterJson.Characters.Deaths.DeathEntries[0]
134+
firstDeath := characterJson.Characters.Deaths[0]
135135
assert.Equal(28, len(firstDeath.Killers))
136136
}
137137

0 commit comments

Comments
 (0)