Commit 7cbae6f35f2a78ae537e157c2f2b31e04f92623e
1 parent
9ad83c89
fix: Role:costItem增加返回值, 调用该函数的地方加上逻辑判断。
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 | 419 | costs[k] = v * count |
420 | 420 | end |
421 | 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 | 424 | curCount = curCount + count |
425 | 425 | exchangeData[id] = curCount |
... | ... | @@ -490,7 +490,7 @@ function _M.gachakonRpc(agent, data) |
490 | 490 | |
491 | 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 | 495 | local reward, change = role:award(award, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) |
496 | 496 | --print("-----------", remain, count) |
... | ... | @@ -1220,7 +1220,7 @@ function _M.friendHelpRpc(agent, data) |
1220 | 1220 | local cost = {[itemId1] = rewardData.condition1, [itemId2] = rewardData.condition2} |
1221 | 1221 | |
1222 | 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 | 1225 | if rewardData.reward ~= "" then |
1226 | 1226 | result = 1 |
... | ... | @@ -1385,7 +1385,7 @@ function _M.buyBattleCommandLvlRpc(agent, data) |
1385 | 1385 | if cost == 0 then return 5 end |
1386 | 1386 | |
1387 | 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 | 1389 | actData["lvl"] = nextLvl |
1390 | 1390 | role.activity:updateActData("BattleCommand", actData) |
1391 | 1391 | role:mylog("act_action", {desc="buyBcLvl", int1=count, int2=nextLvl}) |
... | ... | @@ -1533,7 +1533,7 @@ function _M.buyBattleTicketRpc(agent, data) |
1533 | 1533 | end |
1534 | 1534 | local cost = globalCsv.activity_scrofa_tickets[curCount + 1] |
1535 | 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 | 1537 | actData["ticket"] = (actData["ticket"] or 0) + 1 |
1538 | 1538 | actData["buyC"] = curCount + count |
1539 | 1539 | |
... | ... | @@ -1946,7 +1946,7 @@ function _M.buyWorldBossBattleTicketRpc(agent, data) |
1946 | 1946 | end |
1947 | 1947 | local cost = globalCsv.activity_scrofa_tickets[curCount + 1] |
1948 | 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 | 1950 | actData["ticket"] = (actData["ticket"] or 0) + 1 |
1951 | 1951 | actData["buyC"] = curCount + count |
1952 | 1952 | ... | ... |
src/actions/AdvAction.lua
... | ... | @@ -383,7 +383,7 @@ function _M.quickHangRpc(agent, data) |
383 | 383 | local cost = math.ceil((info.time - skynet.timex()) / 3600 * globalCsv.adv_idle_quicken) |
384 | 384 | |
385 | 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 | 387 | info.time = 0 |
388 | 388 | role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) |
389 | 389 | |
... | ... | @@ -519,7 +519,7 @@ function _M.buyAdvCountRpc(agent , data) |
519 | 519 | |
520 | 520 | |
521 | 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 | 523 | if isEl then |
524 | 524 | role.dailyData:updateProperty({field = "advElC", delta = -count}) |
525 | 525 | role.dailyData:updateProperty({field = "advElBC", delta = count}) |
... | ... | @@ -904,7 +904,7 @@ function _M.wheelSurfRpc(agent, data) |
904 | 904 | if role:checkRuneFully(tmpcount) then return 6 end |
905 | 905 | |
906 | 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 | 908 | local oldLv, lv = role:addAdvLvExp(costs[ItemId.OldCoin] or 0) |
909 | 909 | local advDrawB = role:getProperty("advDrawB") |
910 | 910 | advDrawB[ptype] = (advDrawB[ptype] or 0) + count |
... | ... | @@ -1038,7 +1038,7 @@ function _M.refreshSupportRpc(agent, data) |
1038 | 1038 | role.dailyData:updateProperty({field = "advSupRe", delta = 1}) |
1039 | 1039 | else -- 付费 |
1040 | 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 | 1042 | end |
1043 | 1043 | |
1044 | 1044 | role:advRandomSupportEffect() | ... | ... |
src/actions/CapsuleAction.lua
... | ... | @@ -123,7 +123,7 @@ function _M.drawRpc(agent, data) |
123 | 123 | cost[token[1]] = drawsNum * token[2] |
124 | 124 | |
125 | 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 | 129 | if typ == 1 then |
... | ... | @@ -185,7 +185,7 @@ function _M.convertCapsuleRpc(agent, data) |
185 | 185 | end |
186 | 186 | cost[convert[1]] = convert[2] * count |
187 | 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 | 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 | 48 | if not role:checkItemEnough(cost) then |
49 | 49 | return 4 |
50 | 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 | 52 | local own = potionBag[potionId] or 0 |
53 | 53 | potionBag[potionId] = own + count |
54 | 54 | role:updateProperty({field = "potionBag", value = potionBag}) |
... | ... | @@ -108,7 +108,7 @@ function _M.equipUpRpc( agent, data ) |
108 | 108 | return 4 |
109 | 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 | 112 | role:addEquip(typ, lv, -costCount, {log = {desc = "equipUp"}}) |
113 | 113 | role:addEquip(typ, nextLv ,count, {log = {desc = "equipUp"}}) |
114 | 114 | role:checkTaskEnter("EquipUp", {count = count}) |
... | ... | @@ -151,7 +151,7 @@ function _M.runeUpRpc( agent, data ) |
151 | 151 | return 7 |
152 | 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 | 155 | ownRune:updateProperty({field = "level",value = level+1}) |
156 | 156 | role:checkTaskEnter("RuneUp") |
157 | 157 | |
... | ... | @@ -269,7 +269,7 @@ function _M.sparkQualityUpRpc( agent, data ) |
269 | 269 | return 7 |
270 | 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 | 274 | local newSet = csvdb["sparkCsv"][sparkData.star_up] |
275 | 275 | if not newSet then return 8 end |
... | ... | @@ -315,7 +315,7 @@ function _M.sparkLvlUpRpc( agent, data ) |
315 | 315 | addLvl = 2 |
316 | 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 | 319 | local attrs = {} |
320 | 320 | for i = 1, addLvl do |
321 | 321 | local cfg = sparkSet[level + i] | ... | ... |
src/actions/DinerAction.lua
... | ... | @@ -54,7 +54,7 @@ function _M.addSellRpc( agent, data ) |
54 | 54 | return 6 |
55 | 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 | 58 | role.dinerData:updateSell(slot) |
59 | 59 | |
60 | 60 | role:checkTaskEnter("MakeFood", {id = dish, count = count}) |
... | ... | @@ -275,7 +275,7 @@ function _M.expediteSellRpc( agent, data ) |
275 | 275 | if not role:checkItemEnough(cost) then |
276 | 276 | return 2 |
277 | 277 | end |
278 | - role:costItems(cost, {log = {desc = "dinerSellQ"}}) | |
278 | + if not role:costItems(cost, {log = {desc = "dinerSellQ"}}) then return 3 end | |
279 | 279 | end |
280 | 280 | |
281 | 281 | local dirty = false |
... | ... | @@ -385,7 +385,7 @@ function _M.levelUpRpc( agent, data ) |
385 | 385 | return |
386 | 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 | 389 | role.dinerData:updateProperty({field = "buildL", value = buildL:setv(index, curLevel + 1)}) |
390 | 390 | role:checkTaskEnter("DinerLevelUp", {type = index, level = curLevel + 1}) |
391 | 391 | |
... | ... | @@ -471,7 +471,7 @@ function _M.talentUpRpc( agent, data ) |
471 | 471 | -- if next(role:getProperty("advTeam")) then return 8 end |
472 | 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 | 475 | role.dinerData:updateProperty({field = "dishTree", value = dishTree:setv(dish, dishLevel + 1)}) |
476 | 476 | -- local treePoint = talentData.tree_point:toNumMap() |
477 | 477 | -- if next(treePoint) then |
... | ... | @@ -520,7 +520,7 @@ function _M.skillUpRpc( agent, data ) |
520 | 520 | return |
521 | 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 | 524 | role.dinerData:updateProperty({field = "skillTree", value = skillTree:setv(skill, skillLevel + 1)}) |
525 | 525 | role:mylog("diner_action", {desc = "skillUp", int1 = skill, int2 = skillLevel + 1}) |
526 | 526 | |
... | ... | @@ -683,7 +683,7 @@ function _M.refreshTaskRpc( agent, data ) |
683 | 683 | end |
684 | 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 | 689 | for idx, order in ipairs(orders) do |
... | ... | @@ -939,7 +939,7 @@ function _M.entrustRpc(agent , data) |
939 | 939 | if curData.type == 1 then |
940 | 940 | local cost = curData.condition:toNumMap() |
941 | 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 | 943 | elseif curData.type == 2 then |
944 | 944 | -- todo 数据校验 |
945 | 945 | else | ... | ... |
src/actions/HangAction.lua
... | ... | @@ -481,7 +481,7 @@ function _M.quickRpc(agent , data) |
481 | 481 | local costCount = table.findMinKeyByIndex(globalCsv.idle_quickproduce_cost, curCount * change, change) |
482 | 482 | |
483 | 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 | 486 | role.dailyData:updateProperty({field = "hangQC", value = curCount}) |
487 | 487 | |
... | ... | @@ -579,7 +579,7 @@ function _M.buyBonusCountRpc(agent, data) |
579 | 579 | |
580 | 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 | 583 | bonusC["b"] = costCount |
584 | 584 | bonusC["c"] = (bonusC["c"] or 0) - count |
585 | 585 | |
... | ... | @@ -910,7 +910,7 @@ function _M.startWorkBattleRpc(agent, data) |
910 | 910 | role:updateProperty({field = "workBattle", value = workBattle}) |
911 | 911 | end |
912 | 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 | 914 | end |
915 | 915 | redisproxy:hincrby(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. bonusData.type]) * 10 + bonusData.type, count * bonusData.target_add) |
916 | 916 | local reward, change = workWinReward(role, bonusData, 3, count, true) |
... | ... | @@ -1041,7 +1041,7 @@ function _M.endWorkBattleRpc(agent, data) |
1041 | 1041 | role:updateProperty({field = "workBattle", value = workBattle}) |
1042 | 1042 | end |
1043 | 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 | 1045 | end |
1046 | 1046 | redisproxy:hincrby(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. bonusData.type]) * 10 + bonusData.type, bonusData.target_add) |
1047 | 1047 | reward, change = workWinReward(role, bonusData, rewardType) |
... | ... | @@ -1101,7 +1101,7 @@ function _M.bagFieldRpc(agent, data) |
1101 | 1101 | return 2 |
1102 | 1102 | end |
1103 | 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 | 1105 | SendPacket(actionCodes.Hang_bagFieldRpc, '') |
1106 | 1106 | return true |
1107 | 1107 | end | ... | ... |
src/actions/HeroAction.lua
... | ... | @@ -51,7 +51,7 @@ function _M.levelUpRpc( agent, data ) |
51 | 51 | local accountLevel = role:getAccountLevel() |
52 | 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 | 56 | local oldAttr = hero:getTotalAttrs() |
57 | 57 | local oldBattleV = hero:getProperty("battleV") |
... | ... | @@ -95,7 +95,7 @@ function _M.breakRpc( agent, data ) |
95 | 95 | -- if not role:checkHangPass(pass) then return 4 end |
96 | 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 | 99 | local oldAttr = hero:getTotalAttrs() |
100 | 100 | hero:updateProperty({field = "breakL", delta = 1}) |
101 | 101 | |
... | ... | @@ -145,7 +145,7 @@ function _M.wakeRpc(agent, data) |
145 | 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 | 150 | local oldAttr = hero:getTotalAttrs() |
151 | 151 | local oldBattleV = hero:getProperty("battleV") |
... | ... | @@ -215,7 +215,7 @@ function _M.talentRpc(agent, data) |
215 | 215 | |
216 | 216 | cost = talentData.money:toNumMap() |
217 | 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 | 219 | talent = talent:setv(1, curLevel + 1) |
220 | 220 | end |
221 | 221 | curStage = talent:getv(0, 1) |
... | ... | @@ -474,7 +474,7 @@ function _M.createHeroRpc(agent, data) |
474 | 474 | if hero:getProperty("type") == heroType then return end |
475 | 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 | 478 | role:award({[heroType + ItemStartId.Hero] = 1}, {log = {desc = "createHero"}}) |
479 | 479 | |
480 | 480 | SendPacket(actionCodes.Hero_createHeroRpc, "") |
... | ... | @@ -642,7 +642,7 @@ function _M.createHeroRandomRpc(agent, data) |
642 | 642 | local temp = randomData.gift1:randWeight(true) |
643 | 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 | 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 | 688 | --if pay and not role:costDiamond({count = globalCsv.unit_heroBack_cost or 200, log = {desc = "resetHero", int1 = msg.id}}) then |
689 | 689 | -- return 1 |
690 | 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 | 692 | end |
693 | 693 | |
694 | 694 | local reward = {} |
... | ... | @@ -999,7 +999,7 @@ function _M.drawHeroRpc(agent, data) |
999 | 999 | end |
1000 | 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 | 1004 | local guideHero = nil |
1005 | 1005 | if role:getProperty("newerGuide") == "8=1" then |
... | ... | @@ -1303,7 +1303,7 @@ function _M.itemComposeRpc(agent, data) |
1303 | 1303 | cost[k] = v * count |
1304 | 1304 | end |
1305 | 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 | 1307 | role:award({[itemId] = count}, {log = {desc = "itemCompose"}}) |
1308 | 1308 | |
1309 | 1309 | SendPacket(actionCodes.Hero_itemComposeRpc, "") |
... | ... | @@ -1428,7 +1428,7 @@ function _M.stickersConvertRpc(agent, data) |
1428 | 1428 | |
1429 | 1429 | local cost = {[itemId] = 1} |
1430 | 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 | 1432 | local reward, change = role:award({[heroType] = 1}, {log = {desc = "heroStickers"}}) |
1433 | 1433 | |
1434 | 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 | 249 | if count + pvpBought > globalCsv["pvp_buy_max"] then return 3 end |
250 | 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 | 253 | role:award({[ItemId.PvpKey] = count}, {log = {desc = "buyPvpKey"}}) |
254 | 254 | |
255 | 255 | SendPacket(actionCodes.Pvp_buyCountRpc, '') |
... | ... | @@ -331,7 +331,7 @@ function _M.startBattleRpc(agent, data) |
331 | 331 | if pvpFree >= globalCsv.pvp_battle_free_count then |
332 | 332 | local cost = {[ItemId.PvpKey] = 1} |
333 | 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 | 335 | else |
336 | 336 | role.dailyData:updateProperty({field = "pvpFree", delta = 1}) |
337 | 337 | end |
... | ... | @@ -380,7 +380,7 @@ function _M.endBattleRpc(agent, data) |
380 | 380 | if pvpFree >= globalCsv.pvp_battle_free_count then |
381 | 381 | local cost = {[ItemId.PvpKey] = 1} |
382 | 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 | 384 | else |
385 | 385 | role.dailyData:updateProperty({field = "pvpFree", delta = 1}) |
386 | 386 | end |
... | ... | @@ -583,7 +583,7 @@ function _M.startBattleHRpc(agent, data) |
583 | 583 | if pvpFreeH >= globalCsv.pvp_battle_free_count_high then |
584 | 584 | local cost = {[ItemId.PvpKey] = globalCsv.pvp_battle_high_cost} |
585 | 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 | 587 | else |
588 | 588 | role.dailyData:updateProperty({field = "pvpFreeH", delta = 1}) |
589 | 589 | end |
... | ... | @@ -734,7 +734,7 @@ function _M.endBattleHRpc(agent, data) |
734 | 734 | if pvpFreeH >= globalCsv.pvp_battle_free_count_high then |
735 | 735 | local cost = {[ItemId.PvpKey] = globalCsv.pvp_battle_high_cost} |
736 | 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 | 738 | else |
739 | 739 | role.dailyData:updateProperty({field = "pvpFreeH", delta = 1}) |
740 | 740 | end |
... | ... | @@ -1007,7 +1007,7 @@ function _M.shopBuyRpc(agent, data) |
1007 | 1007 | |
1008 | 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 | 1011 | if csvData.limit > 0 then |
1012 | 1012 | role:changeUpdates({{type = "pvpShop", field = id, value = (pvpShop[id] or 0) + count}}) |
1013 | 1013 | end | ... | ... |
src/actions/RadioAction.lua
... | ... | @@ -254,7 +254,7 @@ function _M.cancelQuestRpc(agent, data) |
254 | 254 | if remainT > 0 then |
255 | 255 | local cost = math.ceil(remainT / 3600) * globalCsv.crusade_quicken |
256 | 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 | 258 | local reward = getCrusadeReward(role, id) |
259 | 259 | if type(reward) == "number" then |
260 | 260 | return reward | ... | ... |
src/actions/RoleAction.lua
... | ... | @@ -656,7 +656,7 @@ function _M.saleItemRpc(agent, data) |
656 | 656 | }) |
657 | 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 | 660 | local reward, change = role:award(reward, {log = {desc = "saleItem"}}) |
661 | 661 | role:checkTaskEnter("DecoFrag", {count = fragCount}) |
662 | 662 | |
... | ... | @@ -696,7 +696,7 @@ function _M.openItemRpc(agent, data) |
696 | 696 | end |
697 | 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 | 700 | local change |
701 | 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 | 753 | local cost_pre = globalCsv.box_timeOpen_diamond:toArray(true, "=") |
754 | 754 | local costKey = math.ceil(quick / (cost_pre[1] * 60)) * cost_pre[2] |
755 | 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 | 757 | else |
758 | 758 | stopTime = math.min(nowTime,time + globalCsv.box_productLine_time * 3600 + role:getBnousDismantlingMaximum()) |
759 | 759 | end |
... | ... | @@ -771,8 +771,8 @@ function _M.openTimeBoxRpc(agent, data) |
771 | 771 | boxL[slot] = {id = itemId, process = (process + stopTime - time) % unitTime, time = nowTime} |
772 | 772 | role:pushMsg({type = "box", slot = slot, time = nowTime + globalCsv.box_productLine_time * 3600 + role:getBnousDismantlingMaximum()}) |
773 | 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 | 776 | if not costId or not csvdb["itemCsv"][costId] or not next(costs) then return 6 end |
777 | 777 | |
778 | 778 | local costIdData = csvdb["itemCsv"][costId] |
... | ... | @@ -794,14 +794,14 @@ function _M.openTimeBoxRpc(agent, data) |
794 | 794 | if role:getItemCount(costId) < count then return 8 end |
795 | 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 | 799 | reward = {} |
800 | 800 | for itemId, value in pairs(costs) do |
801 | 801 | local tempReward = {} |
802 | 802 | local randomData = csvdb["item_randomCsv"][itemId] |
803 | 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 | 805 | for _ = 1, value do |
806 | 806 | for i = 1, 10 do |
807 | 807 | local num = randomData["num" .. tostring(i)] |
... | ... | @@ -898,7 +898,7 @@ function _M.openSpeedUpBoxRpc(agent, data) |
898 | 898 | return 6 |
899 | 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 | 902 | end |
903 | 903 | |
904 | 904 | local doubleCoef = role.activity:isOpen("DoubleDrop") and 2 or 1 |
... | ... | @@ -974,7 +974,7 @@ function _M.unLockStoryBookRpc(agent, data) |
974 | 974 | local cost = storyBookData.lockItem:toNumMap() |
975 | 975 | if not cost or not next(cost) then return end |
976 | 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 | 978 | end |
979 | 979 | |
980 | 980 | -- 解锁 |
... | ... | @@ -1555,7 +1555,7 @@ function _M.goldBuyRpc(agent, data) |
1555 | 1555 | end |
1556 | 1556 | |
1557 | 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 | 1559 | local reward, change = role:award({[ItemId.Gold] = math.floor(goldC)}, {log = {desc = "goldBuy"}}) |
1560 | 1560 | SendPacket(actionCodes.Role_goldBuyRpc, MsgPack.pack(role:packReward(reward, change))) |
1561 | 1561 | return true |
... | ... | @@ -1590,7 +1590,7 @@ function _M.diamondConvertRpc(agent, data) |
1590 | 1590 | role:checkWorldChangePoints({[ItemWorldLine.CostJade]= quan * globalCsv.recruit_cost}) |
1591 | 1591 | elseif remain == old then |
1592 | 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 | 1594 | role:checkWorldChangePoints({[ItemWorldLine.CostJade]= quan * globalCsv.recruit_cost - (old - remain)}) |
1595 | 1595 | end |
1596 | 1596 | |
... | ... | @@ -1650,7 +1650,7 @@ function _M.useSelectItemRpc(agent, data) |
1650 | 1650 | |
1651 | 1651 | if next(reward) then |
1652 | 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 | 1654 | end |
1655 | 1655 | SendPacket(actionCodes.Role_useSelectItemRpc, MsgPack.pack(role:packReward(reward, change))) |
1656 | 1656 | return true |
... | ... | @@ -1721,7 +1721,7 @@ function _M.runeBuyRpc(agent, data) |
1721 | 1721 | |
1722 | 1722 | local glodCount = globalCsv.rune_exchange * count |
1723 | 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 | 1725 | local reward, change = {} |
1726 | 1726 | reward[ItemId.RuneFragment] = count |
1727 | 1727 | reward, change = role:award(reward, {log = {desc = "glodConvertRune"}}) |
... | ... | @@ -1795,7 +1795,7 @@ function _M.itemConvertSpecialRpc(agent, data) |
1795 | 1795 | end |
1796 | 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 | 1800 | SendPacket(actionCodes.Role_itemConvertSpecialRpc, MsgPack.pack(role:packReward(reward))) |
1801 | 1801 | return true |
... | ... | @@ -1875,7 +1875,7 @@ function _M.itemConvertDevilTicketRpc(agent, data) |
1875 | 1875 | |
1876 | 1876 | local cost = {[itemId] = createCost[1] * count} |
1877 | 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 | 1879 | local reward, change = role:award({[createCost[2]] = count}, {log = {desc = "itemConvertDevilTicket", int1 = itemId, int2 = cost[itemId]}}) |
1880 | 1880 | |
1881 | 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 | 65 | role:updateProperty({field = "seaport", value = seaport}) |
66 | 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 | 69 | local reward, change = role:award(rewards, {log = {desc = "seaportDonate", int1 = ddata.phase, int2 = ddata.id}}) |
70 | 70 | |
71 | 71 | role:mylog("role_action", {desc = "seaportDonate", int1 = itemId, int2 = itemCount}) |
... | ... | @@ -205,7 +205,7 @@ function _M.taskRpc(agent, data) |
205 | 205 | if quick and remainT > 0 then |
206 | 206 | local cost = math.ceil(remainT / 3600) * globalCsv.seaport_task_quick |
207 | 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 | 209 | end |
210 | 210 | |
211 | 211 | local carbonCsv = csvdb["idle_battleCsv"] |
... | ... | @@ -286,7 +286,7 @@ function _M.shopRpc(agent, data) |
286 | 286 | |
287 | 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 | 291 | local itemReward = sdata.gift:toNumMap() |
292 | 292 | for itemId, value in pairs(itemReward) do | ... | ... |
src/actions/StoreAction.lua
... | ... | @@ -413,7 +413,7 @@ function _M.shopBuyRpc(agent , data) |
413 | 413 | role.storeData:updateProperty({field = "buyR", value = buyRecord}) |
414 | 414 | limitStr = string.format("%s/%s", buyRecord[id], dataSet.limit) |
415 | 415 | end |
416 | - role:costItems(cost, {log = {desc = desc, int1 = id, int2 = count, long1= dataSet.shop}}) | |
416 | + if not role:costItems(cost, {log = {desc = desc, int1 = id, int2 = count, long1= dataSet.shop}}) then return 5 end | |
417 | 417 | |
418 | 418 | local gift = {} |
419 | 419 | for _id, _count in pairs(dataSet.gift:toNumMap()) do | ... | ... |
src/actions/TowerAction.lua
... | ... | @@ -177,7 +177,7 @@ function _M.bugCountRpc(agent, data) |
177 | 177 | cost[k] = v * needCount |
178 | 178 | end |
179 | 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 | 181 | curCount = curCount + needCount |
182 | 182 | end |
183 | 183 | towerInfo.c = curCount | ... | ... |
src/adv/Adv.lua
... | ... | @@ -1179,7 +1179,7 @@ function Adv:cost(item, params, check) |
1179 | 1179 | |
1180 | 1180 | self:award(advCost, params) |
1181 | 1181 | if next(less) then |
1182 | - self.owner:costItems(less, params) | |
1182 | + if not self.owner:costItems(less, params) then return false end | |
1183 | 1183 | end |
1184 | 1184 | return true |
1185 | 1185 | end | ... | ... |
src/models/Activity.lua
... | ... | @@ -1031,7 +1031,7 @@ function Activity:recycleActItem(actId) |
1031 | 1031 | end |
1032 | 1032 | itemStr = itemStr .. k .. "=" .. v |
1033 | 1033 | end |
1034 | - role:costItems(costs, {log = {desc = "actRecycle"}}) | |
1034 | + if not role:costItems(costs, {log = {desc = "actRecycle"}}) then return end | |
1035 | 1035 | role:sendMail(actCfg.recycle_email, nil, gift, {itemStr}) |
1036 | 1036 | end |
1037 | 1037 | end | ... | ... |
src/models/HeroPlugin.lua
... | ... | @@ -435,7 +435,7 @@ function HeroPlugin.bind(Hero) |
435 | 435 | local cost = unit_starTalent_reset:toNumMap() |
436 | 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 | 439 | return true |
440 | 440 | end |
441 | 441 | ... | ... |
src/models/RolePlugin.lua
... | ... | @@ -443,6 +443,10 @@ function RolePlugin.bind(Role) |
443 | 443 | |
444 | 444 | function Role:costItems(itemCountT, params) |
445 | 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 | 450 | if itemCountT[ItemId.Diamond] then --优先扣除钻石 |
447 | 451 | pms.count = itemCountT[ItemId.Diamond] |
448 | 452 | if not self:costDiamond(pms) then | ... | ... |
src/models/RolePvp.lua
... | ... | @@ -633,7 +633,7 @@ function Role:setCrossServerPvpBet(idx) |
633 | 633 | local ok, result = pcall(skynet.call, pvpd, "lua", "setBet", idx, self:getProperty("id"), costNum) |
634 | 634 | if ok then |
635 | 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 | 637 | pvpBet[day] = {idx, cost[ItemId.Gold]} |
638 | 638 | self:setProperty("pvpBet", pvpBet) |
639 | 639 | end | ... | ... |