47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package moonfantasy
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.MoonfantasyReceiveReq) (code pb.ErrorCode) {
|
|
if req.Bid == "" || req.Mid == "" {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
}
|
|
return
|
|
}
|
|
|
|
///领取战斗奖励
|
|
func (this *apiComp) Receive(session comm.IUserSession, req *pb.MoonfantasyReceiveReq) (code pb.ErrorCode, data proto.Message) {
|
|
var (
|
|
boss *cfg.GameDreamlandBoosData
|
|
award []*cfg.Gameatn = make([]*cfg.Gameatn, 0)
|
|
iswin bool
|
|
err error
|
|
)
|
|
|
|
if code = this.ReceiveCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
if boss, err = this.module.configure.GetMonsterById(req.Mid); err != nil {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
if code, iswin = this.module.battle.CheckBattleReport(session, req.Report); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
if !iswin {
|
|
code = pb.ErrorCode_MoonfantasyBattleNoWin
|
|
return
|
|
}
|
|
this.module.configure.GetDropReward(boss.Prize, award)
|
|
this.module.DispenseRes(session, award, true)
|
|
session.SendMsg(string(this.module.GetType()), "receive", &pb.MoonfantasyReceiveResp{Issucc: true})
|
|
return
|
|
}
|