fix: 修复PVP赛季数据结构及相关逻辑
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
This commit is contained in:
@@ -15,10 +15,8 @@ const TableNamePlayerPVP = "player_pvp"
|
||||
type PVP struct {
|
||||
*cool.Model
|
||||
PlayerID uint64 `gorm:"not null;index:idx_pvp_player_id;comment:'所属玩家ID'" json:"player_id"`
|
||||
|
||||
SeasonData []PVPRankInfo `gorm:"type:jsonb;not null;comment:'赛季核心数据'" json:"season_data"`
|
||||
|
||||
RankInfo PVPRankInfo `gorm:"type:jsonb;not null;comment:'本赛季排名信息'" json:"rank_info"`
|
||||
//本赛季排名信息'通过下标来确认当前赛季
|
||||
RankInfo []PVPRankInfo `gorm:"type:jsonb;not null;comment:'赛季核心数据'" json:"season_data"`
|
||||
}
|
||||
|
||||
func (u *PVP) Key() uint32 {
|
||||
@@ -27,10 +25,10 @@ func (u *PVP) Key() uint32 {
|
||||
|
||||
// 如果分数不对的话,就按时间排序
|
||||
func (u *PVP) Less(than *PVP) bool {
|
||||
if u.RankInfo.Score == than.RankInfo.Score {
|
||||
return u.RankInfo.LastMatchTime.Unix() < than.RankInfo.LastMatchTime.Unix()
|
||||
if u.RankInfo[len(u.RankInfo)-1].Score == than.RankInfo[len(u.RankInfo)-1].Score {
|
||||
return u.RankInfo[len(u.RankInfo)-1].LastMatchTime.Unix() < than.RankInfo[len(u.RankInfo)-1].LastMatchTime.Unix()
|
||||
}
|
||||
return u.RankInfo.Score < than.RankInfo.Score
|
||||
return u.RankInfo[len(u.RankInfo)-1].Score < than.RankInfo[len(u.RankInfo)-1].Score
|
||||
}
|
||||
func NewPVP() *PVP {
|
||||
return &PVP{
|
||||
|
||||
Reference in New Issue
Block a user