From 09d202d65dbe1e87cab3079cf60694817297ffbb Mon Sep 17 00:00:00 2001 From: liwei <2211068034@qq.com> Date: Tue, 1 Aug 2023 13:40:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=BA=A2=E7=82=B9=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 2 +- modules/arena/modelarena.go | 23 ++++++++++++--------- modules/arena/module.go | 40 +++++++++++++++++++++++++++++-------- 3 files changed, 47 insertions(+), 18 deletions(-) diff --git a/comm/const.go b/comm/const.go index f73123811..96352f3af 100644 --- a/comm/const.go +++ b/comm/const.go @@ -535,7 +535,7 @@ const ( //竞技场 Reddot22100 ReddotType = 22100 //当玩家竞技场可挑战次数到达最大时 Reddot22102 ReddotType = 22102 //当竞技场npc可以挑战时 - Reddot22202 ReddotType = 22102 //今日剩余挑战券:x + Reddot22202 ReddotType = 22202 //今日剩余挑战券:x Reddot6 ReddotType = 10006 //爬塔----可挑战红点 Reddot7 ReddotType = 10007 //爬塔----奖励红点 diff --git a/modules/arena/modelarena.go b/modules/arena/modelarena.go index b9cc1f04c..143315413 100644 --- a/modules/arena/modelarena.go +++ b/modules/arena/modelarena.go @@ -446,29 +446,34 @@ func (this *modelArena) recoverTicket(session comm.IUserSession, info *pb.DBAren } } -func (this *modelArena) reddot(session comm.IUserSession) bool { +func (this *modelArena) reddot(session comm.IUserSession) (info *pb.DBArenaUser, ticket int32, activated bool) { var ( - info *pb.DBArenaUser ticketitem *cfg.Gameatn err error ) if info, err = this.queryPlayerInfo(session.GetUserId()); err != nil && err != mgo.MongodbNil { - return false + activated = false + info = nil + return } if err == mgo.MongodbNil { global := this.module.ModuleTools.GetGlobalConf() if global.ArenaTicketMax >= global.ArenaTicketCos.N { - return true + ticket = global.ArenaTicketMax + activated = true + return } - return false + activated = false } if ticketitem = this.module.ModuleTools.GetGlobalConf().ArenaTicketCos; ticketitem == nil { this.module.Error("竞技场配置未找到!", log.Field{Key: "key", Value: "ArenaTicketCos"}) - return false + activated = false + return } - ticket := int32(this.module.ModuleItems.QueryItemAmount(info.Uid, ticketitem.T)) + ticket = int32(this.module.ModuleItems.QueryItemAmount(info.Uid, ticketitem.T)) if ticket > this.module.ModuleTools.GetGlobalConf().ArenaTicketCos.N { - return true + activated = true + return } - return false + return } diff --git a/modules/arena/module.go b/modules/arena/module.go index a0d46e193..1d9a1cb2b 100644 --- a/modules/arena/module.go +++ b/modules/arena/module.go @@ -39,12 +39,12 @@ type Arena struct { modelRank *modelRank } -//模块名 +// 模块名 func (this *Arena) GetType() core.M_Modules { return comm.ModuleArena } -//模块初始化接口 注册用户创建角色事件 +// 模块初始化接口 注册用户创建角色事件 func (this *Arena) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { err = this.ModuleBase.Init(service, module, options) this.service = service.(base.IRPCXService) @@ -70,7 +70,7 @@ func (this *Arena) Start() (err error) { return } -//装备组件 +// 装备组件 func (this *Arena) OnInstallComp() { this.ModuleBase.OnInstallComp() this.api = this.RegisterComp(new(apiComp)).(*apiComp) @@ -79,7 +79,7 @@ func (this *Arena) OnInstallComp() { this.modelRank = this.RegisterComp(new(modelRank)).(*modelRank) } -//比赛结算 +// 比赛结算 func (this *Arena) Rpc_ModuleArenaRaceSettlement(ctx context.Context, args *pb.EmptyReq, reply *pb.EmptyResp) (err error) { this.Debug("Rpc_ModuleArenaRaceSettlement", log.Field{Key: "args", Value: args.String()}, @@ -88,23 +88,47 @@ func (this *Arena) Rpc_ModuleArenaRaceSettlement(ctx context.Context, args *pb.E return } -//修改用户积分 +// 修改用户积分 func (this *Arena) Rpc_ModuleArenaModifyIntegral(ctx context.Context, args *pb.RPCModifyIntegralReq, reply *pb.EmptyResp) (err error) { this.Debug("Rpc_ModuleArenaModifyIntegral", log.Field{Key: "args", Value: args.String()}) err = this.modelArena.modifyIntegral(args.Uid, args.Integral) return } -//红点需求 +// 红点需求 func (this *Arena) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (result map[comm.ReddotType]*pb.ReddotItem) { + var ( + info *pb.DBArenaUser = &pb.DBArenaUser{} + activated bool + ticket int32 + ) + if info, ticket, activated = this.modelArena.reddot(session); info == nil { + return + } result = make(map[comm.ReddotType]*pb.ReddotItem) for _, v := range rid { switch v { + case comm.Reddot22100: + result[comm.Reddot22102] = &pb.ReddotItem{ + Rid: int32(comm.Reddot22102), + } + if ticket == this.ModuleTools.GetGlobalConf().ArenaTicketCos.N { + result[comm.Reddot22102].Activated = true + } + break case comm.Reddot22102: result[comm.Reddot22102] = &pb.ReddotItem{ Rid: int32(comm.Reddot22102), } - result[comm.Reddot22102].Activated = this.modelArena.reddot(session) + result[comm.Reddot22102].Activated = activated + break + + case comm.Reddot22202: + result[comm.Reddot22102] = &pb.ReddotItem{ + Rid: int32(comm.Reddot22102), + Activated: true, + Progress: ticket, + } break } } @@ -128,7 +152,7 @@ func (this *Arena) SetUserIntegral(session comm.IUserSession, Integral int32) (e return } -///获取竞技场匹配目标战斗阵型数据 +// /获取竞技场匹配目标战斗阵型数据 func (this *Arena) GetMatcheBattleRoles(uid string) (captain int32, rules []*pb.BattleRole, err error) { var ( global *cfg.GameGlobalData