From 7bb889e862627aefad3663ceadd07112ad5f43fb Mon Sep 17 00:00:00 2001 From: Tobias Lindberg Date: Sun, 7 Dec 2025 11:37:04 +0100 Subject: [PATCH 1/4] feat: add support for new highscore categories --- src/validation/highscore.go | 8 +++++++- src/validation/highscore_test.go | 8 ++++++++ src/webserver.go | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/validation/highscore.go b/src/validation/highscore.go index 89b6988a..e1f107d8 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,6 +40,8 @@ const ( HighScoreSwordfighting HighScoreDromescore HighScoreBosspoints + HighScoreBountypoints + HighScoreWeeklytasks ) func (hc HighscoreCategory) String() (string, error) { @@ -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 } diff --git a/src/validation/highscore_test.go b/src/validation/highscore_test.go index 88f65471..e8269519 100644 --- a/src/validation/highscore_test.go +++ b/src/validation/highscore_test.go @@ -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 { diff --git a/src/webserver.go b/src/webserver.go index 9c19ff4e..28d9632c 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 From c5aa186d8945bb3e8fd016a60c7fee347eb0c7a5 Mon Sep 17 00:00:00 2001 From: Tobias Lindberg Date: Sun, 7 Dec 2025 11:45:01 +0100 Subject: [PATCH 2/4] chore: adjust case-ordering Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/validation/highscore.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/validation/highscore.go b/src/validation/highscore.go index e1f107d8..9ca07188 100644 --- a/src/validation/highscore.go +++ b/src/validation/highscore.go @@ -86,7 +86,7 @@ func HighscoreCategoryFromString(input string) HighscoreCategory { return HighScoreBosspoints case "bountypoints", "bountypoint", "bountypointsearned": return HighScoreBountypoints - case "weeklytaskscompleted", "weeklytasks", "weeklytask": + case "weeklytasks", "weeklytask", "weeklytaskscompleted": return HighScoreWeeklytasks default: return HighScoreExperience From 37c27d90dc33397460c60f6ce471bd2b0f5de357 Mon Sep 17 00:00:00 2001 From: Tobias Lindberg Date: Sun, 7 Dec 2025 11:46:33 +0100 Subject: [PATCH 3/4] test: extend tests with new categories --- src/validation/highscore.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/validation/highscore.go b/src/validation/highscore.go index 9ca07188..b7673b38 100644 --- a/src/validation/highscore.go +++ b/src/validation/highscore.go @@ -45,8 +45,8 @@ const ( ) 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 From 74dd37c943b40df22b7a1c5874932df74fed45d5 Mon Sep 17 00:00:00 2001 From: Tobias Lindberg Date: Sun, 7 Dec 2025 11:47:48 +0100 Subject: [PATCH 4/4] test: add two highscore-string test cases --- src/validation/highscore_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/validation/highscore_test.go b/src/validation/highscore_test.go index e8269519..6687fdb9 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)