dto-player.go
2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package roomrank
import (
"apigame/service-common/svconst"
"apigame/service-common/svmysql"
"apigame/util/util-lx/lxtime"
"fmt"
)
// Player 房间排行持久数据
type Player struct {
Uid int64 `gorm:"column:uid;primaryKey;comment:玩家唯一ID"`
TopType int `gorm:"comment:排行榜类型"`
Name string `gorm:"-"` // 玩家名字
Icon string `gorm:"-"` // 玩家头像
ActivityId int64 `gorm:"comment:活动ID"`
ActivityTime int64 `gorm:"comment:当前活动周期时间"`
UserType int `gorm:"comment:用户类型"` // 0=新手用户 1=优质用户 2=普通用户 3=垃圾用户
UserScore int `gorm:"comment:用户评级分"`
UserClass int `gorm:"comment:用户评级"`
Score int64 `gorm:"comment:本轮分数"`
RoomUid int64 `gorm:"comment:所在房间唯一ID"`
SettleActivityId int64 `gorm:"comment:上次结算的活动ID"`
SettleActivityTime int64 `gorm:"comment:上次结算的活动时间戳"`
SettleRank int `gorm:"comment:结算名次"`
SettleScore int64 `gorm:"comment:结算分数"`
SettleUserClass int `gorm:"comment:结算用户评级"`
SettleAward string `gorm:"comment:结算奖励内容"`
CreateTime int64 `gorm:"comment:创建时间戳"`
UpdateTime int64 `gorm:"comment:修改时间戳"`
}
func (d *Player) MysqlInfo(suffix string) *svmysql.MysqlInfo {
tableName := svconst.MYSQL_TABLE_S_ROOMRANK_PLAYER
return &svmysql.MysqlInfo{
DbMysql: svconst.DbCommon,
TableName: fmt.Sprintf("%s_%s_%d", tableName, suffix, d.TopType),
}
}
func NewPlayer(uid int64, topType int) *Player {
d := &Player{
Uid: uid,
TopType: topType,
}
return d
}
func (d *Player) Init(uid int64, topType int) {
d.Uid = uid
d.TopType = topType
d.CreateTime = lxtime.NowUninx()
}
func (d *Player) AddUserScore(count int) {
d.UserScore += count
userScoreMin := UserClassMin * 10
userScoreMax := UserClassMax*10 + 20
if d.UserScore < userScoreMin {
d.UserScore = userScoreMin
}
if d.UserScore > userScoreMax {
d.UserScore = userScoreMax
}
d.UserClass = d.UserScore / 10
if d.UserClass < UserClassMin {
d.UserClass = UserClassMin
}
if d.UserClass > UserClassMax {
d.UserClass = UserClassMax
}
}
func (d *Player) SettleHas() bool {
return d.SettleAward != ""
}