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 | 280 | R = 2, |
281 | 281 | SR = 3, |
282 | 282 | SSR = 4, |
283 | -} | |
284 | 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 | 186 | Store_iosRechargeRpc = 557, |
187 | 187 | Store_shopBuyRpc = 558, |
188 | 188 | Store_updateproperty = 559, |
189 | - Store_getFreeChectRpc = 560, | |
189 | + Store_getFreeChestRpc = 560, | |
190 | 190 | Store_getGrowFundRewardRpc = 561, --成长助力奖励 |
191 | 191 | Store_getBattlePassRewardRpc = 562, --赛季卡奖励 |
192 | 192 | ... | ... |
src/actions/GmAction.lua
... | ... | @@ -516,7 +516,7 @@ function _M.test(role, pms) |
516 | 516 | local id = tonum(pms.pm1, 0) |
517 | 517 | --local hero = require ("actions.HeroAction") |
518 | 518 | --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) |
519 | - role.storeData:resetStoreReored(21) | |
519 | + role.storeData:onBattleCardReset() | |
520 | 520 | return "成功" |
521 | 521 | end |
522 | 522 | ... | ... |
src/actions/HangAction.lua
... | ... | @@ -25,13 +25,23 @@ local function checkReward(role) |
25 | 25 | local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0) |
26 | 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 | 43 | local items = role:getProperty("hangBag") |
44 | + coinCount = coinCount + coinDoubleCount | |
35 | 45 | items[ItemId.Gold] = (items[ItemId.Gold] or 0) + coinCount * carbonData.money |
36 | 46 | items[ItemId.Exp] = (items[ItemId.Exp] or 0) + coinCount * carbonData.exp |
37 | 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 | 304 | return true |
305 | 305 | end |
306 | 306 | |
307 | -function _M.getFreeCheckRpc(agent, data) | |
307 | +function _M.getFreeChestRpc(agent, data) | |
308 | 308 | local role = agent.role |
309 | 309 | local msg = MsgPack.unpack(data) |
310 | 310 | local id = msg.id |
... | ... | @@ -317,12 +317,12 @@ function _M.getFreeCheckRpc(agent, data) |
317 | 317 | if getCount >= config.limit then |
318 | 318 | return 1 |
319 | 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 | 322 | rechargeRecord[id] = getCount + 1 |
323 | 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 | 326 | return true |
327 | 327 | end |
328 | 328 | ... | ... |
src/models/Activity.lua
... | ... | @@ -3,6 +3,7 @@ local string_format = string.format |
3 | 3 | |
4 | 4 | Activity.ActivityType = { |
5 | 5 | Sign = 1, -- 签到 |
6 | + DoubleDrop = 2, -- 双倍掉落 | |
6 | 7 | } |
7 | 8 | |
8 | 9 | |
... | ... | @@ -193,5 +194,23 @@ function Activity:checkActivity(notNotify, activityType, ...) |
193 | 194 | end |
194 | 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 | 216 | \ No newline at end of file |
217 | +return Activity | ... | ... |
src/models/RolePlugin.lua
... | ... | @@ -1400,9 +1400,10 @@ function RolePlugin.bind(Role) |
1400 | 1400 | red:hget(string.format(R_EMAIL_ITEM, roleId, id), "status") |
1401 | 1401 | end |
1402 | 1402 | end) |
1403 | + | |
1404 | + self.SendMailFlag = false | |
1403 | 1405 | for index, id in ipairs(emailIds) do |
1404 | 1406 | if tonumber(redret[index]) == 0 then |
1405 | - self.SendMailFlag = false | |
1406 | 1407 | return true |
1407 | 1408 | end |
1408 | 1409 | end |
... | ... | @@ -1569,7 +1570,7 @@ function RolePlugin.bind(Role) |
1569 | 1570 | end |
1570 | 1571 | |
1571 | 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 | 1574 | end |
1574 | 1575 | |
1575 | 1576 | -- 累充 |
... | ... | @@ -1589,7 +1590,7 @@ function RolePlugin.bind(Role) |
1589 | 1590 | tgift[one[1]] = (tgift[one[1]] or 0) + one[2] |
1590 | 1591 | end |
1591 | 1592 | else |
1592 | - tgift = gift | |
1593 | + tgift = reward or {} | |
1593 | 1594 | end |
1594 | 1595 | local gift = "" |
1595 | 1596 | for k, v in pairs(tgift) do | ... | ... |
src/models/Store.lua
... | ... | @@ -60,7 +60,8 @@ end |
60 | 60 | -- 发送月卡邮件 |
61 | 61 | function Store:sendMonthCardEmail() |
62 | 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 | 65 | for _, v in ipairs(tabs) do |
65 | 66 | local ex = self:getProperty(v.ex) |
66 | 67 | local ts = self:getProperty(v.t) or 0 |
... | ... | @@ -200,12 +201,10 @@ end |
200 | 201 | |
201 | 202 | -- 赛季卡重置 需要把未能领取的奖励通过邮件发送 |
202 | 203 | function Store:onBattleCardReset() |
203 | - local gift = "" | |
204 | + local gift = {} | |
204 | 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 | 208 | end |
210 | 209 | end |
211 | 210 | local battleCardFlag = self:getProperty("battleCard") |
... | ... | @@ -229,10 +228,9 @@ function Store:onBattleCardReset() |
229 | 228 | end |
230 | 229 | end |
231 | 230 | end |
232 | - self.owner:sendMail(210, nil, gift) | |
231 | + self.owner:sendMail(MailId.BattleCardAward, nil, gift) | |
233 | 232 | -- 计算剩余奖励 |
234 | 233 | self:updateProperty({field = "battleCard", value=0}) |
235 | - self:updateProperty({field = "battleCardR", value=""}) | |
236 | 234 | self:updateProperty({field = "battleFR", value=""}) |
237 | 235 | self:updateProperty({field = "battleLR", value=""}) |
238 | 236 | self.owner:updateProperty({field = "battlePoint", value=0}) | ... | ... |