diff --git a/src/validation/highscore.go b/src/validation/highscore.go index 89b6988..b7673b3 100644 --- a/src/validation/highscore.go +++ b/src/validation/highscore.go @@ -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 @@ -40,11 +40,13 @@ const ( HighScoreSwordfighting HighScoreDromescore HighScoreBosspoints + HighScoreBountypoints + HighScoreWeeklytasks ) func (hc HighscoreCategory) String() (string, error) { - seasons := [...]string{"achievements", "axefighting", "charmpoints", "clubfighting", "distancefighting", "experience", "fishing", "fistfighting", "goshnarstaint", "loyaltypoints", "magiclevel", "shielding", "swordfighting", "dromescore", "bosspoints"} - if hc < HighScoreAchievements || hc > HighScoreBosspoints { + seasons := [...]string{"achievements", "axefighting", "charmpoints", "clubfighting", "distancefighting", "experience", "fishing", "fistfighting", "goshnarstaint", "loyaltypoints", "magiclevel", "shielding", "swordfighting", "dromescore", "bosspoints", "bountypoints", "weeklytasks"} + if hc < HighScoreAchievements || hc > HighScoreWeeklytasks { return "", errors.New("invalid HighscoreCategory value") } return seasons[hc-1], nil @@ -82,6 +84,10 @@ func HighscoreCategoryFromString(input string) HighscoreCategory { return HighScoreDromescore case "boss", "bosses", "bosspoints": return HighScoreBosspoints + case "bountypoints", "bountypoint", "bountypointsearned": + return HighScoreBountypoints + case "weeklytasks", "weeklytask", "weeklytaskscompleted": + return HighScoreWeeklytasks default: return HighScoreExperience } diff --git a/src/validation/highscore_test.go b/src/validation/highscore_test.go index 88f6547..6687fdb 100644 --- a/src/validation/highscore_test.go +++ b/src/validation/highscore_test.go @@ -49,6 +49,26 @@ func TestHighscoreCategoryBosspointsString(t *testing.T) { assert.Equal(HighscoreCategory(15), highscoreCategory) } +func TestHighscoreCategoryBountypointsString(t *testing.T) { + assert := assert.New(t) + highscoreCategory := HighScoreBountypoints + stringValue, err := highscoreCategory.String() + + assert.Nil(err) + assert.Equal("bountypoints", stringValue) + assert.Equal(HighscoreCategory(16), highscoreCategory) +} + +func TestHighscoreCategoryWeeklytasksString(t *testing.T) { + assert := assert.New(t) + highscoreCategory := HighScoreWeeklytasks + stringValue, err := highscoreCategory.String() + + assert.Nil(err) + assert.Equal("weeklytasks", stringValue) + assert.Equal(HighscoreCategory(17), highscoreCategory) +} + func TestHighscoreCategoryInvalidValueString(t *testing.T) { assert := assert.New(t) @@ -125,6 +145,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 { diff --git a/src/webserver.go b/src/webserver.go index 9c19ff4..28d9632 100644 --- a/src/webserver.go +++ b/src/webserver.go @@ -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