体力药剂使用
This commit is contained in:
parent
c892485391
commit
775716bde7
@ -14,13 +14,13 @@ import (
|
||||
"github.com/go-redis/redis/v8"
|
||||
)
|
||||
|
||||
///竞技场 数据组件
|
||||
// /竞技场 数据组件
|
||||
type modelRank struct {
|
||||
modules.MCompModel
|
||||
module *Arena
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
// 组件初始化接口
|
||||
func (this *modelRank) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) {
|
||||
this.TableName = comm.TableArenaRank
|
||||
this.MCompModel.Init(service, module, comp, opt)
|
||||
@ -29,7 +29,7 @@ func (this *modelRank) Init(service core.IService, module core.IModule, comp cor
|
||||
return
|
||||
}
|
||||
|
||||
//更新排名
|
||||
// 更新排名
|
||||
func (this *modelRank) updateArenaRank(users ...*pb.ArenaPlayer) (err error) {
|
||||
var (
|
||||
pipe *pipe.RedisPipe = this.DBModel.Redis.RedisPipe(context.TODO())
|
||||
@ -66,7 +66,7 @@ func (this *modelRank) updateArenaRank(users ...*pb.ArenaPlayer) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
//获取排行榜前50的用户名单
|
||||
// 获取排行榜前50的用户名单
|
||||
func (this *modelRank) queryRankUser() (ranks []string, err error) {
|
||||
var (
|
||||
result []string
|
||||
@ -82,7 +82,7 @@ func (this *modelRank) queryRankUser() (ranks []string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
//比赛结算
|
||||
// 比赛结算
|
||||
func (this *modelRank) raceSettlement() {
|
||||
var (
|
||||
reward *cfg.GameArenaRankReward
|
||||
@ -96,7 +96,7 @@ func (this *modelRank) raceSettlement() {
|
||||
return
|
||||
}
|
||||
for _, v := range reward.GetDataList() {
|
||||
if result, err = this.DBModel.Redis.ZRevRange(this.TableName, int64(v.RankLow-1), int64(v.RankUp-1)).Result(); err != nil {
|
||||
if result, err = this.DBModel.Redis.ZRevRange(this.TableName, int64(v.RankLow-1), int64(v.RankUp)).Result(); err != nil {
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
|
@ -789,28 +789,21 @@ func (this *ModelItemsComp) useitem(session comm.IUserSession, gid string, amoun
|
||||
}
|
||||
return
|
||||
}
|
||||
sale := make([]*cfg.Gameatn, 0, len(itemcf.DecomposeDeplete))
|
||||
for _, v := range itemcf.DecomposeDeplete {
|
||||
sale = append(sale, &cfg.Gameatn{
|
||||
A: v.A,
|
||||
T: v.T,
|
||||
N: v.N * int32(amount),
|
||||
})
|
||||
}
|
||||
if errdata = this.module.ConsumeRes(session, sale, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if errdata = this.module.AddItemforGrid(session, gid, -1*int32(amount), true); errdata != nil {
|
||||
return
|
||||
offps := this.module.ModuleUser.RemainingPS(session.GetUserId())
|
||||
addps := itemcf.DecomposeGet[0].N * int32(amount)
|
||||
if addps > offps { //溢出
|
||||
amount = int32(math.Floor(float64(offps) / float64(itemcf.DecomposeGet[0].N)))
|
||||
}
|
||||
|
||||
sale = make([]*cfg.Gameatn, len(itemcf.Sale))
|
||||
sale := make([]*cfg.Gameatn, len(itemcf.Sale))
|
||||
for i, v := range itemcf.DecomposeGet {
|
||||
temp := *v
|
||||
sale[i] = &temp
|
||||
sale[i].N = v.N * int32(amount)
|
||||
}
|
||||
if errdata = this.module.AddItemforGrid(session, gid, -1*int32(amount), true); errdata != nil {
|
||||
return
|
||||
}
|
||||
if errdata = this.module.DispenseRes(session, sale, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user