上传梦境购买次数特权

This commit is contained in:
liwei1dao 2023-01-04 10:43:01 +08:00
parent d78785fdfd
commit 6580f92a4e
3 changed files with 42 additions and 9 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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)