#31958 任务 【梦工场系统】 后端 【体力购买】- 次数限制与价格递增
This commit is contained in:
parent
44455f9f39
commit
798648c15a
@ -824,6 +824,7 @@
|
|||||||
"Passcheck4_WeekNum": 6,
|
"Passcheck4_WeekNum": 6,
|
||||||
"stonehenge_KeyMaxNum": 8,
|
"stonehenge_KeyMaxNum": 8,
|
||||||
"stonehenge_DayNum": 1,
|
"stonehenge_DayNum": 1,
|
||||||
"stonehenge_KeyItemId": "10000039"
|
"stonehenge_KeyItemId": "10000039",
|
||||||
|
"ps_buyGroup": 1003
|
||||||
}
|
}
|
||||||
]
|
]
|
@ -21,12 +21,13 @@ func (this *apiComp) BuyPhysicalCheck(session comm.IUserSession, req *pb.ItemsBu
|
|||||||
//购买
|
//购买
|
||||||
func (this *apiComp) BuyPhysical(session comm.IUserSession, req *pb.ItemsBuyPhysicalReq) (errdata *pb.ErrorData) {
|
func (this *apiComp) BuyPhysical(session comm.IUserSession, req *pb.ItemsBuyPhysicalReq) (errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
user *pb.DBUserExpand
|
user *pb.DBUserExpand
|
||||||
psitem *cfg.Gameatn
|
psitem *cfg.Gameatn
|
||||||
needs []*cfg.Gameatn
|
needs []*cfg.Gameatn
|
||||||
haveneeds []*cfg.Gameatn
|
maxbuy int32
|
||||||
sale []*cfg.Gameatn
|
need []*cfg.Gameatn
|
||||||
|
pricekey int32
|
||||||
)
|
)
|
||||||
if errdata = this.BuyPhysicalCheck(session, req); errdata != nil {
|
if errdata = this.BuyPhysicalCheck(session, req); errdata != nil {
|
||||||
return
|
return
|
||||||
@ -59,29 +60,46 @@ func (this *apiComp) BuyPhysical(session comm.IUserSession, req *pb.ItemsBuyPhys
|
|||||||
if time.Unix(user.PhysicalbuyLasttime, 0).Day() != time.Now().Day() { //不是同一天 重置购买次数
|
if time.Unix(user.PhysicalbuyLasttime, 0).Day() != time.Now().Day() { //不是同一天 重置购买次数
|
||||||
user.Physicalbuynum = 0
|
user.Physicalbuynum = 0
|
||||||
}
|
}
|
||||||
|
pricekey = this.module.ModuleTools.GetGlobalConf().PsBuyGroup
|
||||||
if req.Amount+uint32(user.Physicalbuynum) > uint32(len(needs)) {
|
if maxbuy, err = this.module.ModuleTools.GetPriceGroupLen(pricekey); err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_ItemsBuyPsUpperLimit,
|
Code: pb.ErrorCode_ConfigNoFound,
|
||||||
Title: pb.ErrorCode_ItemsBuyPsUpperLimit.ToString(),
|
Title: pb.ErrorCode_CacheReadError.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
need = make([]*cfg.Gameatn, 0)
|
||||||
haveneeds = make([]*cfg.Gameatn, 0)
|
for i := int32(0); i < int32(req.Amount); i++ {
|
||||||
for i := uint32(0); i < req.Amount; i++ {
|
if user.Physicalbuynum+i+1 > maxbuy {
|
||||||
haveneeds = append(haveneeds, needs[int(int32(i)+user.Physicalbuynum)])
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_ArenaTicketBuyUp,
|
||||||
|
Title: pb.ErrorCode_ArenaTicketBuyUp.ToString(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if res, err := this.module.ModuleTools.GetPriceGroupCost(pricekey, user.Physicalbuynum+i+1); len(res) > 0 {
|
||||||
|
need = append(need, res...)
|
||||||
|
} else {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_ConfigNoFound,
|
||||||
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if errdata = this.module.ConsumeRes(session, haveneeds, true); errdata != nil {
|
if errdata = this.module.ConsumeRes(session, need, true); errdata != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
sale = []*cfg.Gameatn{{A: psitem.A, T: psitem.T, N: int32(req.Amount)}}
|
sale := []*cfg.Gameatn{{A: psitem.A, T: psitem.T, N: psitem.N * int32(req.Amount)}}
|
||||||
|
|
||||||
if errdata = this.module.DispenseRes(session, sale, true); errdata != nil {
|
if errdata = this.module.DispenseRes(session, sale, true); errdata != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
user.Physicalbuynum += int32(req.Amount)
|
user.Physicalbuynum += int32(req.Amount)
|
||||||
user.PhysicalbuyLasttime = time.Now().Unix()
|
user.PhysicalbuyLasttime = time.Now().Unix()
|
||||||
this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{
|
this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{
|
||||||
|
@ -405,9 +405,8 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha
|
|||||||
|
|
||||||
if user == nil || userEx == nil {
|
if user == nil || userEx == nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_UserSessionNobeing,
|
Code: pb.ErrorCode_UserSessionNobeing,
|
||||||
Title: pb.ErrorCode_UserSessionNobeing.ToString(),
|
Title: pb.ErrorCode_UserSessionNobeing.ToString(),
|
||||||
Message: err.Error(),
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -266,6 +266,7 @@ type GameGlobalData struct {
|
|||||||
StonehengeKeyMaxNum int32
|
StonehengeKeyMaxNum int32
|
||||||
StonehengeDayNum int32
|
StonehengeDayNum int32
|
||||||
StonehengeKeyItemId string
|
StonehengeKeyItemId string
|
||||||
|
PsBuyGroup int32
|
||||||
}
|
}
|
||||||
|
|
||||||
const TypeId_GameGlobalData = 477542761
|
const TypeId_GameGlobalData = 477542761
|
||||||
@ -1089,6 +1090,7 @@ func (_v *GameGlobalData)Deserialize(_buf map[string]interface{}) (err error) {
|
|||||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["stonehenge_KeyMaxNum"].(float64); !_ok_ { err = errors.New("stonehenge_KeyMaxNum error"); return }; _v.StonehengeKeyMaxNum = int32(_tempNum_) }
|
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["stonehenge_KeyMaxNum"].(float64); !_ok_ { err = errors.New("stonehenge_KeyMaxNum error"); return }; _v.StonehengeKeyMaxNum = int32(_tempNum_) }
|
||||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["stonehenge_DayNum"].(float64); !_ok_ { err = errors.New("stonehenge_DayNum error"); return }; _v.StonehengeDayNum = int32(_tempNum_) }
|
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["stonehenge_DayNum"].(float64); !_ok_ { err = errors.New("stonehenge_DayNum error"); return }; _v.StonehengeDayNum = int32(_tempNum_) }
|
||||||
{ var _ok_ bool; if _v.StonehengeKeyItemId, _ok_ = _buf["stonehenge_KeyItemId"].(string); !_ok_ { err = errors.New("stonehenge_KeyItemId error"); return } }
|
{ var _ok_ bool; if _v.StonehengeKeyItemId, _ok_ = _buf["stonehenge_KeyItemId"].(string); !_ok_ { err = errors.New("stonehenge_KeyItemId error"); return } }
|
||||||
|
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["ps_buyGroup"].(float64); !_ok_ { err = errors.New("ps_buyGroup error"); return }; _v.PsBuyGroup = int32(_tempNum_) }
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user