上传竞技场

This commit is contained in:
liwei 2023-08-04 16:55:01 +08:00
parent ace966196f
commit a464b5dbf1
2 changed files with 36 additions and 13 deletions

View File

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

View File

@ -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
}
//用户