商店购买打折

This commit is contained in:
meixiongfeng 2022-12-02 10:26:59 +08:00
parent 1045cca0f0
commit 23d44b7c00

View File

@ -29,7 +29,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HeroBuyReq) (code pb
totalCount int32 // 当前购买的总次数 totalCount int32 // 当前购买的总次数
update map[string]interface{} update map[string]interface{}
price []int32 // 购买所需的价钱 price []int32 // 购买所需的价钱
totalCost float32 // 购买打折系数 totalCost float64 // 购买打折系数
udata *pb.DBUser udata *pb.DBUser
) )
update = make(map[string]interface{}) update = make(map[string]interface{})
@ -75,16 +75,17 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HeroBuyReq) (code pb
for i := record.Onebuy; i < req.BuyCount; i++ { for i := record.Onebuy; i < req.BuyCount; i++ {
if i >= int32(len(price)) { if i >= int32(len(price)) {
totalCost += float32(price[len(price)-1]) / 1000 totalCost += float64(price[len(price)-1]) / 1000
continue
} }
totalCost += float32(price[i]) / 1000 totalCost += float64(price[i]) / 1000
} }
need = make([]*cfg.Gameatn, len(conf.Need)) need = make([]*cfg.Gameatn, len(conf.Need))
for i, v := range conf.Need { for i, v := range conf.Need {
need[i] = &cfg.Gameatn{ need[i] = &cfg.Gameatn{
A: v.A, A: v.A,
T: v.T, T: v.T,
N: int32(math.Ceil(float64(v.N) * float64(totalCost))), N: int32(math.Ceil(float64(v.N) * totalCost)),
} }
} }
// 消耗 // 消耗