上传竞技场
This commit is contained in:
parent
ace966196f
commit
a464b5dbf1
@ -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) {
|
func (this *arenaModel) reddot(session comm.IUserSession) (info *pb.DBArenaUser, ticket int32, activated bool) {
|
||||||
var (
|
var (
|
||||||
ticketitem *cfg.Gameatn
|
err error
|
||||||
err error
|
|
||||||
)
|
)
|
||||||
if info, err = this.queryPlayerInfo(session.GetUserId()); err != nil && err != mgo.MongodbNil {
|
if info, err = this.queryPlayerInfo(session.GetUserId()); err != nil && err != mgo.MongodbNil {
|
||||||
activated = false
|
activated = false
|
||||||
@ -495,15 +494,39 @@ func (this *arenaModel) reddot(session comm.IUserSession) (info *pb.DBArenaUser,
|
|||||||
}
|
}
|
||||||
activated = false
|
activated = false
|
||||||
}
|
}
|
||||||
if ticketitem = this.module.ModuleTools.GetGlobalConf().ArenaTicketCos; ticketitem == nil {
|
activated = true
|
||||||
this.module.Error("竞技场配置未找到!", log.Field{Key: "key", Value: "ArenaTicketCos"})
|
ticket = this.recoverTicket(session, info)
|
||||||
activated = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ticket = int32(this.module.ModuleItems.QueryItemAmount(info.Uid, ticketitem.T))
|
|
||||||
if ticket > this.module.ModuleTools.GetGlobalConf().ArenaTicketCos.N {
|
|
||||||
activated = true
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
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
|
||||||
|
}
|
||||||
|
@ -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
|
reddot[int32(k)] = v
|
||||||
}
|
}
|
||||||
//用户
|
//用户
|
||||||
|
Loading…
Reference in New Issue
Block a user