购买抽卡阶梯消费
This commit is contained in:
parent
d11d389910
commit
e75b401909
@ -28,6 +28,8 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HeroBuyReq) (code pb
|
||||
give []*cfg.Gameatn
|
||||
totalCount int32 // 当前购买的总次数
|
||||
update map[string]interface{}
|
||||
price []int32 // 购买所需的价钱
|
||||
totalCost float32 // 购买打折系数
|
||||
)
|
||||
update = make(map[string]interface{})
|
||||
if code = this.BuyCheck(session, req); code != pb.ErrorCode_Success {
|
||||
@ -45,9 +47,14 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HeroBuyReq) (code pb
|
||||
return
|
||||
}
|
||||
global = this.module.configure.GetGlobalConf()
|
||||
for _, v := range conf.Salelist {
|
||||
price = append(price, v)
|
||||
}
|
||||
if req.BuyType == global.DrawCardSupplement1 {
|
||||
totalCount = record.Onebuy + req.BuyCount
|
||||
update["onebuy"] = totalCount // 记录购买的数据
|
||||
// 重新计算价格
|
||||
|
||||
} else if req.BuyType == global.DrawCardSupplement10 {
|
||||
totalCount = record.Tenbuy + req.BuyCount
|
||||
update["tenbuy"] = totalCount
|
||||
@ -59,12 +66,20 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HeroBuyReq) (code pb
|
||||
code = pb.ErrorCode_ShopGoodsIsSoldOut
|
||||
return
|
||||
}
|
||||
|
||||
for i := record.Onebuy; i < req.BuyCount; i++ {
|
||||
|
||||
if i >= int32(len(price)) {
|
||||
totalCost += float32(price[len(price)-1]) / 1000
|
||||
}
|
||||
totalCost += float32(price[i]) / 1000
|
||||
}
|
||||
need = make([]*cfg.Gameatn, len(conf.Need))
|
||||
for i, v := range conf.Need {
|
||||
need[i] = &cfg.Gameatn{
|
||||
A: v.A,
|
||||
T: v.T,
|
||||
N: int32(math.Ceil(float64(v.N)*float64(conf.Sale)/float64(1000))) * req.BuyCount,
|
||||
N: int32(math.Ceil(float64(v.N) * float64(totalCost))),
|
||||
}
|
||||
}
|
||||
// 消耗
|
||||
|
Loading…
Reference in New Issue
Block a user