Commit 058b4f092a0228868802b42018f8ac161eccca38

Authored by zhangqijia
1 parent 4d684a8b

feat: 限制每天购买竞技场门票的张数

Showing 2 changed files with 10 additions and 0 deletions   Show diff stats
src/actions/PvpAction.lua
... ... @@ -243,6 +243,12 @@ function _M.buyCountRpc(agent, data)
243 243  
244 244 local cost = {[ItemId.Jade] = globalCsv.pvp_buy_cost * count}
245 245 if not role:checkItemEnough(cost) then return 2 end
  246 +
  247 + --限制每天购买次数
  248 + local pvpBought = role.dailyData:getProperty("pvpBought")
  249 + if count + pvpBought > globalCsv["pvp_buy_max"] then return 3 end
  250 + role.dailyData:updateProperty({field = "pvpBought", value = count + pvpBought})
  251 +
246 252 role:costItems(cost, {log = {desc = "buyPvpKey"}})
247 253 role:award({[ItemId.PvpKey] = count}, {log = {desc = "buyPvpKey"}})
248 254  
... ...
src/models/Daily.lua
... ... @@ -22,6 +22,7 @@ Daily.schema = {
22 22 getFP = {"table", {}}, -- 领过谁的心心
23 23 pvpFree = {"number", 0}, -- pvp使用免费次数
24 24 pvpFreeH = {"number", 0}, -- 高级pvp使用免费次数
  25 + pvpBought = {"number", 0}, -- pvp购买次数
25 26  
26 27 dailySDC = {"table", {}}, -- daily shop diamond count {[id] = count} -- 每日商城购买次数统计
27 28 dailySDD = {"table", {}}, -- daily shop diamond disount {[id] = 1} -- 每日商城折扣统计
... ... @@ -69,6 +70,8 @@ function Daily:refreshDailyData(notify)
69 70 -- skip
70 71 elseif field == "treasureList" then
71 72 dataMap[field] = self:getTreasrueList()
  73 + elseif field == "pvpBought" then
  74 + dataMap[field] = 0
72 75 elseif field ~= "key" then
73 76 local typ, def = table.unpack(schema)
74 77 dataMap[field] = def
... ... @@ -367,6 +370,7 @@ function Daily:data()
367 370 getFP = self:getProperty("getFP"),
368 371 pvpFree = self:getProperty("pvpFree"),
369 372 pvpFreeH = self:getProperty("pvpFreeH"),
  373 + pvpBought = self:getProperty("pvpBought"),
370 374 dailySDC = self:getProperty("dailySDC"),
371 375 dailySDD = self:getProperty("dailySDD"),
372 376 advSupRe = self:getProperty("advSupRe"),
... ...