Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 7 additions & 1 deletion src/validation/highscore.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

var (
// validHighscoreCatregories stores all valid highscore categories
validHighscoreCategories = []string{"achievements", "achievement", "axe", "axefighting", "charm", "charms", "charmpoints", "charmspoints", "club", "clubfighting", "distance", "distancefighting", "fishing", "fist", "fistfighting", "goshnar", "goshnars", "goshnarstaint", "loyalty", "loyaltypoints", "magic", "mlvl", "magiclevel", "shielding", "shield", "sword", "swordfighting", "drome", "dromescore", "experience", "boss", "bosses", "bosspoints"}
validHighscoreCategories = []string{"achievements", "achievement", "axe", "axefighting", "charm", "charms", "charmpoints", "charmspoints", "club", "clubfighting", "distance", "distancefighting", "fishing", "fist", "fistfighting", "goshnar", "goshnars", "goshnarstaint", "loyalty", "loyaltypoints", "magic", "mlvl", "magiclevel", "shielding", "shield", "sword", "swordfighting", "drome", "dromescore", "experience", "boss", "bosses", "bosspoints", "bountypoints", "bountypoint", "bountypointsearned", "weeklytasks", "weeklytask", "weeklytaskscompleted"}
)

// IsHighscoreCategoryValid reports wheter the provided string represents a valid highscore category
Expand Down Expand Up @@ -40,6 +40,8 @@ const (
HighScoreSwordfighting
HighScoreDromescore
HighScoreBosspoints
HighScoreBountypoints
HighScoreWeeklytasks
)

func (hc HighscoreCategory) String() (string, error) {
Expand Down Expand Up @@ -82,6 +84,10 @@ func HighscoreCategoryFromString(input string) HighscoreCategory {
return HighScoreDromescore
case "boss", "bosses", "bosspoints":
return HighScoreBosspoints
case "bountypoints", "bountypoint", "bountypointsearned":
return HighScoreBountypoints
case "weeklytaskscompleted", "weeklytasks", "weeklytask":
return HighScoreWeeklytasks
default:
return HighScoreExperience
}
Expand Down
8 changes: 8 additions & 0 deletions src/validation/highscore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ func TestHighscoreCategoryFromString(t *testing.T) {
inputs: []string{"boss", "bosses", "bosspoints"},
expected: HighScoreBosspoints,
},
"Bountypoints": {
inputs: []string{"bountypoints", "bountypoint", "bountypointsearned"},
expected: HighscoreBountypoints,
},
"Weeklytasks": {
inputs: []string{"weeklytasks", "weeklytask", "weeklytaskscompleted"},
expected: HighscoreWeeklytasks,
},
}

for category, data := range categoryTests {
Expand Down
2 changes: 1 addition & 1 deletion src/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ func tibiaGuildsOverview(c *gin.Context) {
// @Accept json
// @Produce json
// @Param world path string true "The world" default(all) extensions(x-example=Antica)
// @Param category path string true "The category" default(experience) Enums(achievements, axefighting, charmpoints, clubfighting, distancefighting, experience, fishing, fistfighting, goshnarstaint, loyaltypoints, magiclevel, shielding, swordfighting, dromescore, bosspoints) extensions(x-example=fishing)
// @Param category path string true "The category" default(experience) Enums(achievements, axefighting, charmpoints, clubfighting, distancefighting, experience, fishing, fistfighting, goshnarstaint, loyaltypoints, magiclevel, shielding, swordfighting, dromescore, bosspoints, bountypoints, weeklytasks) extensions(x-example=fishing)
// @Param vocation path string true "The vocation" default(all) Enums(all, knights, paladins, sorcerers, druids, monks) extensions(x-example=all)
// @Param page path int true "The current page" default(1) minimum(1) extensions(x-example=1)
// @Success 200 {object} HighscoresResponse
Expand Down