147 lines
4.6 KiB
Go
147 lines
4.6 KiB
Go
package logic
|
|
|
|
import (
|
|
"ecs/proto/pb"
|
|
"ecs/servers/game/data"
|
|
"github.com/oylshe1314/framework/util"
|
|
)
|
|
|
|
type PlayerCopyStatus struct {
|
|
Key uint64 `bson:"key" key:"1"` //copyType<<48|copyArg1<<32|copyArg2<<16|copyArg3
|
|
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) 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}
|
|
this.CopyStatus[copyStatus.Key] = copyStatus
|
|
}
|
|
|
|
if maxScore > copyStatus.MaxScore {
|
|
copyStatus.MaxScore = maxScore
|
|
}
|
|
this.SaveModel(copyStatus)
|
|
|
|
//this.CopyMainSceneId = uint32(copyChapterTable.SceneId)
|
|
//this.SaveField("role.mainline_scene_id", this.Role.CopyMainSceneId)
|
|
|
|
_ = this.Send(uint16(pb.ModId_ModuleLevel), uint16(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) PassedCopyMaterial(copyMaterialTable *data.CopyMaterial, maxScore int32) uint32 {
|
|
// var key = util.Compose2uint32(util.Compose2uint16(uint16(proto.CopyTypeMaterial), uint16(copyMaterialTable.MaterialType)), 0)
|
|
// var copyStatus = this.CopyStatus[key]
|
|
// if copyStatus == nil {
|
|
// copyStatus = &PlayerCopyStatus{Key: key}
|
|
// this.CopyStatus[copyStatus.Key] = copyStatus
|
|
// }
|
|
//
|
|
// copyStatus.IndexId = uint32(copyMaterialTable.Id)
|
|
// if maxDepth > copyStatus.MaxDepth {
|
|
// copyStatus.MaxDepth = maxDepth
|
|
// }
|
|
// if maxScore > copyStatus.MaxScore {
|
|
// copyStatus.MaxScore = maxScore
|
|
// }
|
|
// this.SaveModel(copyStatus)
|
|
//
|
|
// _ = this.Send(proto.ModIdLevel, proto.MsgIdCopyStatueChange, &proto.MsgCopyStatusChangeAck{CopyStatus: copyStatus.BuildMsgCopyStatus()})
|
|
// return 0
|
|
// }
|
|
|
|
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}
|
|
}
|
|
|
|
//func (this *Player) BuildMsgCopyMainlineRankListAck() *proto.MsgCopyMainlineRankListAck {
|
|
// 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 ranking = this.manager.arenaManager.CopyMainRanking()
|
|
// if ranking == nil {
|
|
// return &proto.MsgCopyMainlineRankListAck{MyRank: myRank}
|
|
// }
|
|
//
|
|
// var score *RankingScore
|
|
// var rankingPlayer = ranking.GetPlayer(this.PlayerId)
|
|
// if rankingPlayer != nil {
|
|
// score = rankingPlayer.Scores[0]
|
|
// }
|
|
//
|
|
// if score != nil {
|
|
// myRank.CopyId = score.CopyId
|
|
// myRank.RankIndex = score.RankIndex
|
|
// }
|
|
//
|
|
// var rankList []*proto.ArenaPlayer
|
|
// for _, rank := range ranking.GetRanking(0, 50) {
|
|
// if rank.player.PlayerId == this.PlayerId {
|
|
// rankList = append(rankList, myRank)
|
|
// } else {
|
|
// rankList = append(rankList, &proto.ArenaPlayer{
|
|
// PlayerId: rank.player.PlayerId,
|
|
// IsRobot: rank.player.PlayerId < 1000000000,
|
|
// 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,
|
|
// RankIndex: rank.score.RankIndex,
|
|
// })
|
|
// }
|
|
// }
|
|
//
|
|
// return &proto.MsgCopyMainlineRankListAck{MyRank: myRank, RankList: rankList}
|
|
//}
|