113 lines
3.1 KiB
Go
113 lines
3.1 KiB
Go
package integral
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) ChallengeCheck(session comm.IUserSession, req *pb.IntegralChallengeReq) (errdata *pb.ErrorData) {
|
|
if req.Nandu <= 0 || req.Battle == nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
}
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
// /挑战主线关卡
|
|
func (this *apiComp) Challenge(session comm.IUserSession, req *pb.IntegralChallengeReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
dibuff []int32 // 敌方buff
|
|
webuff []int32 // 我方buff
|
|
)
|
|
errdata = this.ChallengeCheck(session, req)
|
|
if errdata != nil {
|
|
return // 参数校验失败直接返回
|
|
}
|
|
list, err := this.module.modelIntegral.getIntegralList(session)
|
|
if err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_PagodaNotFound, // 道具数量不足
|
|
Title: pb.ErrorCode_PagodaNotFound.ToString(),
|
|
}
|
|
return
|
|
}
|
|
|
|
cfgData, err := this.module.configure.GetStageBoss(list.Hid, req.Nandu)
|
|
if err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound, // 道具数量不足
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
// 校验门票 最大值等配置
|
|
if list.Count >= this.module.ModuleTools.GetGlobalConf().IntegralBossChallengeNum {
|
|
errdata = &pb.ErrorData{ // 不能挑战了
|
|
Code: pb.ErrorCode_TntegralDayMaxChallenge,
|
|
Title: pb.ErrorCode_TntegralDayMaxChallenge.ToString(),
|
|
}
|
|
return
|
|
}
|
|
// TODU 稍后处理任务校验
|
|
// if list.Itype == 2 { // 事件模式
|
|
// var condiIds []int32
|
|
// if confList := this.configure.GetIntegralCondition(); len(confList) > 0 {
|
|
// for _, v := range confList {
|
|
// condiIds = append(condiIds, v.Id)
|
|
// }
|
|
// }
|
|
|
|
// if _, progress, err := this.module.ModuleBuried.CheckCondition(session, condiIds...); err == nil {
|
|
// condiIds = []int32{}
|
|
// for _, v := range progress { // 没有完成的
|
|
// if v.State == pb.BuriedItemFinishState_buried_finish {
|
|
// condiIds = append(condiIds, v.Conid)
|
|
// }
|
|
// }
|
|
// }
|
|
// dibuff = this.module.configure.GetIntegralConditionByKeys(condiIds)
|
|
// }
|
|
for _, v := range req.Buff {
|
|
if c, err := this.module.configure.GetIntegralBuffByKey(v); err != nil {
|
|
if c.Type == 1 {
|
|
webuff = append(webuff, v)
|
|
} else if c.Type == 2 {
|
|
dibuff = append(dibuff, v)
|
|
}
|
|
}
|
|
}
|
|
errdata, record := this.module.battle.CreateDebuffBattle(session, &pb.BattlePVEReq{
|
|
Rulesid: cfgData.BattleReadyID,
|
|
Ptype: pb.PlayType_integral,
|
|
Title: "",
|
|
Format: req.Battle,
|
|
Mformat: cfgData.Boss,
|
|
}, webuff, dibuff)
|
|
|
|
if errdata != nil {
|
|
return
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "challenge", &pb.IntegralChallengeResp{
|
|
Info: &pb.BattleInfo{Id: record.Id,
|
|
Title: record.Title,
|
|
Rulesid: cfgData.BattleReadyID,
|
|
Btype: record.Btype,
|
|
Ptype: record.Ptype,
|
|
RedCompId: record.RedCompId,
|
|
Redflist: record.Redflist,
|
|
BlueCompId: record.BlueCompId,
|
|
Buleflist: record.Buleflist,
|
|
Tasks: record.Tasks,
|
|
Params: []float32{cfgData.Coefficient}, // 伤害系数
|
|
},
|
|
Nandu: req.Nandu,
|
|
})
|
|
|
|
return
|
|
}
|