diff --git a/src/GlobalVar.lua b/src/GlobalVar.lua index e182cba..ba283d2 100644 --- a/src/GlobalVar.lua +++ b/src/GlobalVar.lua @@ -280,4 +280,12 @@ HeroQuality = { R = 2, SR = 3, SSR = 4, -} \ No newline at end of file +} + +MailId = { + MonthCard = 201, + SuperMonthCard = 202, + MonthCardEx = 203, + SuperMonthCardEx = 204, + BattleCardAward = 210, +} diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index f3cab31..3dc3e2d 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -186,7 +186,7 @@ actionCodes = { Store_iosRechargeRpc = 557, Store_shopBuyRpc = 558, Store_updateproperty = 559, - Store_getFreeChectRpc = 560, + Store_getFreeChestRpc = 560, Store_getGrowFundRewardRpc = 561, --成长助力奖励 Store_getBattlePassRewardRpc = 562, --赛季卡奖励 diff --git a/src/actions/GmAction.lua b/src/actions/GmAction.lua index 161cab4..14e7346 100644 --- a/src/actions/GmAction.lua +++ b/src/actions/GmAction.lua @@ -516,7 +516,7 @@ function _M.test(role, pms) local id = tonum(pms.pm1, 0) --local hero = require ("actions.HeroAction") --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) - role.storeData:resetStoreReored(21) + role.storeData:onBattleCardReset() return "成功" end diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index 3c56a61..7b4e677 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -25,13 +25,23 @@ local function checkReward(role) local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0) local nowItemTime = math.min(skynet.timex(), hangInfo.endItemTime or 0) - local coinCount = math.max(0, math.floor((nowCoinTime - hangInfo.coinTime) / globalCsv.idle_money_produce_cd)) - hangInfo.coinTime = hangInfo.coinTime + coinCount * globalCsv.idle_money_produce_cd + -- 此次挂机,其中翻倍时长占多少 + local doubleTime = role.activity:getActHangDoubleTime(hangInfo.coinTime, nowCoinTime) + local normalTime = nowCoinTime - hangInfo.coinTime - doubleTime - local itemCount = math.max(0, math.floor((nowItemTime - hangInfo.itemTime) / globalCsv.idle_item_produce_cd)) - hangInfo.itemTime = hangInfo.itemTime + itemCount * globalCsv.idle_item_produce_cd + local coinCount = math.max(0, math.floor((normalTime) / globalCsv.idle_money_produce_cd)) + 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 + 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") + coinCount = coinCount + coinDoubleCount items[ItemId.Gold] = (items[ItemId.Gold] or 0) + coinCount * carbonData.money items[ItemId.Exp] = (items[ItemId.Exp] or 0) + coinCount * carbonData.exp items[ItemId.PlayerExp] = (items[ItemId.PlayerExp] or 0) + coinCount * carbonData.playerExp diff --git a/src/actions/StoreAction.lua b/src/actions/StoreAction.lua index 8883d38..13adae8 100644 --- a/src/actions/StoreAction.lua +++ b/src/actions/StoreAction.lua @@ -304,7 +304,7 @@ function _M.shopBuyRpc(agent , data) return true end -function _M.getFreeCheckRpc(agent, data) +function _M.getFreeChestRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) local id = msg.id @@ -317,12 +317,12 @@ function _M.getFreeCheckRpc(agent, data) if getCount >= config.limit then return 1 end - local reward, _ = role:award(rechargeData.itemFirst, {log = {desc = "freeGift", int1 = id}}) + local reward, _ = role:award(config.itemFirst, {log = {desc = "freeGift", int1 = id}}) rechargeRecord[id] = getCount + 1 role.storeData:updateProperty({field = "payR", value = rechargeRecord}) - SendPacket(actionCodes.Store_getFreeChectRpc, MsgPack.pack({reward = reward})) + SendPacket(actionCodes.Store_getFreeChestRpc, MsgPack.pack({reward = reward})) return true end diff --git a/src/csvdata b/src/csvdata index 1cad049..cec9d59 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit 1cad049d6adc4948e9ff001acc64529e05e8acb6 +Subproject commit cec9d59109c7fb315958587ba44a88eb101bae46 diff --git a/src/models/Activity.lua b/src/models/Activity.lua index 64c56d7..d39ab6e 100644 --- a/src/models/Activity.lua +++ b/src/models/Activity.lua @@ -3,6 +3,7 @@ local string_format = string.format Activity.ActivityType = { Sign = 1, -- 签到 + DoubleDrop = 2, -- 双倍掉落 } @@ -193,5 +194,23 @@ function Activity:checkActivity(notNotify, activityType, ...) end end +-- 获取此次挂机掉落翻倍时长 +function Activity:getActHangDoubleTime(lastTs, nowTs) + local type = "DoubleDrop" + local actId = checkActivityType(type) + local isOpen = self:isOpen(type) + local openTs = self:getProperty("actime")[actId] or 0 + local timeNow = skynet.timex() + lastTs = math.max(lastTs, openTs) + if isOpen then + if nowTs > openTs then + return nowTs - lastTs + else + return 0 + end + end + return 0 +end + -return Activity \ No newline at end of file +return Activity diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index 3ac1b74..60ab149 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -1400,9 +1400,10 @@ function RolePlugin.bind(Role) red:hget(string.format(R_EMAIL_ITEM, roleId, id), "status") end end) + + self.SendMailFlag = false for index, id in ipairs(emailIds) do if tonumber(redret[index]) == 0 then - self.SendMailFlag = false return true end end @@ -1569,7 +1570,7 @@ function RolePlugin.bind(Role) end if diamondCount > 0 then - reward[Itemid.Diamond] = (reward[Itemid.Diamond] or 0) + diamondCount + reward[ItemId.Diamond] = (reward[ItemId.Diamond] or 0) + diamondCount end -- 累充 @@ -1589,7 +1590,7 @@ function RolePlugin.bind(Role) tgift[one[1]] = (tgift[one[1]] or 0) + one[2] end else - tgift = gift + tgift = reward or {} end local gift = "" for k, v in pairs(tgift) do diff --git a/src/models/Store.lua b/src/models/Store.lua index a8f3dfd..792359e 100644 --- a/src/models/Store.lua +++ b/src/models/Store.lua @@ -60,7 +60,8 @@ end -- 发送月卡邮件 function Store:sendMonthCardEmail() local timeNow = skynet.timex() - local tabs = {{ex="monthCardEx", t="getMailT1", mail=201, alert=203}, {ex="smonthCardEx", t="getMailT2", mail=202, alert=204}} + local tabs = {{ex="monthCardEx", t="getMailT1", mail=MailId.MonthCard, alert=MailId.MonthCardEx}, + {ex="smonthCardEx", t="getMailT2", mail=MailId.SuperMonthCard, alert=MailId.SuperMonthCardEx}} for _, v in ipairs(tabs) do local ex = self:getProperty(v.ex) local ts = self:getProperty(v.t) or 0 @@ -200,12 +201,10 @@ end -- 赛季卡重置 需要把未能领取的奖励通过邮件发送 function Store:onBattleCardReset() - local gift = "" + local gift = {} local function concatGift(data) - if gift == "" then - gift = data - else - gift = gift .. " " .. data + for key, v in pairs(data:toNumMap()) do + gift[key] = (gift[key] or 0) + v end end local battleCardFlag = self:getProperty("battleCard") @@ -229,10 +228,9 @@ function Store:onBattleCardReset() end end end - self.owner:sendMail(210, nil, gift) + self.owner:sendMail(MailId.BattleCardAward, nil, gift) -- 计算剩余奖励 self:updateProperty({field = "battleCard", value=0}) - self:updateProperty({field = "battleCardR", value=""}) self:updateProperty({field = "battleFR", value=""}) self:updateProperty({field = "battleLR", value=""}) self.owner:updateProperty({field = "battlePoint", value=0}) -- libgit2 0.21.2