Skip to content

Commit fc833c1

Browse files
Expanded HighscoreCategory with new boss points (#153)
Co-authored-by: Tobias Lindberg <[email protected]>
1 parent 7a0ecd0 commit fc833c1

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

src/HighscoreCategory.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ const (
2222
shielding
2323
swordfighting
2424
dromescore
25+
bosspoints
2526
)
2627

2728
func (hc HighscoreCategory) String() (string, error) {
28-
seasons := [...]string{"achievements", "axefighting", "charmpoints", "clubfighting", "distancefighting", "experience", "fishing", "fistfighting", "goshnarstaint", "loyaltypoints", "magiclevel", "shielding", "swordfighting", "dromescore"}
29-
if hc < achievements || hc > dromescore {
29+
seasons := [...]string{"achievements", "axefighting", "charmpoints", "clubfighting", "distancefighting", "experience", "fishing", "fistfighting", "goshnarstaint", "loyaltypoints", "magiclevel", "shielding", "swordfighting", "dromescore", "bosspoints"}
30+
if hc < achievements || hc > bosspoints {
3031
return "", errors.New("invalid HighscoreCategory value")
3132
}
3233
return seasons[hc-1], nil
@@ -62,6 +63,8 @@ func HighscoreCategoryFromString(input string) HighscoreCategory {
6263
return swordfighting
6364
case "drome", "dromescore":
6465
return dromescore
66+
case "boss", "bosses", "bosspoints":
67+
return bosspoints
6568
default:
6669
return experience
6770
}

src/HighscoreCategory_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ func TestHighscoreCategoryDromescoreString(t *testing.T) {
3939
assert.Equal(HighscoreCategory(14), highscoreCategory)
4040
}
4141

42+
func TestHighscoreCategoryBossPointsString(t *testing.T) {
43+
assert := assert.New(t)
44+
45+
highscoreCategory := bosspoints
46+
stringValue, err := highscoreCategory.String()
47+
48+
assert.Nil(err)
49+
assert.Equal("bosspoints", stringValue)
50+
assert.Equal(HighscoreCategory(15), highscoreCategory)
51+
}
52+
4253
func TestHighscoreCategoryInvalidValueString(t *testing.T) {
4354
assert := assert.New(t)
4455

@@ -94,4 +105,8 @@ func TestHighscoreCategoryFromString(t *testing.T) {
94105

95106
assert.Equal(dromescore, HighscoreCategoryFromString("drome"))
96107
assert.Equal(dromescore, HighscoreCategoryFromString("dromescore"))
108+
109+
assert.Equal(bosspoints, HighscoreCategoryFromString("boss"))
110+
assert.Equal(bosspoints, HighscoreCategoryFromString("bosses"))
111+
assert.Equal(bosspoints, HighscoreCategoryFromString("bosspoints"))
97112
}

src/TibiaHighscoresV3.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ func TibiaHighscoresV3Impl(world string, category HighscoreCategory, vocationNam
7878
Tibia highscore table columns
7979
Achievment => Rank Name Vocation World Level Points
8080
Axe => Rank Name Vocation World Level Skill Level
81+
Boss => Rank Name Vocation World Level Points
8182
Charm => Rank Name Vocation World Level Points
8283
Club => Rank Name Vocation World Level Skill Level
8384
Distance => Rank Name Vocation World Level Skill Level

src/webserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ func tibiaGuildsOverviewV3(c *gin.Context) {
359359
// @Accept json
360360
// @Produce json
361361
// @Param world path string true "The world" default(all) extensions(x-example=Antica)
362-
// @Param category path string true "The category" default(experience) Enums(achievements, axefighting, charmpoints, clubfighting, distancefighting, experience, fishing, fistfighting, goshnarstaint, loyaltypoints, magiclevel, shielding, swordfighting, dromescore) extensions(x-example=fishing)
362+
// @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)
363363
// @Param vocation path string true "The vocation" default(all) Enums(all, knights, paladins, sorcerers, druids) extensions(x-example=knights)
364364
// @Success 200 {object} HighscoresResponse
365365
// @Router /v3/highscores/{world}/{category}/{vocation} [get]

0 commit comments

Comments
 (0)