package logic import ( "ecs/proto/pb" "ecs/servers/game/data" "github.com/oylshe1314/framework/util" ) type PlayerCopyStatus struct { Key uint64 `bson:"scene_id" key:"1"` TotalNum uint32 `bson:"total_num"` MaxScore int32 `bson:"max_score"` } func (this *PlayerCopyStatus) BuildMsgCopyStatus() *pb.CopyStatus { copyType, levelId := util.Split2uint32(this.Key) return &pb.CopyStatus{CopyType: copyType, LevelId: levelId, MaxScore: this.MaxScore} } func (this *Player) GetCopyStatus(copyType pb.CopyType, levelId uint32) *PlayerCopyStatus { return this.CopyStatus[util.Compose2uint32(uint32(copyType), levelId)] } func (this *Player) GetCopyPassed(copyType pb.CopyType, levelId uint32) uint32 { if status := this.GetCopyStatus(copyType, levelId); status != nil { return status.TotalNum } return 0 } func (this *Player) PassedCopyMain(copyMainTable *data.CopyMain, maxScore int32) uint32 { var key = util.Compose2uint32(uint32(copyMainTable.CopyType), uint32(copyMainTable.Id)) var copyStatus = this.CopyStatus[key] if copyStatus == nil { copyStatus = &PlayerCopyStatus{Key: key, TotalNum: 1, MaxScore: maxScore} this.CopyStatus[copyStatus.Key] = copyStatus } else { copyStatus.TotalNum += 1 if maxScore > copyStatus.MaxScore { copyStatus.MaxScore = maxScore } } this.SaveModel(copyStatus) this.AddCounter(pb.CounterType_CopyPassed, key, 1) //this.CopyMainSceneId = uint32(copyChapterTable.SceneId) //this.SaveField("role.mainline_scene_id", this.Role.CopyMainSceneId) _ = this.Send(pb.ModId_ModuleLevel, pb.MsgId_ModLevelCopyStatusChange, &pb.MsgCopyStatusChangeAck{Status: copyStatus.BuildMsgCopyStatus()}) //var copyMainRanking = this.manager.arenaManager.copyMainRanking //if copyMainRanking != nil { // copyMainRanking.SavePlayer(this, uint32(copyChapterTable.Id), util.UnixMilli(), 0, 0) //} // //this.checkComponentUnlock(1, copyStatus.IndexId) //this.checkCharacterUnlock(1, copyStatus.IndexId) // //this.checkChapterGiftPack(3, uint32(copyChapterTable.SceneId)) // //this.checkArenaEnter() return 0 } func (this *Player) PassedCopy(sceneTable *data.Scene, maxScore int32) { switch pb.CopyType(sceneTable.CopyType) { case pb.CopyType_CopyMain: var copyMainTable = this.manager.tables.CopyMain.Find1(sceneTable.CopyId) if copyMainTable == nil { return } this.PassedCopyMain(copyMainTable, maxScore) // this.copyStorePoolUnlock(uint32(sceneTable.Id), util.Unix()) // this.chapterBattlePassLevelUnlock(uint32(sceneTable.Id)) //case pb.CopyTypeMaterial: // var copyMaterialTable = this.manager.tables.CopyMaterialExtend.Get(sceneTable.Id) // if copyMaterialTable == nil { // this.manager.logger.Error("Data error, CopyMaterial not found, sceneId: ", sceneTable.Id) // return 0, proto.ErrDataTablesError // } // // this.AddCounter(proto.CounterTypeCopyMaterial, uint32(copyMaterialTable.MaterialType), 1) // // copyRank = this.PassedCopyMaterial(copyMaterialTable, duration, maxDepth, maxScore) //case pb.CopyTypeReserve: // //暂时保留 //case pb.CopyTypeSpeed: // var copySpeedTable = this.manager.tables.CopySpeedExtend.Get(sceneTable.Id) // if copySpeedTable == nil { // this.manager.logger.Error("Data error, CopySpeed not found, sceneId: ", sceneTable.Id) // return 0, proto.ErrDataTablesError // } // // this.AddCounter(proto.CounterTypeCopySpeed, uint32(copySpeedTable.CopyType), 1) // // copyRank = this.PassedCopySpeed(copySpeedTable, duration, maxDepth, maxScore) } //this.CheckTask(proto.TaskSection1PassSpecificScene, sceneTable.Id, 1) //this.CheckTask(proto.TaskSection1PassAnyScene, 0, 1) //this.CheckTask(proto.TaskSection1PassedClassifyCopies, sceneTable.CopyType, 1) //this.CheckAchievement(proto.AchievementTypePassedCopyTimes, uint32(sceneTable.CopyType), 1) } func (this *Player) BuildMsgCopyStatusListAck() *pb.CopyStatusListAck { var list []*pb.CopyStatus for _, copyStatus := range this.CopyStatus { list = append(list, copyStatus.BuildMsgCopyStatus()) } return &pb.CopyStatusListAck{StatusList: list} }