From 6580f92a4e8314613b71b73524b888558f36fc01 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Wed, 4 Jan 2023 10:43:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=A2=A6=E5=A2=83=E8=B4=AD?= =?UTF-8?q?=E4=B9=B0=E6=AC=A1=E6=95=B0=E7=89=B9=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/moonfantasy/api_buy.go | 24 ++++++++++++++++-------- modules/moonfantasy/configure.go | 22 +++++++++++++++++++++- modules/moonfantasy/module.go | 5 +++++ 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/modules/moonfantasy/api_buy.go b/modules/moonfantasy/api_buy.go index c9a23fb53..5372168ec 100644 --- a/modules/moonfantasy/api_buy.go +++ b/modules/moonfantasy/api_buy.go @@ -20,10 +20,11 @@ func (this *apiComp) BuyCheck(session comm.IUserSession, req *pb.MoonfantasyBuyR ///询问怪物是否可以挑战 func (this *apiComp) Buy(session comm.IUserSession, req *pb.MoonfantasyBuyReq) (code pb.ErrorCode, data proto.Message) { var ( - info *pb.DBUserMFantasy - challengeD *cfg.GameDreamlandChallengeData - need []*cfg.Gameatn - err error + info *pb.DBUserMFantasy + challengeD *cfg.GameDreamlandChallengeData + need []*cfg.Gameatn + maxbuy, vipbuy int + err error ) if code = this.BuyCheck(session, req); code != pb.ErrorCode_Success { return @@ -32,14 +33,21 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.MoonfantasyBuyReq) ( code = pb.ErrorCode_CacheReadError return } - this.module.modelUserMF.recoverTicket(session,info) + this.module.modelUserMF.recoverTicket(session, info) + if maxbuy, err = this.module.configure.GetchallengeDataCount(); err != nil { + code = pb.ErrorCode_ConfigNoFound + return + } + vipbuy = int(this.module.privilege.GetCountByPrivilegeId(session.GetUserId(), comm.PrivilegeType6)) + need = make([]*cfg.Gameatn, 0) for i := int32(0); i < req.BuyNum; i++ { - if challengeD, err = this.module.configure.GetchallengeData(info.BuyNum + i + 1); err != nil { - code = pb.ErrorCode_ConfigNoFound + + if int(info.BuyNum+i+1) > maxbuy+vipbuy { + code = pb.ErrorCode_ArenaTicketBuyUp return } - if challengeD == nil { + if challengeD, err = this.module.configure.GetchallengeData(info.BuyNum + i + 1); err != nil || challengeD == nil { code = pb.ErrorCode_ConfigNoFound return } diff --git a/modules/moonfantasy/configure.go b/modules/moonfantasy/configure.go index 5556f3260..83c2e2427 100644 --- a/modules/moonfantasy/configure.go +++ b/modules/moonfantasy/configure.go @@ -100,7 +100,27 @@ func (this *configureComp) GetchallengeData(buynum int32) (result *cfg.GameDream this.module.Errorln(err) return } else { - result = v.(*cfg.GameDreamlandChallenge).GetDataMap()[buynum] + for _, v := range v.(*cfg.GameDreamlandChallenge).GetDataList() { + if v.Buynum == buynum { + result = v + return + } + result = v + } + } + return +} + +///获取月之秘境触购买表 +func (this *configureComp) GetchallengeDataCount() (count int, err error) { + var ( + v interface{} + ) + if v, err = this.GetConfigure(game_dreamlandchallenge); err != nil { + this.module.Errorln(err) + return + } else { + count = len(v.(*cfg.GameDreamlandChallenge).GetDataList()) } return } diff --git a/modules/moonfantasy/module.go b/modules/moonfantasy/module.go index c2b1faa13..4f696b26f 100644 --- a/modules/moonfantasy/module.go +++ b/modules/moonfantasy/module.go @@ -32,6 +32,7 @@ type Moonfantasy struct { chat comm.IChat friend comm.IFriend battle comm.IBattle + privilege comm.IPrivilege api_comp *apiComp configure *configureComp modelDream *modelDreamComp @@ -65,6 +66,10 @@ func (this *Moonfantasy) Start() (err error) { return } this.battle = module.(comm.IBattle) + if module, err = this.service.GetModule(comm.ModulePrivilege); err != nil { + return + } + this.privilege = module.(comm.IPrivilege) this.service.RegisterFunctionName(string(comm.Rpc_ModuleMoonfantasyTrigger), this.Rpc_ModuleMoonfantasyTrigger) this.service.RegisterFunctionName(string(comm.Rpc_ModuleMoonfantasyTriggerMF), this.Rpc_ModuleMoonfantasyTriggerMF) event.RegisterGO(comm.EventOpenCond, this.EventOpenCond)