75 lines
1.9 KiB
Go
75 lines
1.9 KiB
Go
package hunting
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) ChallengeCheck(session comm.IUserSession, req *pb.HuntingChallengeReq) (code pb.ErrorCode) {
|
|
if req.BossType <= 0 && req.Difficulty > 0 {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
///挑战主线关卡
|
|
func (this *apiComp) Challenge(session comm.IUserSession, req *pb.HuntingChallengeReq) (code pb.ErrorCode, data proto.Message) {
|
|
|
|
code = this.ChallengeCheck(session, req)
|
|
if code != pb.ErrorCode_Success {
|
|
return // 参数校验失败直接返回
|
|
}
|
|
|
|
hunting, err := this.module.modelHunting.getHuntingList(session.GetUserId())
|
|
if err != nil {
|
|
code = pb.ErrorCode_PagodaNotFound
|
|
return
|
|
}
|
|
if hunting.ChallengeCount > this.module.configure.GetGlobalConf().HuntingNum+hunting.BuyCount {
|
|
code = pb.ErrorCode_HuntingMaxChallengeCount
|
|
return
|
|
}
|
|
cfgData := this.module.configure.GetHuntingBossConfigData(req.BossType, req.Difficulty)
|
|
if cfgData == nil {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
value, ok := hunting.Boss[req.BossType]
|
|
if !ok { // 类型校验
|
|
hunting.Boss[req.BossType] = 0
|
|
}
|
|
if value < req.Difficulty {
|
|
if value+1 != req.Difficulty {
|
|
code = pb.ErrorCode_HuntingLvErr
|
|
return
|
|
}
|
|
}
|
|
|
|
code, record := this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
|
|
Ptype: pb.PlayType_moonfantasy,
|
|
Title: "",
|
|
Leadpos: req.Leadpos,
|
|
Teamids: req.Teamids,
|
|
Mformat: cfgData.Boss,
|
|
})
|
|
if code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), HuntingChallengeResp, &pb.VikingChallengeResp{Info: &pb.BattleInfo{
|
|
Id: record.Id,
|
|
Title: record.Title,
|
|
Btype: record.Btype,
|
|
Ptype: record.Ptype,
|
|
RedCompId: record.RedCompId,
|
|
Redflist: record.Redflist,
|
|
BlueCompId: record.BlueCompId,
|
|
Buleflist: record.Buleflist,
|
|
}})
|
|
|
|
return
|
|
}
|