diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index 96959f3..fd6a226 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -22,6 +22,7 @@ local function checkReward(role) return false end local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] + local expCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0) local nowItemTime = math.min(skynet.timex(), hangInfo.endItemTime or 0) @@ -39,9 +40,9 @@ local function checkReward(role) local items = role:getProperty("hangBag") coinCount = coinCount + coinDoubleCount - items[ItemId.Gold] = math.floor((items[ItemId.Gold] or 0) + coinCount * carbonData.money) - items[ItemId.Exp] = math.floor((items[ItemId.Exp] or 0) + coinCount * carbonData.exp) - items[ItemId.PlayerExp] = math.floor((items[ItemId.PlayerExp] or 0) + coinCount * carbonData.playerExp) + items[ItemId.Gold] = math.floor((items[ItemId.Gold] or 0) + coinCount * expCarbonData.money) + items[ItemId.Exp] = math.floor((items[ItemId.Exp] or 0) + coinCount * expCarbonData.exp) + items[ItemId.PlayerExp] = math.floor((items[ItemId.PlayerExp] or 0) + coinCount * expCarbonData.playerExp) local pool = {} for _, temp in pairs(carbonData.item:toArray()) do @@ -139,6 +140,7 @@ function _M.startRpc( agent, data ) local hangInfo = role:getProperty("hangInfo") local isNew = not hangInfo.carbonId hangInfo.carbonId = carbonId + hangInfo.expCarbonId = isNew and carbonId or hangInfo.expCarbonId local nowTime = skynet.timex() if isNew then hangInfo.coinTime = nowTime @@ -193,7 +195,7 @@ function _M.startBattleRpc(agent, data) return 1 end - local hangInfo = role:getProperty("hangInfo") + local hangInfo = role:getProperty("hangInfo") or {} if curData.main ~= 1 then if carbonId ~= hangInfo.carbonId then return 2 @@ -214,7 +216,7 @@ end function _M.endBattleRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) - local hangInfo = role:getProperty("hangInfo") + local hangInfo = role:getProperty("hangInfo") or {} if not msg.key or msg.key ~= _BattleKey then SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({errorCode = 1})) return true @@ -225,6 +227,7 @@ function _M.endBattleRpc(agent, data) if not carbonData then return 2 end + if carbonData.main ~= 1 then if carbonId ~= hangInfo.carbonId then return 3 @@ -273,8 +276,8 @@ function _M.endBattleRpc(agent, data) end local nextCarbonId = role:getNextCarbonId(carbonId) -- 设置挂机关卡 - if isWin and hangInfo.carbonId < nextCarbonId then - hangInfo.carbonId = nextCarbonId + if isWin and (hangInfo.carbonId or 0) < nextCarbonId then + hangInfo.expCarbonId = nextCarbonId local cfg = csvdb["idle_battleCsv"][nextCarbonId] if cfg then hangInfo.bossTime = skynet.timex() + cfg.idle_time @@ -382,6 +385,7 @@ function _M.quickRpc(agent , data) local hangInfo = role:getProperty("hangInfo") if not hangInfo.carbonId then return end local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] + local expCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] local curCount = role.dailyData:getProperty("hangQC") + 1 local costs = globalCsv.idle_quickproduce_cost:toArray(true, "=") @@ -398,9 +402,9 @@ function _M.quickRpc(agent , data) local coinCount = math.floor(time / globalCsv.idle_money_produce_cd) local itemCount = math.floor(time / globalCsv.idle_item_produce_cd) - reward[ItemId.Gold] = math.floor((reward[ItemId.Gold] or 0) + coinCount * carbonData.money) - reward[ItemId.Exp] = math.floor((reward[ItemId.Exp] or 0) + coinCount * carbonData.exp) - reward[ItemId.PlayerExp] = math.floor((reward[ItemId.PlayerExp] or 0) + coinCount * carbonData.playerExp) + reward[ItemId.Gold] = math.floor((reward[ItemId.Gold] or 0) + coinCount * expCarbonData.money) + reward[ItemId.Exp] = math.floor((reward[ItemId.Exp] or 0) + coinCount * expCarbonData.exp) + reward[ItemId.PlayerExp] = math.floor((reward[ItemId.PlayerExp] or 0) + coinCount * expCarbonData.playerExp) local pool = {} for _, temp in pairs(carbonData.item:toArray()) do diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index a4c2171..2784235 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -734,6 +734,13 @@ function _M.drawHeroRpc(agent, data) if btype ~= 1 then subType = 1 end + + if btype == 1 then + -- 判断定向卡池活动开启 + if not role.activity:isOpen("RaceDraw") then + return + end + end local buildTypeData = csvdb["build_typeCsv"][btype] if not buildTypeData then return 2 end diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index a1be9c6..ef6491d 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -615,52 +615,57 @@ end function _M.openSpeedUpBoxRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) - - local id = msg.id - local count = msg.count - local itemData = csvdb["itemCsv"][id] - if not itemData or itemData.type ~= ItemType.SpeedBox then return end - - if math.illegalNum(count, 1, role:getItemCount(id)) then return end - local useType, hour = table.unpack(itemData.use_effect:toArray(true, "=")) - local time = hour * 60 * 60 + local itemInfo = msg.itemInfo local reward = {} - if useType == 1 then -- 挂机齿轮 - local hangInfo = role:getProperty("hangInfo") - if not hangInfo.carbonId then - return - end - local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] - reward[ItemId.Gold] = math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.money * count - elseif useType == 2 then -- 挂机经验 - local hangInfo = role:getProperty("hangInfo") - if not hangInfo.carbonId then - return - end - local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] - reward[ItemId.Exp] = math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.exp * count - elseif useType == 3 then -- 食材商人收入 - local buildType = 6 - local level = role.dinerData:getProperty("buildL"):getv(buildType, 1) - local buildingData = csvdb["diner_buildingCsv"][buildType][level] - if not buildingData then - return 1 - end - local gfood = role.dinerData:getProperty("gfood") - if not next(gfood) then return end - for k , v in pairs(gfood) do - local itemId = v.id - local speed = globalCsv.diner_get_food_speed[csvdb["itemCsv"][itemId].quality] * buildingData.speed / 100 - reward[itemId] = math.floor(time / speed) * count + for i = 1, #itemInfo do + local pair = itemInfo[i] + local id = pair[1] + local count = pair[2] + local itemData = csvdb["itemCsv"][id] + if not itemData or itemData.type ~= ItemType.SpeedBox then return end + + if math.illegalNum(count, 1, role:getItemCount(id)) then return 1 end + local useType, hour = table.unpack(itemData.use_effect:toArray(true, "=")) + local time = hour * 60 * 60 + + if useType == 1 then -- 挂机齿轮 + local hangInfo = role:getProperty("hangInfo") + if not hangInfo.expCarbonId then + return 2 + end + local carbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] + reward[ItemId.Gold] = (reward[ItemId.Gold] or 0) + math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.money * count + elseif useType == 2 then -- 挂机经验 + local hangInfo = role:getProperty("hangInfo") + if not hangInfo.expCarbonId then + return 3 + end + local carbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] + reward[ItemId.Exp] = (reward[ItemId.Exp] or 0) + math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.exp * count + elseif useType == 3 then -- 食材商人收入 + local buildType = 6 + local level = role.dinerData:getProperty("buildL"):getv(buildType, 1) + local buildingData = csvdb["diner_buildingCsv"][buildType][level] + if not buildingData then + return 4 + end + local gfood = role.dinerData:getProperty("gfood") + if not next(gfood) then return 5 end + for k , v in pairs(gfood) do + local itemId = v.id + local speed = globalCsv.diner_get_food_speed[csvdb["itemCsv"][itemId].quality] * buildingData.speed / 100 + reward[itemId] = (reward[itemId] or 0) + math.floor(time / speed) * count + end + else + return 6 end - else - return + + role:costItems({[id] = count}, {log = {desc = "speedUpBox"}}) end - role:costItems({[id] = count}, {log = {desc = "speedUpBox"}}) local change - reward, change = role:award(reward, {log = {desc = "speedUpBox"}, int1 = id, int2 = count}) + reward, change = role:award(reward, {log = {desc = "speedUpBox"}}) SendPacket(actionCodes.Role_openSpeedUpBoxRpc, MsgPack.pack(role:packReward(reward, change))) return true diff --git a/src/models/Activity.lua b/src/models/Activity.lua index 712d1eb..6630e3d 100644 --- a/src/models/Activity.lua +++ b/src/models/Activity.lua @@ -18,6 +18,7 @@ Activity.ActivityType = { DrawHero = 12, --抽卡周 招募 AdvDraw = 13, --拾荒抽周 资助 OpenBox = 14, --拆解周 时钟箱 + RaceDraw = 15, -- 定向招募活动 } diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index f9cfb2a..d2c3239 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -1691,13 +1691,9 @@ function RolePlugin.bind(Role) if not csvdb["idle_battleCsv"][nextId] then nextId = makeCarbonId(diff, chapterId + 1, 1) if not csvdb["idle_battleCsv"][nextId] then - if diff + 1 == 3 then + nextId = makeCarbonId(diff + 1, 1, 1) + if not csvdb["idle_battleCsv"][nextId] then nextId = 0 - else - nextId = makeCarbonId(diff + 1, 1, 1) - if not csvdb["idle_battleCsv"][nextId] then - nextId = 0 - end end end end -- libgit2 0.21.2