diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index 5cb6b94..a9bca0e 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -180,6 +180,9 @@ actionCodes = { Email_checkRpc = 603, Email_delRpc = 604, + Activity_sudokuRpc = 650, + Activity_signRpc = 651, + Activity_sudokuRewardRpc = 652, } rpcResponseBegin = 10000 diff --git a/src/actions/ActivityAction.lua b/src/actions/ActivityAction.lua new file mode 100644 index 0000000..f498603 --- /dev/null +++ b/src/actions/ActivityAction.lua @@ -0,0 +1,138 @@ +local ipairs = ipairs +local table = table +local math = math +local string = string +local redisproxy = redisproxy +local MsgPack = MsgPack +local string_format = string.format +local tonumber = tonumber +local table_insert = table.insert +local table_unpack = table.unpack +local table_find = table.find +local table_nums = table.nums +local math_random = math.randomInt + + +local _M = {} + + +function _M.sudokuRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + local id = msg.id + + local sudoku = role:getProperty("sudoku") + local phase = sudoku[-1] or 1 + local curData = (csvdb["guide_sudokuCsv"][phase] or {})[id] + if phase == -1 or not curData then return 1 end + + sudoku.task = sudoku.task or {} + sudoku.task[phase] = sudoku.task[phase] or {} + + if (sudoku.task[phase][id] or 0) < curData.con1 then return 2 end + + sudoku.task[phase][id] = -1 + local task = role:award(curData.reward, {log = {desc = "sudoku", int1 = id, int2 = phase}}) -- 任务奖励 + + local reward = {} + local rId = {} + for pid, pdata in pairs(csvdb["guide_sudoku_rewardCsv"][phase] or {}) do + local pos = pdata.pos:toArray(true, "=") + local ok, is = true, false + for _, one in pairs(pos) do + if one == id then + is = true + end + if sudoku.task[phase][one] ~= -1 then + ok = false + break + end + end + + if ok and is then + for itemId, count in pairs(pdata.reward:toNumMap()) do + reward[itemId] = (reward[itemId] or 0) + count + end + table.insert(rId, pid) + end + end + + if not next(reward) then + reward = nil + else + reward = role:award(reward, {log = {desc = "sudokuR", int1 = id, int2 = phase}}) + end + + role:updateProperty({field = "sudoku", value = sudoku}) + + role:log("act_action", {desc = "sudoku", int1 = id, int2 = phase}) + + SendPacket(actionCodes.Activity_sudokuRpc, MsgPack.pack({task = task, reward = reward, rId = rId})) + return true +end + +function _M.sudokuRewardRpc(agent, data) + local role = agent.role + + + local sudoku = role:getProperty("sudoku") + local phase = sudoku[-1] or 1 + + local curData = csvdb["guide_sudokuCsv"][phase] + if not curData then return end + if not globalCsv.guide_sudoku_reward[phase] then return end + + local curTask = (sudoku.task or {})[phase] or {} + + for id, _ in pairs(curData) do + if curTask[id] ~= -1 then + return + end + end + + local reward = role:award(globalCsv.guide_sudoku_reward[phase], {log = {desc = "sudokuRP", int1 = phase}}) + + sudoku[-1] = phase + 1 + sudoku.task[phase] = nil + if not csvdb["guide_sudokuCsv"][sudoku[-1]] then + sudoku[-1] = -1 + sudoku.task = nil + end + role:updateProperty({field = "sudoku", value = sudoku}) + + SendPacket(actionCodes.Activity_sudokuRewardRpc, MsgPack.pack(reward)) + return true +end + + +function _M.signRpc(agent, data) + local role = agent.role + + local serverT = skynet.timex() + local tm = os.date("*t", serverT) + + local curDay = tm.day + + local yearMonth = tm.year * 100 + tm.month + local monthData = csvdb["daily_signInCsv"][yearMonth] + if not monthData or not monthData[curDay] then + return 1 + end + + local signs = role:getProperty("sign") + if signs[curDay] == yearMonth then -- 未重置的还可以签到正常(本月已经签到) + return 2 + end + signs[curDay] = yearMonth + + local raward = role:award(monthData[curDay].item, {log = {desc = "sign", int1 = yearMonth, int2 = curDay}}) + role:changeUpdates({{type = "sign", field = curDay, value = yearMonth}}) + + SendPacket(actionCodes.Activity_signRpc, MsgPack.pack(raward)) + return true +end + + + + +return _M \ No newline at end of file diff --git a/src/actions/DinerAction.lua b/src/actions/DinerAction.lua index c8a58ce..1d38055 100644 --- a/src/actions/DinerAction.lua +++ b/src/actions/DinerAction.lua @@ -399,7 +399,7 @@ function _M.talentUpRpc( agent, data ) -- role:award(treePoint) -- end - role:checkTaskEnter("DinerTalentUp", {type = talentData.effect:toArray(true,"=")[1]}) + role:checkTaskEnter("DinerTalentUp", {type = talentData.effect:toArray(true,"=")[1], level = dishLevel + 1}) role:log("diner_action", {desc = "talentUp", int1 = dish, int2 = dishLevel + 1}) diff --git a/src/models/Role.lua b/src/models/Role.lua index d2259f6..c024e94 100644 --- a/src/models/Role.lua +++ b/src/models/Role.lua @@ -146,6 +146,8 @@ Role.schema = { floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count} ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count} newerDraw = {"table", {}}, -- 新手池子 {N, 1} 抽了多少次, 是否出了ssr + + sudoku = {"table", {}}, -- 九宫格 {[-1] = 1, task = {[1] = {}, [2] = {}}}} -- [-1] 阶段 如果为 -1 关闭(都做完了), task 当前阶段任务进度, reward 连串奖励领取情况 } @@ -351,6 +353,8 @@ function Role:data() rmbC = self:getProperty("rmbC"), -- repayHero = self:getProperty("repayHero"), newerDraw = self:getProperty("newerDraw"), + + sudoku = self:getProperty("sudoku"), } end diff --git a/src/models/RoleLog.lua b/src/models/RoleLog.lua index 9ed9ea7..faadc5f 100644 --- a/src/models/RoleLog.lua +++ b/src/models/RoleLog.lua @@ -32,6 +32,7 @@ local LogType = { diner_action = "common", tower_action = "common", gm_action = "common", + act_action = "common", } -- 如要修改 要提前修改 _template mapping -- 对应 mapping 为 gamelog-* diff --git a/src/models/RoleTask.lua b/src/models/RoleTask.lua index 0a1fd73..71cdb7a 100644 --- a/src/models/RoleTask.lua +++ b/src/models/RoleTask.lua @@ -59,11 +59,12 @@ local TaskType = { FoodSellGold = 607, -- 贩卖获得齿轮 - count DinerPopular = 608, -- 人气值 - count DinerLevelUp = 609, -- 餐厅升级 - level type - DinerTalentUp = 610, -- 天赋升级 - type + DinerTalentUp = 610, -- 天赋升级 - type level -- 车厢相关 PotionMake = 701, -- 营养剂制作 - id count OpenBox = 702, -- 拆解时间箱 - id + SupportSkill = 703, -- 后勤支援技升级 - id level -- pvp相关 @@ -87,8 +88,8 @@ local TaskType = { ShopAll = 1013, -- 在任意商店购买 } -local function f(field) - return {type = "field", value = field} +local function f(field, func) + return {type = "field", value = field, func = func} end -- 剧情任务监听 @@ -183,11 +184,33 @@ local AchievListener = { } } +local SudokuListerer = { + func = "checkSudokuTask", + listen = { + [TaskType.HangPass] = {{1, 1, f("id")}}, + [TaskType.DrawHero] = {{4, f("count")}}, + [TaskType.HeroLevelUp] = {{5, f("level")}}, + [TaskType.Wake] = {{6, f("wakeL")}}, + [TaskType.AddFriend] = {{7, f("count")}}, + [TaskType.GetFriendP] = {{8, f("count")}}, + [TaskType.AdvStart] = {{9, 1}}, + [TaskType.AdvDraw] = {{10, f("count")}}, + [TaskType.DinerLevelUp] = {{11, f("level"), f("type")}}, + [TaskType.FoodSell] = {{12, f("count")}}, + [TaskType.OpenBox] = {{13, 1}}, + [TaskType.TowerPass] = {{14, f("level")}}, + [TaskType.PvpWin] = {{15, 1}}, + [TaskType.DinerTalentUp] = {{16, f("level"), f("type")}}, + [TaskType.RuneUp] = {{17, 1}}, + } +} + local TaskListeners = { StoryListener, CommonListener, AchievListener, + SudokuListerer, } local RoleTask = {} @@ -207,7 +230,11 @@ function RoleTask.bind(Role) for __, v in ipairs(vs) do if type(v) == "table" and v.type then if v.type == "field" then - table.insert(pms, params[v.value]) + local value = params[v.value] + if v.func then + value = v.func(value) + end + table.insert(pms, value) else table.insert(pms, v) end @@ -333,7 +360,6 @@ function RoleTask.bind(Role) local achiveStatus = self:getProperty("achiveT") local IsFindMax = { - [1] = true, [4] = true, [6] = true, [7] = true, @@ -442,6 +468,55 @@ function RoleTask.bind(Role) end end + -- 九宫格任务 + function Role:checkSudokuTask(notNotify, stype, count, cond) + local change = false + local sudoku = self:getProperty("sudoku") + + local curPhase = sudoku[-1] or 1 + if curPhase == -1 then return end + + local IsFindMax = { + [5] = true, + [6] = true, + [7] = true, + [11] = true, + [14] = true, + [16] = true, + } + + sudoku.task = sudoku.task or {} + local hangPass = self:getProperty("hangPass") + for pause, guide_sudokuData in pairs(csvdb["guide_sudokuCsv"]) do + if pause >= curPhase then + sudoku.task[pause] = sudoku.task[pause] or {} + for id , sudikuData in pairs(guide_sudokuData) do + local curStatus = sudoku.task[pause][id] or 0 + + if curStatus ~= -1 and sudikuData.type == stype and (sudikuData.unlock == 0 or hangPass[sudikuData.unlock]) then + if IsFindMax[sudikuData.type] then -- 最大值 + if sudikuData.con2 == 0 or sudikuData.con2 == cond then + if (count or 0) > curStatus then + change = true + sudoku.task[pause][id] = count + end + end + else --通用增加 + if sudikuData.con2 == 0 or sudikuData.con2 == cond then + change = true + sudoku.task[pause][id] = curStatus + (count or 1) + end + end + end + end + end + end + + if change then + self:updateProperty({field = "sudoku", value = sudoku, notNotify = notNotify}) + end + end + end return RoleTask \ No newline at end of file -- libgit2 0.21.2