Commit 706b517e7e0bfbadbc68a9ee00ccb5a1ef6e569e
1 parent
fb3d084d
翻倍掉落活动,商城免费宝箱
Showing
9 changed files
with
59 additions
and
23 deletions
 
Show diff stats
src/GlobalVar.lua
| @@ -280,4 +280,12 @@ HeroQuality = { | @@ -280,4 +280,12 @@ HeroQuality = { | ||
| 280 | R = 2, | 280 | R = 2, | 
| 281 | SR = 3, | 281 | SR = 3, | 
| 282 | SSR = 4, | 282 | SSR = 4, | 
| 283 | -} | ||
| 284 | \ No newline at end of file | 283 | \ No newline at end of file | 
| 284 | +} | ||
| 285 | + | ||
| 286 | +MailId = { | ||
| 287 | + MonthCard = 201, | ||
| 288 | + SuperMonthCard = 202, | ||
| 289 | + MonthCardEx = 203, | ||
| 290 | + SuperMonthCardEx = 204, | ||
| 291 | + BattleCardAward = 210, | ||
| 292 | +} | 
src/ProtocolCode.lua
| @@ -186,7 +186,7 @@ actionCodes = { | @@ -186,7 +186,7 @@ actionCodes = { | ||
| 186 | Store_iosRechargeRpc = 557, | 186 | Store_iosRechargeRpc = 557, | 
| 187 | Store_shopBuyRpc = 558, | 187 | Store_shopBuyRpc = 558, | 
| 188 | Store_updateproperty = 559, | 188 | Store_updateproperty = 559, | 
| 189 | - Store_getFreeChectRpc = 560, | 189 | + Store_getFreeChestRpc = 560, | 
| 190 | Store_getGrowFundRewardRpc = 561, --成长助力奖励 | 190 | Store_getGrowFundRewardRpc = 561, --成长助力奖励 | 
| 191 | Store_getBattlePassRewardRpc = 562, --赛季卡奖励 | 191 | Store_getBattlePassRewardRpc = 562, --赛季卡奖励 | 
| 192 | 192 | 
src/actions/GmAction.lua
| @@ -516,7 +516,7 @@ function _M.test(role, pms) | @@ -516,7 +516,7 @@ function _M.test(role, pms) | ||
| 516 | local id = tonum(pms.pm1, 0) | 516 | local id = tonum(pms.pm1, 0) | 
| 517 | --local hero = require ("actions.HeroAction") | 517 | --local hero = require ("actions.HeroAction") | 
| 518 | --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) | 518 | --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) | 
| 519 | - role.storeData:resetStoreReored(21) | 519 | + role.storeData:onBattleCardReset() | 
| 520 | return "成功" | 520 | return "成功" | 
| 521 | end | 521 | end | 
| 522 | 522 | 
src/actions/HangAction.lua
| @@ -25,13 +25,23 @@ local function checkReward(role) | @@ -25,13 +25,23 @@ local function checkReward(role) | ||
| 25 | local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0) | 25 | local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0) | 
| 26 | local nowItemTime = math.min(skynet.timex(), hangInfo.endItemTime or 0) | 26 | local nowItemTime = math.min(skynet.timex(), hangInfo.endItemTime or 0) | 
| 27 | 27 | ||
| 28 | - local coinCount = math.max(0, math.floor((nowCoinTime - hangInfo.coinTime) / globalCsv.idle_money_produce_cd)) | ||
| 29 | - hangInfo.coinTime = hangInfo.coinTime + coinCount * globalCsv.idle_money_produce_cd | 28 | + -- 此次挂机,其中翻倍时长占多少 | 
| 29 | + local doubleTime = role.activity:getActHangDoubleTime(hangInfo.coinTime, nowCoinTime) | ||
| 30 | + local normalTime = nowCoinTime - hangInfo.coinTime - doubleTime | ||
| 30 | 31 | ||
| 31 | - local itemCount = math.max(0, math.floor((nowItemTime - hangInfo.itemTime) / globalCsv.idle_item_produce_cd)) | ||
| 32 | - hangInfo.itemTime = hangInfo.itemTime + itemCount * globalCsv.idle_item_produce_cd | 32 | + local coinCount = math.max(0, math.floor((normalTime) / globalCsv.idle_money_produce_cd)) | 
| 33 | + local coinDoubleCount = math.max(0, math.floor((doubleTime) / globalCsv.idle_money_produce_cd)) * 2 | ||
| 34 | + hangInfo.coinTime = nowCoinTime | ||
| 35 | + | ||
| 36 | + doubleTime = role.activity:getActHangDoubleTime(hangInfo.itemTime, nowitemTime) | ||
| 37 | + normalTime = nowItemTime - hangInfo.coinTime - doubleTime | ||
| 38 | + local itemCount = math.max(0, math.floor((normalTime) / globalCsv.idle_item_produce_cd)) | ||
| 39 | + local itemDoubleCount = math.max(0, math.floor((doubleTime) / globalCsv.idle_item_produce_cd)) | ||
| 40 | + itemCount = itemCount + itemDoubleCount | ||
| 41 | + hangInfo.itemTime = nowItemTime | ||
| 33 | 42 | ||
| 34 | local items = role:getProperty("hangBag") | 43 | local items = role:getProperty("hangBag") | 
| 44 | + coinCount = coinCount + coinDoubleCount | ||
| 35 | items[ItemId.Gold] = (items[ItemId.Gold] or 0) + coinCount * carbonData.money | 45 | items[ItemId.Gold] = (items[ItemId.Gold] or 0) + coinCount * carbonData.money | 
| 36 | items[ItemId.Exp] = (items[ItemId.Exp] or 0) + coinCount * carbonData.exp | 46 | items[ItemId.Exp] = (items[ItemId.Exp] or 0) + coinCount * carbonData.exp | 
| 37 | items[ItemId.PlayerExp] = (items[ItemId.PlayerExp] or 0) + coinCount * carbonData.playerExp | 47 | items[ItemId.PlayerExp] = (items[ItemId.PlayerExp] or 0) + coinCount * carbonData.playerExp | 
src/actions/StoreAction.lua
| @@ -304,7 +304,7 @@ function _M.shopBuyRpc(agent , data) | @@ -304,7 +304,7 @@ function _M.shopBuyRpc(agent , data) | ||
| 304 | return true | 304 | return true | 
| 305 | end | 305 | end | 
| 306 | 306 | ||
| 307 | -function _M.getFreeCheckRpc(agent, data) | 307 | +function _M.getFreeChestRpc(agent, data) | 
| 308 | local role = agent.role | 308 | local role = agent.role | 
| 309 | local msg = MsgPack.unpack(data) | 309 | local msg = MsgPack.unpack(data) | 
| 310 | local id = msg.id | 310 | local id = msg.id | 
| @@ -317,12 +317,12 @@ function _M.getFreeCheckRpc(agent, data) | @@ -317,12 +317,12 @@ function _M.getFreeCheckRpc(agent, data) | ||
| 317 | if getCount >= config.limit then | 317 | if getCount >= config.limit then | 
| 318 | return 1 | 318 | return 1 | 
| 319 | end | 319 | end | 
| 320 | - local reward, _ = role:award(rechargeData.itemFirst, {log = {desc = "freeGift", int1 = id}}) | 320 | + local reward, _ = role:award(config.itemFirst, {log = {desc = "freeGift", int1 = id}}) | 
| 321 | 321 | ||
| 322 | rechargeRecord[id] = getCount + 1 | 322 | rechargeRecord[id] = getCount + 1 | 
| 323 | role.storeData:updateProperty({field = "payR", value = rechargeRecord}) | 323 | role.storeData:updateProperty({field = "payR", value = rechargeRecord}) | 
| 324 | 324 | ||
| 325 | - SendPacket(actionCodes.Store_getFreeChectRpc, MsgPack.pack({reward = reward})) | 325 | + SendPacket(actionCodes.Store_getFreeChestRpc, MsgPack.pack({reward = reward})) | 
| 326 | return true | 326 | return true | 
| 327 | end | 327 | end | 
| 328 | 328 | 
src/models/Activity.lua
| @@ -3,6 +3,7 @@ local string_format = string.format | @@ -3,6 +3,7 @@ local string_format = string.format | ||
| 3 | 3 | ||
| 4 | Activity.ActivityType = { | 4 | Activity.ActivityType = { | 
| 5 | Sign = 1, -- 签到 | 5 | Sign = 1, -- 签到 | 
| 6 | + DoubleDrop = 2, -- 双倍掉落 | ||
| 6 | } | 7 | } | 
| 7 | 8 | ||
| 8 | 9 | ||
| @@ -193,5 +194,23 @@ function Activity:checkActivity(notNotify, activityType, ...) | @@ -193,5 +194,23 @@ function Activity:checkActivity(notNotify, activityType, ...) | ||
| 193 | end | 194 | end | 
| 194 | end | 195 | end | 
| 195 | 196 | ||
| 197 | +-- 获取此次挂机掉落翻倍时长 | ||
| 198 | +function Activity:getActHangDoubleTime(lastTs, nowTs) | ||
| 199 | + local type = "DoubleDrop" | ||
| 200 | + local actId = checkActivityType(type) | ||
| 201 | + local isOpen = self:isOpen(type) | ||
| 202 | + local openTs = self:getProperty("actime")[actId] or 0 | ||
| 203 | + local timeNow = skynet.timex() | ||
| 204 | + lastTs = math.max(lastTs, openTs) | ||
| 205 | + if isOpen then | ||
| 206 | + if nowTs > openTs then | ||
| 207 | + return nowTs - lastTs | ||
| 208 | + else | ||
| 209 | + return 0 | ||
| 210 | + end | ||
| 211 | + end | ||
| 212 | + return 0 | ||
| 213 | +end | ||
| 214 | + | ||
| 196 | 215 | ||
| 197 | -return Activity | ||
| 198 | \ No newline at end of file | 216 | \ No newline at end of file | 
| 217 | +return Activity | 
src/models/RolePlugin.lua
| @@ -1400,9 +1400,10 @@ function RolePlugin.bind(Role) | @@ -1400,9 +1400,10 @@ function RolePlugin.bind(Role) | ||
| 1400 | red:hget(string.format(R_EMAIL_ITEM, roleId, id), "status") | 1400 | red:hget(string.format(R_EMAIL_ITEM, roleId, id), "status") | 
| 1401 | end | 1401 | end | 
| 1402 | end) | 1402 | end) | 
| 1403 | + | ||
| 1404 | + self.SendMailFlag = false | ||
| 1403 | for index, id in ipairs(emailIds) do | 1405 | for index, id in ipairs(emailIds) do | 
| 1404 | if tonumber(redret[index]) == 0 then | 1406 | if tonumber(redret[index]) == 0 then | 
| 1405 | - self.SendMailFlag = false | ||
| 1406 | return true | 1407 | return true | 
| 1407 | end | 1408 | end | 
| 1408 | end | 1409 | end | 
| @@ -1569,7 +1570,7 @@ function RolePlugin.bind(Role) | @@ -1569,7 +1570,7 @@ function RolePlugin.bind(Role) | ||
| 1569 | end | 1570 | end | 
| 1570 | 1571 | ||
| 1571 | if diamondCount > 0 then | 1572 | if diamondCount > 0 then | 
| 1572 | - reward[Itemid.Diamond] = (reward[Itemid.Diamond] or 0) + diamondCount | 1573 | + reward[ItemId.Diamond] = (reward[ItemId.Diamond] or 0) + diamondCount | 
| 1573 | end | 1574 | end | 
| 1574 | 1575 | ||
| 1575 | -- 累充 | 1576 | -- 累充 | 
| @@ -1589,7 +1590,7 @@ function RolePlugin.bind(Role) | @@ -1589,7 +1590,7 @@ function RolePlugin.bind(Role) | ||
| 1589 | tgift[one[1]] = (tgift[one[1]] or 0) + one[2] | 1590 | tgift[one[1]] = (tgift[one[1]] or 0) + one[2] | 
| 1590 | end | 1591 | end | 
| 1591 | else | 1592 | else | 
| 1592 | - tgift = gift | 1593 | + tgift = reward or {} | 
| 1593 | end | 1594 | end | 
| 1594 | local gift = "" | 1595 | local gift = "" | 
| 1595 | for k, v in pairs(tgift) do | 1596 | for k, v in pairs(tgift) do | 
src/models/Store.lua
| @@ -60,7 +60,8 @@ end | @@ -60,7 +60,8 @@ end | ||
| 60 | -- 发送月卡邮件 | 60 | -- 发送月卡邮件 | 
| 61 | function Store:sendMonthCardEmail() | 61 | function Store:sendMonthCardEmail() | 
| 62 | local timeNow = skynet.timex() | 62 | local timeNow = skynet.timex() | 
| 63 | - local tabs = {{ex="monthCardEx", t="getMailT1", mail=201, alert=203}, {ex="smonthCardEx", t="getMailT2", mail=202, alert=204}} | 63 | + local tabs = {{ex="monthCardEx", t="getMailT1", mail=MailId.MonthCard, alert=MailId.MonthCardEx}, | 
| 64 | + {ex="smonthCardEx", t="getMailT2", mail=MailId.SuperMonthCard, alert=MailId.SuperMonthCardEx}} | ||
| 64 | for _, v in ipairs(tabs) do | 65 | for _, v in ipairs(tabs) do | 
| 65 | local ex = self:getProperty(v.ex) | 66 | local ex = self:getProperty(v.ex) | 
| 66 | local ts = self:getProperty(v.t) or 0 | 67 | local ts = self:getProperty(v.t) or 0 | 
| @@ -200,12 +201,10 @@ end | @@ -200,12 +201,10 @@ end | ||
| 200 | 201 | ||
| 201 | -- 赛季卡重置 需要把未能领取的奖励通过邮件发送 | 202 | -- 赛季卡重置 需要把未能领取的奖励通过邮件发送 | 
| 202 | function Store:onBattleCardReset() | 203 | function Store:onBattleCardReset() | 
| 203 | - local gift = "" | 204 | + local gift = {} | 
| 204 | local function concatGift(data) | 205 | local function concatGift(data) | 
| 205 | - if gift == "" then | ||
| 206 | - gift = data | ||
| 207 | - else | ||
| 208 | - gift = gift .. " " .. data | 206 | + for key, v in pairs(data:toNumMap()) do | 
| 207 | + gift[key] = (gift[key] or 0) + v | ||
| 209 | end | 208 | end | 
| 210 | end | 209 | end | 
| 211 | local battleCardFlag = self:getProperty("battleCard") | 210 | local battleCardFlag = self:getProperty("battleCard") | 
| @@ -229,10 +228,9 @@ function Store:onBattleCardReset() | @@ -229,10 +228,9 @@ function Store:onBattleCardReset() | ||
| 229 | end | 228 | end | 
| 230 | end | 229 | end | 
| 231 | end | 230 | end | 
| 232 | - self.owner:sendMail(210, nil, gift) | 231 | + self.owner:sendMail(MailId.BattleCardAward, nil, gift) | 
| 233 | -- 计算剩余奖励 | 232 | -- 计算剩余奖励 | 
| 234 | self:updateProperty({field = "battleCard", value=0}) | 233 | self:updateProperty({field = "battleCard", value=0}) | 
| 235 | - self:updateProperty({field = "battleCardR", value=""}) | ||
| 236 | self:updateProperty({field = "battleFR", value=""}) | 234 | self:updateProperty({field = "battleFR", value=""}) | 
| 237 | self:updateProperty({field = "battleLR", value=""}) | 235 | self:updateProperty({field = "battleLR", value=""}) | 
| 238 | self.owner:updateProperty({field = "battlePoint", value=0}) | 236 | self.owner:updateProperty({field = "battlePoint", value=0}) |