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
19 changes: 6 additions & 13 deletions src/TibiaCharactersCharacterV3.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,23 @@ type Achievements struct {
Secret bool `json:"secret"`
}

// Child of DeathEntries
// Child of Deaths
type Killers struct {
Name string `json:"name"`
Player bool `json:"player"`
Traded bool `json:"traded"`
Summon string `json:"summon"`
}

// Child of Deaths
type DeathEntries struct {
// Child of Characters
type Deaths struct {
Time string `json:"time"`
Level int `json:"level"`
Killers []Killers `json:"killers"`
Assists []Killers `json:"assists"`
Reason string `json:"reason"`
}

// Child of Characters
type Deaths struct {
DeathEntries []DeathEntries `json:"death_entries,omitempty"`
TruncatedDeaths bool `json:"truncated,omitempty"` // deathlist can be truncated.. but we don't have logic for that atm
}

// Child of Characters
type AccountInformation struct {
Position string `json:"position,omitempty"`
Expand All @@ -105,7 +99,7 @@ type Characters struct {
Character Character `json:"character"`
AccountBadges []AccountBadges `json:"account_badges,omitempty"`
Achievements []Achievements `json:"achievements,omitempty"`
Deaths Deaths `json:"deaths,omitempty"`
Deaths []Deaths `json:"deaths,omitempty"`
AccountInformation AccountInformation `json:"account_information,omitempty"`
OtherCharacters []OtherCharacters `json:"other_characters,omitempty"`
}
Expand Down Expand Up @@ -144,7 +138,7 @@ func TibiaCharactersCharacterV3Impl(BoxContentHTML string) CharacterResponse {
CharacterInformationData Character
AccountBadgesData []AccountBadges
AchievementsData []Achievements
DeathsData Deaths
DeathsData []Deaths
AccountInformationData AccountInformation
OtherCharactersData []OtherCharacters
)
Expand Down Expand Up @@ -320,7 +314,6 @@ func TibiaCharactersCharacterV3Impl(BoxContentHTML string) CharacterResponse {

// Removing line breaks
CharacterListHTML = TibiadataHTMLRemoveLinebreaksV3(CharacterListHTML)
//log.Println(CharacterListHTML)
CharacterListHTML = strings.ReplaceAll(CharacterListHTML, ".<br/>Assisted by", ". Assisted by")

// Regex to get data for deaths
Expand Down Expand Up @@ -388,7 +381,7 @@ func TibiaCharactersCharacterV3Impl(BoxContentHTML string) CharacterResponse {
}

// append deadentry to death list
DeathsData.DeathEntries = append(DeathsData.DeathEntries, DeathEntries{
DeathsData = append(DeathsData, Deaths{
Time: TibiadataDatetimeV3(subma1[0][1]),
Level: TibiadataStringToIntegerV3(subma1[0][3]),
Killers: DeathKillers,
Expand Down
4 changes: 2 additions & 2 deletions src/TibiaCharactersCharacterV3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ func TestNumber4(t *testing.T) {
assert.Equal("Nataraya Soldrac", characterJson.Characters.Character.FormerNames[3])

//validate death data
assert.Equal(79, len(characterJson.Characters.Deaths.DeathEntries))
assert.Equal(79, len(characterJson.Characters.Deaths))

firstDeath := characterJson.Characters.Deaths.DeathEntries[0]
firstDeath := characterJson.Characters.Deaths[0]
assert.Equal(28, len(firstDeath.Killers))
}

Expand Down