Files
jiang13-forum/model/level.go
freefire 6b0a1d4281 增加用户认证、等级、徽章与积分体系,并优化管理后台体验。
覆盖站长调账与积分解锁内容;后台按审核优先分组导航,仪表盘展示待办,用户管理改为成员目录式布局。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-06 02:42:18 +08:00

35 lines
694 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package model
// LevelThresholds 各等级所需最低 Exp下标 0 对应 Lv1
var LevelThresholds = []int{0, 20, 50, 100, 200, 400, 800, 1500, 3000, 5000}
// LevelFromExp 由经验推导等级110
func LevelFromExp(exp int) int {
if exp < 0 {
exp = 0
}
level := 1
for i, th := range LevelThresholds {
if exp >= th {
level = i + 1
}
}
return level
}
// ExpForLevel 某等级的门槛 Exp超出范围则钳制
func ExpForLevel(level int) int {
if level < 1 {
level = 1
}
if level > len(LevelThresholds) {
level = len(LevelThresholds)
}
return LevelThresholds[level-1]
}
// MaxLevel 最高等级
func MaxLevel() int {
return len(LevelThresholds)
}