diff --git a/src/GlobalVar.lua b/src/GlobalVar.lua index 5d50020..e182cba 100644 --- a/src/GlobalVar.lua +++ b/src/GlobalVar.lua @@ -2,6 +2,7 @@ XXTEA_KEY = "699D448D6D24f7F941E9F6E99F823E18" RESET_TIME = 0 START_RESET_TIME_BASE = 1584316800 -- 0时区 +DAY_SEC = 86400 TIME_ZONE = math.floor(os.difftime(START_RESET_TIME_BASE, os.time(os.date("!*t", START_RESET_TIME_BASE))) / 3600) -- 本地时区 START_RESET_TIME = START_RESET_TIME_BASE - TIME_ZONE * 3600 diff --git a/src/actions/GmAction.lua b/src/actions/GmAction.lua index 974505f..161cab4 100644 --- a/src/actions/GmAction.lua +++ b/src/actions/GmAction.lua @@ -512,12 +512,11 @@ function _M.helpRpc(agent, data) return true end -table.insert(helpDes, {"测试", "test", ""}) 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(id) + role.storeData:resetStoreReored(21) return "成功" end diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index 3c961a0..b13484c 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -1070,10 +1070,11 @@ function _M.repayHeroRpc(agent, data) local role = agent.role local repayHero = role:getProperty("repayHero") - if repayHero < globalCsv.draw_free_count then + local cnt = globalCsv.draw_times_to_get_ssr or 100 + if repayHero < cnt then return end - local result = repayHero - globalCsv.draw_free_count + local result = repayHero - cnt role:updateProperty({field = "repayHero", value = result}) local id = math.randWeight(csvdb["build_giftCsv"], "pool_1") @@ -1113,7 +1114,7 @@ function _M.unlockPoolRpc(agent, data) end if needCost then - if not role:costDiamond({count = 300, log = {desc = "unlockPool", short1 = type}}) then + if not role:costDiamond({count = globalCsv.draw_unlock_pool_diamond or 300, log = {desc = "unlockPool", short1 = type}}) then return end end diff --git a/src/actions/StoreAction.lua b/src/actions/StoreAction.lua index 4b8bca1..8883d38 100644 --- a/src/actions/StoreAction.lua +++ b/src/actions/StoreAction.lua @@ -371,7 +371,7 @@ function _M.getBattlePassRewardRpc(agent, data) if not config then return end local timeNow = skynet.timex() - local battleCardExTs = role.storeData:getProperty("battleCardEx") + local battleCardFlag = role.storeData:getProperty("battleCard") local battleCardFreeRecord = role.storeData:getProperty("battleFR") local battleCardLimitRecord = role.storeData:getProperty("battleLR") @@ -383,11 +383,11 @@ function _M.getBattlePassRewardRpc(agent, data) return 1 end - if battleCardExTs < timeNow and freeFlag == "1" then + if battleCardFlag == 1 and limitFlag == "1" then return 1 end - if role:getProperty("battlePoint") < config.condition then + if role:getProperty("battlePoint") < config.point then skynet.error(string.format("user do not have enough battle point, user_id:%d", role:getProperty("id"))) return 1 end @@ -400,14 +400,14 @@ function _M.getBattlePassRewardRpc(agent, data) role.storeData:updateProperty({field = "battleFR", value = battleCardFreeRecord}) end - if battleCardExTs > timeNow and limitFlag == "0" then + if battleCardFlag == 1 and limitFlag == "0" then if gift ~= "" then gift = gift .. " " end gift = gift .. config.giftLimit battleCardLimitRecord = string.setbit(battleCardLimitRecord, id) - role.storeData:updateProperty({field = "battleFR", value = battleCardLimitRecord}) + role.storeData:updateProperty({field = "battleLR", value = battleCardLimitRecord}) end local reward, _ = role:award(gift, {log = {desc = "battleCard", int1 = id}}) diff --git a/src/csvdata b/src/csvdata index 12409da..1cad049 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit 12409daded138b2934c0741b15b2e0de305bb109 +Subproject commit 1cad049d6adc4948e9ff001acc64529e05e8acb6 diff --git a/src/models/Role.lua b/src/models/Role.lua index b15d695..8afcc60 100644 --- a/src/models/Role.lua +++ b/src/models/Role.lua @@ -27,6 +27,7 @@ function Role:ctor( properties ) self.activity = nil self.advElChapter = tonum(redisproxy:hget("adv_season", "chapter"), globalCsv.adv_endless_default_chapter) -- 无尽模式记录的赛季对应章节 self.advOverTime = tonum(redisproxy:hget("adv_season", "overTime")) -- 无尽模式关闭时间戳 + self.sendMailFlag = false --发送邮件标识 end Role.schema = { @@ -147,7 +148,7 @@ Role.schema = { emailSync = {"number", 0}, -- 已经同步到的邮件Id - repayHero = {"number", 0}, -- 超级招募 回馈 + repayHero = {"number", 0}, -- 招募次数 (除去友情招募) floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count} ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count} newerDraw = {"table", {}}, -- 新手池子 {N, 1} 抽了多少次, 是否出了ssr @@ -365,7 +366,7 @@ function Role:data() battlePoint = self:getProperty("battlePoint"), rmbC = self:getProperty("rmbC"), - -- repayHero = self:getProperty("repayHero"), + repayHero = self:getProperty("repayHero"), newerDraw = self:getProperty("newerDraw"), floorHero = self:getProperty("floorHero"), diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index 255b947..3ac1b74 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -1343,9 +1343,13 @@ function RolePlugin.bind(Role) self:checkNewEvent(now) end - local function breath(sec) + local function breath(sec, name) local last_breath = 0 - return function (now) + return function (now, role) + if name == "email" and role.sendMailFlag then + last_breath = now + sec + return true + end if now >= last_breath then last_breath = now + sec return true @@ -1354,8 +1358,8 @@ function RolePlugin.bind(Role) end end local breathes = { - ["email"] = breath(120), -- email - ["pvphg"] = breath(300), -- 高级竞技场 奖励满的红点 + ["email"] = breath(120, "email"), -- email + ["pvphg"] = breath(300, "pvphg"), -- 高级竞技场 奖励满的红点 } function Role:checkNewEvent(now) if now - self:getProperty("ltime") < 5 then @@ -1398,6 +1402,7 @@ function RolePlugin.bind(Role) end) for index, id in ipairs(emailIds) do if tonumber(redret[index]) == 0 then + self.SendMailFlag = false return true end end @@ -1420,7 +1425,7 @@ function RolePlugin.bind(Role) local events = {} for name, breath in pairs(breathes) do - if breath(now) and checks[name] then + if breath(now, self) and checks[name] then local status = checks[name]() if status then if status == true then @@ -1576,6 +1581,24 @@ function RolePlugin.bind(Role) return reward end + --直接给玩家发送邮件,立即推送小红点 + function Role:sendMail(mailId, createTime, reward) + local tgift = {} + if type(reward) == "string" then + for _, one in pairs(reward:toTableArray(true)) do + tgift[one[1]] = (tgift[one[1]] or 0) + one[2] + end + else + tgift = gift + end + local gift = "" + for k, v in pairs(tgift) do + gift = gift .. k.."="..v.." " + end + redisproxy:insertEmail({roleId = self:getProperty("id"), emailId = mailId, createtime = createTime, attachments = gift}) + self.sendMailFlag = true + end + end return RolePlugin \ No newline at end of file diff --git a/src/models/RoleTimeReset.lua b/src/models/RoleTimeReset.lua index e3834eb..8611bbc 100644 --- a/src/models/RoleTimeReset.lua +++ b/src/models/RoleTimeReset.lua @@ -10,6 +10,7 @@ ResetFunc["CrossDay"] = function(self, notify, response, now) self.dailyData:refreshDailyData(notify) self.dinerData:refreshDailyData(notify) self.activity:refreshDailyData(notify) + self.storeData:onCrossDay() self:setProperty("dTask", {}) self:advRandomSupportEffect(not notify) diff --git a/src/models/Store.lua b/src/models/Store.lua index b9372d3..a8f3dfd 100644 --- a/src/models/Store.lua +++ b/src/models/Store.lua @@ -13,11 +13,13 @@ Store.schema = { growFundR = {"string", ""}, -- 成长基金领取记录 monthCardEx = {"number", 0}, -- 月卡过期时间戳 smonthCardEx = {"number", 0}, -- 超级月卡过期时间戳 - battleCardEx = {"number", 0}, -- 赛季卡过期时间戳 + battleCard = {"number", 0}, -- 赛季卡 battleFR = {"string", ""}, -- 免费赛季卡领取记录 battleLR = {"string", ""}, -- 付费赛季卡领取记录 limitTPack = {"table", {}}, -- 限时礼包 {id=expire_ts} - privCardEx = {"number", 0} -- 特权卡过期时间戳 + privCardEx = {"number", 0}, -- 特权卡过期时间戳 + getMailT1 = {"number",0}, -- 上次发送月卡福利邮件的时间 + getMailT2 = {"number",0}, -- 上次发送超级月卡福利邮件的时间 } function Store:updateProperty(params) @@ -39,46 +41,54 @@ function Store:updateProperty(params) end end -function Store:refreshData(notify, refreshType) - local buyRecord = self:getProperty("buyR") - local result = {} - for id, data in pairs(csvdb["shop_normalCsv"]) do - if data.shop == 1 and refreshType == RefreshType.RefreshType_Daily then - buyRecord[id] = nil - end - if data.shop == 2 and refreshType == RefreshType.RefreshType_Weekly then - buyRecord[id] = nil - end - end - self:setProperty("buyR", buyRecord) - if notify then - self:notifyUpdateProperty({field="buyR", value=buyRecord}) - end +function Store:onCrossDay() + self:sendMonthCardEmail() + self:deleteExpireLimitGoods() end -function Store:refreshPvpBuyRecord(notify) - local buyRecord = self:getProperty("buyR") - for id, data in pairs(csvdb["shop_normalCsv"]) do - if data.shop == 3 then - buyRecord[id] = nil - end +-- 删除过期商品 +function Store:deleteExpireLimitGoods() + local timeNow = skynet.timex() + local limitGoodsList = self:getProperty("limitTPack") + for k, v in pairs(limitGoodsList) do + if timeNow > v then + limitGoodsList[k] = nil + end end - self:setProperty("buyR", buyRecord) - if notify then - self:notifyUpdateProperty({field="buyR", value=buyRecord}) - end end -- 发送月卡邮件 function Store:sendMonthCardEmail() - local monthCardEx = self:getProperty("monthCardEx") - local smonthCardEx = self:getProperty("smonthCardEx") local timeNow = skynet.timex() - if monthCardEx < timeNow then - redisproxy:insertEmail({roleId = self.owner:getProperty("id"), emailId = 19}) - end - if smonthCardEx < timeNow then - redisproxy:insertEmail({roleId = self.owner:getProperty("id"), emailId = 20}) + local tabs = {{ex="monthCardEx", t="getMailT1", mail=201, alert=203}, {ex="smonthCardEx", t="getMailT2", mail=202, alert=204}} + for _, v in ipairs(tabs) do + local ex = self:getProperty(v.ex) + local ts = self:getProperty(v.t) or 0 + local mailId = v.mail + local alertId = v.alert + local alertTs = dayLater(ex) - DAY_SEC + if ex > timeNow then + local cnt = 0 + if ts == 0 then + cnt = 1 + else + local diff = dayLater(timeNow) - dayLater(ts) + diff = diff < 0 and 0 or diff + diff = diff > 31 and 31 or diff + cnt = diff + end + for i = cnt - 1, 0, -1 do + local createTs = timeNow - i * DAY_SEC + self.owner:sendMail(mailId, createTs) + -- 过期头一天发提醒邮件 + if dayLater(createTs) == alertTs then + self.owner:sendMail(alertId, createTs) + end + end + if cnt > 0 then + self:updateProperty({field=v.t, value=timeNow}) + end + end end end @@ -100,19 +110,13 @@ function Store:isPrivCardExpire() return ts < timeNow end -function Store:isBattleCardExpire() - local timeNow = skynet.timex() - local ts = self:getProperty("battleCardEx") - return ts < timeNow -end - -- 挂机栏位 特权卡额外个数 function Store:getHangSlotExtraCount() if self:isPrivCardExpire() then return 0 end - return 4 + return csvdb.shop_priv_card_hang_slot_cnt or 4 end -- 探索加速/餐厅加速 特权卡系数 @@ -120,8 +124,8 @@ function Store:getProduceItemSpeedCoef() if self:isPrivCardExpire() then return 1 end - - return 1 + 0.25 + local coef = (globalCsv.shop_priv_card_produce_coef or 25)/ 100 + return 1 + coef end -- 拆解室栏位 特权卡额外个数 @@ -130,7 +134,7 @@ function Store:getTimeBoxSlotExtraCount() return 0 end - return 3 + return csvdb.shop_priv_time_box_slot_cnt or 3 end -- 齿轮兑换 特权卡系数 @@ -139,7 +143,8 @@ function Store:getGearExchangeCoef() return 1 end - return 1 + 0.5 + local coef = (globalCsv.shop_priv_card_produce_coef or 50)/ 100 + return 1 + coef end -- 购买通行证 @@ -151,12 +156,14 @@ function Store:onBuyCard(type, duration) else self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + duration}) end + self:sendMonthCardEmail() elseif type == CardType.SuperMonthCard then if self:isSuperMonthCardExpire() then self:updateProperty({field = "smonthCardEx", value = timeNow + duration}) else self:updateProperty({field = "smonthCardEx", value = self:getProperty("smonthCardEx") + duration}) end + self:sendMonthCardEmail() elseif type == CardType.PrivilegeCard then if self:isPrivCardExpire() then self:updateProperty({field = "privCardEx", value = timeNow + duration}) @@ -166,14 +173,11 @@ function Store:onBuyCard(type, duration) elseif type == CardType.GrowFund then self:updateProperty({field = "growFund", value = 1}) elseif type == CardType.BattleCard then - if self:isBattleCardExpire() then - self:updateProperty({field = "battleCardEx", value = timeNow + duration}) - else - self:updateProperty({field = "battleCardEx", value = self:getProperty("battleCardEx") + duration}) - end + self:updateProperty({field = "battleCard", value = 1}) end end +--检测购买是否超过限制数量 function Store:checkRechargeRecord(limit, id) local rechargeRecord = self:getProperty("payR") if limit ~= 0 and limit <= (rechargeRecord[id] or 0) then @@ -194,6 +198,47 @@ function Store:notifyUpdateProperty(field, newValue, oldValue) SendPacket(actionCodes.Store_updateproperty, MsgPack.pack(datas)) end +-- 赛季卡重置 需要把未能领取的奖励通过邮件发送 +function Store:onBattleCardReset() + local gift = "" + local function concatGift(data) + if gift == "" then + gift = data + else + gift = gift .. " " .. data + end + end + local battleCardFlag = self:getProperty("battleCard") + local battleCardFreeRecord = self:getProperty("battleFR") + local battleCardLimitRecord = self:getProperty("battleLR") + local battlePoint = self.owner:getProperty("battlePoint") + + for id, config in pairs(csvdb["reward_battlepassCsv"]) do + if config then + local freeFlag = string.char(string.getbit(battleCardFreeRecord, id)) + local limitFlag = string.char(string.getbit(battleCardLimitRecord, id)) + + if battlePoint < config.point then + break + end + if freeFlag == "0" then + concatGift(config.giftFree) + end + if limitFlag == "0" and battleCardFlag == 1 then + concatGift(config.giftLimit) + end + end + end + self.owner:sendMail(210, 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}) +end + +-- 重置购买记录 function Store:resetStoreReored(resetId) local payRecord = self:getProperty("payR") or {} local buyRecord = self:getProperty("buyR") or {} @@ -202,6 +247,12 @@ function Store:resetStoreReored(resetId) if config then if config.resetTime == resetId then payRecord[k] = nil + --通行证商店 + if config.shop == 2 then + if config.type == CardType.BattleCard then + self:onBattleCardReset() + end + end end end end @@ -225,8 +276,9 @@ function Store:data() growFundR = self:getProperty("growFundR"), monthCardEx = self:getProperty("monthCardEx"), smonthCardEx = self:getProperty("smonthCardEx"), - battleCardEx = self:getProperty("battleCardEx"), - battleCardR = self:getProperty("battleCardR"), + battleCard = self:getProperty("battleCard"), + battleFR = self:getProperty("battleFR"), + battleLR = self:getProperty("battleLR"), limitTPack = self:getProperty("limitTPack"), privCardEx = self:getProperty("privCardEx"), } -- libgit2 0.21.2