Commit d82e0b8ec1644cce93a3dd8d587a990c4419e827
Merge branch 'cn/develop' into cn/publish/zhaolu
Showing
18 changed files
with
74 additions
and
70 deletions
Show diff stats
src/actions/ActivityAction.lua
@@ -419,7 +419,7 @@ function _M.exchangeRpc(agent, data) | @@ -419,7 +419,7 @@ function _M.exchangeRpc(agent, data) | ||
419 | costs[k] = v * count | 419 | costs[k] = v * count |
420 | end | 420 | end |
421 | if not role:checkItemEnough(costs) then return 5 end | 421 | if not role:checkItemEnough(costs) then return 5 end |
422 | - role:costItems(costs, {log = {desc = "actExchange", int1 = actid, int2 = id}}) | 422 | + if not role:costItems(costs, {log = {desc = "actExchange", int1 = actid, int2 = id}}) then return 6 end |
423 | 423 | ||
424 | curCount = curCount + count | 424 | curCount = curCount + count |
425 | exchangeData[id] = curCount | 425 | exchangeData[id] = curCount |
@@ -490,7 +490,7 @@ function _M.gachakonRpc(agent, data) | @@ -490,7 +490,7 @@ function _M.gachakonRpc(agent, data) | ||
490 | 490 | ||
491 | if not role:checkItemEnough(cost) then return 5 end | 491 | if not role:checkItemEnough(cost) then return 5 end |
492 | 492 | ||
493 | - role:costItems(cost, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) | 493 | + if not role:costItems(cost, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) then return 6 end |
494 | 494 | ||
495 | local reward, change = role:award(award, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) | 495 | local reward, change = role:award(award, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) |
496 | --print("-----------", remain, count) | 496 | --print("-----------", remain, count) |
@@ -1220,7 +1220,7 @@ function _M.friendHelpRpc(agent, data) | @@ -1220,7 +1220,7 @@ function _M.friendHelpRpc(agent, data) | ||
1220 | local cost = {[itemId1] = rewardData.condition1, [itemId2] = rewardData.condition2} | 1220 | local cost = {[itemId1] = rewardData.condition1, [itemId2] = rewardData.condition2} |
1221 | 1221 | ||
1222 | if not role:checkItemEnough(cost) then return 7 end | 1222 | if not role:checkItemEnough(cost) then return 7 end |
1223 | - role:costItems(cost, {log = {desc = "actFriendHelp", int1 = actid, int2 = level}}) | 1223 | + if not role:costItems(cost, {log = {desc = "actFriendHelp", int1 = actid, int2 = level}}) then return 8 end |
1224 | 1224 | ||
1225 | if rewardData.reward ~= "" then | 1225 | if rewardData.reward ~= "" then |
1226 | result = 1 | 1226 | result = 1 |
@@ -1385,7 +1385,7 @@ function _M.buyBattleCommandLvlRpc(agent, data) | @@ -1385,7 +1385,7 @@ function _M.buyBattleCommandLvlRpc(agent, data) | ||
1385 | if cost == 0 then return 5 end | 1385 | if cost == 0 then return 5 end |
1386 | 1386 | ||
1387 | if not role:checkItemEnough({[ItemId.Diamond] = cost}) then return 6 end | 1387 | if not role:checkItemEnough({[ItemId.Diamond] = cost}) then return 6 end |
1388 | - role:costItems({[ItemId.Diamond] = cost}, {log = {desc = "actBuyBpLevel", int1 = curLvl}}) | 1388 | + if not role:costItems({[ItemId.Diamond] = cost}, {log = {desc = "actBuyBpLevel", int1 = curLvl}}) then return 7 end |
1389 | actData["lvl"] = nextLvl | 1389 | actData["lvl"] = nextLvl |
1390 | role.activity:updateActData("BattleCommand", actData) | 1390 | role.activity:updateActData("BattleCommand", actData) |
1391 | role:mylog("act_action", {desc="buyBcLvl", int1=count, int2=nextLvl}) | 1391 | role:mylog("act_action", {desc="buyBcLvl", int1=count, int2=nextLvl}) |
@@ -1533,7 +1533,7 @@ function _M.buyBattleTicketRpc(agent, data) | @@ -1533,7 +1533,7 @@ function _M.buyBattleTicketRpc(agent, data) | ||
1533 | end | 1533 | end |
1534 | local cost = globalCsv.activity_scrofa_tickets[curCount + 1] | 1534 | local cost = globalCsv.activity_scrofa_tickets[curCount + 1] |
1535 | if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 3 end | 1535 | if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 3 end |
1536 | - role:costItems({[ItemId.Jade] = cost}, {log = {desc = "buyActivityBattleTicket", int1 = actid, int2 = count, long1 = curCount}}) | 1536 | + if not role:costItems({[ItemId.Jade] = cost}, {log = {desc = "buyActivityBattleTicket", int1 = actid, int2 = count, long1 = curCount}}) then return 4 end |
1537 | actData["ticket"] = (actData["ticket"] or 0) + 1 | 1537 | actData["ticket"] = (actData["ticket"] or 0) + 1 |
1538 | actData["buyC"] = curCount + count | 1538 | actData["buyC"] = curCount + count |
1539 | 1539 | ||
@@ -1946,7 +1946,7 @@ function _M.buyWorldBossBattleTicketRpc(agent, data) | @@ -1946,7 +1946,7 @@ function _M.buyWorldBossBattleTicketRpc(agent, data) | ||
1946 | end | 1946 | end |
1947 | local cost = globalCsv.activity_scrofa_tickets[curCount + 1] | 1947 | local cost = globalCsv.activity_scrofa_tickets[curCount + 1] |
1948 | if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 3 end | 1948 | if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 3 end |
1949 | - role:costItems({[ItemId.Jade] = cost}, {log = {desc = "buyRegularWorldBossTicket", int1 = actid, int2 = count, long1 = curCount}}) | 1949 | + if not role:costItems({[ItemId.Jade] = cost}, {log = {desc = "buyRegularWorldBossTicket", int1 = actid, int2 = count, long1 = curCount}}) then return 4 end |
1950 | actData["ticket"] = (actData["ticket"] or 0) + 1 | 1950 | actData["ticket"] = (actData["ticket"] or 0) + 1 |
1951 | actData["buyC"] = curCount + count | 1951 | actData["buyC"] = curCount + count |
1952 | 1952 |
src/actions/AdvAction.lua
@@ -383,7 +383,7 @@ function _M.quickHangRpc(agent, data) | @@ -383,7 +383,7 @@ function _M.quickHangRpc(agent, data) | ||
383 | local cost = math.ceil((info.time - skynet.timex()) / 3600 * globalCsv.adv_idle_quicken) | 383 | local cost = math.ceil((info.time - skynet.timex()) / 3600 * globalCsv.adv_idle_quicken) |
384 | 384 | ||
385 | if not role:checkItemEnough({[ItemId.Jade] = cost}) then return end | 385 | if not role:checkItemEnough({[ItemId.Jade] = cost}) then return end |
386 | - role:costItems({[ItemId.Jade] = cost}, {log = {desc = "advQuickHang", int1 = chapterId}}) | 386 | + if not role:costItems({[ItemId.Jade] = cost}, {log = {desc = "advQuickHang", int1 = chapterId}}) then return end |
387 | info.time = 0 | 387 | info.time = 0 |
388 | role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) | 388 | role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) |
389 | 389 | ||
@@ -519,7 +519,7 @@ function _M.buyAdvCountRpc(agent , data) | @@ -519,7 +519,7 @@ function _M.buyAdvCountRpc(agent , data) | ||
519 | 519 | ||
520 | 520 | ||
521 | if not role:checkItemEnough(cost) then return end | 521 | if not role:checkItemEnough(cost) then return end |
522 | - role:costItems(cost, {log = {desc = "buyAdvCount", int1 = isEl and 1 or 0, int2 = count}}) | 522 | + if not role:costItems(cost, {log = {desc = "buyAdvCount", int1 = isEl and 1 or 0, int2 = count}}) then return end |
523 | if isEl then | 523 | if isEl then |
524 | role.dailyData:updateProperty({field = "advElC", delta = -count}) | 524 | role.dailyData:updateProperty({field = "advElC", delta = -count}) |
525 | role.dailyData:updateProperty({field = "advElBC", delta = count}) | 525 | role.dailyData:updateProperty({field = "advElBC", delta = count}) |
@@ -904,7 +904,7 @@ function _M.wheelSurfRpc(agent, data) | @@ -904,7 +904,7 @@ function _M.wheelSurfRpc(agent, data) | ||
904 | if role:checkRuneFully(tmpcount) then return 6 end | 904 | if role:checkRuneFully(tmpcount) then return 6 end |
905 | 905 | ||
906 | if not role:checkItemEnough(costs) then return 5 end | 906 | if not role:checkItemEnough(costs) then return 5 end |
907 | - role:costItems(costs, {log = {desc = "advWheelSurf", int1 = ptype}}) | 907 | + if not role:costItems(costs, {log = {desc = "advWheelSurf", int1 = ptype}}) then return 6 end |
908 | local oldLv, lv = role:addAdvLvExp(costs[ItemId.OldCoin] or 0) | 908 | local oldLv, lv = role:addAdvLvExp(costs[ItemId.OldCoin] or 0) |
909 | local advDrawB = role:getProperty("advDrawB") | 909 | local advDrawB = role:getProperty("advDrawB") |
910 | advDrawB[ptype] = (advDrawB[ptype] or 0) + count | 910 | advDrawB[ptype] = (advDrawB[ptype] or 0) + count |
@@ -1038,7 +1038,7 @@ function _M.refreshSupportRpc(agent, data) | @@ -1038,7 +1038,7 @@ function _M.refreshSupportRpc(agent, data) | ||
1038 | role.dailyData:updateProperty({field = "advSupRe", delta = 1}) | 1038 | role.dailyData:updateProperty({field = "advSupRe", delta = 1}) |
1039 | else -- 付费 | 1039 | else -- 付费 |
1040 | if not role:checkItemEnough({[ItemId.Jade] = globalCsv.adv_support_refresh_cost}) then return end | 1040 | if not role:checkItemEnough({[ItemId.Jade] = globalCsv.adv_support_refresh_cost}) then return end |
1041 | - role:costItems({[ItemId.Jade] = globalCsv.adv_support_refresh_cost}, {log = {desc = "advReSupport"}}) | 1041 | + if not role:costItems({[ItemId.Jade] = globalCsv.adv_support_refresh_cost}, {log = {desc = "advReSupport"}}) then return end |
1042 | end | 1042 | end |
1043 | 1043 | ||
1044 | role:advRandomSupportEffect() | 1044 | role:advRandomSupportEffect() |
src/actions/CapsuleAction.lua
@@ -123,7 +123,7 @@ function _M.drawRpc(agent, data) | @@ -123,7 +123,7 @@ function _M.drawRpc(agent, data) | ||
123 | cost[token[1]] = drawsNum * token[2] | 123 | cost[token[1]] = drawsNum * token[2] |
124 | 124 | ||
125 | if not role:checkItemEnough(cost) then return 2 end | 125 | if not role:checkItemEnough(cost) then return 2 end |
126 | - role:costItems(cost, {log = {desc = "CapsuleCoinCost", int1 = token[1], int2 = cost[token[1]]}}) | 126 | + if not role:costItems(cost, {log = {desc = "CapsuleCoinCost", int1 = token[1], int2 = cost[token[1]]}}) then return 6 end |
127 | 127 | ||
128 | --开始抽奖 | 128 | --开始抽奖 |
129 | if typ == 1 then | 129 | if typ == 1 then |
@@ -185,7 +185,7 @@ function _M.convertCapsuleRpc(agent, data) | @@ -185,7 +185,7 @@ function _M.convertCapsuleRpc(agent, data) | ||
185 | end | 185 | end |
186 | cost[convert[1]] = convert[2] * count | 186 | cost[convert[1]] = convert[2] * count |
187 | if not role:checkItemEnough(cost) then return 1 end | 187 | if not role:checkItemEnough(cost) then return 1 end |
188 | - role:costItems(cost, {log = {desc = "CapsuleConvert", int1 = convert[1], int2 = cost[convert[1]]}}) | 188 | + if not role:costItems(cost, {log = {desc = "CapsuleConvert", int1 = convert[1], int2 = cost[convert[1]]}}) then return 2 end |
189 | 189 | ||
190 | 190 | ||
191 | local reward, change = role:award({[coin]= count}, {log = {desc = "CapsuleConvert"}}) | 191 | local reward, change = role:award({[coin]= count}, {log = {desc = "CapsuleConvert"}}) |
src/actions/CarAction.lua
@@ -48,7 +48,7 @@ function _M.makePotionRpc( agent, data ) | @@ -48,7 +48,7 @@ function _M.makePotionRpc( agent, data ) | ||
48 | if not role:checkItemEnough(cost) then | 48 | if not role:checkItemEnough(cost) then |
49 | return 4 | 49 | return 4 |
50 | end | 50 | end |
51 | - role:costItems(cost, {log = {desc = "makePotion", int1 = potionId, int2 = count}}) | 51 | + if not role:costItems(cost, {log = {desc = "makePotion", int1 = potionId, int2 = count}}) then return 5 end |
52 | local own = potionBag[potionId] or 0 | 52 | local own = potionBag[potionId] or 0 |
53 | potionBag[potionId] = own + count | 53 | potionBag[potionId] = own + count |
54 | role:updateProperty({field = "potionBag", value = potionBag}) | 54 | role:updateProperty({field = "potionBag", value = potionBag}) |
@@ -108,7 +108,7 @@ function _M.equipUpRpc( agent, data ) | @@ -108,7 +108,7 @@ function _M.equipUpRpc( agent, data ) | ||
108 | return 4 | 108 | return 4 |
109 | end | 109 | end |
110 | 110 | ||
111 | - role:costItems(cost, {log = {desc = "equipUp", int1 = id, int2 = count}}) | 111 | + if not role:costItems(cost, {log = {desc = "equipUp", int1 = id, int2 = count}}) then return 5 end |
112 | role:addEquip(typ, lv, -costCount, {log = {desc = "equipUp"}}) | 112 | role:addEquip(typ, lv, -costCount, {log = {desc = "equipUp"}}) |
113 | role:addEquip(typ, nextLv ,count, {log = {desc = "equipUp"}}) | 113 | role:addEquip(typ, nextLv ,count, {log = {desc = "equipUp"}}) |
114 | role:checkTaskEnter("EquipUp", {count = count}) | 114 | role:checkTaskEnter("EquipUp", {count = count}) |
@@ -151,7 +151,7 @@ function _M.runeUpRpc( agent, data ) | @@ -151,7 +151,7 @@ function _M.runeUpRpc( agent, data ) | ||
151 | return 7 | 151 | return 7 |
152 | end | 152 | end |
153 | 153 | ||
154 | - role:costItems(cost, {log = {desc = "runeUp", int1 = uid, int2 = level}}) | 154 | + if not role:costItems(cost, {log = {desc = "runeUp", int1 = uid, int2 = level}}) then return 8 end |
155 | ownRune:updateProperty({field = "level",value = level+1}) | 155 | ownRune:updateProperty({field = "level",value = level+1}) |
156 | role:checkTaskEnter("RuneUp") | 156 | role:checkTaskEnter("RuneUp") |
157 | 157 | ||
@@ -269,7 +269,7 @@ function _M.sparkQualityUpRpc( agent, data ) | @@ -269,7 +269,7 @@ function _M.sparkQualityUpRpc( agent, data ) | ||
269 | return 7 | 269 | return 7 |
270 | end | 270 | end |
271 | 271 | ||
272 | - role:costItems(cost, {log = {desc = "sparkQualityUp", int1 = uid, int2 = level}}) | 272 | + if not role:costItems(cost, {log = {desc = "sparkQualityUp", int1 = uid, int2 = level}})then return 8 end |
273 | 273 | ||
274 | local newSet = csvdb["sparkCsv"][sparkData.star_up] | 274 | local newSet = csvdb["sparkCsv"][sparkData.star_up] |
275 | if not newSet then return 8 end | 275 | if not newSet then return 8 end |
@@ -315,7 +315,7 @@ function _M.sparkLvlUpRpc( agent, data ) | @@ -315,7 +315,7 @@ function _M.sparkLvlUpRpc( agent, data ) | ||
315 | addLvl = 2 | 315 | addLvl = 2 |
316 | end | 316 | end |
317 | 317 | ||
318 | - role:costItems(cost, {log = {desc = "sparkLvlUp", int1 = uid, int2 = level}}) | 318 | + if not role:costItems(cost, {log = {desc = "sparkLvlUp", int1 = uid, int2 = level}}) then return 8 end |
319 | local attrs = {} | 319 | local attrs = {} |
320 | for i = 1, addLvl do | 320 | for i = 1, addLvl do |
321 | local cfg = sparkSet[level + i] | 321 | local cfg = sparkSet[level + i] |
src/actions/DinerAction.lua
@@ -54,7 +54,7 @@ function _M.addSellRpc( agent, data ) | @@ -54,7 +54,7 @@ function _M.addSellRpc( agent, data ) | ||
54 | return 6 | 54 | return 6 |
55 | end | 55 | end |
56 | 56 | ||
57 | - role:costItems(cost, {log = {desc = "addSell"}}) | 57 | + if not role:costItems(cost, {log = {desc = "addSell"}}) then return 7 end |
58 | role.dinerData:updateSell(slot) | 58 | role.dinerData:updateSell(slot) |
59 | 59 | ||
60 | role:checkTaskEnter("MakeFood", {id = dish, count = count}) | 60 | role:checkTaskEnter("MakeFood", {id = dish, count = count}) |
@@ -275,7 +275,7 @@ function _M.expediteSellRpc( agent, data ) | @@ -275,7 +275,7 @@ function _M.expediteSellRpc( agent, data ) | ||
275 | if not role:checkItemEnough(cost) then | 275 | if not role:checkItemEnough(cost) then |
276 | return 2 | 276 | return 2 |
277 | end | 277 | end |
278 | - role:costItems(cost, {log = {desc = "dinerSellQ"}}) | 278 | + if not role:costItems(cost, {log = {desc = "dinerSellQ"}}) then return 3 end |
279 | end | 279 | end |
280 | 280 | ||
281 | local dirty = false | 281 | local dirty = false |
@@ -385,7 +385,7 @@ function _M.levelUpRpc( agent, data ) | @@ -385,7 +385,7 @@ function _M.levelUpRpc( agent, data ) | ||
385 | return | 385 | return |
386 | end | 386 | end |
387 | 387 | ||
388 | - role:costItems(cost, {log = {desc = "dinerBuildUp", int1 = index}}) | 388 | + if not role:costItems(cost, {log = {desc = "dinerBuildUp", int1 = index}}) then return end |
389 | role.dinerData:updateProperty({field = "buildL", value = buildL:setv(index, curLevel + 1)}) | 389 | role.dinerData:updateProperty({field = "buildL", value = buildL:setv(index, curLevel + 1)}) |
390 | role:checkTaskEnter("DinerLevelUp", {type = index, level = curLevel + 1}) | 390 | role:checkTaskEnter("DinerLevelUp", {type = index, level = curLevel + 1}) |
391 | 391 | ||
@@ -471,7 +471,7 @@ function _M.talentUpRpc( agent, data ) | @@ -471,7 +471,7 @@ function _M.talentUpRpc( agent, data ) | ||
471 | -- if next(role:getProperty("advTeam")) then return 8 end | 471 | -- if next(role:getProperty("advTeam")) then return 8 end |
472 | -- end | 472 | -- end |
473 | 473 | ||
474 | - role:costItems(cost, {log = {desc = "talentUp", int1 = dish, int2 = dishLevel + 1}}) | 474 | + if not role:costItems(cost, {log = {desc = "talentUp", int1 = dish, int2 = dishLevel + 1}}) then return 8 end |
475 | role.dinerData:updateProperty({field = "dishTree", value = dishTree:setv(dish, dishLevel + 1)}) | 475 | role.dinerData:updateProperty({field = "dishTree", value = dishTree:setv(dish, dishLevel + 1)}) |
476 | -- local treePoint = talentData.tree_point:toNumMap() | 476 | -- local treePoint = talentData.tree_point:toNumMap() |
477 | -- if next(treePoint) then | 477 | -- if next(treePoint) then |
@@ -520,7 +520,7 @@ function _M.skillUpRpc( agent, data ) | @@ -520,7 +520,7 @@ function _M.skillUpRpc( agent, data ) | ||
520 | return | 520 | return |
521 | end | 521 | end |
522 | 522 | ||
523 | - role:costItems(cost, {log = {desc = "dinerSkillUp", int1 = skill, int2 = skillLevel + 1}}) | 523 | + if not role:costItems(cost, {log = {desc = "dinerSkillUp", int1 = skill, int2 = skillLevel + 1}}) then return end |
524 | role.dinerData:updateProperty({field = "skillTree", value = skillTree:setv(skill, skillLevel + 1)}) | 524 | role.dinerData:updateProperty({field = "skillTree", value = skillTree:setv(skill, skillLevel + 1)}) |
525 | role:mylog("diner_action", {desc = "skillUp", int1 = skill, int2 = skillLevel + 1}) | 525 | role:mylog("diner_action", {desc = "skillUp", int1 = skill, int2 = skillLevel + 1}) |
526 | 526 | ||
@@ -683,7 +683,7 @@ function _M.refreshTaskRpc( agent, data ) | @@ -683,7 +683,7 @@ function _M.refreshTaskRpc( agent, data ) | ||
683 | end | 683 | end |
684 | if not role:checkItemEnough(cost) then return end | 684 | if not role:checkItemEnough(cost) then return end |
685 | 685 | ||
686 | - role:costItems(cost, {log = {desc = "dinerReTask"}}) | 686 | + if not role:costItems(cost, {log = {desc = "dinerReTask"}}) then return 4 end |
687 | 687 | ||
688 | 688 | ||
689 | for idx, order in ipairs(orders) do | 689 | for idx, order in ipairs(orders) do |
@@ -939,7 +939,7 @@ function _M.entrustRpc(agent , data) | @@ -939,7 +939,7 @@ function _M.entrustRpc(agent , data) | ||
939 | if curData.type == 1 then | 939 | if curData.type == 1 then |
940 | local cost = curData.condition:toNumMap() | 940 | local cost = curData.condition:toNumMap() |
941 | if not role:checkItemEnough(cost) then return end | 941 | if not role:checkItemEnough(cost) then return end |
942 | - role:costItems(cost, {log = {desc = "dinerEntrus", int1 = entrustId}}) | 942 | + if not role:costItems(cost, {log = {desc = "dinerEntrus", int1 = entrustId}}) then return end |
943 | elseif curData.type == 2 then | 943 | elseif curData.type == 2 then |
944 | -- todo 数据校验 | 944 | -- todo 数据校验 |
945 | else | 945 | else |
src/actions/HangAction.lua
@@ -481,7 +481,7 @@ function _M.quickRpc(agent , data) | @@ -481,7 +481,7 @@ function _M.quickRpc(agent , data) | ||
481 | local costCount = table.findMinKeyByIndex(globalCsv.idle_quickproduce_cost, curCount * change, change) | 481 | local costCount = table.findMinKeyByIndex(globalCsv.idle_quickproduce_cost, curCount * change, change) |
482 | 482 | ||
483 | if not role:checkItemEnough({[ItemId.Jade] = costCount}) then return 2 end | 483 | if not role:checkItemEnough({[ItemId.Jade] = costCount}) then return 2 end |
484 | - role:costItems({[ItemId.Jade] = costCount}, {log = {desc = "quickHang", int1 = hangInfo.carbonId}}) | 484 | + if not role:costItems({[ItemId.Jade] = costCount}, {log = {desc = "quickHang", int1 = hangInfo.carbonId}}) then return 3 end |
485 | 485 | ||
486 | role.dailyData:updateProperty({field = "hangQC", value = curCount}) | 486 | role.dailyData:updateProperty({field = "hangQC", value = curCount}) |
487 | 487 | ||
@@ -579,7 +579,7 @@ function _M.buyBonusCountRpc(agent, data) | @@ -579,7 +579,7 @@ function _M.buyBonusCountRpc(agent, data) | ||
579 | 579 | ||
580 | if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 2 end | 580 | if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 2 end |
581 | 581 | ||
582 | - role:costItems({[ItemId.Jade] = cost}, {log = {desc = "buyBonusCount", int1 = btype, int2 = count}}) | 582 | + if not role:costItems({[ItemId.Jade] = cost}, {log = {desc = "buyBonusCount", int1 = btype, int2 = count}}) then return 3 end |
583 | bonusC["b"] = costCount | 583 | bonusC["b"] = costCount |
584 | bonusC["c"] = (bonusC["c"] or 0) - count | 584 | bonusC["c"] = (bonusC["c"] or 0) - count |
585 | 585 | ||
@@ -910,7 +910,7 @@ function _M.startWorkBattleRpc(agent, data) | @@ -910,7 +910,7 @@ function _M.startWorkBattleRpc(agent, data) | ||
910 | role:updateProperty({field = "workBattle", value = workBattle}) | 910 | role:updateProperty({field = "workBattle", value = workBattle}) |
911 | end | 911 | end |
912 | if needCount > 0 then | 912 | if needCount > 0 then |
913 | - role:costItems({[ticketId] = needCount}, {log = {desc = "workBattle", int1 = id}}) | 913 | + if not role:costItems({[ticketId] = needCount}, {log = {desc = "workBattle", int1 = id}}) then return 12 end |
914 | end | 914 | end |
915 | redisproxy:hincrby(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. bonusData.type]) * 10 + bonusData.type, count * bonusData.target_add) | 915 | redisproxy:hincrby(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. bonusData.type]) * 10 + bonusData.type, count * bonusData.target_add) |
916 | local reward, change = workWinReward(role, bonusData, 3, count, true) | 916 | local reward, change = workWinReward(role, bonusData, 3, count, true) |
@@ -1041,7 +1041,7 @@ function _M.endWorkBattleRpc(agent, data) | @@ -1041,7 +1041,7 @@ function _M.endWorkBattleRpc(agent, data) | ||
1041 | role:updateProperty({field = "workBattle", value = workBattle}) | 1041 | role:updateProperty({field = "workBattle", value = workBattle}) |
1042 | end | 1042 | end |
1043 | if needCount > 0 then | 1043 | if needCount > 0 then |
1044 | - role:costItems({[ticketId] = needCount}, {log = {desc = "workBattle", int1 = id}}) | 1044 | + if not role:costItems({[ticketId] = needCount}, {log = {desc = "workBattle", int1 = id}}) then return 2 end |
1045 | end | 1045 | end |
1046 | redisproxy:hincrby(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. bonusData.type]) * 10 + bonusData.type, bonusData.target_add) | 1046 | redisproxy:hincrby(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. bonusData.type]) * 10 + bonusData.type, bonusData.target_add) |
1047 | reward, change = workWinReward(role, bonusData, rewardType) | 1047 | reward, change = workWinReward(role, bonusData, rewardType) |
@@ -1101,7 +1101,7 @@ function _M.bagFieldRpc(agent, data) | @@ -1101,7 +1101,7 @@ function _M.bagFieldRpc(agent, data) | ||
1101 | return 2 | 1101 | return 2 |
1102 | end | 1102 | end |
1103 | role:updateProperty({field = "hangBagLimit", value = curBL + 1}) | 1103 | role:updateProperty({field = "hangBagLimit", value = curBL + 1}) |
1104 | - role:costItems({[ItemId.Jade] = costD}, {log = {desc = "bagField"}}) | 1104 | + if not role:costItems({[ItemId.Jade] = costD}, {log = {desc = "bagField"}}) then return 3 end |
1105 | SendPacket(actionCodes.Hang_bagFieldRpc, '') | 1105 | SendPacket(actionCodes.Hang_bagFieldRpc, '') |
1106 | return true | 1106 | return true |
1107 | end | 1107 | end |
src/actions/HeroAction.lua
@@ -51,7 +51,7 @@ function _M.levelUpRpc( agent, data ) | @@ -51,7 +51,7 @@ function _M.levelUpRpc( agent, data ) | ||
51 | local accountLevel = role:getAccountLevel() | 51 | local accountLevel = role:getAccountLevel() |
52 | if level >= accountLevel then return 4 end | 52 | if level >= accountLevel then return 4 end |
53 | 53 | ||
54 | - role:costItems(cost, {log = {desc = "heroLevelUp", int1 = msg.id, int2 = hero:getProperty("type")}}) | 54 | + if not role:costItems(cost, {log = {desc = "heroLevelUp", int1 = msg.id, int2 = hero:getProperty("type")}}) then return 5 end |
55 | 55 | ||
56 | local oldAttr = hero:getTotalAttrs() | 56 | local oldAttr = hero:getTotalAttrs() |
57 | local oldBattleV = hero:getProperty("battleV") | 57 | local oldBattleV = hero:getProperty("battleV") |
@@ -95,7 +95,7 @@ function _M.breakRpc( agent, data ) | @@ -95,7 +95,7 @@ function _M.breakRpc( agent, data ) | ||
95 | -- if not role:checkHangPass(pass) then return 4 end | 95 | -- if not role:checkHangPass(pass) then return 4 end |
96 | --end | 96 | --end |
97 | 97 | ||
98 | - role:costItems(cost, {log = {desc = "heroBreak", int1 = msg.id, int2 = hero:getProperty("type")}}) | 98 | + if not role:costItems(cost, {log = {desc = "heroBreak", int1 = msg.id, int2 = hero:getProperty("type")}}) then return 5 end |
99 | local oldAttr = hero:getTotalAttrs() | 99 | local oldAttr = hero:getTotalAttrs() |
100 | hero:updateProperty({field = "breakL", delta = 1}) | 100 | hero:updateProperty({field = "breakL", delta = 1}) |
101 | 101 | ||
@@ -145,7 +145,7 @@ function _M.wakeRpc(agent, data) | @@ -145,7 +145,7 @@ function _M.wakeRpc(agent, data) | ||
145 | end | 145 | end |
146 | 146 | ||
147 | 147 | ||
148 | - role:costItems(cost, {log = {desc = "heroWake", int1 = msg.id, int2 = hero:getProperty("type")}}) | 148 | + if not role:costItems(cost, {log = {desc = "heroWake", int1 = msg.id, int2 = hero:getProperty("type")}}) then return 8 end |
149 | 149 | ||
150 | local oldAttr = hero:getTotalAttrs() | 150 | local oldAttr = hero:getTotalAttrs() |
151 | local oldBattleV = hero:getProperty("battleV") | 151 | local oldBattleV = hero:getProperty("battleV") |
@@ -215,7 +215,7 @@ function _M.talentRpc(agent, data) | @@ -215,7 +215,7 @@ function _M.talentRpc(agent, data) | ||
215 | 215 | ||
216 | cost = talentData.money:toNumMap() | 216 | cost = talentData.money:toNumMap() |
217 | if not role:checkItemEnough(cost) then return 5 end | 217 | if not role:checkItemEnough(cost) then return 5 end |
218 | - role:costItems(cost, {log = {desc = "heroTalent", int1 = msg.id, int2 = hero:getProperty("type")}}) | 218 | + if not role:costItems(cost, {log = {desc = "heroTalent", int1 = msg.id, int2 = hero:getProperty("type")}}) then return 6 end |
219 | talent = talent:setv(1, curLevel + 1) | 219 | talent = talent:setv(1, curLevel + 1) |
220 | end | 220 | end |
221 | curStage = talent:getv(0, 1) | 221 | curStage = talent:getv(0, 1) |
@@ -474,7 +474,7 @@ function _M.createHeroRpc(agent, data) | @@ -474,7 +474,7 @@ function _M.createHeroRpc(agent, data) | ||
474 | if hero:getProperty("type") == heroType then return end | 474 | if hero:getProperty("type") == heroType then return end |
475 | end | 475 | end |
476 | 476 | ||
477 | - role:costItems({[heroType] = cost}, {log = {desc = "createHero"}}) | 477 | + if not role:costItems({[heroType] = cost}, {log = {desc = "createHero"}}) then return end |
478 | role:award({[heroType + ItemStartId.Hero] = 1}, {log = {desc = "createHero"}}) | 478 | role:award({[heroType + ItemStartId.Hero] = 1}, {log = {desc = "createHero"}}) |
479 | 479 | ||
480 | SendPacket(actionCodes.Hero_createHeroRpc, "") | 480 | SendPacket(actionCodes.Hero_createHeroRpc, "") |
@@ -642,7 +642,7 @@ function _M.createHeroRandomRpc(agent, data) | @@ -642,7 +642,7 @@ function _M.createHeroRandomRpc(agent, data) | ||
642 | local temp = randomData.gift1:randWeight(true) | 642 | local temp = randomData.gift1:randWeight(true) |
643 | if not temp or not next(temp) then return 3 end | 643 | if not temp or not next(temp) then return 3 end |
644 | 644 | ||
645 | - role:costItems({[itemId] = cost}, {log = {desc = "createHeroRandom"}}) | 645 | + if not role:costItems({[itemId] = cost}, {log = {desc = "createHeroRandom"}}) then return 4 end |
646 | local reward, change = role:award({[temp[1]] = 1}, {log = {desc = "createHeroRandom"}}) | 646 | local reward, change = role:award({[temp[1]] = 1}, {log = {desc = "createHeroRandom"}}) |
647 | 647 | ||
648 | 648 | ||
@@ -688,7 +688,7 @@ function _M.getResetRewardRpc(agent, data) | @@ -688,7 +688,7 @@ function _M.getResetRewardRpc(agent, data) | ||
688 | --if pay and not role:costDiamond({count = globalCsv.unit_heroBack_cost or 200, log = {desc = "resetHero", int1 = msg.id}}) then | 688 | --if pay and not role:costDiamond({count = globalCsv.unit_heroBack_cost or 200, log = {desc = "resetHero", int1 = msg.id}}) then |
689 | -- return 1 | 689 | -- return 1 |
690 | --end | 690 | --end |
691 | - role:costItems(totalCost, {log = {desc = "resetHero", int1 = msg.id}}) | 691 | + if not role:costItems(totalCost, {log = {desc = "resetHero", int1 = msg.id}}) then return 2 end |
692 | end | 692 | end |
693 | 693 | ||
694 | local reward = {} | 694 | local reward = {} |
@@ -999,7 +999,7 @@ function _M.drawHeroRpc(agent, data) | @@ -999,7 +999,7 @@ function _M.drawHeroRpc(agent, data) | ||
999 | end | 999 | end |
1000 | end | 1000 | end |
1001 | 1001 | ||
1002 | - role:costItems(cost, {log = {desc = "drawHero", int1 = btype, int2 = poolId}}) | 1002 | + if not role:costItems(cost, {log = {desc = "drawHero", int1 = btype, int2 = poolId}}) then return 7 end |
1003 | 1003 | ||
1004 | local guideHero = nil | 1004 | local guideHero = nil |
1005 | if role:getProperty("newerGuide") == "8=1" then | 1005 | if role:getProperty("newerGuide") == "8=1" then |
@@ -1303,7 +1303,7 @@ function _M.itemComposeRpc(agent, data) | @@ -1303,7 +1303,7 @@ function _M.itemComposeRpc(agent, data) | ||
1303 | cost[k] = v * count | 1303 | cost[k] = v * count |
1304 | end | 1304 | end |
1305 | if not role:checkItemEnough(cost) then return 2 end | 1305 | if not role:checkItemEnough(cost) then return 2 end |
1306 | - role:costItems(cost, {log = {desc = "itemCompose", int1 = itemId, int2 = count}}) | 1306 | + if not role:costItems(cost, {log = {desc = "itemCompose", int1 = itemId, int2 = count}}) then return 3 end |
1307 | role:award({[itemId] = count}, {log = {desc = "itemCompose"}}) | 1307 | role:award({[itemId] = count}, {log = {desc = "itemCompose"}}) |
1308 | 1308 | ||
1309 | SendPacket(actionCodes.Hero_itemComposeRpc, "") | 1309 | SendPacket(actionCodes.Hero_itemComposeRpc, "") |
@@ -1428,7 +1428,7 @@ function _M.stickersConvertRpc(agent, data) | @@ -1428,7 +1428,7 @@ function _M.stickersConvertRpc(agent, data) | ||
1428 | 1428 | ||
1429 | local cost = {[itemId] = 1} | 1429 | local cost = {[itemId] = 1} |
1430 | if not role:checkItemEnough(cost) then return 4 end | 1430 | if not role:checkItemEnough(cost) then return 4 end |
1431 | - role:costItems({[heroType] = cost}, {log = {desc = "heroStickers"}}) | 1431 | + if not role:costItems({[heroType] = cost}, {log = {desc = "heroStickers"}}) then return 5 end |
1432 | local reward, change = role:award({[heroType] = 1}, {log = {desc = "heroStickers"}}) | 1432 | local reward, change = role:award({[heroType] = 1}, {log = {desc = "heroStickers"}}) |
1433 | 1433 | ||
1434 | SendPacket(actionCodes.Hero_stickersConvertRpc, MsgPack.pack(role:packReward(reward, change))) | 1434 | SendPacket(actionCodes.Hero_stickersConvertRpc, MsgPack.pack(role:packReward(reward, change))) |
src/actions/PvpAction.lua
@@ -249,7 +249,7 @@ function _M.buyCountRpc(agent, data) | @@ -249,7 +249,7 @@ function _M.buyCountRpc(agent, data) | ||
249 | if count + pvpBought > globalCsv["pvp_buy_max"] then return 3 end | 249 | if count + pvpBought > globalCsv["pvp_buy_max"] then return 3 end |
250 | role.dailyData:updateProperty({field = "pvpBought", value = count + pvpBought}) | 250 | role.dailyData:updateProperty({field = "pvpBought", value = count + pvpBought}) |
251 | 251 | ||
252 | - role:costItems(cost, {log = {desc = "buyPvpKey"}}) | 252 | + if not role:costItems(cost, {log = {desc = "buyPvpKey"}}) then return 4 end |
253 | role:award({[ItemId.PvpKey] = count}, {log = {desc = "buyPvpKey"}}) | 253 | role:award({[ItemId.PvpKey] = count}, {log = {desc = "buyPvpKey"}}) |
254 | 254 | ||
255 | SendPacket(actionCodes.Pvp_buyCountRpc, '') | 255 | SendPacket(actionCodes.Pvp_buyCountRpc, '') |
@@ -331,7 +331,7 @@ function _M.startBattleRpc(agent, data) | @@ -331,7 +331,7 @@ function _M.startBattleRpc(agent, data) | ||
331 | if pvpFree >= globalCsv.pvp_battle_free_count then | 331 | if pvpFree >= globalCsv.pvp_battle_free_count then |
332 | local cost = {[ItemId.PvpKey] = 1} | 332 | local cost = {[ItemId.PvpKey] = 1} |
333 | if not role:checkItemEnough(cost) then return 5 end | 333 | if not role:checkItemEnough(cost) then return 5 end |
334 | - role:costItems(cost, {log = {desc = "startPvp", int1 = 1}}) | 334 | + if not role:costItems(cost, {log = {desc = "startPvp", int1 = 1}}) then return 6 end |
335 | else | 335 | else |
336 | role.dailyData:updateProperty({field = "pvpFree", delta = 1}) | 336 | role.dailyData:updateProperty({field = "pvpFree", delta = 1}) |
337 | end | 337 | end |
@@ -380,7 +380,7 @@ function _M.endBattleRpc(agent, data) | @@ -380,7 +380,7 @@ function _M.endBattleRpc(agent, data) | ||
380 | if pvpFree >= globalCsv.pvp_battle_free_count then | 380 | if pvpFree >= globalCsv.pvp_battle_free_count then |
381 | local cost = {[ItemId.PvpKey] = 1} | 381 | local cost = {[ItemId.PvpKey] = 1} |
382 | if not role:checkItemEnough(cost) then return 5 end | 382 | if not role:checkItemEnough(cost) then return 5 end |
383 | - role:costItems(cost, {log = {desc = "startPvp", int1 = 1}}) | 383 | + if not role:costItems(cost, {log = {desc = "startPvp", int1 = 1}}) then return 6 end |
384 | else | 384 | else |
385 | role.dailyData:updateProperty({field = "pvpFree", delta = 1}) | 385 | role.dailyData:updateProperty({field = "pvpFree", delta = 1}) |
386 | end | 386 | end |
@@ -583,7 +583,7 @@ function _M.startBattleHRpc(agent, data) | @@ -583,7 +583,7 @@ function _M.startBattleHRpc(agent, data) | ||
583 | if pvpFreeH >= globalCsv.pvp_battle_free_count_high then | 583 | if pvpFreeH >= globalCsv.pvp_battle_free_count_high then |
584 | local cost = {[ItemId.PvpKey] = globalCsv.pvp_battle_high_cost} | 584 | local cost = {[ItemId.PvpKey] = globalCsv.pvp_battle_high_cost} |
585 | if not role:checkItemEnough(cost) then return 5 end | 585 | if not role:checkItemEnough(cost) then return 5 end |
586 | - role:costItems(cost, {log = {desc = "startPvp", int1 = 2}}) | 586 | + if not role:costItems(cost, {log = {desc = "startPvp", int1 = 2}}) then return 6 end |
587 | else | 587 | else |
588 | role.dailyData:updateProperty({field = "pvpFreeH", delta = 1}) | 588 | role.dailyData:updateProperty({field = "pvpFreeH", delta = 1}) |
589 | end | 589 | end |
@@ -734,7 +734,7 @@ function _M.endBattleHRpc(agent, data) | @@ -734,7 +734,7 @@ function _M.endBattleHRpc(agent, data) | ||
734 | if pvpFreeH >= globalCsv.pvp_battle_free_count_high then | 734 | if pvpFreeH >= globalCsv.pvp_battle_free_count_high then |
735 | local cost = {[ItemId.PvpKey] = globalCsv.pvp_battle_high_cost} | 735 | local cost = {[ItemId.PvpKey] = globalCsv.pvp_battle_high_cost} |
736 | if not role:checkItemEnough(cost) then return 5 end | 736 | if not role:checkItemEnough(cost) then return 5 end |
737 | - role:costItems(cost, {log = {desc = "startPvp", int1 = 2}}) | 737 | + if not role:costItems(cost, {log = {desc = "startPvp", int1 = 2}}) then return 6 end |
738 | else | 738 | else |
739 | role.dailyData:updateProperty({field = "pvpFreeH", delta = 1}) | 739 | role.dailyData:updateProperty({field = "pvpFreeH", delta = 1}) |
740 | end | 740 | end |
@@ -1007,7 +1007,7 @@ function _M.shopBuyRpc(agent, data) | @@ -1007,7 +1007,7 @@ function _M.shopBuyRpc(agent, data) | ||
1007 | 1007 | ||
1008 | if not role:checkItemEnough({[ItemId.PvpCoin] = csvData.cost * count}) then return end | 1008 | if not role:checkItemEnough({[ItemId.PvpCoin] = csvData.cost * count}) then return end |
1009 | 1009 | ||
1010 | - role:costItems({[ItemId.PvpCoin] = csvData.cost * count}, {log = {desc = "pvpShop", int1 = id, int2 = count}}) | 1010 | + if not role:costItems({[ItemId.PvpCoin] = csvData.cost * count}, {log = {desc = "pvpShop", int1 = id, int2 = count}}) then return end |
1011 | if csvData.limit > 0 then | 1011 | if csvData.limit > 0 then |
1012 | role:changeUpdates({{type = "pvpShop", field = id, value = (pvpShop[id] or 0) + count}}) | 1012 | role:changeUpdates({{type = "pvpShop", field = id, value = (pvpShop[id] or 0) + count}}) |
1013 | end | 1013 | end |
src/actions/RadioAction.lua
@@ -254,7 +254,7 @@ function _M.cancelQuestRpc(agent, data) | @@ -254,7 +254,7 @@ function _M.cancelQuestRpc(agent, data) | ||
254 | if remainT > 0 then | 254 | if remainT > 0 then |
255 | local cost = math.ceil(remainT / 3600) * globalCsv.crusade_quicken | 255 | local cost = math.ceil(remainT / 3600) * globalCsv.crusade_quicken |
256 | if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 6 end | 256 | if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 6 end |
257 | - role:costItems({[ItemId.Jade] = cost}, {log = {desc = "radioQuest", int1 = id}}) | 257 | + if not role:costItems({[ItemId.Jade] = cost}, {log = {desc = "radioQuest", int1 = id}}) then return 7 end |
258 | local reward = getCrusadeReward(role, id) | 258 | local reward = getCrusadeReward(role, id) |
259 | if type(reward) == "number" then | 259 | if type(reward) == "number" then |
260 | return reward | 260 | return reward |
src/actions/RoleAction.lua
@@ -656,7 +656,7 @@ function _M.saleItemRpc(agent, data) | @@ -656,7 +656,7 @@ function _M.saleItemRpc(agent, data) | ||
656 | }) | 656 | }) |
657 | end | 657 | end |
658 | 658 | ||
659 | - role:costItems(backs, {log = {desc = "saleItem"}}) | 659 | + if not role:costItems(backs, {log = {desc = "saleItem"}}) then return 4 end |
660 | local reward, change = role:award(reward, {log = {desc = "saleItem"}}) | 660 | local reward, change = role:award(reward, {log = {desc = "saleItem"}}) |
661 | role:checkTaskEnter("DecoFrag", {count = fragCount}) | 661 | role:checkTaskEnter("DecoFrag", {count = fragCount}) |
662 | 662 | ||
@@ -696,7 +696,7 @@ function _M.openItemRpc(agent, data) | @@ -696,7 +696,7 @@ function _M.openItemRpc(agent, data) | ||
696 | end | 696 | end |
697 | reward[0] = nil | 697 | reward[0] = nil |
698 | 698 | ||
699 | - role:costItems({[itemId] = count}, {log = {desc = "openItem"}}) | 699 | + if not role:costItems({[itemId] = count}, {log = {desc = "openItem"}}) then return 4 end |
700 | local change | 700 | local change |
701 | reward, change = role:award(reward, {log = {desc = "openItem", int1 = itemId, int2 = count}}) | 701 | reward, change = role:award(reward, {log = {desc = "openItem", int1 = itemId, int2 = count}}) |
702 | 702 | ||
@@ -753,7 +753,7 @@ function _M.openTimeBoxRpc(agent, data) | @@ -753,7 +753,7 @@ function _M.openTimeBoxRpc(agent, data) | ||
753 | local cost_pre = globalCsv.box_timeOpen_diamond:toArray(true, "=") | 753 | local cost_pre = globalCsv.box_timeOpen_diamond:toArray(true, "=") |
754 | local costKey = math.ceil(quick / (cost_pre[1] * 60)) * cost_pre[2] | 754 | local costKey = math.ceil(quick / (cost_pre[1] * 60)) * cost_pre[2] |
755 | if not role:checkItemEnough({[ItemId.Jade] = costKey}) then return 5 end | 755 | if not role:checkItemEnough({[ItemId.Jade] = costKey}) then return 5 end |
756 | - role:costItems({[ItemId.Jade] = costKey}, {log = {desc = "openTimeBox", int1 = slot, int2 = oper}}) | 756 | + if not role:costItems({[ItemId.Jade] = costKey}, {log = {desc = "openTimeBox", int1 = slot, int2 = oper}}) then return 6 end |
757 | else | 757 | else |
758 | stopTime = math.min(nowTime,time + globalCsv.box_productLine_time * 3600 + role:getBnousDismantlingMaximum()) | 758 | stopTime = math.min(nowTime,time + globalCsv.box_productLine_time * 3600 + role:getBnousDismantlingMaximum()) |
759 | end | 759 | end |
@@ -771,8 +771,8 @@ function _M.openTimeBoxRpc(agent, data) | @@ -771,8 +771,8 @@ function _M.openTimeBoxRpc(agent, data) | ||
771 | boxL[slot] = {id = itemId, process = (process + stopTime - time) % unitTime, time = nowTime} | 771 | boxL[slot] = {id = itemId, process = (process + stopTime - time) % unitTime, time = nowTime} |
772 | role:pushMsg({type = "box", slot = slot, time = nowTime + globalCsv.box_productLine_time * 3600 + role:getBnousDismantlingMaximum()}) | 772 | role:pushMsg({type = "box", slot = slot, time = nowTime + globalCsv.box_productLine_time * 3600 + role:getBnousDismantlingMaximum()}) |
773 | elseif oper == 3 then -- 开箱子 | 773 | elseif oper == 3 then -- 开箱子 |
774 | - local costId = msg.costId | ||
775 | - local costs = (msg.costs or ""):toNumMap() | 774 | + local costId = msg.costId --钥匙id |
775 | + local costs = (msg.costs or ""):toNumMap() --箱子s | ||
776 | if not costId or not csvdb["itemCsv"][costId] or not next(costs) then return 6 end | 776 | if not costId or not csvdb["itemCsv"][costId] or not next(costs) then return 6 end |
777 | 777 | ||
778 | local costIdData = csvdb["itemCsv"][costId] | 778 | local costIdData = csvdb["itemCsv"][costId] |
@@ -794,14 +794,14 @@ function _M.openTimeBoxRpc(agent, data) | @@ -794,14 +794,14 @@ function _M.openTimeBoxRpc(agent, data) | ||
794 | if role:getItemCount(costId) < count then return 8 end | 794 | if role:getItemCount(costId) < count then return 8 end |
795 | if not role:checkItemEnough(costs) then return 9 end | 795 | if not role:checkItemEnough(costs) then return 9 end |
796 | 796 | ||
797 | - role:costItems({[costId] = count}, {log = {desc = "openTimeBox"}}) | 797 | + if not role:costItems({[costId] = count}, {log = {desc = "openTimeBox"}}) then return 10 end |
798 | 798 | ||
799 | reward = {} | 799 | reward = {} |
800 | for itemId, value in pairs(costs) do | 800 | for itemId, value in pairs(costs) do |
801 | local tempReward = {} | 801 | local tempReward = {} |
802 | local randomData = csvdb["item_randomCsv"][itemId] | 802 | local randomData = csvdb["item_randomCsv"][itemId] |
803 | local itemData = csvdb["itemCsv"][itemId] | 803 | local itemData = csvdb["itemCsv"][itemId] |
804 | - role:costItems({[itemId] = value}, {log = {desc = "openTimeBox"}}) | 804 | + if not role:costItems({[itemId] = value}, {log = {desc = "openTimeBox"}}) then return 11 end |
805 | for _ = 1, value do | 805 | for _ = 1, value do |
806 | for i = 1, 10 do | 806 | for i = 1, 10 do |
807 | local num = randomData["num" .. tostring(i)] | 807 | local num = randomData["num" .. tostring(i)] |
@@ -898,7 +898,7 @@ function _M.openSpeedUpBoxRpc(agent, data) | @@ -898,7 +898,7 @@ function _M.openSpeedUpBoxRpc(agent, data) | ||
898 | return 6 | 898 | return 6 |
899 | end | 899 | end |
900 | 900 | ||
901 | - role:costItems({[id] = count}, {log = {desc = "speedUpBox"}}) | 901 | + if not role:costItems({[id] = count}, {log = {desc = "speedUpBox"}}) then return 7 end |
902 | end | 902 | end |
903 | 903 | ||
904 | local doubleCoef = role.activity:isOpen("DoubleDrop") and 2 or 1 | 904 | local doubleCoef = role.activity:isOpen("DoubleDrop") and 2 or 1 |
@@ -974,7 +974,7 @@ function _M.unLockStoryBookRpc(agent, data) | @@ -974,7 +974,7 @@ function _M.unLockStoryBookRpc(agent, data) | ||
974 | local cost = storyBookData.lockItem:toNumMap() | 974 | local cost = storyBookData.lockItem:toNumMap() |
975 | if not cost or not next(cost) then return end | 975 | if not cost or not next(cost) then return end |
976 | if not role:checkItemEnough(cost) then return end -- 消耗品不足 | 976 | if not role:checkItemEnough(cost) then return end -- 消耗品不足 |
977 | - role:costItems(cost, {log = {desc = "unlockStory", int1 = storyId}}) | 977 | + if not role:costItems(cost, {log = {desc = "unlockStory", int1 = storyId}}) then return end |
978 | end | 978 | end |
979 | 979 | ||
980 | -- 解锁 | 980 | -- 解锁 |
@@ -1555,7 +1555,7 @@ function _M.goldBuyRpc(agent, data) | @@ -1555,7 +1555,7 @@ function _M.goldBuyRpc(agent, data) | ||
1555 | end | 1555 | end |
1556 | 1556 | ||
1557 | role.dailyData:updateProperty({field = "goldBuyT", value = curT + 1}) | 1557 | role.dailyData:updateProperty({field = "goldBuyT", value = curT + 1}) |
1558 | - role:costItems({[ItemId.Jade] = costD}, {log = {desc = "goldBuy"}}) | 1558 | + if not role:costItems({[ItemId.Jade] = costD}, {log = {desc = "goldBuy"}}) then return 4 end |
1559 | local reward, change = role:award({[ItemId.Gold] = math.floor(goldC)}, {log = {desc = "goldBuy"}}) | 1559 | local reward, change = role:award({[ItemId.Gold] = math.floor(goldC)}, {log = {desc = "goldBuy"}}) |
1560 | SendPacket(actionCodes.Role_goldBuyRpc, MsgPack.pack(role:packReward(reward, change))) | 1560 | SendPacket(actionCodes.Role_goldBuyRpc, MsgPack.pack(role:packReward(reward, change))) |
1561 | return true | 1561 | return true |
@@ -1590,7 +1590,7 @@ function _M.diamondConvertRpc(agent, data) | @@ -1590,7 +1590,7 @@ function _M.diamondConvertRpc(agent, data) | ||
1590 | role:checkWorldChangePoints({[ItemWorldLine.CostJade]= quan * globalCsv.recruit_cost}) | 1590 | role:checkWorldChangePoints({[ItemWorldLine.CostJade]= quan * globalCsv.recruit_cost}) |
1591 | elseif remain == old then | 1591 | elseif remain == old then |
1592 | else | 1592 | else |
1593 | - role:costItems({[ItemId.Jade] = old - remain}, {log = {desc = "convert", short1=oper}}) | 1593 | + if not role:costItems({[ItemId.Jade] = old - remain}, {log = {desc = "convert", short1=oper}}) then return 3 end |
1594 | role:checkWorldChangePoints({[ItemWorldLine.CostJade]= quan * globalCsv.recruit_cost - (old - remain)}) | 1594 | role:checkWorldChangePoints({[ItemWorldLine.CostJade]= quan * globalCsv.recruit_cost - (old - remain)}) |
1595 | end | 1595 | end |
1596 | 1596 | ||
@@ -1650,7 +1650,7 @@ function _M.useSelectItemRpc(agent, data) | @@ -1650,7 +1650,7 @@ function _M.useSelectItemRpc(agent, data) | ||
1650 | 1650 | ||
1651 | if next(reward) then | 1651 | if next(reward) then |
1652 | reward, change = role:award(reward, {log = {desc = "openItem", int1 = itemId, int2 = count}}) | 1652 | reward, change = role:award(reward, {log = {desc = "openItem", int1 = itemId, int2 = count}}) |
1653 | - role:costItems({[itemId] = count}, {log = {desc = "openItem"}}) | 1653 | + if not role:costItems({[itemId] = count}, {log = {desc = "openItem"}}) then return end |
1654 | end | 1654 | end |
1655 | SendPacket(actionCodes.Role_useSelectItemRpc, MsgPack.pack(role:packReward(reward, change))) | 1655 | SendPacket(actionCodes.Role_useSelectItemRpc, MsgPack.pack(role:packReward(reward, change))) |
1656 | return true | 1656 | return true |
@@ -1721,7 +1721,7 @@ function _M.runeBuyRpc(agent, data) | @@ -1721,7 +1721,7 @@ function _M.runeBuyRpc(agent, data) | ||
1721 | 1721 | ||
1722 | local glodCount = globalCsv.rune_exchange * count | 1722 | local glodCount = globalCsv.rune_exchange * count |
1723 | if not role:checkItemEnough({[ItemId.Gold] = glodCount}) then return end | 1723 | if not role:checkItemEnough({[ItemId.Gold] = glodCount}) then return end |
1724 | - role:costItems({[ItemId.Gold] = glodCount}, {log = {desc = "glodConvertRune", int1 = count, int2 = glodCount}}) | 1724 | + if not role:costItems({[ItemId.Gold] = glodCount}, {log = {desc = "glodConvertRune", int1 = count, int2 = glodCount}}) then return end |
1725 | local reward, change = {} | 1725 | local reward, change = {} |
1726 | reward[ItemId.RuneFragment] = count | 1726 | reward[ItemId.RuneFragment] = count |
1727 | reward, change = role:award(reward, {log = {desc = "glodConvertRune"}}) | 1727 | reward, change = role:award(reward, {log = {desc = "glodConvertRune"}}) |
@@ -1795,7 +1795,7 @@ function _M.itemConvertSpecialRpc(agent, data) | @@ -1795,7 +1795,7 @@ function _M.itemConvertSpecialRpc(agent, data) | ||
1795 | end | 1795 | end |
1796 | end | 1796 | end |
1797 | 1797 | ||
1798 | - role:costItems({[itemId] = 1}, {log = {desc = "itemConvertSpecial", int1 = itemId, int2 = itemData.type}}) | 1798 | + if not role:costItems({[itemId] = 1}, {log = {desc = "itemConvertSpecial", int1 = itemId, int2 = itemData.type}}) then return 7 end |
1799 | 1799 | ||
1800 | SendPacket(actionCodes.Role_itemConvertSpecialRpc, MsgPack.pack(role:packReward(reward))) | 1800 | SendPacket(actionCodes.Role_itemConvertSpecialRpc, MsgPack.pack(role:packReward(reward))) |
1801 | return true | 1801 | return true |
@@ -1875,7 +1875,7 @@ function _M.itemConvertDevilTicketRpc(agent, data) | @@ -1875,7 +1875,7 @@ function _M.itemConvertDevilTicketRpc(agent, data) | ||
1875 | 1875 | ||
1876 | local cost = {[itemId] = createCost[1] * count} | 1876 | local cost = {[itemId] = createCost[1] * count} |
1877 | if not role:checkItemEnough(cost) then return 4 end | 1877 | if not role:checkItemEnough(cost) then return 4 end |
1878 | - role:costItems({cost}, {log = {desc = "itemConvertDevilTicket"}}) | 1878 | + if not role:costItems({cost}, {log = {desc = "itemConvertDevilTicket"}}) then return 5 end |
1879 | local reward, change = role:award({[createCost[2]] = count}, {log = {desc = "itemConvertDevilTicket", int1 = itemId, int2 = cost[itemId]}}) | 1879 | local reward, change = role:award({[createCost[2]] = count}, {log = {desc = "itemConvertDevilTicket", int1 = itemId, int2 = cost[itemId]}}) |
1880 | 1880 | ||
1881 | SendPacket(actionCodes.Role_itemConvertDevilTicketRpc, MsgPack.pack(role:packReward(reward, change))) | 1881 | SendPacket(actionCodes.Role_itemConvertDevilTicketRpc, MsgPack.pack(role:packReward(reward, change))) |
src/actions/SeaportAction.lua
@@ -65,7 +65,7 @@ function _M.donateRpc(agent, data) | @@ -65,7 +65,7 @@ function _M.donateRpc(agent, data) | ||
65 | role:updateProperty({field = "seaport", value = seaport}) | 65 | role:updateProperty({field = "seaport", value = seaport}) |
66 | end | 66 | end |
67 | 67 | ||
68 | - role:costItems({[itemId] = itemCount}, {log = {desc = "seaportDonate", int1 = phase, int2 = id}}) | 68 | + if not role:costItems({[itemId] = itemCount}, {log = {desc = "seaportDonate", int1 = phase, int2 = id}}) then return 5 end |
69 | local reward, change = role:award(rewards, {log = {desc = "seaportDonate", int1 = ddata.phase, int2 = ddata.id}}) | 69 | local reward, change = role:award(rewards, {log = {desc = "seaportDonate", int1 = ddata.phase, int2 = ddata.id}}) |
70 | 70 | ||
71 | role:mylog("role_action", {desc = "seaportDonate", int1 = itemId, int2 = itemCount}) | 71 | role:mylog("role_action", {desc = "seaportDonate", int1 = itemId, int2 = itemCount}) |
@@ -205,7 +205,7 @@ function _M.taskRpc(agent, data) | @@ -205,7 +205,7 @@ function _M.taskRpc(agent, data) | ||
205 | if quick and remainT > 0 then | 205 | if quick and remainT > 0 then |
206 | local cost = math.ceil(remainT / 3600) * globalCsv.seaport_task_quick | 206 | local cost = math.ceil(remainT / 3600) * globalCsv.seaport_task_quick |
207 | if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 8 end | 207 | if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 8 end |
208 | - role:costItems({[ItemId.Jade] = cost}, {log = {desc = "seaportTask", int1 = taskId, int2 = level}}) | 208 | + if not role:costItems({[ItemId.Jade] = cost}, {log = {desc = "seaportTask", int1 = taskId, int2 = level}}) then return 9 end |
209 | end | 209 | end |
210 | 210 | ||
211 | local carbonCsv = csvdb["idle_battleCsv"] | 211 | local carbonCsv = csvdb["idle_battleCsv"] |
@@ -286,7 +286,7 @@ function _M.shopRpc(agent, data) | @@ -286,7 +286,7 @@ function _M.shopRpc(agent, data) | ||
286 | 286 | ||
287 | if role:getItemCount(sdata.icon) < sdata.cost * count then return 3 end | 287 | if role:getItemCount(sdata.icon) < sdata.cost * count then return 3 end |
288 | 288 | ||
289 | - role:costItems({[sdata.icon] = sdata.cost * count}, {log = {desc = "seaportShop", int1 = id, int2 = count}}) | 289 | + if not role:costItems({[sdata.icon] = sdata.cost * count}, {log = {desc = "seaportShop", int1 = id, int2 = count}}) then return 4 end |
290 | 290 | ||
291 | local itemReward = sdata.gift:toNumMap() | 291 | local itemReward = sdata.gift:toNumMap() |
292 | for itemId, value in pairs(itemReward) do | 292 | for itemId, value in pairs(itemReward) do |
src/actions/StoreAction.lua
@@ -414,7 +414,7 @@ function _M.shopBuyRpc(agent , data) | @@ -414,7 +414,7 @@ function _M.shopBuyRpc(agent , data) | ||
414 | role.storeData:updateProperty({field = "buyR", value = buyRecord}) | 414 | role.storeData:updateProperty({field = "buyR", value = buyRecord}) |
415 | limitStr = string.format("%s/%s", buyRecord[id], dataSet.limit) | 415 | limitStr = string.format("%s/%s", buyRecord[id], dataSet.limit) |
416 | end | 416 | end |
417 | - role:costItems(cost, {log = {desc = desc, int1 = id, int2 = count, long1= dataSet.shop}}) | 417 | + if not role:costItems(cost, {log = {desc = desc, int1 = id, int2 = count, long1= dataSet.shop}}) then return 5 end |
418 | 418 | ||
419 | local gift = {} | 419 | local gift = {} |
420 | for _id, _count in pairs(dataSet.gift:toNumMap()) do | 420 | for _id, _count in pairs(dataSet.gift:toNumMap()) do |
src/actions/TowerAction.lua
@@ -177,7 +177,7 @@ function _M.bugCountRpc(agent, data) | @@ -177,7 +177,7 @@ function _M.bugCountRpc(agent, data) | ||
177 | cost[k] = v * needCount | 177 | cost[k] = v * needCount |
178 | end | 178 | end |
179 | if not role:checkItemEnough(cost) then return end | 179 | if not role:checkItemEnough(cost) then return end |
180 | - role:costItems(cost, {log = {desc = "towerCount"}}) | 180 | + if not role:costItems(cost, {log = {desc = "towerCount"}}) then return end |
181 | curCount = curCount + needCount | 181 | curCount = curCount + needCount |
182 | end | 182 | end |
183 | towerInfo.c = curCount | 183 | towerInfo.c = curCount |
src/adv/Adv.lua
@@ -1179,7 +1179,7 @@ function Adv:cost(item, params, check) | @@ -1179,7 +1179,7 @@ function Adv:cost(item, params, check) | ||
1179 | 1179 | ||
1180 | self:award(advCost, params) | 1180 | self:award(advCost, params) |
1181 | if next(less) then | 1181 | if next(less) then |
1182 | - self.owner:costItems(less, params) | 1182 | + if not self.owner:costItems(less, params) then return false end |
1183 | end | 1183 | end |
1184 | return true | 1184 | return true |
1185 | end | 1185 | end |
src/models/Activity.lua
@@ -1031,7 +1031,7 @@ function Activity:recycleActItem(actId) | @@ -1031,7 +1031,7 @@ function Activity:recycleActItem(actId) | ||
1031 | end | 1031 | end |
1032 | itemStr = itemStr .. k .. "=" .. v | 1032 | itemStr = itemStr .. k .. "=" .. v |
1033 | end | 1033 | end |
1034 | - role:costItems(costs, {log = {desc = "actRecycle"}}) | 1034 | + if not role:costItems(costs, {log = {desc = "actRecycle"}}) then return end |
1035 | role:sendMail(actCfg.recycle_email, nil, gift, {itemStr}) | 1035 | role:sendMail(actCfg.recycle_email, nil, gift, {itemStr}) |
1036 | end | 1036 | end |
1037 | end | 1037 | end |
src/models/HeroPlugin.lua
@@ -435,7 +435,7 @@ function HeroPlugin.bind(Hero) | @@ -435,7 +435,7 @@ function HeroPlugin.bind(Hero) | ||
435 | local cost = unit_starTalent_reset:toNumMap() | 435 | local cost = unit_starTalent_reset:toNumMap() |
436 | if not self.owner:checkItemEnough(cost) then return false end | 436 | if not self.owner:checkItemEnough(cost) then return false end |
437 | 437 | ||
438 | - self.owner:costItems(cost, {log = {desc = "heroGenius", int1 = self:getProperty("id"), int2 = self:getProperty("type")}}) | 438 | + if not self.owner:costItems(cost, {log = {desc = "heroGenius", int1 = self:getProperty("id"), int2 = self:getProperty("type")}}) then return false end |
439 | return true | 439 | return true |
440 | end | 440 | end |
441 | 441 |
src/models/RolePlugin.lua
@@ -443,6 +443,10 @@ function RolePlugin.bind(Role) | @@ -443,6 +443,10 @@ function RolePlugin.bind(Role) | ||
443 | 443 | ||
444 | function Role:costItems(itemCountT, params) | 444 | function Role:costItems(itemCountT, params) |
445 | local pms = clone(params or {}) | 445 | local pms = clone(params or {}) |
446 | + for _, v in pairs(itemCountT) do | ||
447 | + if v <= 0 then return false end | ||
448 | + end | ||
449 | + | ||
446 | if itemCountT[ItemId.Diamond] then --优先扣除钻石 | 450 | if itemCountT[ItemId.Diamond] then --优先扣除钻石 |
447 | pms.count = itemCountT[ItemId.Diamond] | 451 | pms.count = itemCountT[ItemId.Diamond] |
448 | if not self:costDiamond(pms) then | 452 | if not self:costDiamond(pms) then |
src/models/RolePvp.lua
@@ -633,7 +633,7 @@ function Role:setCrossServerPvpBet(idx) | @@ -633,7 +633,7 @@ function Role:setCrossServerPvpBet(idx) | ||
633 | local ok, result = pcall(skynet.call, pvpd, "lua", "setBet", idx, self:getProperty("id"), costNum) | 633 | local ok, result = pcall(skynet.call, pvpd, "lua", "setBet", idx, self:getProperty("id"), costNum) |
634 | if ok then | 634 | if ok then |
635 | if result then | 635 | if result then |
636 | - self:costItems(cost, {log = {desc = "crossPvpBet", int1 = day}}) | 636 | + if not self:costItems(cost, {log = {desc = "crossPvpBet", int1 = day}}) then return false, 7 end |
637 | pvpBet[day] = {idx, cost[ItemId.Gold]} | 637 | pvpBet[day] = {idx, cost[ItemId.Gold]} |
638 | self:setProperty("pvpBet", pvpBet) | 638 | self:setProperty("pvpBet", pvpBet) |
639 | end | 639 | end |