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"` 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"` SettleHas bool `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", tableName, suffix), } } func NewPlayer(uid int64) *Player { d := &Player{ Uid: uid, } return d } func (d *Player) Init(uid int64) { d.Uid = uid 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 } }