Skip to content

Commit

Permalink
fix: omit level if int is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasehlert committed Mar 3, 2025
1 parent cb34e81 commit 5c01ec1
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/TibiaCharactersCharacter.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ type Killers struct {

// Child of Character
type Deaths struct {
Time string `json:"time"` // The timestamp when the death occurred.
Level int `json:"level"` // The level when the death occurred.
Killers []Killers `json:"killers"` // List of killers involved.
Assists []Killers `json:"assists"` // List of assists involved.
Reason string `json:"reason"` // The plain text reason of death.
Time string `json:"time"` // The timestamp when the death occurred.
Level int `json:"level,omitempty"` // The level when the death occurred.
Killers []Killers `json:"killers"` // List of killers involved.
Assists []Killers `json:"assists"` // List of assists involved.
Reason string `json:"reason"` // The plain text reason of death.
}

// Child of Character
Expand Down Expand Up @@ -444,6 +444,11 @@ func TibiaCharactersCharacterImpl(BoxContentHTML string, url string) (CharacterR

level := TibiaDataStringToInteger(dataNoTags[levelIdx:endLevelIdx])

// if kill is with assist only (and level is set to 25), then we reset level
if reasonStart == "Assisted by " && level == 25 {
level = 0
}

killersIdx := strings.Index(
CharacterListHTML, killersIndexer,
) + len(killersIndexer)
Expand Down

0 comments on commit 5c01ec1

Please sign in to comment.