From a464b5dbf1a52878db29cc7077ab4277a7eec2b4 Mon Sep 17 00:00:00 2001 From: liwei <2211068034@qq.com> Date: Fri, 4 Aug 2023 16:55:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=AB=9E=E6=8A=80=E5=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/arena/modelarena.go | 47 +++++++++++++++++++++++++++--------- modules/reddot/api_getall.go | 2 +- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/modules/arena/modelarena.go b/modules/arena/modelarena.go index 7c2e2340b..47c6c03e7 100644 --- a/modules/arena/modelarena.go +++ b/modules/arena/modelarena.go @@ -478,8 +478,7 @@ func (this *arenaModel) queryPlayerInfo(uId string) (result *pb.DBArenaUser, err func (this *arenaModel) reddot(session comm.IUserSession) (info *pb.DBArenaUser, ticket int32, activated bool) { var ( - ticketitem *cfg.Gameatn - err error + err error ) if info, err = this.queryPlayerInfo(session.GetUserId()); err != nil && err != mgo.MongodbNil { activated = false @@ -495,15 +494,39 @@ func (this *arenaModel) reddot(session comm.IUserSession) (info *pb.DBArenaUser, } activated = false } - if ticketitem = this.module.ModuleTools.GetGlobalConf().ArenaTicketCos; ticketitem == nil { - this.module.Error("竞技场配置未找到!", log.Field{Key: "key", Value: "ArenaTicketCos"}) - activated = false - return - } - ticket = int32(this.module.ModuleItems.QueryItemAmount(info.Uid, ticketitem.T)) - if ticket > this.module.ModuleTools.GetGlobalConf().ArenaTicketCos.N { - activated = true - return - } + activated = true + ticket = this.recoverTicket(session, info) return } + +func (this *arenaModel) recoverTicket(session comm.IUserSession, info *pb.DBArenaUser) int32 { + var ( + duration time.Duration + ticketitem *cfg.Gameatn + ticket int32 + ticketNum int32 + ) + + if ticketitem = this.module.ModuleTools.GetGlobalConf().ArenaTicketCos; ticketitem == nil { + this.module.Error("竞技场配置未找到!", log.Field{Key: "key", Value: "ArenaTicketCos"}) + return 0 + } + + global := this.module.ModuleTools.GetGlobalConf() + maxTick := global.ArenaTicketMax + // 竞技场最大上限 + maxTick += this.module.privilege.GetCountByPrivilegeId(session.GetUserId(), comm.PrivilegeType10) // 特权 + ticket = int32(this.module.ModuleItems.QueryItemAmount(info.Uid, ticketitem.T)) + if ticket < maxTick && info.Lastrtickettime > 0 { + duration = configure.Now().Sub(time.Unix(info.Lastrtickettime, 0)) + ticketNum = int32(math.Floor(duration.Minutes() / float64(global.ArenaTicketRecoveryTime))) + if ticketNum > 0 { + if ticketNum+ticket > global.ArenaTicketMax { + ticketNum = global.ArenaTicketMax - ticket + } + this.module.DispenseRes(session, []*cfg.Gameatn{{A: ticketitem.A, T: ticketitem.T, N: ticketNum}}, true) + info.Lastrtickettime = time.Unix(info.Lastrtickettime, 0).Add(time.Duration(ticketNum) * time.Minute).Unix() + } + } + return ticket +} diff --git a/modules/reddot/api_getall.go b/modules/reddot/api_getall.go index 8575f70b3..2266821c3 100644 --- a/modules/reddot/api_getall.go +++ b/modules/reddot/api_getall.go @@ -57,7 +57,7 @@ func (this *apiComp) GetAll(session comm.IUserSession, req *pb.ReddotGetAllReq) } //竞技场 - for k, v := range this.module.arena.Reddot(session, comm.Reddot22102, comm.Reddot22102, comm.Reddot22202) { + for k, v := range this.module.arena.Reddot(session, comm.Reddot22100, comm.Reddot22102, comm.Reddot22202) { reddot[int32(k)] = v } //用户