From c6f3e36c4818dbd5cea07c15fc1eee4a5c44a7da Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Fri, 21 Aug 2020 15:29:02 +0800 Subject: [PATCH] 错误的语法 --- src/models/RoleLog.lua | 20 ++++++++++++++++++++ src/models/RolePlugin.lua | 82 +++++++++++++++++++--------------------------------------------------------------- 2 files changed, 39 insertions(+), 63 deletions(-) diff --git a/src/models/RoleLog.lua b/src/models/RoleLog.lua index 5cffee6..ba4b4ea 100644 --- a/src/models/RoleLog.lua +++ b/src/models/RoleLog.lua @@ -491,6 +491,26 @@ function RoleLog.bind(Role) pcall(skynet.send, logd, "lua", "log", doc) end + function Role:logItems(itemId, before, after, reason, subreason, other) + local reasonType = ItemReason[reason] + if not reasonType then + printError(string.format("LOG ERROR: onItems no reasonType [%s].", reason)) + end + local itemData = csvdb["itemCsv"][itemId] + if not itemData then return end + self:log("onItems", { + item_id = itemId, -- 道具id + item_type = itemData.type, -- 道具类型,具体见枚举表中道具类型枚举表 + item_level = 0, -- 道具等级 + item_number = math.abs(after - before), -- 道具变化数量的绝对值 + action_type = after - before > 0 and 1 or 0, -- 变化类型(玩家获取:1,玩家消耗:0) + item_before = before, -- 道具变化前的数量 + item_after = after, -- 道具变化后的数量 + item_reason = reasonType, -- 道具流动一级原因,如抽卡、装备强化、副本掉落,可参考道具动作类型枚举表 + item_subreason = subreason, -- 道具流动二级原因,抽卡:卡池ID,装备强化:装备ID,副本掉落:副本ID + item_other = other, -- 其他(可包含阶数,强化等级,随机属性) + }) + end function Role:startActionUcode() if not self._uniqueCount then diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index 889bc14..930490f 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -224,12 +224,18 @@ function RolePlugin.bind(Role) end end if level > oldLevel then - self:log("setLevel", { - level_before = oldLevel, - level_changemain = params.level_changemain, - level_changedetail = 0, - level_reward = "{}", - }) + if params.log then + local log = params.log + self:log("setLevel", { + level_before = oldLevel, + level_changemain = log.desc, + level_changedetail = log.sub, + level_reward = "{}", + }) + else + print("addPlayExp no log ", debug.traceback()) + end + end self:updateProperties({level = level, exp = newExp}) @@ -253,17 +259,8 @@ function RolePlugin.bind(Role) end if params.log then - local log = clone(params.log) - if log["cint1"] or log["cint2"] then - print("addItem error log have cint1 or cint2 ", debug.traceback()) - end - log["cint1"] = params.itemId - log["cint2"] = math.abs(params.count) - if params.count <= 0 then - self:log("out_item", log) - else - self:log("in_item", log) - end + local log = params.log + self:logItems(params.itemId, origin, nums, log.desc, log.sub, log.other) else print("addItem no log ", debug.traceback()) end @@ -338,12 +335,7 @@ function RolePlugin.bind(Role) if params.log then local log = clone(params.log) - if log["cint1"] or log["cint2"] or log["cint3"] then - print("costDiamond error log have cint1 or cint2 or cint3 ", debug.traceback()) - end - log["cint1"] = origin - log["cint2"] = count - self:log("in_diamond", log) + self:logItems(ItemId.Diamond, origin, count, log.desc, log.sub, log.other) else print("gainDiamond no log ", debug.traceback()) end @@ -352,6 +344,7 @@ function RolePlugin.bind(Role) return true end + function Role:costDiamond(params) if not params or type(params) ~= "table" then return false end local count = tonum(params.count) @@ -386,12 +379,7 @@ function RolePlugin.bind(Role) if params.log then local log = clone(params.log) - if log["cint1"] or log["cint2"] or log["cint3"] then - print("costDiamond error log have cint1 or cint2 or cint3 ", debug.traceback()) - end - log["cint1"] = origin - log["cint2"] = count - self:log("out_diamond", log) + self:logItems(ItemId.Diamond, origin, count, log.desc, log.sub, log.other) else print("costDiamond no log ", debug.traceback()) end @@ -432,12 +420,7 @@ function RolePlugin.bind(Role) end if params.log then local log = clone(params.log) - if log["cint1"] or log["cint2"] or log["cint3"] then - print("addHero error log have cint1 or cint2 or cint3 ", debug.traceback()) - end - log["cint1"] = heroId - log["cint2"] = heroType - self:log("in_hero", log) + self:logItems(heroType + ItemStartId.Hero, 0, 1, log.desc, log.sub, log.other) else print("addHero no log ", debug.traceback()) end @@ -453,33 +436,6 @@ function RolePlugin.bind(Role) end end - function Role:delHero(heroId, params) - params = params or {} - local roleId = self:getProperty('id') - local hero = self.heros[heroId] - local heroType = hero:getProperty("type") - if not hero then return end - - self.heros[heroId] = nil - redisproxy:pipelining(function (red) - red:del(string.format(R_HERO, roleId, heroId)) - red:srem(string.format(R_HEROS, roleId), heroId) - end) - - if params.log then - local log = clone(params.log) - if log["cint1"] or log["cint2"] or log["cint3"] then - print("delHero error log have cint1 or cint2 or cint3 ", debug.traceback()) - end - log["cint1"] = heroId - log["cint2"] = heroType - self:log("out_hero", log) - else - print("delHero no log ", debug.traceback()) - end - - SendPacket(actionCodes.Hero_loadInfos, MsgPack.pack({{id = heroId, bDel = true}})) - end function Role:loadHeros() local roleId = self:getProperty("id") @@ -1514,7 +1470,7 @@ function RolePlugin.bind(Role) return end - local order_type = self.getProperty("rmbC") > 0 and 0 or 1 + local order_type = self:getProperty("rmbC") > 0 and 0 or 1 local status, reward = self:recharge({ id = rechargeId }) -- libgit2 0.21.2