🐞 fix(shop): 修改商店可买次数限制
This commit is contained in:
@@ -72,13 +72,10 @@ export class ShopHandler {
|
||||
}
|
||||
|
||||
// 总计可买次数(从配置表读取)
|
||||
const totalCanBuyTimes = getShopMaxBuyTimes(dicShopItem.price);
|
||||
const totalCanBuyTimes = dicShopItem.purchaseLimit;
|
||||
if (!totalCanBuyTimes || totalCanBuyTimes <= 0) {
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
}
|
||||
|
||||
// 最大已买次数 = 总计可买次数 - 本次要买次数
|
||||
const maxAlreadyBuyTimes = totalCanBuyTimes - count;
|
||||
|
||||
// 消耗
|
||||
let cost = getShopPrice(dicShopItem.money, count, userShop?.count||0, dicShopItem.price);
|
||||
|
||||
@@ -106,22 +106,6 @@ export function getShopPrice(goodId: number, count: number, buyCount: number, st
|
||||
}]
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品的最大购买次数
|
||||
*
|
||||
* @export
|
||||
* @param {string} str 比如: 1&0|2&50|3&100|4&150|5&200
|
||||
*/
|
||||
export function getShopMaxBuyTimes(str: string) {
|
||||
let arr = parseShopPrice(str);
|
||||
for (let { times, maxTimes } of arr) {
|
||||
if (maxTimes === -1) {
|
||||
return times;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function parseShopPrice(str: string) {
|
||||
let result = new Array<{ times: number, price: number, maxTimes: number }>();
|
||||
if (!str) return result;
|
||||
|
||||
Reference in New Issue
Block a user