diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index 7b4e677..9ddbc3c 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -19,7 +19,7 @@ local _M = {} local function checkReward(role) local hangInfo = role:getProperty("hangInfo") if not hangInfo.carbonId or not hangInfo.coinTime or not hangInfo.itemTime then - return + return false end local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0) @@ -33,11 +33,8 @@ local function checkReward(role) local coinDoubleCount = math.max(0, math.floor((doubleTime) / globalCsv.idle_money_produce_cd)) * 2 hangInfo.coinTime = nowCoinTime - doubleTime = role.activity:getActHangDoubleTime(hangInfo.itemTime, nowitemTime) - normalTime = nowItemTime - hangInfo.coinTime - doubleTime + normalTime = nowItemTime - hangInfo.itemTime local itemCount = math.max(0, math.floor((normalTime) / globalCsv.idle_item_produce_cd)) - local itemDoubleCount = math.max(0, math.floor((doubleTime) / globalCsv.idle_item_produce_cd)) - itemCount = itemCount + itemDoubleCount hangInfo.itemTime = nowItemTime local items = role:getProperty("hangBag") @@ -71,34 +68,42 @@ local function checkReward(role) local tempPool = clone(pool) while #tempPool > 0 do local idx = math.randWeight(tempPool, 3) - local cur = pool[idx] - if (items[cur[1]] and math.ceil((items[cur[1]] + cur[2]) / globalCsv.idle_field_limit) > math.ceil(items[cur[1]] / globalCsv.idle_field_limit)) - or not items[cur[1]] then --要占用新栏位的情况 - local addFC - if not items[cur[1]] then - addFC = math.ceil(cur[2] / globalCsv.idle_field_limit) - else - local frontC = items[cur[1]] % globalCsv.idle_field_limit - if frontC == 0 then - frontC = globalCsv.idle_field_limit - end - addFC = math.ceil((cur[2] - (globalCsv.idle_field_limit - frontC)) / globalCsv.idle_field_limit) + local cur = clone(pool[idx]) + if cur[1] ~= 1 then -- 轮空 id + if cur[1] == ItemId.BreakCost and doubleTime > 0 then + cur[2] = cur[2] * 2 end - if curFC + addFC <= selfFC then - curFC = curFC + addFC - items[cur[1]] = (items[cur[1]] or 0) + cur[2] - break + if (items[cur[1]] and math.ceil((items[cur[1]] + cur[2]) / globalCsv.idle_field_limit) > math.ceil(items[cur[1]] / globalCsv.idle_field_limit)) + or not items[cur[1]] then --要占用新栏位的情况 + local addFC + if not items[cur[1]] then + addFC = math.ceil(cur[2] / globalCsv.idle_field_limit) + else + local frontC = items[cur[1]] % globalCsv.idle_field_limit + if frontC == 0 then + frontC = globalCsv.idle_field_limit + end + addFC = math.ceil((cur[2] - (globalCsv.idle_field_limit - frontC)) / globalCsv.idle_field_limit) + end + if curFC + addFC <= selfFC then + curFC = curFC + addFC + items[cur[1]] = (items[cur[1]] or 0) + cur[2] + break + else + --加不了,换别的东西 + table.remove(tempPool, idx) + end else - --加不了,换别的东西 - table.remove(tempPool, idx) + items[cur[1]] = items[cur[1]] + cur[2] + break end else - items[cur[1]] = items[cur[1]] + cur[2] break end end curIC = curIC + 1 end + for i = 1, itemCount do randomItem() end @@ -106,6 +111,8 @@ local function checkReward(role) if coinCount > 0 or itemCount > 0 then return true end + + return false end --开始一个新的关卡 diff --git a/src/models/Activity.lua b/src/models/Activity.lua index b05621b..9d072f0 100644 --- a/src/models/Activity.lua +++ b/src/models/Activity.lua @@ -4,10 +4,10 @@ local string_format = string.format Activity.ActivityType = { Sign = 1, -- 签到 DoubleDrop = 2, -- 双倍掉落 - DrawHero = 3, --抽卡周 - FoodSell = 4, --贩卖周 - OpenBox = 5, --拆解周 - AdvDraw = 6, --拾荒抽周 + FoodSell = 3, --贩卖周 料理 + DrawHero = 4, --抽卡周 招募 + AdvDraw = 5, --拾荒抽周 资助 + OpenBox = 6, --拆解周 时钟箱 } @@ -346,7 +346,7 @@ function Activity:getActHangDoubleTime(lastTs, nowTs) local timeNow = skynet.timex() lastTs = math.max(lastTs, openTs) if isOpen then - if nowTs > openTs then + if nowTs > openTs and nowTs > lastTs then return nowTs - lastTs else return 0 -- libgit2 0.21.2