package msg import ( "leafstalk/covenant/model" ) const ( RankTypeCooperation1 = 1 //联合普通 RankTypeCooperation2 = 2 //联合困难 RankTypeCooperation3 = 3 //联合噩梦 RankTypeMain = 4 //主线 // 对应战区 RankTypeCooperation1Area = 101 RankTypeCooperation2Area = 102 RankTypeCooperation3Area = 103 RankTypeMainArea = 104 ) // 查看主线排行列表 type ViewMainRank struct { PlayerId int64 `json:"userId"` RankType int64 `json:"type"` //同RankTypeXX } type ResponseViewMainRank struct { ErrCode int `json:"errCode"` Msg string `json:"msg,omitempty"` Data *ViewMainRankData `json:"data"` } type ViewMainRankData struct { List []*NormalRankItem `json:"list"` Self NormalRankItem `json:"self"` } // 查看联合排行列表 type ViewCooperationRank struct { PlayerId int64 `json:"userId"` RankType int64 `json:"type"` } type ResponseViewCooperationRank struct { ErrCode int `json:"errCode"` Msg string `json:"msg,omitempty"` Data *ViewCooperationRankData `json:"data"` } type ViewCooperationRankData struct { List []*CooperationRankItem `json:"list"` } type MainRankItem struct { Score int64 `json:"score"` //积分 Ts int64 `json:"ts"` //时间戳 } type NormalRankItem struct { *MainRankItem Rank int64 `json:"rank"` //排行 Player *model.PersonalItem `json:"players"` //单人 // Score int64 `json:"score"` //积分 } type ByMainScore []*NormalRankItem // 实现 sort.Interface 接口 func (a ByMainScore) Len() int { return len(a) } func (a ByMainScore) Swap(i, j int) { a[i], a[j] = a[j], a[i] } func (a ByMainScore) Less(i, j int) bool { if a[i].Score > a[j].Score { return true } else if a[i].Score < a[j].Score { return false } else { return a[i].Ts < a[j].Ts } } // 降序排序 type CoopRankItem struct { Score int64 `json:"score"` //积分 Wave int64 `json:"wave"` //波次 Ts int64 `json:"ts"` //时间戳 BattleId int64 `json:"battleId,string"` } type CooperationRankItem struct { *CoopRankItem Rank int64 `json:"rank"` //排行 Players []*model.PersonalItem `json:"players"` //多人一起 } type ByCoopScore []*CooperationRankItem // 实现 sort.Interface 接口 func (a ByCoopScore) Len() int { return len(a) } func (a ByCoopScore) Swap(i, j int) { a[i], a[j] = a[j], a[i] } func (a ByCoopScore) Less(i, j int) bool { if a[i].Score > a[j].Score { return true } else if a[i].Score < a[j].Score { return false } else { return a[i].Ts < a[j].Ts } } // 降序排序