package logic //type PlayerCopySpeed struct { // Id uint32 `bson:"id" key:"1"` // MaxDepth uint32 `bson:"max_depth"` // Season uint32 `bson:"season"` // Score uint32 `bson:"score"` // RewardStatus map[uint32]uint32 `bson:"reward_status"` //} // //func (this *PlayerCopySpeed) BuildCopySpeedRewardStatusList() []*proto.CopySpeedRewardStatus { // if this.RewardStatus == nil { // return nil // } // // var list []*proto.CopySpeedRewardStatus // for id, status := range this.RewardStatus { // list = append(list, &proto.CopySpeedRewardStatus{Id: id, Status: status}) // } // return list //} // //func (this *Player) AddCopySpeed(season *CopySpeedSeason, copySpeedTable *data.CopySpeed) { // var copySpeed = this.CopySpeed[uint32(copySpeedTable.Id)] // if copySpeed != nil { // return // } // // copySpeed = &PlayerCopySpeed{Id: uint32(copySpeedTable.Id), Season: season.Season, RewardStatus: map[uint32]uint32{}} // this.CopySpeed[copySpeed.Id] = copySpeed // this.SaveModel(copySpeed) //} // //func (this *Player) updateCopySpeedRewardStatus(copySpeed *PlayerCopySpeed) { // var rewardList = this.manager.tables.CopySpeedRewardExtend.Get(int(copySpeed.Id), 0) // for _, reward := range rewardList { // if proto.RewardStatus(copySpeed.RewardStatus[uint32(reward.Id)]) != proto.RewardStatusUnable { // continue // } // // if uint32(reward.TypeArg) > copySpeed.MaxDepth { // break // } // // copySpeed.RewardStatus[uint32(reward.Id)] = uint32(proto.RewardStatusCanGet) // } //} // //func (this *Player) resetCopySpeedStatus(curSeason uint32) bool { // var dirty = false // for _, copySpeed := range this.CopySpeed { // if copySpeed.Season != curSeason { // delete(this.CopySpeed, copySpeed.Id) // this.WipeModel(copySpeed) // dirty = true // } // } // return dirty //} // //func (this *Player) PassedCopySpeed(copySpeedTable *data.CopySpeed, duration int64, maxDepth uint32, maxScore int32) uint32 { // var dirty = false // var copySpeed = this.CopySpeed[uint32(copySpeedTable.Id)] // if copySpeed == nil { // return 0 // } else { // if maxDepth > copySpeed.MaxDepth { // copySpeed.MaxDepth = maxDepth // // this.updateCopySpeedRewardStatus(copySpeed) // dirty = true // } else { // maxDepth = copySpeed.MaxDepth // } // } // // var season = this.manager.arenaManager.CopySpeedSeason() // if season == nil { // return 0 // } // // var rankIndex = season.SavePlayer(this, copySpeed.Id, duration, maxDepth, maxScore) // if rankIndex > 0 { // dirty = true // // _ = this.Send(proto.ModIdLevel, proto.MsgIdCopySpeedStatusList, this.BuildMsgCopySpeedStatusListAck()) // } // // if dirty { // this.SaveModel(copySpeed) // } // // return rankIndex //} // //func (this *Player) BuildMsgCopySpeedStatusListAck() *proto.MsgCopySpeedStatusListAck { // var season = this.manager.arenaManager.CopySpeedSeason() // if season == nil { // return &proto.MsgCopySpeedStatusListAck{} // } // // var list []*proto.CopySpeedStatus // var arenaPlayer = season.GetPlayer(this.PlayerId) // var copySpeedTables = this.manager.tables.CopySpeed.List() // for _, copySpeedTable := range copySpeedTables { // if copySpeedTable.PrevId > 0 && copySpeedTable.PrevScore > 0 { // if arenaPlayer == nil { // continue // } // // var prevScore = arenaPlayer.Scores[uint32(copySpeedTable.PrevId)] // if prevScore == nil { // continue // } // // if prevScore.MaxScore < int32(copySpeedTable.PrevScore) { // continue // } // } // // var copySpeedStatus = &proto.CopySpeedStatus{ // CopyStatus: proto.CopyStatus{CopyType: uint32(proto.CopyTypeSpeed), IndexId: uint32(copySpeedTable.Id)}, // BeginTime: season.BeginTime, // EndTime: season.EndTime, // } // if arenaPlayer != nil { // var score = arenaPlayer.Scores[copySpeedStatus.IndexId] // if score != nil { // copySpeedStatus.MaxScore = score.MaxScore // copySpeedStatus.RankIndex = score.RankIndex // } // // var copySpeed = this.CopySpeed[uint32(copySpeedTable.Id)] // if copySpeed != nil { // copySpeedStatus.MaxDepth = copySpeed.MaxDepth // copySpeedStatus.StatusList = copySpeed.BuildCopySpeedRewardStatusList() // } // } // // list = append(list, copySpeedStatus) // } // // return &proto.MsgCopySpeedStatusListAck{List: list} //} // //func (this *Player) BuildMsgCopySpeedRankListAck(copyId uint32) *proto.MsgCopySpeedRankListAck { // var myRank = &proto.ArenaPlayer{ // PlayerId: this.PlayerId, // IsRobot: false, // Name: this.Role.Name, // Avatar: this.Role.Avatar, // Capacity: this.RigAttrsCapacity(), // } // // var copoment *PlayerRigComponent // copoment = this.RigComponent[this.Rig.Head] // if copoment != nil { // myRank.RigHead = copoment.Id // } // // copoment = this.RigComponent[this.Rig.Body] // if copoment != nil { // myRank.RigBody = copoment.Id // } // // copoment = this.RigComponent[this.Rig.Tail] // if copoment != nil { // myRank.RigTail = copoment.Id // } // // var season = this.manager.arenaManager.CopySpeedSeason() // if season == nil { // return &proto.MsgCopySpeedRankListAck{MyRank: myRank} // } // // var rankingPlayer = season.GetPlayer(this.PlayerId) // if rankingPlayer != nil { // var score = rankingPlayer.Scores[copyId] // if score != nil { // myRank.CopyId = score.CopyId // myRank.Duration = score.Duration // myRank.MaxDepth = score.MaxDepth // myRank.MaxScore = score.MaxScore // myRank.RankIndex = score.RankIndex // } // } // // var rankList []*proto.ArenaPlayer // for _, rank := range season.GetRanking(copyId, 50) { // if rank.player.PlayerId == this.PlayerId { // rankList = append(rankList, myRank) // } else { // rankList = append(rankList, &proto.ArenaPlayer{ // PlayerId: rank.player.PlayerId, // IsRobot: false, // Name: rank.player.Name, // Avatar: rank.player.Avatar, // Capacity: rank.player.Capacity, // RigHead: rank.player.RigHead, // RigBody: rank.player.RigBody, // RigTail: rank.player.RigTail, // CopyId: rank.score.CopyId, // Duration: rank.score.Duration, // MaxDepth: rank.score.MaxDepth, // MaxScore: rank.score.MaxScore, // RankIndex: rank.score.RankIndex, // }) // } // } // // return &proto.MsgCopySpeedRankListAck{MyRank: myRank, RankList: rankList} //}