diff --git a/src/actions/ActivityAction.lua b/src/actions/ActivityAction.lua index 4f617f6..d34d92d 100644 --- a/src/actions/ActivityAction.lua +++ b/src/actions/ActivityAction.lua @@ -419,7 +419,7 @@ function _M.exchangeRpc(agent, data) costs[k] = v * count end if not role:checkItemEnough(costs) then return 5 end - role:costItems(costs, {log = {desc = "actExchange", int1 = actid, int2 = id}}) + if not role:costItems(costs, {log = {desc = "actExchange", int1 = actid, int2 = id}}) then return 6 end curCount = curCount + count exchangeData[id] = curCount @@ -490,7 +490,7 @@ function _M.gachakonRpc(agent, data) if not role:checkItemEnough(cost) then return 5 end - role:costItems(cost, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) + if not role:costItems(cost, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) then return 6 end local reward, change = role:award(award, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) --print("-----------", remain, count) @@ -1220,7 +1220,7 @@ function _M.friendHelpRpc(agent, data) local cost = {[itemId1] = rewardData.condition1, [itemId2] = rewardData.condition2} if not role:checkItemEnough(cost) then return 7 end - role:costItems(cost, {log = {desc = "actFriendHelp", int1 = actid, int2 = level}}) + if not role:costItems(cost, {log = {desc = "actFriendHelp", int1 = actid, int2 = level}}) then return 8 end if rewardData.reward ~= "" then result = 1 @@ -1385,7 +1385,7 @@ function _M.buyBattleCommandLvlRpc(agent, data) if cost == 0 then return 5 end if not role:checkItemEnough({[ItemId.Diamond] = cost}) then return 6 end - role:costItems({[ItemId.Diamond] = cost}, {log = {desc = "actBuyBpLevel", int1 = curLvl}}) + if not role:costItems({[ItemId.Diamond] = cost}, {log = {desc = "actBuyBpLevel", int1 = curLvl}}) then return 7 end actData["lvl"] = nextLvl role.activity:updateActData("BattleCommand", actData) role:mylog("act_action", {desc="buyBcLvl", int1=count, int2=nextLvl}) @@ -1533,7 +1533,7 @@ function _M.buyBattleTicketRpc(agent, data) end local cost = globalCsv.activity_scrofa_tickets[curCount + 1] if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 3 end - role:costItems({[ItemId.Jade] = cost}, {log = {desc = "buyActivityBattleTicket", int1 = actid, int2 = count, long1 = curCount}}) + if not role:costItems({[ItemId.Jade] = cost}, {log = {desc = "buyActivityBattleTicket", int1 = actid, int2 = count, long1 = curCount}}) then return 4 end actData["ticket"] = (actData["ticket"] or 0) + 1 actData["buyC"] = curCount + count @@ -1946,7 +1946,7 @@ function _M.buyWorldBossBattleTicketRpc(agent, data) end local cost = globalCsv.activity_scrofa_tickets[curCount + 1] if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 3 end - role:costItems({[ItemId.Jade] = cost}, {log = {desc = "buyRegularWorldBossTicket", int1 = actid, int2 = count, long1 = curCount}}) + if not role:costItems({[ItemId.Jade] = cost}, {log = {desc = "buyRegularWorldBossTicket", int1 = actid, int2 = count, long1 = curCount}}) then return 4 end actData["ticket"] = (actData["ticket"] or 0) + 1 actData["buyC"] = curCount + count diff --git a/src/actions/AdvAction.lua b/src/actions/AdvAction.lua index 3cfba20..9a72935 100644 --- a/src/actions/AdvAction.lua +++ b/src/actions/AdvAction.lua @@ -383,7 +383,7 @@ function _M.quickHangRpc(agent, data) local cost = math.ceil((info.time - skynet.timex()) / 3600 * globalCsv.adv_idle_quicken) if not role:checkItemEnough({[ItemId.Jade] = cost}) then return end - role:costItems({[ItemId.Jade] = cost}, {log = {desc = "advQuickHang", int1 = chapterId}}) + if not role:costItems({[ItemId.Jade] = cost}, {log = {desc = "advQuickHang", int1 = chapterId}}) then return end info.time = 0 role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) @@ -519,7 +519,7 @@ function _M.buyAdvCountRpc(agent , data) if not role:checkItemEnough(cost) then return end - role:costItems(cost, {log = {desc = "buyAdvCount", int1 = isEl and 1 or 0, int2 = count}}) + if not role:costItems(cost, {log = {desc = "buyAdvCount", int1 = isEl and 1 or 0, int2 = count}}) then return end if isEl then role.dailyData:updateProperty({field = "advElC", delta = -count}) role.dailyData:updateProperty({field = "advElBC", delta = count}) @@ -904,7 +904,7 @@ function _M.wheelSurfRpc(agent, data) if role:checkRuneFully(tmpcount) then return 6 end if not role:checkItemEnough(costs) then return 5 end - role:costItems(costs, {log = {desc = "advWheelSurf", int1 = ptype}}) + if not role:costItems(costs, {log = {desc = "advWheelSurf", int1 = ptype}}) then return 6 end local oldLv, lv = role:addAdvLvExp(costs[ItemId.OldCoin] or 0) local advDrawB = role:getProperty("advDrawB") advDrawB[ptype] = (advDrawB[ptype] or 0) + count @@ -1038,7 +1038,7 @@ function _M.refreshSupportRpc(agent, data) role.dailyData:updateProperty({field = "advSupRe", delta = 1}) else -- 付费 if not role:checkItemEnough({[ItemId.Jade] = globalCsv.adv_support_refresh_cost}) then return end - role:costItems({[ItemId.Jade] = globalCsv.adv_support_refresh_cost}, {log = {desc = "advReSupport"}}) + if not role:costItems({[ItemId.Jade] = globalCsv.adv_support_refresh_cost}, {log = {desc = "advReSupport"}}) then return end end role:advRandomSupportEffect() diff --git a/src/actions/CapsuleAction.lua b/src/actions/CapsuleAction.lua index 931b8a0..8df1b2b 100644 --- a/src/actions/CapsuleAction.lua +++ b/src/actions/CapsuleAction.lua @@ -123,7 +123,7 @@ function _M.drawRpc(agent, data) cost[token[1]] = drawsNum * token[2] if not role:checkItemEnough(cost) then return 2 end - role:costItems(cost, {log = {desc = "CapsuleCoinCost", int1 = token[1], int2 = cost[token[1]]}}) + if not role:costItems(cost, {log = {desc = "CapsuleCoinCost", int1 = token[1], int2 = cost[token[1]]}}) then return 6 end --开始抽奖 if typ == 1 then @@ -185,7 +185,7 @@ function _M.convertCapsuleRpc(agent, data) end cost[convert[1]] = convert[2] * count if not role:checkItemEnough(cost) then return 1 end - role:costItems(cost, {log = {desc = "CapsuleConvert", int1 = convert[1], int2 = cost[convert[1]]}}) + if not role:costItems(cost, {log = {desc = "CapsuleConvert", int1 = convert[1], int2 = cost[convert[1]]}}) then return 2 end local reward, change = role:award({[coin]= count}, {log = {desc = "CapsuleConvert"}}) diff --git a/src/actions/CarAction.lua b/src/actions/CarAction.lua index 572ecb8..3a835c3 100644 --- a/src/actions/CarAction.lua +++ b/src/actions/CarAction.lua @@ -48,7 +48,7 @@ function _M.makePotionRpc( agent, data ) if not role:checkItemEnough(cost) then return 4 end - role:costItems(cost, {log = {desc = "makePotion", int1 = potionId, int2 = count}}) + if not role:costItems(cost, {log = {desc = "makePotion", int1 = potionId, int2 = count}}) then return 5 end local own = potionBag[potionId] or 0 potionBag[potionId] = own + count role:updateProperty({field = "potionBag", value = potionBag}) @@ -108,7 +108,7 @@ function _M.equipUpRpc( agent, data ) return 4 end - role:costItems(cost, {log = {desc = "equipUp", int1 = id, int2 = count}}) + if not role:costItems(cost, {log = {desc = "equipUp", int1 = id, int2 = count}}) then return 5 end role:addEquip(typ, lv, -costCount, {log = {desc = "equipUp"}}) role:addEquip(typ, nextLv ,count, {log = {desc = "equipUp"}}) role:checkTaskEnter("EquipUp", {count = count}) @@ -151,7 +151,7 @@ function _M.runeUpRpc( agent, data ) return 7 end - role:costItems(cost, {log = {desc = "runeUp", int1 = uid, int2 = level}}) + if not role:costItems(cost, {log = {desc = "runeUp", int1 = uid, int2 = level}}) then return 8 end ownRune:updateProperty({field = "level",value = level+1}) role:checkTaskEnter("RuneUp") @@ -269,7 +269,7 @@ function _M.sparkQualityUpRpc( agent, data ) return 7 end - role:costItems(cost, {log = {desc = "sparkQualityUp", int1 = uid, int2 = level}}) + if not role:costItems(cost, {log = {desc = "sparkQualityUp", int1 = uid, int2 = level}})then return 8 end local newSet = csvdb["sparkCsv"][sparkData.star_up] if not newSet then return 8 end @@ -315,7 +315,7 @@ function _M.sparkLvlUpRpc( agent, data ) addLvl = 2 end - role:costItems(cost, {log = {desc = "sparkLvlUp", int1 = uid, int2 = level}}) + if not role:costItems(cost, {log = {desc = "sparkLvlUp", int1 = uid, int2 = level}}) then return 8 end local attrs = {} for i = 1, addLvl do local cfg = sparkSet[level + i] diff --git a/src/actions/DinerAction.lua b/src/actions/DinerAction.lua index 1d898c5..20ac37a 100644 --- a/src/actions/DinerAction.lua +++ b/src/actions/DinerAction.lua @@ -54,7 +54,7 @@ function _M.addSellRpc( agent, data ) return 6 end - role:costItems(cost, {log = {desc = "addSell"}}) + if not role:costItems(cost, {log = {desc = "addSell"}}) then return 7 end role.dinerData:updateSell(slot) role:checkTaskEnter("MakeFood", {id = dish, count = count}) @@ -275,7 +275,7 @@ function _M.expediteSellRpc( agent, data ) if not role:checkItemEnough(cost) then return 2 end - role:costItems(cost, {log = {desc = "dinerSellQ"}}) + if not role:costItems(cost, {log = {desc = "dinerSellQ"}}) then return 3 end end local dirty = false @@ -385,7 +385,7 @@ function _M.levelUpRpc( agent, data ) return end - role:costItems(cost, {log = {desc = "dinerBuildUp", int1 = index}}) + if not role:costItems(cost, {log = {desc = "dinerBuildUp", int1 = index}}) then return end role.dinerData:updateProperty({field = "buildL", value = buildL:setv(index, curLevel + 1)}) role:checkTaskEnter("DinerLevelUp", {type = index, level = curLevel + 1}) @@ -471,7 +471,7 @@ function _M.talentUpRpc( agent, data ) -- if next(role:getProperty("advTeam")) then return 8 end -- end - role:costItems(cost, {log = {desc = "talentUp", int1 = dish, int2 = dishLevel + 1}}) + if not role:costItems(cost, {log = {desc = "talentUp", int1 = dish, int2 = dishLevel + 1}}) then return 8 end role.dinerData:updateProperty({field = "dishTree", value = dishTree:setv(dish, dishLevel + 1)}) -- local treePoint = talentData.tree_point:toNumMap() -- if next(treePoint) then @@ -520,7 +520,7 @@ function _M.skillUpRpc( agent, data ) return end - role:costItems(cost, {log = {desc = "dinerSkillUp", int1 = skill, int2 = skillLevel + 1}}) + if not role:costItems(cost, {log = {desc = "dinerSkillUp", int1 = skill, int2 = skillLevel + 1}}) then return end role.dinerData:updateProperty({field = "skillTree", value = skillTree:setv(skill, skillLevel + 1)}) role:mylog("diner_action", {desc = "skillUp", int1 = skill, int2 = skillLevel + 1}) @@ -683,7 +683,7 @@ function _M.refreshTaskRpc( agent, data ) end if not role:checkItemEnough(cost) then return end - role:costItems(cost, {log = {desc = "dinerReTask"}}) + if not role:costItems(cost, {log = {desc = "dinerReTask"}}) then return 4 end for idx, order in ipairs(orders) do @@ -939,7 +939,7 @@ function _M.entrustRpc(agent , data) if curData.type == 1 then local cost = curData.condition:toNumMap() if not role:checkItemEnough(cost) then return end - role:costItems(cost, {log = {desc = "dinerEntrus", int1 = entrustId}}) + if not role:costItems(cost, {log = {desc = "dinerEntrus", int1 = entrustId}}) then return end elseif curData.type == 2 then -- todo 数据校验 else diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index 8a98193..0cbe140 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -481,7 +481,7 @@ function _M.quickRpc(agent , data) local costCount = table.findMinKeyByIndex(globalCsv.idle_quickproduce_cost, curCount * change, change) if not role:checkItemEnough({[ItemId.Jade] = costCount}) then return 2 end - role:costItems({[ItemId.Jade] = costCount}, {log = {desc = "quickHang", int1 = hangInfo.carbonId}}) + if not role:costItems({[ItemId.Jade] = costCount}, {log = {desc = "quickHang", int1 = hangInfo.carbonId}}) then return 3 end role.dailyData:updateProperty({field = "hangQC", value = curCount}) @@ -579,7 +579,7 @@ function _M.buyBonusCountRpc(agent, data) if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 2 end - role:costItems({[ItemId.Jade] = cost}, {log = {desc = "buyBonusCount", int1 = btype, int2 = count}}) + if not role:costItems({[ItemId.Jade] = cost}, {log = {desc = "buyBonusCount", int1 = btype, int2 = count}}) then return 3 end bonusC["b"] = costCount bonusC["c"] = (bonusC["c"] or 0) - count @@ -910,7 +910,7 @@ function _M.startWorkBattleRpc(agent, data) role:updateProperty({field = "workBattle", value = workBattle}) end if needCount > 0 then - role:costItems({[ticketId] = needCount}, {log = {desc = "workBattle", int1 = id}}) + if not role:costItems({[ticketId] = needCount}, {log = {desc = "workBattle", int1 = id}}) then return 12 end end redisproxy:hincrby(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. bonusData.type]) * 10 + bonusData.type, count * bonusData.target_add) local reward, change = workWinReward(role, bonusData, 3, count, true) @@ -1041,7 +1041,7 @@ function _M.endWorkBattleRpc(agent, data) role:updateProperty({field = "workBattle", value = workBattle}) end if needCount > 0 then - role:costItems({[ticketId] = needCount}, {log = {desc = "workBattle", int1 = id}}) + if not role:costItems({[ticketId] = needCount}, {log = {desc = "workBattle", int1 = id}}) then return 2 end end redisproxy:hincrby(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. bonusData.type]) * 10 + bonusData.type, bonusData.target_add) reward, change = workWinReward(role, bonusData, rewardType) @@ -1101,7 +1101,7 @@ function _M.bagFieldRpc(agent, data) return 2 end role:updateProperty({field = "hangBagLimit", value = curBL + 1}) - role:costItems({[ItemId.Jade] = costD}, {log = {desc = "bagField"}}) + if not role:costItems({[ItemId.Jade] = costD}, {log = {desc = "bagField"}}) then return 3 end SendPacket(actionCodes.Hang_bagFieldRpc, '') return true end diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index b1df09f..358465b 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -51,7 +51,7 @@ function _M.levelUpRpc( agent, data ) local accountLevel = role:getAccountLevel() if level >= accountLevel then return 4 end - role:costItems(cost, {log = {desc = "heroLevelUp", int1 = msg.id, int2 = hero:getProperty("type")}}) + if not role:costItems(cost, {log = {desc = "heroLevelUp", int1 = msg.id, int2 = hero:getProperty("type")}}) then return 5 end local oldAttr = hero:getTotalAttrs() local oldBattleV = hero:getProperty("battleV") @@ -95,7 +95,7 @@ function _M.breakRpc( agent, data ) -- if not role:checkHangPass(pass) then return 4 end --end - role:costItems(cost, {log = {desc = "heroBreak", int1 = msg.id, int2 = hero:getProperty("type")}}) + if not role:costItems(cost, {log = {desc = "heroBreak", int1 = msg.id, int2 = hero:getProperty("type")}}) then return 5 end local oldAttr = hero:getTotalAttrs() hero:updateProperty({field = "breakL", delta = 1}) @@ -145,7 +145,7 @@ function _M.wakeRpc(agent, data) end - role:costItems(cost, {log = {desc = "heroWake", int1 = msg.id, int2 = hero:getProperty("type")}}) + if not role:costItems(cost, {log = {desc = "heroWake", int1 = msg.id, int2 = hero:getProperty("type")}}) then return 8 end local oldAttr = hero:getTotalAttrs() local oldBattleV = hero:getProperty("battleV") @@ -215,7 +215,7 @@ function _M.talentRpc(agent, data) cost = talentData.money:toNumMap() if not role:checkItemEnough(cost) then return 5 end - role:costItems(cost, {log = {desc = "heroTalent", int1 = msg.id, int2 = hero:getProperty("type")}}) + if not role:costItems(cost, {log = {desc = "heroTalent", int1 = msg.id, int2 = hero:getProperty("type")}}) then return 6 end talent = talent:setv(1, curLevel + 1) end curStage = talent:getv(0, 1) @@ -474,7 +474,7 @@ function _M.createHeroRpc(agent, data) if hero:getProperty("type") == heroType then return end end - role:costItems({[heroType] = cost}, {log = {desc = "createHero"}}) + if not role:costItems({[heroType] = cost}, {log = {desc = "createHero"}}) then return end role:award({[heroType + ItemStartId.Hero] = 1}, {log = {desc = "createHero"}}) SendPacket(actionCodes.Hero_createHeroRpc, "") @@ -642,7 +642,7 @@ function _M.createHeroRandomRpc(agent, data) local temp = randomData.gift1:randWeight(true) if not temp or not next(temp) then return 3 end - role:costItems({[itemId] = cost}, {log = {desc = "createHeroRandom"}}) + if not role:costItems({[itemId] = cost}, {log = {desc = "createHeroRandom"}}) then return 4 end local reward, change = role:award({[temp[1]] = 1}, {log = {desc = "createHeroRandom"}}) @@ -688,7 +688,7 @@ function _M.getResetRewardRpc(agent, data) --if pay and not role:costDiamond({count = globalCsv.unit_heroBack_cost or 200, log = {desc = "resetHero", int1 = msg.id}}) then -- return 1 --end - role:costItems(totalCost, {log = {desc = "resetHero", int1 = msg.id}}) + if not role:costItems(totalCost, {log = {desc = "resetHero", int1 = msg.id}}) then return 2 end end local reward = {} @@ -999,7 +999,7 @@ function _M.drawHeroRpc(agent, data) end end - role:costItems(cost, {log = {desc = "drawHero", int1 = btype, int2 = poolId}}) + if not role:costItems(cost, {log = {desc = "drawHero", int1 = btype, int2 = poolId}}) then return 7 end local guideHero = nil if role:getProperty("newerGuide") == "8=1" then @@ -1303,7 +1303,7 @@ function _M.itemComposeRpc(agent, data) cost[k] = v * count end if not role:checkItemEnough(cost) then return 2 end - role:costItems(cost, {log = {desc = "itemCompose", int1 = itemId, int2 = count}}) + if not role:costItems(cost, {log = {desc = "itemCompose", int1 = itemId, int2 = count}}) then return 3 end role:award({[itemId] = count}, {log = {desc = "itemCompose"}}) SendPacket(actionCodes.Hero_itemComposeRpc, "") @@ -1428,7 +1428,7 @@ function _M.stickersConvertRpc(agent, data) local cost = {[itemId] = 1} if not role:checkItemEnough(cost) then return 4 end - role:costItems({[heroType] = cost}, {log = {desc = "heroStickers"}}) + if not role:costItems({[heroType] = cost}, {log = {desc = "heroStickers"}}) then return 5 end local reward, change = role:award({[heroType] = 1}, {log = {desc = "heroStickers"}}) SendPacket(actionCodes.Hero_stickersConvertRpc, MsgPack.pack(role:packReward(reward, change))) diff --git a/src/actions/PvpAction.lua b/src/actions/PvpAction.lua index 129295b..202af19 100644 --- a/src/actions/PvpAction.lua +++ b/src/actions/PvpAction.lua @@ -249,7 +249,7 @@ function _M.buyCountRpc(agent, data) if count + pvpBought > globalCsv["pvp_buy_max"] then return 3 end role.dailyData:updateProperty({field = "pvpBought", value = count + pvpBought}) - role:costItems(cost, {log = {desc = "buyPvpKey"}}) + if not role:costItems(cost, {log = {desc = "buyPvpKey"}}) then return 4 end role:award({[ItemId.PvpKey] = count}, {log = {desc = "buyPvpKey"}}) SendPacket(actionCodes.Pvp_buyCountRpc, '') @@ -331,7 +331,7 @@ function _M.startBattleRpc(agent, data) if pvpFree >= globalCsv.pvp_battle_free_count then local cost = {[ItemId.PvpKey] = 1} if not role:checkItemEnough(cost) then return 5 end - role:costItems(cost, {log = {desc = "startPvp", int1 = 1}}) + if not role:costItems(cost, {log = {desc = "startPvp", int1 = 1}}) then return 6 end else role.dailyData:updateProperty({field = "pvpFree", delta = 1}) end @@ -380,7 +380,7 @@ function _M.endBattleRpc(agent, data) if pvpFree >= globalCsv.pvp_battle_free_count then local cost = {[ItemId.PvpKey] = 1} if not role:checkItemEnough(cost) then return 5 end - role:costItems(cost, {log = {desc = "startPvp", int1 = 1}}) + if not role:costItems(cost, {log = {desc = "startPvp", int1 = 1}}) then return 6 end else role.dailyData:updateProperty({field = "pvpFree", delta = 1}) end @@ -583,7 +583,7 @@ function _M.startBattleHRpc(agent, data) if pvpFreeH >= globalCsv.pvp_battle_free_count_high then local cost = {[ItemId.PvpKey] = globalCsv.pvp_battle_high_cost} if not role:checkItemEnough(cost) then return 5 end - role:costItems(cost, {log = {desc = "startPvp", int1 = 2}}) + if not role:costItems(cost, {log = {desc = "startPvp", int1 = 2}}) then return 6 end else role.dailyData:updateProperty({field = "pvpFreeH", delta = 1}) end @@ -734,7 +734,7 @@ function _M.endBattleHRpc(agent, data) if pvpFreeH >= globalCsv.pvp_battle_free_count_high then local cost = {[ItemId.PvpKey] = globalCsv.pvp_battle_high_cost} if not role:checkItemEnough(cost) then return 5 end - role:costItems(cost, {log = {desc = "startPvp", int1 = 2}}) + if not role:costItems(cost, {log = {desc = "startPvp", int1 = 2}}) then return 6 end else role.dailyData:updateProperty({field = "pvpFreeH", delta = 1}) end @@ -1007,7 +1007,7 @@ function _M.shopBuyRpc(agent, data) if not role:checkItemEnough({[ItemId.PvpCoin] = csvData.cost * count}) then return end - role:costItems({[ItemId.PvpCoin] = csvData.cost * count}, {log = {desc = "pvpShop", int1 = id, int2 = count}}) + if not role:costItems({[ItemId.PvpCoin] = csvData.cost * count}, {log = {desc = "pvpShop", int1 = id, int2 = count}}) then return end if csvData.limit > 0 then role:changeUpdates({{type = "pvpShop", field = id, value = (pvpShop[id] or 0) + count}}) end diff --git a/src/actions/RadioAction.lua b/src/actions/RadioAction.lua index 5f5474b..1b28950 100644 --- a/src/actions/RadioAction.lua +++ b/src/actions/RadioAction.lua @@ -254,7 +254,7 @@ function _M.cancelQuestRpc(agent, data) if remainT > 0 then local cost = math.ceil(remainT / 3600) * globalCsv.crusade_quicken if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 6 end - role:costItems({[ItemId.Jade] = cost}, {log = {desc = "radioQuest", int1 = id}}) + if not role:costItems({[ItemId.Jade] = cost}, {log = {desc = "radioQuest", int1 = id}}) then return 7 end local reward = getCrusadeReward(role, id) if type(reward) == "number" then return reward diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index 8622f8a..da62e83 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -656,7 +656,7 @@ function _M.saleItemRpc(agent, data) }) end - role:costItems(backs, {log = {desc = "saleItem"}}) + if not role:costItems(backs, {log = {desc = "saleItem"}}) then return 4 end local reward, change = role:award(reward, {log = {desc = "saleItem"}}) role:checkTaskEnter("DecoFrag", {count = fragCount}) @@ -696,7 +696,7 @@ function _M.openItemRpc(agent, data) end reward[0] = nil - role:costItems({[itemId] = count}, {log = {desc = "openItem"}}) + if not role:costItems({[itemId] = count}, {log = {desc = "openItem"}}) then return 4 end local change reward, change = role:award(reward, {log = {desc = "openItem", int1 = itemId, int2 = count}}) @@ -753,7 +753,7 @@ function _M.openTimeBoxRpc(agent, data) local cost_pre = globalCsv.box_timeOpen_diamond:toArray(true, "=") local costKey = math.ceil(quick / (cost_pre[1] * 60)) * cost_pre[2] if not role:checkItemEnough({[ItemId.Jade] = costKey}) then return 5 end - role:costItems({[ItemId.Jade] = costKey}, {log = {desc = "openTimeBox", int1 = slot, int2 = oper}}) + if not role:costItems({[ItemId.Jade] = costKey}, {log = {desc = "openTimeBox", int1 = slot, int2 = oper}}) then return 6 end else stopTime = math.min(nowTime,time + globalCsv.box_productLine_time * 3600 + role:getBnousDismantlingMaximum()) end @@ -771,8 +771,8 @@ function _M.openTimeBoxRpc(agent, data) boxL[slot] = {id = itemId, process = (process + stopTime - time) % unitTime, time = nowTime} role:pushMsg({type = "box", slot = slot, time = nowTime + globalCsv.box_productLine_time * 3600 + role:getBnousDismantlingMaximum()}) elseif oper == 3 then -- 开箱子 - local costId = msg.costId - local costs = (msg.costs or ""):toNumMap() + local costId = msg.costId --钥匙id + local costs = (msg.costs or ""):toNumMap() --箱子s if not costId or not csvdb["itemCsv"][costId] or not next(costs) then return 6 end local costIdData = csvdb["itemCsv"][costId] @@ -794,14 +794,14 @@ function _M.openTimeBoxRpc(agent, data) if role:getItemCount(costId) < count then return 8 end if not role:checkItemEnough(costs) then return 9 end - role:costItems({[costId] = count}, {log = {desc = "openTimeBox"}}) + if not role:costItems({[costId] = count}, {log = {desc = "openTimeBox"}}) then return 10 end reward = {} for itemId, value in pairs(costs) do local tempReward = {} local randomData = csvdb["item_randomCsv"][itemId] local itemData = csvdb["itemCsv"][itemId] - role:costItems({[itemId] = value}, {log = {desc = "openTimeBox"}}) + if not role:costItems({[itemId] = value}, {log = {desc = "openTimeBox"}}) then return 11 end for _ = 1, value do for i = 1, 10 do local num = randomData["num" .. tostring(i)] @@ -898,7 +898,7 @@ function _M.openSpeedUpBoxRpc(agent, data) return 6 end - role:costItems({[id] = count}, {log = {desc = "speedUpBox"}}) + if not role:costItems({[id] = count}, {log = {desc = "speedUpBox"}}) then return 7 end end local doubleCoef = role.activity:isOpen("DoubleDrop") and 2 or 1 @@ -974,7 +974,7 @@ function _M.unLockStoryBookRpc(agent, data) local cost = storyBookData.lockItem:toNumMap() if not cost or not next(cost) then return end if not role:checkItemEnough(cost) then return end -- 消耗品不足 - role:costItems(cost, {log = {desc = "unlockStory", int1 = storyId}}) + if not role:costItems(cost, {log = {desc = "unlockStory", int1 = storyId}}) then return end end -- 解锁 @@ -1555,7 +1555,7 @@ function _M.goldBuyRpc(agent, data) end role.dailyData:updateProperty({field = "goldBuyT", value = curT + 1}) - role:costItems({[ItemId.Jade] = costD}, {log = {desc = "goldBuy"}}) + if not role:costItems({[ItemId.Jade] = costD}, {log = {desc = "goldBuy"}}) then return 4 end local reward, change = role:award({[ItemId.Gold] = math.floor(goldC)}, {log = {desc = "goldBuy"}}) SendPacket(actionCodes.Role_goldBuyRpc, MsgPack.pack(role:packReward(reward, change))) return true @@ -1590,7 +1590,7 @@ function _M.diamondConvertRpc(agent, data) role:checkWorldChangePoints({[ItemWorldLine.CostJade]= quan * globalCsv.recruit_cost}) elseif remain == old then else - role:costItems({[ItemId.Jade] = old - remain}, {log = {desc = "convert", short1=oper}}) + if not role:costItems({[ItemId.Jade] = old - remain}, {log = {desc = "convert", short1=oper}}) then return 3 end role:checkWorldChangePoints({[ItemWorldLine.CostJade]= quan * globalCsv.recruit_cost - (old - remain)}) end @@ -1650,7 +1650,7 @@ function _M.useSelectItemRpc(agent, data) if next(reward) then reward, change = role:award(reward, {log = {desc = "openItem", int1 = itemId, int2 = count}}) - role:costItems({[itemId] = count}, {log = {desc = "openItem"}}) + if not role:costItems({[itemId] = count}, {log = {desc = "openItem"}}) then return end end SendPacket(actionCodes.Role_useSelectItemRpc, MsgPack.pack(role:packReward(reward, change))) return true @@ -1721,7 +1721,7 @@ function _M.runeBuyRpc(agent, data) local glodCount = globalCsv.rune_exchange * count if not role:checkItemEnough({[ItemId.Gold] = glodCount}) then return end - role:costItems({[ItemId.Gold] = glodCount}, {log = {desc = "glodConvertRune", int1 = count, int2 = glodCount}}) + if not role:costItems({[ItemId.Gold] = glodCount}, {log = {desc = "glodConvertRune", int1 = count, int2 = glodCount}}) then return end local reward, change = {} reward[ItemId.RuneFragment] = count reward, change = role:award(reward, {log = {desc = "glodConvertRune"}}) @@ -1795,7 +1795,7 @@ function _M.itemConvertSpecialRpc(agent, data) end end - role:costItems({[itemId] = 1}, {log = {desc = "itemConvertSpecial", int1 = itemId, int2 = itemData.type}}) + if not role:costItems({[itemId] = 1}, {log = {desc = "itemConvertSpecial", int1 = itemId, int2 = itemData.type}}) then return 7 end SendPacket(actionCodes.Role_itemConvertSpecialRpc, MsgPack.pack(role:packReward(reward))) return true @@ -1875,7 +1875,7 @@ function _M.itemConvertDevilTicketRpc(agent, data) local cost = {[itemId] = createCost[1] * count} if not role:checkItemEnough(cost) then return 4 end - role:costItems({cost}, {log = {desc = "itemConvertDevilTicket"}}) + if not role:costItems({cost}, {log = {desc = "itemConvertDevilTicket"}}) then return 5 end local reward, change = role:award({[createCost[2]] = count}, {log = {desc = "itemConvertDevilTicket", int1 = itemId, int2 = cost[itemId]}}) SendPacket(actionCodes.Role_itemConvertDevilTicketRpc, MsgPack.pack(role:packReward(reward, change))) diff --git a/src/actions/SeaportAction.lua b/src/actions/SeaportAction.lua index 87e7ea8..ce3f5c0 100644 --- a/src/actions/SeaportAction.lua +++ b/src/actions/SeaportAction.lua @@ -65,7 +65,7 @@ function _M.donateRpc(agent, data) role:updateProperty({field = "seaport", value = seaport}) end - role:costItems({[itemId] = itemCount}, {log = {desc = "seaportDonate", int1 = phase, int2 = id}}) + if not role:costItems({[itemId] = itemCount}, {log = {desc = "seaportDonate", int1 = phase, int2 = id}}) then return 5 end local reward, change = role:award(rewards, {log = {desc = "seaportDonate", int1 = ddata.phase, int2 = ddata.id}}) role:mylog("role_action", {desc = "seaportDonate", int1 = itemId, int2 = itemCount}) @@ -205,7 +205,7 @@ function _M.taskRpc(agent, data) if quick and remainT > 0 then local cost = math.ceil(remainT / 3600) * globalCsv.seaport_task_quick if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 8 end - role:costItems({[ItemId.Jade] = cost}, {log = {desc = "seaportTask", int1 = taskId, int2 = level}}) + if not role:costItems({[ItemId.Jade] = cost}, {log = {desc = "seaportTask", int1 = taskId, int2 = level}}) then return 9 end end local carbonCsv = csvdb["idle_battleCsv"] @@ -286,7 +286,7 @@ function _M.shopRpc(agent, data) if role:getItemCount(sdata.icon) < sdata.cost * count then return 3 end - role:costItems({[sdata.icon] = sdata.cost * count}, {log = {desc = "seaportShop", int1 = id, int2 = count}}) + if not role:costItems({[sdata.icon] = sdata.cost * count}, {log = {desc = "seaportShop", int1 = id, int2 = count}}) then return 4 end local itemReward = sdata.gift:toNumMap() for itemId, value in pairs(itemReward) do diff --git a/src/actions/StoreAction.lua b/src/actions/StoreAction.lua index ceabb36..d07025e 100644 --- a/src/actions/StoreAction.lua +++ b/src/actions/StoreAction.lua @@ -413,7 +413,7 @@ function _M.shopBuyRpc(agent , data) role.storeData:updateProperty({field = "buyR", value = buyRecord}) limitStr = string.format("%s/%s", buyRecord[id], dataSet.limit) end - role:costItems(cost, {log = {desc = desc, int1 = id, int2 = count, long1= dataSet.shop}}) + if not role:costItems(cost, {log = {desc = desc, int1 = id, int2 = count, long1= dataSet.shop}}) then return 5 end local gift = {} for _id, _count in pairs(dataSet.gift:toNumMap()) do diff --git a/src/actions/TowerAction.lua b/src/actions/TowerAction.lua index e32a95a..aa9d004 100644 --- a/src/actions/TowerAction.lua +++ b/src/actions/TowerAction.lua @@ -177,7 +177,7 @@ function _M.bugCountRpc(agent, data) cost[k] = v * needCount end if not role:checkItemEnough(cost) then return end - role:costItems(cost, {log = {desc = "towerCount"}}) + if not role:costItems(cost, {log = {desc = "towerCount"}}) then return end curCount = curCount + needCount end towerInfo.c = curCount diff --git a/src/adv/Adv.lua b/src/adv/Adv.lua index 810b65a..5d71904 100644 --- a/src/adv/Adv.lua +++ b/src/adv/Adv.lua @@ -1179,7 +1179,7 @@ function Adv:cost(item, params, check) self:award(advCost, params) if next(less) then - self.owner:costItems(less, params) + if not self.owner:costItems(less, params) then return false end end return true end diff --git a/src/models/Activity.lua b/src/models/Activity.lua index ac3ccd5..6f939f5 100644 --- a/src/models/Activity.lua +++ b/src/models/Activity.lua @@ -1031,7 +1031,7 @@ function Activity:recycleActItem(actId) end itemStr = itemStr .. k .. "=" .. v end - role:costItems(costs, {log = {desc = "actRecycle"}}) + if not role:costItems(costs, {log = {desc = "actRecycle"}}) then return end role:sendMail(actCfg.recycle_email, nil, gift, {itemStr}) end end diff --git a/src/models/HeroPlugin.lua b/src/models/HeroPlugin.lua index 3136d2b..80d6db4 100644 --- a/src/models/HeroPlugin.lua +++ b/src/models/HeroPlugin.lua @@ -435,7 +435,7 @@ function HeroPlugin.bind(Hero) local cost = unit_starTalent_reset:toNumMap() if not self.owner:checkItemEnough(cost) then return false end - self.owner:costItems(cost, {log = {desc = "heroGenius", int1 = self:getProperty("id"), int2 = self:getProperty("type")}}) + if not self.owner:costItems(cost, {log = {desc = "heroGenius", int1 = self:getProperty("id"), int2 = self:getProperty("type")}}) then return false end return true end diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index f04ac91..95c996d 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -443,6 +443,10 @@ function RolePlugin.bind(Role) function Role:costItems(itemCountT, params) local pms = clone(params or {}) + for _, v in pairs(itemCountT) do + if v <= 0 then return false end + end + if itemCountT[ItemId.Diamond] then --优先扣除钻石 pms.count = itemCountT[ItemId.Diamond] if not self:costDiamond(pms) then diff --git a/src/models/RolePvp.lua b/src/models/RolePvp.lua index ff5c3af..5001a39 100644 --- a/src/models/RolePvp.lua +++ b/src/models/RolePvp.lua @@ -633,7 +633,7 @@ function Role:setCrossServerPvpBet(idx) local ok, result = pcall(skynet.call, pvpd, "lua", "setBet", idx, self:getProperty("id"), costNum) if ok then if result then - self:costItems(cost, {log = {desc = "crossPvpBet", int1 = day}}) + if not self:costItems(cost, {log = {desc = "crossPvpBet", int1 = day}}) then return false, 7 end pvpBet[day] = {idx, cost[ItemId.Gold]} self:setProperty("pvpBet", pvpBet) end -- libgit2 0.21.2