75 lines
2.0 KiB
Go
75 lines
2.0 KiB
Go
package practice
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/sys/configure"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) NPCBattkleFinishCheck(session comm.IUserSession, req *pb.PracticeNPCBattkleFinishReq) (code pb.ErrorCode) {
|
|
|
|
return
|
|
}
|
|
|
|
///npc 战斗结果请求
|
|
func (this *apiComp) NPCBattkleFinish(session comm.IUserSession, req *pb.PracticeNPCBattkleFinishReq) (code pb.ErrorCode, data proto.Message) {
|
|
var (
|
|
err error
|
|
room *pb.DBPracticeRoom
|
|
conf *cfg.GameDispatch_BattleData
|
|
iswin bool
|
|
)
|
|
if room, err = this.module.modelPandata.queryUserMartialhall(session.GetUserId()); err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
if room.Npcstate != 2 {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
return
|
|
}
|
|
|
|
if code, iswin = this.module.battle.CheckBattleReport(session, req.Report); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
|
|
if iswin {
|
|
room.Npcstate = 2
|
|
if conf, err = this.module.configure.getDispatchBattleData(room.Currnpc); err != nil {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
if code = this.module.DispenseRes(session, conf.Award, true); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
this.module.modelPandata.Change(session.GetUserId(), map[string]interface{}{
|
|
"npcstate": room.Npcstate,
|
|
})
|
|
} else {
|
|
room.Npcstate = 1
|
|
room.Battlenum++
|
|
|
|
if room.Battlenum >= this.module.configure.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 = req.Report.Alive
|
|
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})
|
|
return
|
|
}
|