diff --git a/comm/imodule.go b/comm/imodule.go index 0ea91300d..be7dfa42b 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -181,8 +181,6 @@ type ( //战斗系统 IBattle interface { - //创建怪物阵营 - CreateMasterRoles(wheel int, fid int32) (captain int32, roles []*pb.BattleRole, code pb.ErrorCode) //创建eve战斗 CreateEveBattle(session IUserSession, req *pb.BattleEVEReq) (code pb.ErrorCode, record *pb.DBBattleRecord) ///创建pve战斗 diff --git a/modules/academy/api_challenge.go b/modules/academy/api_challenge.go index 1423d53b8..143c9f6f9 100644 --- a/modules/academy/api_challenge.go +++ b/modules/academy/api_challenge.go @@ -33,6 +33,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.AcademyChallen Redflist: record.Redflist, BlueCompId: record.BlueCompId, Buleflist: record.Buleflist, + Tasks: level.Task, }}) } else { session.SendMsg(string(this.module.GetType()), "challenge", &pb.AcademyChallengeResp{Code: cd, Info: nil}) diff --git a/modules/academy/api_reward.go b/modules/academy/api_receive.go similarity index 63% rename from modules/academy/api_reward.go rename to modules/academy/api_receive.go index 70632af23..ba01d7bfc 100644 --- a/modules/academy/api_reward.go +++ b/modules/academy/api_receive.go @@ -9,13 +9,13 @@ import ( ) //参数校验 -func (this *apiComp) RewardCheck(session comm.IUserSession, req *pb.AcademyReceiveReq) (code pb.ErrorCode) { +func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.AcademyReceiveReq) (code pb.ErrorCode) { return } ///奖励领取 -func (this *apiComp) Reward(session comm.IUserSession, req *pb.AcademyReceiveReq) (code pb.ErrorCode, data proto.Message) { +func (this *apiComp) Receive(session comm.IUserSession, req *pb.AcademyReceiveReq) (code pb.ErrorCode, data proto.Message) { var ( iswin bool level *cfg.GameTeachingData @@ -23,7 +23,7 @@ func (this *apiComp) Reward(session comm.IUserSession, req *pb.AcademyReceiveReq // group []*cfg.GameTeachingData err error ) - if code = this.RewardCheck(session, req); code != pb.ErrorCode_Success { + if code = this.ReceiveCheck(session, req); code != pb.ErrorCode_Success { return } if code, iswin = this.module.battle.CheckBattleReport(session, req.Report); code != pb.ErrorCode_Success { @@ -34,6 +34,14 @@ func (this *apiComp) Reward(session comm.IUserSession, req *pb.AcademyReceiveReq code = pb.ErrorCode_DBError return } + if level, err = this.module.configure.getGameTeaching(req.Level); err != nil { + code = pb.ErrorCode_DBError + return + } + if req.Report.Completetask == nil || len(req.Report.Completetask) != len(level.Task) { + return + } + if !info.Level[req.Level] { info.Level[req.Level] = true } @@ -41,21 +49,9 @@ func (this *apiComp) Reward(session comm.IUserSession, req *pb.AcademyReceiveReq code = pb.ErrorCode_DBError return } - if level, err = this.module.configure.getGameTeaching(req.Level); err != nil { - code = pb.ErrorCode_DBError - return - } - // if group, err = this.module.configure.getGameTeachingByGroup(req.Group); err != nil { - // code = pb.ErrorCode_ConfigNoFound - // return - // } - // for _, v := range group { - // if !info.Level[v.Id] { - // return - // } - // } + this.module.DispenseRes(session, level.Award, true) } - + session.SendMsg(string(this.module.GetType()), "receive", &pb.AcademyReceiveResp{Issucc: true}) return } diff --git a/modules/academy/api_teaching.go b/modules/academy/api_teaching.go index f5e6585f3..397e1ea4b 100644 --- a/modules/academy/api_teaching.go +++ b/modules/academy/api_teaching.go @@ -33,6 +33,7 @@ func (this *apiComp) Teaching(session comm.IUserSession, req *pb.AcademyTeaching Redflist: record.Redflist, BlueCompId: record.BlueCompId, Buleflist: record.Buleflist, + Tasks: level.Task, }}) } else { session.SendMsg(string(this.module.GetType()), "teaching", &pb.AcademyTeachingResp{Code: cd, Info: nil}) diff --git a/modules/academy/api_teachingreward.go b/modules/academy/api_teachingreceive.go similarity index 63% rename from modules/academy/api_teachingreward.go rename to modules/academy/api_teachingreceive.go index e8f0200bc..96a562cde 100644 --- a/modules/academy/api_teachingreward.go +++ b/modules/academy/api_teachingreceive.go @@ -9,13 +9,13 @@ import ( ) //参数校验 -func (this *apiComp) TeachingRewardCheck(session comm.IUserSession, req *pb.AcademyTeachingReceiveReq) (code pb.ErrorCode) { +func (this *apiComp) TeachingReceiveCheck(session comm.IUserSession, req *pb.AcademyTeachingReceiveReq) (code pb.ErrorCode) { return } ///奖励领取 -func (this *apiComp) TeachingReward(session comm.IUserSession, req *pb.AcademyTeachingReceiveReq) (code pb.ErrorCode, data proto.Message) { +func (this *apiComp) TeachingReceive(session comm.IUserSession, req *pb.AcademyTeachingReceiveReq) (code pb.ErrorCode, data proto.Message) { var ( iswin bool level *cfg.GameHeroStrategyData @@ -23,7 +23,7 @@ func (this *apiComp) TeachingReward(session comm.IUserSession, req *pb.AcademyTe // group []*cfg.GameTeachingData err error ) - if code = this.TeachingRewardCheck(session, req); code != pb.ErrorCode_Success { + if code = this.TeachingReceiveCheck(session, req); code != pb.ErrorCode_Success { return } if code, iswin = this.module.battle.CheckBattleReport(session, req.Report); code != pb.ErrorCode_Success { @@ -34,6 +34,13 @@ func (this *apiComp) TeachingReward(session comm.IUserSession, req *pb.AcademyTe code = pb.ErrorCode_DBError return } + if level, err = this.module.configure.getGameHeroTeaching(req.HeroId); err != nil { + code = pb.ErrorCode_DBError + return + } + if req.Report.Completetask == nil || len(req.Report.Completetask) != len(level.Task) { + return + } if !info.Hero[req.HeroId] { info.Hero[req.HeroId] = true } @@ -41,12 +48,9 @@ func (this *apiComp) TeachingReward(session comm.IUserSession, req *pb.AcademyTe code = pb.ErrorCode_DBError return } - if level, err = this.module.configure.getGameHeroTeaching(req.HeroId); err != nil { - code = pb.ErrorCode_DBError - return - } + this.module.DispenseRes(session, level.Award, true) } - + session.SendMsg(string(this.module.GetType()), "teachingreceive", &pb.AcademyTeachingReceiveResp{Issucc: true}) return } diff --git a/modules/academy/modelAcademy.go b/modules/academy/modelAcademy.go index 92eaac081..5667a13af 100644 --- a/modules/academy/modelAcademy.go +++ b/modules/academy/modelAcademy.go @@ -32,6 +32,7 @@ func (this *modelAcademyComp) queryInfo(uId string) (result *pb.DBAcademy, err e result = &pb.DBAcademy{ Uid: uId, Level: make(map[int32]bool), + Hero: make(map[string]bool), } if err = this.Get(uId, result); err != nil && err != mgo.MongodbNil { this.module.Errorln(err) diff --git a/modules/battle/modelBattle.go b/modules/battle/modelBattle.go index ee8a61c7d..d8ad98115 100644 --- a/modules/battle/modelBattle.go +++ b/modules/battle/modelBattle.go @@ -61,7 +61,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon masters []*pb.BattleRole ) for i, v := range req.Redformat { - if captain, masters, code = this.createMasterRoles(i, v); code != pb.ErrorCode_Success { + if captain, masters, code = this.createMasterRoles(100, i, v); code != pb.ErrorCode_Success { return } record.Redflist[i] = &pb.DBBattleFormt{ @@ -70,7 +70,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon } } for i, v := range req.Buleformat { - if captain, masters, code = this.createMasterRoles(i, v); code != pb.ErrorCode_Success { + if captain, masters, code = this.createMasterRoles(200, i, v); code != pb.ErrorCode_Success { return } record.Buleflist[i] = &pb.DBBattleFormt{ @@ -153,7 +153,7 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBCon masters []*pb.BattleRole ) for i, v := range req.Mformat { - if captain, masters, code = this.createMasterRoles(i, v); code != pb.ErrorCode_Success { + if captain, masters, code = this.createMasterRoles(200, i, v); code != pb.ErrorCode_Success { return } record.Buleflist[i] = &pb.DBBattleFormt{ @@ -261,7 +261,7 @@ func (this *modelBattleComp) createBattleRole(hero *pb.DBHero, tid, pos int) (ro } //创建怪物阵营 -func (this *modelBattleComp) createMasterRoles(wheel int, fid int32) (captain int32, roles []*pb.BattleRole, code pb.ErrorCode) { +func (this *modelBattleComp) createMasterRoles(comp, wheel int, fid int32) (captain int32, roles []*pb.BattleRole, code pb.ErrorCode) { var ( result []*cfg.GameMonsterFormatData err error @@ -286,7 +286,7 @@ func (this *modelBattleComp) createMasterRoles(wheel int, fid int32) (captain in return } else { roles[i] = &pb.BattleRole{ - Tid: int32(200 + wheel*10 + i), + Tid: int32(comp + wheel*10 + i), Oid: hero.Id, HeroID: hero.HeroID, Pos: int32(i), diff --git a/modules/battle/module.go b/modules/battle/module.go index ffa5e714f..0c377a019 100644 --- a/modules/battle/module.go +++ b/modules/battle/module.go @@ -72,10 +72,6 @@ func (this *Battle) QueryBattleRecord(oid string) (code pb.ErrorCode, record *pb return } -func (this *Battle) CreateMasterRoles(wheel int, fid int32) (captain int32, roles []*pb.BattleRole, code pb.ErrorCode) { - return this.modelBattle.createMasterRoles(wheel, fid) -} - //创建pve战斗 func (this *Battle) CreateEveBattle(session comm.IUserSession, req *pb.BattleEVEReq) (code pb.ErrorCode, record *pb.DBBattleRecord) { var ( diff --git a/pb/battle_msg.pb.go b/pb/battle_msg.pb.go index 64bdc3f3e..8c6d531a3 100644 --- a/pb/battle_msg.pb.go +++ b/pb/battle_msg.pb.go @@ -441,6 +441,7 @@ type BattleInfo struct { Redflist []*DBBattleFormt `protobuf:"bytes,6,rep,name=redflist,proto3" json:"redflist"` //红方阵型列表 BlueCompId string `protobuf:"bytes,7,opt,name=blueCompId,proto3" json:"blueCompId"` //蓝方阵营id Buleflist []*DBBattleFormt `protobuf:"bytes,8,rep,name=buleflist,proto3" json:"buleflist"` //红方阵型列表 + Tasks []int32 `protobuf:"varint,9,rep,packed,name=tasks,proto3" json:"tasks"` //任务列表 } func (x *BattleInfo) Reset() { @@ -531,15 +532,23 @@ func (x *BattleInfo) GetBuleflist() []*DBBattleFormt { return nil } +func (x *BattleInfo) GetTasks() []int32 { + if x != nil { + return x.Tasks + } + return nil +} + //战报数据 type BattleReport struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Info *BattleInfo `protobuf:"bytes,1,opt,name=info,proto3" json:"info"` - Costtime int32 `protobuf:"varint,2,opt,name=Costtime,proto3" json:"Costtime"` //战斗时长 单位ms - Process []byte `protobuf:"bytes,3,opt,name=process,proto3" json:"process"` //战斗过程数据 + Info *BattleInfo `protobuf:"bytes,1,opt,name=info,proto3" json:"info"` + Costtime int32 `protobuf:"varint,2,opt,name=Costtime,proto3" json:"Costtime"` //战斗时长 单位ms + Process []byte `protobuf:"bytes,3,opt,name=process,proto3" json:"process"` //战斗过程数据 + Completetask []int32 `protobuf:"varint,4,rep,packed,name=completetask,proto3" json:"completetask"` //完成任务 } func (x *BattleReport) Reset() { @@ -595,6 +604,13 @@ func (x *BattleReport) GetProcess() []byte { return nil } +func (x *BattleReport) GetCompletetask() []int32 { + if x != nil { + return x.Completetask + } + return nil +} + var File_battle_battle_msg_proto protoreflect.FileDescriptor var file_battle_battle_msg_proto_rawDesc = []byte{ @@ -646,7 +662,7 @@ var file_battle_battle_msg_proto_rawDesc = []byte{ 0x61, 0x74, 0x12, 0x2d, 0x0a, 0x0a, 0x62, 0x75, 0x6c, 0x65, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x50, 0x56, 0x50, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x62, 0x75, 0x6c, 0x65, 0x66, 0x6f, 0x72, 0x6d, 0x61, - 0x74, 0x22, 0x8e, 0x02, 0x0a, 0x0a, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, + 0x74, 0x22, 0xa4, 0x02, 0x0a, 0x0a, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x21, 0x0a, 0x05, 0x62, 0x74, 0x79, 0x70, 0x65, 0x18, @@ -663,14 +679,18 @@ var file_battle_battle_msg_proto_rawDesc = []byte{ 0x6d, 0x70, 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x09, 0x62, 0x75, 0x6c, 0x65, 0x66, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x44, 0x42, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x74, 0x52, 0x09, 0x62, 0x75, 0x6c, 0x65, 0x66, 0x6c, 0x69, - 0x73, 0x74, 0x22, 0x65, 0x0a, 0x0c, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6f, - 0x72, 0x74, 0x12, 0x1f, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x0b, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x69, - 0x6e, 0x66, 0x6f, 0x12, 0x1a, 0x0a, 0x08, 0x43, 0x6f, 0x73, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x43, 0x6f, 0x73, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x12, - 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x07, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, - 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, + 0x05, 0x52, 0x05, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x22, 0x89, 0x01, 0x0a, 0x0c, 0x42, 0x61, 0x74, + 0x74, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x1f, 0x0a, 0x04, 0x69, 0x6e, 0x66, + 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, + 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x1a, 0x0a, 0x08, 0x43, 0x6f, + 0x73, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x43, 0x6f, + 0x73, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, + 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, + 0x12, 0x22, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x74, 0x61, 0x73, 0x6b, + 0x18, 0x04, 0x20, 0x03, 0x28, 0x05, 0x52, 0x0c, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, + 0x74, 0x61, 0x73, 0x6b, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var (