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"` UserType int `gorm:"comment:用户类型"` // 0=新手用户 1=优质用户 2=普通用户 3=垃圾用户 UserScore int `gorm:"comment:用户评级分"` UserClass int `gorm:"comment:用户评级"` RoomUid int64 `gorm:"comment:所在房间唯一ID"` SettleActivityId int64 `gorm:"comment:上次结算的活动ID"` 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 != "" }