diff --git a/src/GlobalVar.lua b/src/GlobalVar.lua index ba283d2..61b461a 100644 --- a/src/GlobalVar.lua +++ b/src/GlobalVar.lua @@ -129,6 +129,7 @@ ItemId = { TimeReset = { CrossDay = 1, --通用跨天 CrossWeek = 2, --通用跨周 + CrossMonth = 1, --通用跨月 索引使用跨天,在回调方法中判断是否跨越 跨月的前置条件是跨天 DinerRank = 1, -- 餐厅排行榜 PvpRank = 2, -- pvp排行榜 PvpHight = 11, --高级竞技场 @@ -288,4 +289,13 @@ MailId = { MonthCardEx = 203, SuperMonthCardEx = 204, BattleCardAward = 210, + + ActDrawCard = 231, + ActOpenBox = 232, + ActAdvDraw = 233, + ActSellFood = 234, + ActDrawCardReward = 221, + ActOpenBoxReward = 222, + ActAdvDrawReward = 223, + ActSellFoodReward = 224, } diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index 4b98329..775a79d 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -130,6 +130,8 @@ function _M.loginRpc( agent, data ) for _, name in ipairs({"dailyData", "dinerData", "activity", "storeData"}) do response[name] = role[name]:data() + --print("["..name.."]") + --dump(response[name]) end response.role = role:data() @@ -516,7 +518,7 @@ function _M.openTimeBoxRpc(agent, data) boxL[slot] = nil reward, change = role:award(reward, {log = {desc = "openTimeBox", int1 = boxId}}) - role:checkTaskEnter("OpenBox", {id = boxId}) + role:checkTaskEnter("OpenBox", {id = boxId, count=1}) else return end @@ -1059,7 +1061,7 @@ function _M.goldBuyRpc(agent, data) goldC = goldC * coef role.dailyData:updateProperty({field = "goldBuyT", value = curT + 1}) role:costItems({[ItemId.Diamond] = costD}, {log = {desc = "goldBuy"}}) - local reward, change = role:award({[ItemId.Gold] = goldC}, {log = {desc = "goldBuy"}}) + local reward, change = role:award({[ItemId.Gold] = math.floor(goldC)}, {log = {desc = "goldBuy"}}) SendPacket(actionCodes.Role_goldBuyRpc, MsgPack.pack(role:packReward(reward, change))) return true end diff --git a/src/actions/StoreAction.lua b/src/actions/StoreAction.lua index 13adae8..4abce08 100644 --- a/src/actions/StoreAction.lua +++ b/src/actions/StoreAction.lua @@ -298,6 +298,9 @@ function _M.shopBuyRpc(agent , data) end local reward = role:award(gift, {log = {desc = desc, int1 = id, int2 = count}}) + if dataSet.shop == 1 then + role:checkTaskEnter("ShopAll", {count = count}) + end role:log("role_action", {desc = desc, int1 = id, int2 = count}) SendPacket(actionCodes.Store_shopBuyRpc, MsgPack.pack({reward = reward})) diff --git a/src/csvdata b/src/csvdata index 060b333..802d384 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit 060b3335605687579bbd930e3a9919561ef75acb +Subproject commit 802d38498d671d29d4d7702a5c1c7b0941183bd1 diff --git a/src/models/Activity.lua b/src/models/Activity.lua index d39ab6e..b05621b 100644 --- a/src/models/Activity.lua +++ b/src/models/Activity.lua @@ -4,6 +4,10 @@ local string_format = string.format Activity.ActivityType = { Sign = 1, -- 签到 DoubleDrop = 2, -- 双倍掉落 + DrawHero = 3, --抽卡周 + FoodSell = 4, --贩卖周 + OpenBox = 5, --拆解周 + AdvDraw = 6, --拾荒抽周 } @@ -24,13 +28,23 @@ end Activity.schema = { actime = {"table", {}}, -- 最近检查某项活动的开始时间 {id = time} + round = {"table", {}}, -- 记录活动到了第几轮 {id = roundnum} act1 = {"table", {}}, -- {0 = day, 1= -1, 2 = -1} == 签到活动 + act3 = {"table", {}}, -- {0 = 抽卡次数, 1=1, 2=1} 抽卡周活动 1表示领取过该档位的奖励 + act4 = {"table", {}}, -- {0 = 贩卖数量, 1=1, 2=1} 贩卖周活动 1表示领取过该档位的奖励 + act5 = {"table", {}}, -- {0 = 拆解数量, 1=1, 2=1} 拆解周活动 1表示领取过该档位的奖励 + act6 = {"table", {}}, -- {0 = 拾荒消耗远古金币数量, 1=1, 2=1} 拾荒周活动 1表示领取过该档位的奖励 } function Activity:data() return { actime = self:getProperty("actime"), + round = self:getProperty("round"), act1 = self:getProperty("act1"), + act3 = self:getProperty("act3"), + act4 = self:getProperty("act4"), + act5 = self:getProperty("act5"), + act6 = self:getProperty("act6"), } end @@ -163,6 +177,133 @@ activityFunc[Activity.ActivityType.Sign] = { end, } +--loop1:累计料理贩卖N次 +--loop2:累计招募N次 +--loop3:累计资助N次 +--loop4:时钟箱拆解N个 +function Activity:checkWeeklyAct(actType, notify, count) + local actInfoMap = { + [Activity.ActivityType.DrawHero] = {mailId = MailId.ActDrawCardReward, table = "activity_loop2Csv"}, + [Activity.ActivityType.AdvDraw] = {mailId = MailId.ActAdvDrawReward, table = "activity_loop3Csv"}, + [Activity.ActivityType.OpenBox] = {mailId = MailId.ActOpenBoxReward, table = "activity_loop4Csv"}, + [Activity.ActivityType.FoodSell] = {mailId = MailId.ActSellFoodReward, table = "activity_loop1Csv"} + } + local info = actInfoMap[actType] + if not info then return end + + local curData = self:getActData(actType) + local roundData = self:getProperty("round") + local curRound = roundData[actType] or 0 + local ctrlData = csvdb["activity_ctrlCsv"][actType] + if not ctrlData then return end + if curRound >= ctrlData.condition then + return + end + curData[0] = (curData[0] or 0) + count + local totalCnt = 0 + local finishCnt = 0 + local maxCondition = 0 + for k, cfg in pairs(csvdb[info.table] or {}) do + totalCnt = totalCnt + 1 + if maxCondition < cfg.condition1 then + maxCondition = cfg.condition1 + end + if not curData[cfg.id] and curData[0] >= cfg.condition1 then + if info.mailId then + self.owner:sendMail(info.mailId, nil, cfg.reward, {cfg.condition1}) + curData[cfg.id] = 1 + end + end + if curData[cfg.id] then + finishCnt = finishCnt + 1 + end + end + if totalCnt == finishCnt then + roundData[actType] = curRound + 1 + for k,v in pairs(curData) do + if k == 0 then + curData[k] = curData[0] >= maxCondition and curData[0] - maxCondition or 0 + else + curData[k] = nil + end + end + self:updateProperty({field = "round", value = roundData, notNotify = not notify}) + end + self:updateActData(actType, curData, not notify) +end + +-- 抽卡周 +activityFunc[Activity.ActivityType.DrawHero] = { + ["check"] = function(self, actType, notify, count) -- 检查 + self:checkWeeklyAct(actType, notify, count) + end, + ["init"] = function(self, actType, isCrossDay, notify) + local roundData = self:getProperty("round") + roundData[actType] = 0 + self:updateProperty({field = "round", value = roundData, notNotify = not notify}) + end, + -- ["close"] = function(self, actType, notify) + -- end, + ["crossDay"] = function(self, actType, notify) + print("cross day draw card") + self.owner:sendMail(MailId.ActDrawCard) + end, +} + +-- 售卖周 +activityFunc[Activity.ActivityType.FoodSell] = { + ["check"] = function(self, actType, notify, count) -- 检查 + self:checkWeeklyAct(actType, notify, count) + end, + ["init"] = function(self, actType, isCrossDay, notify) + local roundData = self:getProperty("round") + roundData[actType] = 0 + self:updateProperty({field = "round", value = roundData, notNotify = not notify}) + end, + -- ["close"] = function(self, actType, notify) + -- end, + ["crossDay"] = function(self, actType, notify) + print("cross day sell food") + self.owner:sendMail(MailId.ActSellFood) + end, +} + +-- 拾荒周 +activityFunc[Activity.ActivityType.AdvDraw] = { + ["check"] = function(self, actType, notify, count) -- 检查 + self:checkWeeklyAct(actType, notify, count) + end, + ["init"] = function(self, actType, isCrossDay, notify) + local roundData = self:getProperty("round") + roundData[actType] = 0 + self:updateProperty({field = "round", value = roundData, notNotify = not notify}) + end, + -- ["close"] = function(self, actType, notify) + -- end, + ["crossDay"] = function(self, actType, notify) + print("cross day act adv cost") + self.owner:sendMail(MailId.ActAdvDraw) + end, +} + +-- 拆解周 +activityFunc[Activity.ActivityType.OpenBox] = { + ["check"] = function(self, actType, notify, count) -- 检查 + self:checkWeeklyAct(actType, notify, count) + end, + ["init"] = function(self, actType, isCrossDay, notify) + local roundData = self:getProperty("round") + roundData[actType] = 0 + self:updateProperty({field = "round", value = roundData, notNotify = not notify}) + end, + -- ["close"] = function(self, actType, notify) + -- end, + ["crossDay"] = function(self, actType, notify) + print("cross day open box") + self.owner:sendMail(MailId.ActOpenBox) + end, +} + function Activity:initActivity(actType, isCrossDay, notify) if activityFunc[actType] and activityFunc[actType]['close'] then activityFunc[actType]["init"](self, actType, isCrossDay, notify) @@ -173,7 +314,9 @@ function Activity:closeActivity(actType, notify, notUpdateAct) if activityFunc[actType] and activityFunc[actType]['close'] then activityFunc[actType]["close"](self, actType, notify) end - self:updateActData(actType, Activity.schema["act" .. actType][2], not notify or notUpdateAct) + if Activity.schema["act".. actType] then + self:updateActData(actType, Activity.schema["act" .. actType][2], not notify or notUpdateAct) + end end function Activity:refreshDailyData(notify) diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index 60ab149..ad74057 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -1583,7 +1583,7 @@ function RolePlugin.bind(Role) end --直接给玩家发送邮件,立即推送小红点 - function Role:sendMail(mailId, createTime, reward) + function Role:sendMail(mailId, createTime, reward, contentPms) local tgift = {} if type(reward) == "string" then for _, one in pairs(reward:toTableArray(true)) do @@ -1596,7 +1596,7 @@ function RolePlugin.bind(Role) for k, v in pairs(tgift) do gift = gift .. k.."="..v.." " end - redisproxy:insertEmail({roleId = self:getProperty("id"), emailId = mailId, createtime = createTime, attachments = gift}) + redisproxy:insertEmail({roleId = self:getProperty("id"), emailId = mailId, createtime = createTime, attachments = gift, contentPms = contentPms}) self.sendMailFlag = true end diff --git a/src/models/RoleTask.lua b/src/models/RoleTask.lua index 3a50cee..cd94306 100644 --- a/src/models/RoleTask.lua +++ b/src/models/RoleTask.lua @@ -205,10 +205,14 @@ local SudokuListener = { } } +local Activity = require("models.Activity") local ActivityListener = { func = "checkActivityTask", - listener = { - + listen = { + [TaskType.DrawHero] = {{Activity.ActivityType.DrawHero, f("count")}}, + [TaskType.FoodSell] = {{Activity.ActivityType.FoodSell, f("count")}}, + [TaskType.AdvDraw] = {{Activity.ActivityType.AdvDraw, f("count")}}, + [TaskType.OpenBox] = {{Activity.ActivityType.OpenBox, f("count")}}, } } diff --git a/src/models/RoleTimeReset.lua b/src/models/RoleTimeReset.lua index 8611bbc..d848608 100644 --- a/src/models/RoleTimeReset.lua +++ b/src/models/RoleTimeReset.lua @@ -30,6 +30,14 @@ ResetFunc["CrossWeek"] = function(self, notify, response) response.dinerS = {} end +ResetFunc["CrossMonth"] = function(self, notify, response) + local ltime = self:getProperty("ltime") + if isCrossMonth(ltime, skynet.timex()) then + print("cross month") + self.storeData:resetStoreReored(3) --商店跨月重置 time_reset表关联id + end +end + ResetFunc["DinerRank"] = function(self, notify, response) self.dinerData:rankResetData(notify) @@ -52,9 +60,11 @@ function Role:updateTimeReset(now, notify) local needResetId = {} for resetId, resetData in pairs(csvdb["time_resetCsv"]) do - local curRound = math.floor((passTime - resetData.start) / resetData.interval) - if not timeReset[resetId] or curRound ~= timeReset[resetId] then - needResetId[resetId] = curRound + if resetData.interval > 0 then + local curRound = math.floor((passTime - resetData.start) / resetData.interval) + if not timeReset[resetId] or curRound ~= timeReset[resetId] then + needResetId[resetId] = curRound + end end end if not next(needResetId) then return end diff --git a/src/models/Store.lua b/src/models/Store.lua index 0a0c1ba..9031af0 100644 --- a/src/models/Store.lua +++ b/src/models/Store.lua @@ -144,7 +144,7 @@ function Store:getGearExchangeCoef() return 1 end - local coef = (globalCsv.shop_priv_card_produce_coef or 50)/ 100 + local coef = (globalCsv.shop_priv_exchange_gear_coef or 50)/ 100 return 1 + coef end -- libgit2 0.21.2