97 lines
2.7 KiB
Go
97 lines
2.7 KiB
Go
package practice
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/sys/configure"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) NPCBattkleFinishCheck(session comm.IUserSession, req *pb.PracticeNPCBattkleFinishReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// /npc 战斗结果请求
|
|
func (this *apiComp) NPCBattkleFinish(session comm.IUserSession, req *pb.PracticeNPCBattkleFinishReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
err error
|
|
room *pb.DBPracticeRoom
|
|
conf *cfg.GameDispatch_BattleData
|
|
award []*pb.UserAtno
|
|
tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0)
|
|
)
|
|
if room, err = this.module.modelPandata.queryUserMartialhall(session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if room.Npcstate == 2 || room.Npcstate == 3 {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if errdata, _ = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
|
|
return
|
|
}
|
|
|
|
if req.Report.WinSide == 1 {
|
|
room.Npcstate = 3
|
|
if conf, err = this.module.configure.getDispatchBattleData(room.Currnpc); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if errdata, award = this.module.DispenseAtno(session, conf.Award, true); errdata != nil {
|
|
return
|
|
}
|
|
room.Refresh = configure.Now().Unix()
|
|
this.module.modelPandata.Change(session.GetUserId(), map[string]interface{}{
|
|
"npcstate": room.Npcstate,
|
|
"refresh": room.Refresh,
|
|
})
|
|
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype182, 1))
|
|
} else {
|
|
room.Npcstate = 1
|
|
room.Battlenum++
|
|
|
|
if room.Battlenum >= this.module.ModuleTools.GetGlobalConf().PandamasFightNum {
|
|
room.Npcstate = 3
|
|
room.Refresh = configure.Now().Unix()
|
|
this.module.modelPandata.Change(session.GetUserId(), map[string]interface{}{
|
|
"npcstate": room.Npcstate,
|
|
"refresh": room.Refresh,
|
|
})
|
|
} else {
|
|
room.Formation = make([]*pb.BattleRole, 5)
|
|
for _, v := range req.Report.Alive {
|
|
if v.Tid/200 == 1 {
|
|
room.Formation[v.Pos] = v
|
|
}
|
|
}
|
|
this.module.modelPandata.Change(session.GetUserId(), map[string]interface{}{
|
|
"npcstate": room.Npcstate,
|
|
"battlenum": room.Battlenum,
|
|
"formation": room.Formation,
|
|
})
|
|
}
|
|
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "npcbattklefinish", &pb.PracticeNPCBattkleFinishResp{Issucc: true, Award: award})
|
|
|
|
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
|
this.module.ModuleBuried.TriggerBuried(session, tasks...)
|
|
})
|
|
return
|
|
}
|