diff --git a/src/validation/highscore.go b/src/validation/highscore.go index 6ea09359..d75075ac 100644 --- a/src/validation/highscore.go +++ b/src/validation/highscore.go @@ -10,8 +10,8 @@ import ( var ( // validHighscoreCategories stores all valid highscore categories validHighscoreCategories = func() *cimap.CaseInsensitiveMap[bool] { - m := cimap.New[bool](38) - for _, v := range []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"} { + m := cimap.New[bool](41) + for _, v := range []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", "phosphorusrecord", "phosphorus", "phosphorusrecords"} { m.Add(v, true) } return m @@ -48,11 +48,12 @@ const ( HighScoreBosspoints HighScoreBountypoints HighScoreWeeklytasks + HighScorePhosphorusrecord ) func (hc HighscoreCategory) String() (string, error) { - seasons := [...]string{"achievements", "axefighting", "charmpoints", "clubfighting", "distancefighting", "experience", "fishing", "fistfighting", "goshnarstaint", "loyaltypoints", "magiclevel", "shielding", "swordfighting", "dromescore", "bosspoints", "bountypoints", "weeklytasks"} - if hc < HighScoreAchievements || hc > HighScoreWeeklytasks { + seasons := [...]string{"achievements", "axefighting", "charmpoints", "clubfighting", "distancefighting", "experience", "fishing", "fistfighting", "goshnarstaint", "loyaltypoints", "magiclevel", "shielding", "swordfighting", "dromescore", "bosspoints", "bountypoints", "weeklytasks", "phosphorusrecord"} + if hc < HighScoreAchievements || hc > HighScorePhosphorusrecord { return "", errors.New("invalid HighscoreCategory value") } return seasons[hc-1], nil @@ -94,6 +95,8 @@ func HighscoreCategoryFromString(input string) HighscoreCategory { return HighScoreBountypoints case "weeklytasks", "weeklytask", "weeklytaskscompleted": return HighScoreWeeklytasks + case "phosphorusrecord", "phosphorus", "phosphorusrecords": + return HighScorePhosphorusrecord default: return HighScoreExperience } diff --git a/src/validation/highscore_test.go b/src/validation/highscore_test.go index 2f13f0ce..45f1b91e 100644 --- a/src/validation/highscore_test.go +++ b/src/validation/highscore_test.go @@ -69,6 +69,16 @@ func TestHighscoreCategoryWeeklytasksString(t *testing.T) { assert.Equal(HighscoreCategory(17), highscoreCategory) } +func TestHighscoreCategoryPhosphorusrecordString(t *testing.T) { + assert := assert.New(t) + highscoreCategory := HighScorePhosphorusrecord + stringValue, err := highscoreCategory.String() + + assert.Nil(err) + assert.Equal("phosphorusrecord", stringValue) + assert.Equal(HighscoreCategory(18), highscoreCategory) +} + func TestHighscoreCategoryInvalidValueString(t *testing.T) { assert := assert.New(t) @@ -153,6 +163,10 @@ func TestHighscoreCategoryFromString(t *testing.T) { inputs: []string{"weeklytasks", "weeklytask", "weeklytaskscompleted"}, expected: HighScoreWeeklytasks, }, + "Phosphorusrecord": { + inputs: []string{"phosphorusrecord", "phosphorus", "phosphorusrecords"}, + expected: HighScorePhosphorusrecord, + }, } for category, data := range categoryTests { diff --git a/src/webserver.go b/src/webserver.go index 77ffc685..48e45726 100644 --- a/src/webserver.go +++ b/src/webserver.go @@ -530,7 +530,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, bountypoints, weeklytasks) 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, phosphorusrecord) 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