diff --git a/src/actions/ActivityAction.lua b/src/actions/ActivityAction.lua index fff5b85..9eceded 100644 --- a/src/actions/ActivityAction.lua +++ b/src/actions/ActivityAction.lua @@ -65,7 +65,11 @@ function _M.sudokuRpc(agent, data) role:updateProperty({field = "sudoku", value = sudoku}) - role:log("act_action", {desc = "sudoku", int1 = id, int2 = phase}) + role:log("activity", { + activity_id = id, -- 活动ID(或活动指定任务的ID) + activity_type = 0, -- 活动类型,见活动类型枚举表 + activity_reward = json.encode(reward), -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} + }) SendPacket(actionCodes.Activity_sudokuRpc, MsgPack.pack({task = role:packReward(task, tchange), reward = role:packReward(reward, rchange), rId = rId})) return true @@ -100,6 +104,12 @@ function _M.sudokuRewardRpc(agent, data) end role:updateProperty({field = "sudoku", value = sudoku}) + role:log("activity", { + activity_id = 10000 + phase, -- 活动ID(或活动指定任务的ID) + activity_type = 0, -- 活动类型,见活动类型枚举表 + activity_reward = json.encode(reward), -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} + }) + SendPacket(actionCodes.Activity_sudokuRewardRpc, MsgPack.pack(role:packReward(reward, change))) return true end @@ -156,6 +166,13 @@ function _M.actSignRpc(agent, data) role.activity:updateActData("Sign", curData) reward, change = role:award(reward, {log = {desc = "actSign"}}) end + + role:log("activity", { + activity_id = curData[0], -- 活动ID(或活动指定任务的ID) + activity_type = role.activity.ActivityType.Sign, -- 活动类型,见活动类型枚举表 + activity_reward = json.encode(reward), -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} + }) + SendPacket(actionCodes.Activity_actSignRpc, MsgPack.pack(role:packReward(reward, change))) return true end diff --git a/src/actions/CarAction.lua b/src/actions/CarAction.lua index 4712c81..066dc3a 100644 --- a/src/actions/CarAction.lua +++ b/src/actions/CarAction.lua @@ -41,6 +41,13 @@ function _M.makePotionRpc( agent, data ) role:checkTaskEnter("PotionMake", {count = count, id = potionId}) role:log("role_action", {desc = "makePotion", int1 = potionId, int2 = count}) + role:log("carriage_cook", { + item_id = potionId, -- 道具id + item_level = potionLv, -- 道具等级 + item_type = 0, -- 道具类型,具体见枚举表中道具类型枚举表 + carriage_cook_amount = count, -- 制作总量 + carriage_cook_cost = json.encode(cost), -- 制作消耗道具,json格式记录,{'itemid1':10,'itemid2':5,…………..} + }) SendPacket(actionCodes.Car_makePotionRpc, MsgPack.pack({potionBag = potionBag})) return true end @@ -91,7 +98,14 @@ function _M.equipUpRpc( agent, data ) role:addEquip(typ, nextLv ,count, {log = {desc = "equipUp"}}) role:checkTaskEnter("EquipUp", {count = count}) - role:log("role_action", {desc = "equipUp", int1 = id, int2 = count}) + role:log("equip_upgrade", { + equip_upgrade_part = typ, -- 升级部位,记录部位ID + equip_id = nextLv, -- 升级后的装备ID + equip_upgrade_amount = count, -- 升级获取的装备数量 + equip_upgrade_usedid = lv, -- 升级消耗的装备ID + equip_upgrade_cost = costCount, -- 升级操作消耗装备数量 + equip_upgrade_current = json.encode(cost), -- 升级消耗的货币类型 + }) SendPacket(actionCodes.Car_equipUpRpc, '') return true diff --git a/src/actions/DinerAction.lua b/src/actions/DinerAction.lua index 022aeac..62490e7 100644 --- a/src/actions/DinerAction.lua +++ b/src/actions/DinerAction.lua @@ -140,7 +140,7 @@ function _M.removeSellRpc( agent, data ) return 5 end - role.dinerData:updateSell(slot) + local temp = role.dinerData:updateSell(slot) local reward, change = {} local cost = dishData.material:toNumMap() for k, n in pairs(cost) do @@ -150,7 +150,14 @@ function _M.removeSellRpc( agent, data ) reward, change = role:award(reward, {log = {desc = "removeSell"}}) sells[slot].count = 0 - role:log("diner_action", {desc = "removeSell", int1 = dish}) + role:log("restaurant_sale", { + item_id = dish, -- 售卖物品ID + restaurant_sale_seat = slot, -- 售卖物品所在位置 + restaurant_sale_time = temp.deltaTime or 0, -- 售卖时长 + restaurant_sale_type = 2, -- 售卖方式,正常售卖:0, 加速:1,移除售卖:2 + restaurant_sale_coin = reward[ItemId.DinerCoin] or 0, -- 售卖获得美食币 + restaurant_sale_gear = reward[ItemId.Gold] or 0, -- 售卖获得齿轮 + }) role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) SendPacket(actionCodes.Diner_removeSellRpc, MsgPack.pack({reward = reward, change = change})) @@ -162,8 +169,11 @@ function _M.getSellRewardRpc( agent, data ) local dirty = false local reward, popular = "", 0 local sells = json.decode(role.dinerData:getProperty("sells")) + + local deltaTimes = {} for slot, _ in pairs(sells) do - role.dinerData:updateSell(slot) + local temp = role.dinerData:updateSell(slot) + deltaTimes[slot] = temp.deltaTime end sells = json.decode(role.dinerData:getProperty("sells")) for slot, sell in pairs(sells) do @@ -187,6 +197,15 @@ function _M.getSellRewardRpc( agent, data ) end sells[slot].reward = "" sells[slot].popular = 0 + + role:log("restaurant_sale", { + item_id = sell.dish, -- 售卖物品ID + restaurant_sale_seat = slot, -- 售卖物品所在位置 + restaurant_sale_time = deltaTimes[slot] or 0, -- 售卖时长 + restaurant_sale_type = 0, -- 售卖方式,正常售卖:0, 加速:1,移除售卖:2 + restaurant_sale_coin = rewards[ItemId.DinerCoin] or 0, -- 售卖获得美食币 + restaurant_sale_gear = rewards[ItemId.Gold] or 0, -- 售卖获得齿轮 + }) end role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) local gift = reward:toNumMap() @@ -204,7 +223,7 @@ function _M.getSellRewardRpc( agent, data ) role.dinerData:notifyUpdateProperty("order", role.dinerData:getProperty("order")) end - role:log("diner_action", {desc = "sell"}) + SendPacket(actionCodes.Diner_getSellRewardRpc, MsgPack.pack({reward = reward, change = change})) return true @@ -254,6 +273,15 @@ function _M.expediteSellRpc( agent, data ) dirty = true end end + + role:log("restaurant_sale", { + item_id = sell.dish, -- 售卖物品ID + restaurant_sale_seat = slot, -- 售卖物品所在位置 + restaurant_sale_time = result.deltaTime or 0, -- 售卖时长 + restaurant_sale_type = 1, -- 售卖方式,正常售卖:0, 加速:1,移除售卖:2 + restaurant_sale_coin = rewards[ItemId.DinerCoin] or 0, -- 售卖获得美食币 + restaurant_sale_gear = rewards[ItemId.Gold] or 0, -- 售卖获得齿轮 + }) end end @@ -325,7 +353,13 @@ function _M.levelUpRpc( agent, data ) role.dinerData:updateProperty({field = "buildL", value = buildL:setv(index, curLevel + 1)}) role:checkTaskEnter("DinerLevelUp", {type = index, level = curLevel + 1}) - role:log("diner_action", {desc = "buildUp", int1 = index, int2 = curLevel + 1}) + role:log("restaurant_up", { + restaurant_up_type = index - 1, --升级部件类型,店面:0, 接客:1, 满意度:2, 宣传:3, 广告:4, 周边:5 + restaurant_up_gear = cost[ItemId.Gold] or 0, --消耗齿轮数量 + restaurant_up_coin = cost[ItemId.DinerCoin] or 0, --花费美食币数量 + restaurant_up_effectbef = curLevel, --升级前加成 + restaurant_up_effect = curLevel + 1, --升级后加成 + }) SendPacket(actionCodes.Diner_levelUpRpc, '') return true @@ -409,7 +443,13 @@ function _M.talentUpRpc( agent, data ) role:checkTaskEnter("DinerTalentUp", {type = talentData.effect:toArray(true,"=")[1], level = dishLevel + 1}) role:finishGuide(27) role:log("diner_action", {desc = "talentUp", int1 = dish, int2 = dishLevel + 1}) - + role:log("carriage_logistics", { + carriage_logistics_type = typ, -- 后勤室制作类型ID,变异:0,通常:1,魔法:2 + carriage_logistics_itemid = dish, -- 后勤室升级物品或技能ID + carriage_logistics_itemlv = dishLevel + 1, -- 升级后物品或技能等级 + carriage_logistics_gear = cost[ItemId.Gold] or 0, -- 后勤室升级花费齿轮数量 + carriage_logistics_coin = cost[ItemId.DinerCoin] or 0, -- 后勤室升级花费美食币数量 + }) SendPacket(actionCodes.Diner_talentUpRpc, '') return true end @@ -509,8 +549,6 @@ function _M.updateTaskRpc( agent, data ) orders[index].status = 1 orders[index].lock = 1 - role:log("diner_action", {desc = "getTask", int1 = order.id}) - role:checkTaskEnter("GetOderTask", {rarity = taskSet.rarity}) elseif cmd == 1 then if order.status ~= 1 then @@ -519,8 +557,6 @@ function _M.updateTaskRpc( agent, data ) orders[index].status = 0 orders[index].lock = 0 - role:log("diner_action", {desc = "deleteTask", int1 = order.id}) - elseif cmd == 2 then if order.status ~= 1 then return 32 @@ -528,7 +564,6 @@ function _M.updateTaskRpc( agent, data ) if order.n < taskData.value then return 6 end - role:log("diner_action", {desc = "finishTask", int1 = order.id}) reward, change = role:award(taskData.reward, {log = {desc = "dinerFinishTask", int1 = order.id}}) table.remove(orders,index) @@ -537,6 +572,14 @@ function _M.updateTaskRpc( agent, data ) return 33 end + + role:log("restaurant_order", { + restaurant_order_id = order.id, -- 订单任务ID + restaurant_order_status = cmd, -- 订单任务状态,接受:0, 拒绝:1, 完成:2 + restaurant_order_rwd = json.encode(reward), -- 订单完成奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} + restaurant_order_lv = taskSet.rarity, -- 订单品质等级,普通:0, 稀有:1, 顶级:2, 豪华:3 + }) + role.dinerData:updateProperty({field = "order", value = json.encode(orders)}) SendPacket(actionCodes.Diner_updateTaskRpc, MsgPack.pack({reward = reward, change = change})) return true @@ -687,12 +730,19 @@ function _M.getGreenhouseRpc( agent, data ) else gfood[k].st = st + speed * reward[itemId] end + + role:log("restaurant_material", { + item_id = itemId, -- 获取物品ID + restaurant_material_start = st, -- 申请获取时间 + restaurant_material_time = endTime2 - st, -- 申请到领取耗时 + restaurant_material_num = reward[itemId], -- 获取物品数量 + }) + end role.dinerData:updateProperty({field = "gfood", value = gfood}) local reward, change = role:award(reward, {log = {desc = "greenHourse", int1 = level}}) role:checkTaskEnter("FoodMGet") - role:log("diner_action", {desc = "greenHourse"}) SendPacket(actionCodes.Diner_getGreenhouseRpc, MsgPack.pack({reward = reward, change = change})) return true @@ -858,7 +908,17 @@ function _M.collectRpc(agent , data) local reward, change = role:award(customerData.reward, {log = {desc = "dinerCollect", int1 = id}}) customer[id] = 1 role.dinerData:updateProperty({field = "customer", value = customer}) -- 解锁了 - role:log("diner_action", {desc = "collect", int1 = id}) + + local count = 0 + for c_, v in pairs(customer) do + count = count + 1 + end + + role:log("restaurant_collect", { + restaurant_collect_id = id, -- 图谱收集ID + restaurant_collect_rwd = json.encode(reward), -- 订单完成奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} + restaurant_collect_plan = count, -- 收集进度,即解锁顾客,数字表示 + }) SendPacket(actionCodes.Diner_collectRpc, MsgPack.pack({reward = reward, change = change})) return true diff --git a/src/actions/FriendAction.lua b/src/actions/FriendAction.lua index 0f03f82..b56de5f 100644 --- a/src/actions/FriendAction.lua +++ b/src/actions/FriendAction.lua @@ -217,6 +217,7 @@ local function checkHandleApply(roleId, objectId, needAddNew) red:sismember(FRIEND_BLACK_KEY:format(objectId), roleId) red:sismember(FRIEND_BLACK_KEY:format(roleId), objectId) end) + --自己好友满了 if (redret[1] + needAddNew) >= globalCsv.friendListLimit then return 1 @@ -233,6 +234,8 @@ local function checkHandleApply(roleId, objectId, needAddNew) if redret[4] == 1 then return 4 end + + return nil, redret[1] end function _M.handleApplyRpc(agent, data) @@ -251,7 +254,8 @@ function _M.handleApplyRpc(agent, data) if not redisproxy:zscore(FRIEND_APPLY_KEY:format(roleId), objectId) then return end - result = checkHandleApply(roleId, objectId) + local curCount + result, curCount = checkHandleApply(roleId, objectId) if not result then redisproxy:pipelining(function (red) @@ -277,8 +281,11 @@ function _M.handleApplyRpc(agent, data) otherInfo.pGet = redret[2] == 1 and 1 or nil SendPacket(actionCodes.Friend_updateProperty, MsgPack.pack({newFriend = 1, info = {otherInfo}})) - role:log("role_action", {desc = "addFriend", int1 = 1}) - + role:log("friend_opt", { + friend_opt_type = 100, -- 好友操作类型,见枚举表中 好友操作类型枚举表 + friend_roleid = objectId, -- 好友账户下的角色id + friend_cnt = curCount + 1, -- 操作后好友数量 + }) end elseif cmd == 0 then -- 不同意 @@ -301,7 +308,7 @@ function _M.handleApplyRpc(agent, data) local needAddInfo = {} for _, objId in ipairs(allIds) do objId = tonumber(objId) - local cr = checkHandleApply(roleId, objId, #needAdd) + local cr, curCount = checkHandleApply(roleId, objId, #needAdd) if not cr then table.insert(needAdd, objId) table.insert(needAddMy, objId) @@ -312,6 +319,12 @@ function _M.handleApplyRpc(agent, data) otherInfo.isFriend = true otherInfo.pGet = fpoint[objId] and 1 or nil table.insert(needAddInfo, otherInfo) + + role:log("friend_opt", { + friend_opt_type = 100, -- 好友操作类型,见枚举表中 好友操作类型枚举表 + friend_roleid = objId, -- 好友账户下的角色id + friend_cnt = curCount + 1, -- 操作后好友数量 + }) end end @@ -420,6 +433,11 @@ function _M.deleteRpc(agent, data) end rpcRole(objectId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({deleteFriend = 1, roleId = roleId})) + role:log("friend_opt", { + friend_opt_type = 200, -- 好友操作类型,见枚举表中 好友操作类型枚举表 + friend_roleid = objectId, -- 好友账户下的角色id + friend_cnt = 0, -- 操作后好友数量 + }) SendPacket(actionCodes.Friend_deleteRpc, MsgPack.pack("")) return true end @@ -449,15 +467,18 @@ function _M.blockRpc(agent, data) red:ZREM(FRIEND_APPLY_KEY:format(objectId), roleId) red:sadd(FRIEND_BLACK_KEY:format(roleId), objectId) end) - rpcRole(objectId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({deleteFriend = 1, roleId = roleId})) - + rpcRole(objectId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({deleteFriend = 1, roleId = roleId})) + role:log("friend_opt", { + friend_opt_type = 300, -- 好友操作类型,见枚举表中 好友操作类型枚举表 + friend_roleid = objectId, -- 好友账户下的角色id + friend_cnt = 0, -- 操作后好友数量 + }) end elseif cmd == 2 then redisproxy:SREM(FRIEND_BLACK_KEY:format(roleId), objectId) else return end - SendPacket(actionCodes.Friend_blockRpc, MsgPack.pack({result = result})) return true end diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index 9e05743..6ed77e4 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -16,6 +16,18 @@ local table_unpack = table.unpack local _M = {} +local function getChangeAttrJson(oldAttr, newAttr) + local change = {} + for k, v in pairs(newAttr) do + change[k] = v - oldAttr[k] + change[k] = math.ceil(change[k]) + if change[k] == 0 then + change[k] = nil + end + end + return json.encode(change) +end + function _M.levelUpRpc( agent, data ) local role = agent.role local msg = MsgPack.unpack(data) @@ -28,9 +40,19 @@ function _M.levelUpRpc( agent, data ) local cost = {[ItemId.Exp] = curData.exp, [ItemId.Gold] = curData.gold} if not role:checkItemEnough(cost) then return 3 end role:costItems(cost, {log = {desc = "heroLevelUp", int1 = msg.id, int2 = hero:getProperty("type")}}) + + local oldAttr = hero:getTotalAttrs() + local oldBattleV = hero:getProperty("battleV") hero:updateProperty({field = "level", delta = 1}) - hero:log({desc = "levelUp", int1 = hero:getProperty("level")}) + role:log("hero_upgrade", { + hero_id = hero:getProperty("type"), --英雄ID + hero_upgrade_cost = json.encode(cost), -- 英雄升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} + hero_upgrade_result = getChangeAttrJson(oldAttr, hero:getTotalAttrs()), -- 英雄升级效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..} + hero_upgrade_type = 0, -- 英雄升级方式,连续升级:1,单击升级:0 + hero_upgrade_score = hero:getProperty("battleV"), -- 英雄升级后评分 + hero_upgrade_scoreget = hero:getProperty("battleV") - oldBattleV, -- 通过英雄升级提升的评分 + }) if hero:getProperty("type") == 103 then role:finishGuide(7) @@ -53,9 +75,15 @@ function _M.breakRpc( agent, data ) local cost = {[ItemId.BreakCost] = curData.cost, [ItemId.Gold] = curData.gold} if not role:checkItemEnough(cost) then return 4 end role:costItems(cost, {log = {desc = "heroBreak", int1 = msg.id, int2 = hero:getProperty("type")}}) + local oldAttr = hero:getTotalAttrs() hero:updateProperty({field = "breakL", delta = 1}) - hero:log({desc = "break", int1 = hero:getProperty("breakL")}) + role:log("hero_break", { + hero_id = hero:getProperty("type"), --英雄ID + hero_break_cost = json.encode(cost), -- 英雄突破消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} + hero_break_result = getChangeAttrJson(oldAttr, hero:getTotalAttrs()), -- 英雄突破效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..} + hero_break_level = hero:getMaxLevel(), -- 英雄突破后等级上限 + }) SendPacket(actionCodes.Hero_breakRpc, '') return true @@ -78,6 +106,7 @@ function _M.wakeRpc(agent, data) role:costItems(cost, {log = {desc = "heroWake", int1 = msg.id, int2 = hero:getProperty("type")}}) + local oldAttr = hero:getTotalAttrs() hero:updateProperty({field = "wakeL", delta = 1}) local curLevel = hero:getProperty("wakeL") @@ -85,9 +114,14 @@ function _M.wakeRpc(agent, data) if curLevel == 4 then -- 解锁cg role:checkTaskEnter("WakeCG", {heroType = typ}) end - hero:log({desc = "wake", int1 = hero:getProperty("wakeL")}) - + role:log("hero_rise", { + hero_id = typ, --英雄ID + hero_rise_cost = json.encode(cost), --英雄觉醒消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} + hero_rise_score = hero:getProperty("battleV"), --英雄觉醒后评分提升 + hero_rise_result = getChangeAttrJson(oldAttr, hero:getTotalAttrs()), --英雄觉醒效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..} + }) + SendPacket(actionCodes.Hero_wakeRpc, '') return true end @@ -107,7 +141,10 @@ function _M.talentRpc(agent, data) local curStage = talent:getv(0, 1) local curData = csvdb["unit_talentCsv"][curStage] if not curData then return 4 end + local oldSkillLv = hero:getSkillLevel(1) + + local cost = {} if index == 0 then --是否进阶 local max = true @@ -135,7 +172,7 @@ function _M.talentRpc(agent, data) if talentData.lvRequire > hero:getProperty("level") then return 6 end - local cost = talentData.money:toNumMap() + cost = talentData.money:toNumMap() local cost2 = talentData.cost:toNumMap() for k,v in pairs(cost2) do cost[globalCsv.unit_talent_cost[csvdb["unitCsv"][hero:getProperty("type")].camp][k]] = v @@ -156,7 +193,12 @@ function _M.talentRpc(agent, data) hero:updateProperty({field = "talent", value = talent}) - hero:log({desc = "talent", int1 = index, int2 = talent:getv(index, 0)}) + role:log("hero_talent", { + hero_id = hero:getProperty("type"), --英雄ID + hero_talent_cost = json.encode(cost), -- 英雄天赋升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} + hero_talent_levelbef = oldSkillLv, -- 英雄技能升级前等级 + hero_talent_level = hero:getSkillLevel(1), -- 英雄技能升级后等级 + }) SendPacket(actionCodes.Hero_talentRpc, '') return true @@ -256,6 +298,14 @@ function _M.commentHeroRpc(agent, data) comment.like = 0 result.comment = comment role.dailyData:setProperty("commentHero", curStutus:setv(heroType, 1)) + + + role:log("hero_note", { + hero_id = heroType, -- 英雄ID + hero_note_action = 0, -- 英雄评价界面操作,发布评论:0,点赞:1,反对:2 + hero_note_id = commentId, -- 操作的评价ID + hero_note_text = content, -- 操作的评价内容 + }) end SendPacket(actionCodes.Hero_commentHeroRpc, MsgPack.pack(result)) return true @@ -326,7 +376,7 @@ function _M.likeCommentRpc(agent, data) local commentIndex = heroType .. ":" .. commentId local commentRoleKey = string.format("comment:%d:like", role:getProperty("id")) local redret = redisproxy:pipelining(function (red) - red:hexists(commentKey.commentKey, commentId) + red:hget(commentKey.commentKey, commentId) red:lrem(commentRoleKey, 1, commentIndex) red:lpush(commentRoleKey, commentIndex) red:ltrim(commentRoleKey, 0, 999) @@ -334,7 +384,8 @@ function _M.likeCommentRpc(agent, data) if (tonumber(redret[2]) or 0) > 0 then result.status = 1 else - if redret[1] == 1 then-- 查不到也返回ture + if redret[1] then-- 查不到也返回ture + local comment = json.decode(redret[1]) local redret2 = redisproxy:pipelining(function (red) red:zrevrange(commentKey.commentRankKey, 0, RankLikeNum - 1) --热门 red:zincrby(commentKey.commentRankKey, add, commentId) @@ -360,6 +411,13 @@ function _M.likeCommentRpc(agent, data) red:lrem(commentKey.commentListKey, 0, tempId) end end) + + role:log("hero_note", { + hero_id = heroType, -- 英雄ID + hero_note_action = add > 0 and 1 or 2, -- 英雄评价界面操作,发布评论:0,点赞:1,反对:2 + hero_note_id = commentId, -- 操作的评价ID + hero_note_text = comment.content, -- 操作的评价内容 + }) end end @@ -367,108 +425,6 @@ function _M.likeCommentRpc(agent, data) return true end --- function _M.loveItemRpc(agent, data) --- local role = agent.role --- local msg = MsgPack.unpack(data) --- local hero = role.heros[msg.heroId] --- if not hero then --- return --- end --- local curL = hero:getProperty("loveL") --- local curExp = hero:getProperty("loveExp") --- local curType = hero:getProperty("type") --- local curPlus = csvdb["unit_love_plusCsv"][curType] --- if not curPlus then --- return --- end --- if curL >= curPlus.limit then --- SendPacket(actionCodes.Hero_loveItemRpc, MsgPack.pack({errMsg = 1})) --已满级 --- return true --- end --- local curEffect = csvdb["unit_love_effectCsv"][curL] --- if not curEffect then --- return --- end --- if curExp >= curEffect.loveValue and not msg.bBreak then --- SendPacket(actionCodes.Hero_loveItemRpc, MsgPack.pack({errMsg = 2})) --当前等级经验已满 --- return true --- end - --- if msg.bBreak then --- local cost = curEffect.cost:toArray(true, "=") --- if not role:checkItemEnough({[cost[1]] = cost[2]}) then --- SendPacket(actionCodes.Hero_loveItemRpc, MsgPack.pack({errMsg = 3, itemId = cost[1]})) --物品不足 --- return true --- end --- role:costItems({[cost[1]] = cost[2]}) --- local newLevel = curL + 1 --- hero:updateProperty({field = "loveL", value = newLevel}) --- hero:updateProperty({field = "loveExp", value = 0}) - --- if role:getProperty("loveStatus"):getv(curType, 0) < newLevel then --- role:changeUpdates({{type = "loveStatus", field = curType, value = newLevel}}) -- 总的 --- end - --- role:checkTaskEnter("LoveBreak", {heroType = curType, loveL = newLevel}) - --- else --- local delta = globalCsv.unit_love_presentValue[msg.itemId] --- if not delta then --- return --- end --- if not role:checkItemEnough({[msg.itemId] = 1}) then --- SendPacket(actionCodes.Hero_loveItemRpc, MsgPack.pack({errMsg = 3, itemId = msg.itemId})) --- return true --- end --- local newExp = curExp + delta --- if newExp > curEffect.loveValue then --- newExp = curEffect.loveValue --- end --- role:costItems({[msg.itemId] = 1}) --- hero:updateProperty({field = "loveExp", value = newExp}) --- end --- SendPacket(actionCodes.Hero_loveItemRpc, "") --- return true --- end - --- function _M.loveTaskRpc(agent, data) --- local role = agent.role --- local msg = MsgPack.unpack(data) --- local hero = role.heros[msg.id] --- if not hero then return end - --- local curL = hero:getProperty("loveL") --- local curExp = hero:getProperty("loveExp") --- local curType = hero:getProperty("type") --- local curPlus = csvdb["unit_love_plusCsv"][curType] --- if not curPlus or curL >= curPlus.limit then return end - --- local curEffect = csvdb["unit_love_effectCsv"][curL] --- if not curEffect or curExp < curEffect.loveValue then return end - --- local lastEffect = csvdb["unit_love_effectCsv"][curL + 1] --- local newExp = curExp - curEffect.loveValue --- if lastEffect and curL + 1 < curPlus.limit then --- if newExp >= lastEffect.loveValue then --- -- todo 发任务 --- end --- else --- newExp = 0 --- end --- local newLevel = curL + 1 --- hero:updateProperty({field = "loveExp", value = newExp}) --- hero:updateProperty({field = "loveL", value = newLevel}) - --- if role:getProperty("loveStatus"):getv(curType, 0) < newLevel then --- role:changeUpdates({{type = "loveStatus", field = curType, value = newLevel}}) -- 总的 --- end - --- role:checkTaskEnter("LoveBreak", {heroType = curType, loveL = newLevel}) - --- SendPacket(actionCodes.Hero_loveTaskRpc, "") --- return true --- end - function _M.createHeroRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) @@ -497,6 +453,7 @@ function _M.referEquipsRpc(agent, data) local hero = role.heros[msg.id] if not hero then return 10 end local equips = msg.equips + local isAuto = msg.isAuth if not equips or not next(equips) then return 11 end for typ = 1, 4 do -- 4件装备 @@ -506,6 +463,11 @@ function _M.referEquipsRpc(agent, data) end end end + + local oldAttr = hero:getTotalAttrs() + local oldBattleV = hero:getProperty("battleV") + local wear = {} + local curEquip = hero:getProperty("equip") for typ = 1, 4 do -- 4件装备 if equips[typ] then @@ -516,19 +478,37 @@ function _M.referEquipsRpc(agent, data) else role:addEquip(typ, equips[typ], -1, {log = {desc = "refer"}}) -- 穿上 curEquip = curEquip:setv(typ, equips[typ]) + + wear[typ] = {id = equips[typ], act = 0} end if cur ~= 0 then role:addEquip(typ, cur, 1, {log = {desc = "refer"}}) -- 脱掉 + + wear[typ] = {id = cur, act = 1} end end end end + -- 更新角色 hero:updateProperty({field = "equip", value = curEquip}) role:finishGuide(23) + local curAttr = hero:getTotalAttrs() + local attrChange = getChangeAttrJson(oldAttr, curAttr) + for typ, data in pairs(wear) do + role:log("hero_jewel", { + hero_id = hero:getProperty("type"), --英雄ID + equip_id = data.id, --装备ID + equip_wear_action = data.act, --装备操作类型:装备:0,卸载:1 + equip_wear_part = typ, --装备部位,记录部位ID + equip_wear_result = curAttr, --装备操作后结果,记录属性变化,json格式记录,{“aa”:1234,"bb":4567} + equip_wear_change = attrChange, --装备操作变化值,记录属性变化,记录正负值,json格式记录,{“aa”:1234,"bb":-45} + equip_wear_mode = isAuto and 0 or 1, --用以区分自动装备还是手动装备,自动记录为0,手动记录为1 + }) + end SendPacket(actionCodes.Hero_referEquipsRpc, "") return true end @@ -565,6 +545,9 @@ function _M.referRunesRpc(agent, data) chero:updateProperty({field = "rune", value = hrunes}) end + local oldAttr = hero:getTotalAttrs() + local oldBattleV = hero:getProperty("battleV") + local wear = {} local curRune = hero:getProperty("rune") for typ = 1, 6 do if runes[typ] then @@ -576,6 +559,7 @@ function _M.referRunesRpc(agent, data) local newRune = role.runeBag[runes[typ]] newRune:updateProperty({field = "refer",value = hero:getProperty("id")}) curRune = curRune:setv(typ, runes[typ]) + wear[runes[typ]] = typ end if cur ~= 0 then @@ -587,7 +571,22 @@ function _M.referRunesRpc(agent, data) end end end + hero:updateProperty({field = "rune", value = curRune}) + + local attrChange = getChangeAttrJson(oldAttr, hero:getTotalAttrs()) + for runeId, typ in pairs(wear) do + local ownRune = role.runeBag[runeId] + role:log("hero_jewel", { + hero_id = hero:getProperty("type"), -- 英雄ID + hero_jewel_id = ownRune:getProperty("id"), -- 铭文ID + hero_jewel_part = typ, -- 铭文装备部位 + hero_jewel_score = hero:getProperty("battleV"), -- 铭文装备后的英雄分值 + hero_jewel_scorebefore = oldBattleV, -- 铭文装备前的英雄分值 + hero_jewel_result = attrChange, -- 铭文装备后效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..} + }) + end + SendPacket(actionCodes.Hero_referRunesRpc, "") return true end @@ -675,7 +674,6 @@ function _M.getResetRewardRpc(agent, data) hero:updateProperty({field = "level", value = level}) hero:updateProperty({field = "breakL", value = breakL}) hero:updateProperty({field = "talent", value = ""}) - hero:log({desc = "resetHero"}) for itemId, count in pairs(reward) do reward[itemId] = math.floor(count * globalCsv.unit_back_discount) @@ -683,259 +681,15 @@ function _M.getResetRewardRpc(agent, data) local change reward, change = role:award(reward, {log = {desc = "resetHero", int1 = msg.id, int2 = hero:getProperty("type")}}) + role:log("hero_recycle", { + hero_recycle_list = hero:getProperty("type"), -- 回收的英雄id列表,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} + hero_recycle_reward = json.encode(reward), -- 回收后获得的奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} + hero_recycle_cnt = 1, -- 总回收英雄量 + }) SendPacket(actionCodes.Hero_getResetRewardRpc, MsgPack.pack(role:packReward(reward, change))) return true end -function _M.unuse_drawHeroRpc(agent, data) - local role = agent.role - local msg = MsgPack.unpack(data) - - if not role:isFuncUnlock(FuncUnlock.GetHero) then return end - local btype = msg.pool -- 1 2 3 4 - local drawType = msg.type -- 1 单抽 2 十连 - - local buildTypeData = csvdb["build_typeCsv"][btype] - if not buildTypeData then return 1 end - - local drawCount = {1, 10} -- 抽取次数 - if not drawCount[drawType] then return 2 end - - local newerDraw - if btype == 4 then - newerDraw = role:getProperty("newerDraw") - if math.illegalNum(globalCsv.draw_newer[2] - (newerDraw[1] or 0), drawCount[drawType], globalCsv.draw_newer[2]) then return 11 end - end - - local cost = {} - local lastCount = drawCount[drawType] - for _, costType in ipairs({"draw_card", "draw_coin"}) do - if buildTypeData[costType] ~= "" then - local curCost = buildTypeData[costType]:toArray(true, "=") - local hadCount = role:getItemCount(curCost[1]) - local curCount = math.floor(hadCount / curCost[2]) - if curCount >= lastCount then - cost[curCost[1]] = curCost[2] * lastCount - lastCount = 0 - break - elseif curCount > 0 then - cost[curCost[1]] = curCost[2] * curCount - lastCount = lastCount - curCount - end - end - end - if lastCount > 0 then -- 钱不够 - return 3 - end - - -- pool 固定的 - local poolEnum = { - [1] = { - [1] = 1, - [2] = 2, - [3] = 3, - }, - [2] = 10, - [3] = 11, - [4] = 12, - } - - -- 抽取的池子 - local pool = poolEnum[btype] - if btype == 1 then - -- 超级卡池子 每周轮换 有活动覆盖之 - --TODO 活动判断 - if false then - else - for idx, poolId in pairs(pool) do - if role:isTimeResetOpen(TimeReset["DrawType" .. idx]) then - pool = poolId - break - end - end - if type(pool) ~= "number" then - pool = -1 - end - end - end - local unitPool = csvdb["build_unitCsv"][pool] - if not unitPool then return 4 end - - -- 开始抽 - local resultPool = {} - local function fillDrawPool(fixRare, fixCamp, ssrUp, floorBack) - local condition = {"rare", "camp"} - local values = {fixRare, fixCamp} - - for idx, field in ipairs(condition) do - if not values[idx] then - local lpool = {} - local curIdx = 1 - while unitPool[field .. "_" .. curIdx] do - lpool[curIdx] = {unitPool[field .. "_" .. curIdx]} - curIdx = curIdx + 1 - end - - -- 稀有度 ssr up - if field == "rare" then - local all = 0 - for _, weight in pairs(lpool) do - all = all + weight[1] - end - --[[ - SSR概率值:初始概率 + 步长概率 - SR概率值:初始概率 * [ (初始概率+R初始概率) - 步长概率 ] /(初始概率+R初始概率) - R概率值:初始概率 * [ (初始概率+SR初始概率) - 步长概率 ] /(初始概率+SR初始概率) - ]] - local ssrAdd = (ssrUp or 0) * all - local last = all - lpool[4][1] - lpool[4][1] = lpool[4][1] + ssrAdd - lpool[3][1] = lpool[3][1] * (last - ssrAdd) / last - lpool[2][1] = lpool[2][1] * (last - ssrAdd) / last - end - - if next(lpool) then - values[idx] = math.randWeight(lpool, 1) - end - end - end - - for itemId, oneData in pairs(floorBack and csvdb["build_floorCsv"] or csvdb["build_poolCsv"]) do - if oneData["pool_" .. pool] and oneData["pool_" .. pool] ~= "" then - local itemData = csvdb["itemCsv"][itemId] - while itemData do - if itemData.type ~= ItemType.Hero then break end - local heroData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero] - if not heroData then break end - local ok = true - for idx, field in ipairs(condition) do - if heroData[field] ~= values[idx] then ok = false break end - end - if not ok then break end - if oneData["pool_" .. pool] > 0 then - resultPool[itemId] = {oneData["pool_" .. pool]} -- itemId, count, 概率 - end - break - end - end - end - end - - role:costItems(cost, {log = {desc = "drawHero", short1 = btype, int1 = pool}}) - - local draw_floor_back_counts = globalCsv.draw_floor_back_counts[btype] - local draw_ssr_up_count_rate = globalCsv.draw_ssr_up_count_rate[btype] - local floorHeroCount = role:getProperty("floorHero")[btype] or 0 - local ssrUpCount = role:getProperty("ssrUp")[btype] or 0 - - local newerDrawCount, newerHadSSR - if btype == 4 then - newerDrawCount = newerDraw[1] or 0 - newerHadSSR = newerDraw[2] or 0 - end - - local guideHero - local funcGuide = role:getProperty("funcGuide") - if funcGuide:getv(11001,0) == 1 and funcGuide:getv(12001,0) == 0 then - guideHero = 613 - end - - local ssrCount = 0 - local reward = {} - for i = 1, drawCount[drawType] do - floorHeroCount = floorHeroCount + 1 - if btype == 4 then - newerDrawCount = newerDrawCount + 1 - end - - resultPool = {} - local isFloorBack = draw_floor_back_counts and floorHeroCount >= draw_floor_back_counts - local isNewerSSR = btype == 4 and (newerHadSSR == 0 and newerDrawCount >= globalCsv.draw_newer[1]) or false - - local ssrUp = 0 - if draw_ssr_up_count_rate and ssrUpCount > draw_ssr_up_count_rate[1] then - ssrUp = math.min((ssrUpCount - draw_ssr_up_count_rate[1]) * draw_ssr_up_count_rate[2], draw_ssr_up_count_rate[3]) / 100 - end - while not next(resultPool) do - if isNewerSSR then - fillDrawPool(4) -- 新手保底的 ssr - elseif isFloorBack then - -- 保底 sr 【郑斌】明确 - -- 保底 sr 改为 池子随机 sr 或者 ssr【郑斌】 - fillDrawPool(nil, nil, nil, true) - else - fillDrawPool(nil, nil, ssrUp) - end - end - - -- 引导必送 613 丝路德 - local itemId = math.randWeight(resultPool, 1) - if guideHero then - itemId = guideHero - guideHero = nil - end - local itemData = csvdb["itemCsv"][itemId] - if itemData.quality == 4 then - ssrCount = ssrCount + 1 - ssrUpCount = 0 - if btype == 4 then - newerHadSSR = newerHadSSR + 1 - end - else - ssrUpCount = ssrUpCount + 1 - end - - if itemData.quality >= 3 then - floorHeroCount = 0 - end - - if role:isHaveHero(itemData.id - ItemStartId.Hero) then - local fragId = itemData.id - ItemStartId.Hero - local heroData = csvdb["unitCsv"][fragId] - local count = globalCsv.draw_unit_tofragment[heroData.rare] - role:award({[fragId] = count}, {log = {desc = "drawHero", short1 = btype, int1 = pool}}) - table.insert(reward, {id = fragId, count = count, from = itemId, fcount = 1}) - else - role:award({[itemId] = 1}, {log = {desc = "drawHero", short1 = btype, int1 = pool}}) - table.insert(reward, {id = itemId, count = 1}) - end - end - - if draw_floor_back_counts then - local floorHero = role:getProperty("floorHero") - floorHero[btype] = floorHeroCount - role:setProperty("floorHero", floorHero) - end - - if draw_ssr_up_count_rate then - local ssrUp = role:getProperty("ssrUp") - ssrUp[btype] = ssrUpCount - role:setProperty("ssrUp", ssrUp) - end - - if btype == 4 then - newerDraw[1] = newerDrawCount - newerDraw[2] = newerHadSSR - role:updateProperty({field = "newerDraw", value = newerDraw}) - end - - -- if pool == 1 then - -- local repayHero = role:getProperty("repayHero") - -- repayHero = math.min(globalCsv.draw_super_repay_count, repayHero + drawCount[drawType]) - -- role:updateProperty({field = "repayHero", value = repayHero}) - -- end - - role:finishGuide(11) - - role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]}) - if ssrCount > 0 then - role:checkTaskEnter("DrawSSR", {count = ssrCount}) - end - role:log("hero_action", {desc = "drawHero", short1 = btype, int1 = drawCount[drawType], int2 = pool}) - SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组 - return true -end - function _M.drawHeroRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) @@ -1048,7 +802,7 @@ function _M.drawHeroRpc(agent, data) end end - role:costItems(cost, {log = {desc = "drawHero", short1 = btype, int1 = poolId}}) + role:costItems(cost, {log = {desc = "drawHero", int1 = btype, int2 = poolId}}) local ssrCount = 0 local reward = {} @@ -1077,10 +831,10 @@ function _M.drawHeroRpc(agent, data) local fragId = itemData.id - ItemStartId.Hero local heroData = csvdb["unitCsv"][fragId] local count = globalCsv.draw_unit_tofragment[heroData.rare] - role:award({[fragId] = count}, {log = {desc = "drawHero", short1 = btype, int1 = poolId}}) + role:award({[fragId] = count}, {log = {desc = "drawHero", int1 = btype, int2 = poolId}}) table.insert(reward, {id = fragId, count = count, from = itemId, fcount = 1}) else - role:award({[itemId] = 1}, {log = {desc = "drawHero", short1 = btype, int1 = poolId}}) + role:award({[itemId] = 1}, {log = {desc = "drawHero", int1 = btype, int2 = poolId}}) table.insert(reward, {id = itemId, count = 1}) end end @@ -1101,7 +855,16 @@ function _M.drawHeroRpc(agent, data) if ssrCount > 0 then role:checkTaskEnter("DrawSSR", {count = ssrCount}) end - role:log("hero_action", {desc = "drawHero", short1 = btype, int1 = drawCount[drawType], int2 = poolId}) + role:finishGuide(11) + + role:log("gacha", { + gacha_id = poolId, -- 卡池ID + gacha_type = btype, -- 卡池类型 + gacha_up = 0, -- 卡池UP角色 + gacha_times = drawCount[drawType], -- 抽卡次数 + gacha_reward = json.encode(reward), -- 抽卡结果,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} + currency = json.encode(cost), -- 购买道具消耗的货币 + }) SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组 return true end @@ -1131,7 +894,6 @@ function _M.repayHeroRpc(agent, data) role:award({[id] = 1}, {log = {desc = "heroRepay"}}) reward = {id = id, count = 1} end - role:log("hero_action", {desc = "heroRepay", int1=result}) SendPacket(actionCodes.Hero_repayHeroRpc, MsgPack.pack({reward = reward})) return true end @@ -1168,4 +930,20 @@ function _M.unlockPoolRpc(agent, data) return true end +function _M.changeCrownRpc(agnet, data) + local role = agent.role + local msg = MsgPack.unpack(data) + + local heroType = msg.heroType + + if not role:isHaveHero(heroType) then return end + role:setProperty("crown", heroType) + + role:log("hero_show", { + hero_id = heroType, + }) + SendPacket(actionCodes.Hero_changeCrownRpc, "") + return true +end + return _M \ No newline at end of file diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index dc60791..e80f90e 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -453,11 +453,21 @@ function _M.saleItemRpc(agent, data) end local sellEffect = itemData.sell_effect:toArray(true, "=") reward[sellEffect[1]] = (reward[sellEffect[1]] or 0) + sellEffect[2] * count + + role:log("carriage_decals", { + item_id = itemId, --道具id + item_type = itemData.type, --道具类型,具体见枚举表中道具类型枚举表 + item_level = 0, --道具等级 + item_number = count, --道具变化数量的绝对值 + carriage_decals_rwdid = sellEffect[1], --拆解获得物资ID + carriage_decals_rwdnum = sellEffect[2] * count, --拆解获得物资数量 + }) end role:costItems(backs, {log = {desc = "saleItem"}}) local reward, change = role:award(reward, {log = {desc = "saleItem"}}) role:checkTaskEnter("DecoFrag", {count = fragCount}) + SendPacket(actionCodes.Role_saleItemRpc, MsgPack.pack(role:packReward(reward, change))) return true end @@ -530,12 +540,14 @@ function _M.openTimeBoxRpc(agent, data) elseif oper == 2 then -- 领取 local quick = msg.quick if not boxL[slot] then return end + local costKey = 0 + local costTime = skynet.timex() - boxL[slot].time if boxL[slot].time > skynet.timex() then -- 没开完 if not quick then return end local cost_pre = globalCsv.box_timeOpen_diamond:toArray(true, "=") - local costD = math.ceil((boxL[slot].time - skynet.timex()) / (cost_pre[1] * 60)) * cost_pre[2] - if not role:checkItemEnough({[ItemId.BoxKey] = costD}) then return end - role:costItems({[ItemId.BoxKey] = costD}, {log = {desc = "openTimeBox"}}) + local costKey = math.ceil((boxL[slot].time - skynet.timex()) / (cost_pre[1] * 60)) * cost_pre[2] + if not role:checkItemEnough({[ItemId.BoxKey] = costKey}) then return end + role:costItems({[ItemId.BoxKey] = costKey}, {log = {desc = "openTimeBox"}}) end local boxId = boxL[slot].id local itemData = csvdb["itemCsv"][boxId] @@ -565,6 +577,17 @@ function _M.openTimeBoxRpc(agent, data) boxL[slot] = nil reward, change = role:award(reward, {log = {desc = "openTimeBox", int1 = boxId}}) role:checkTaskEnter("OpenBox", {id = boxId, count=1}) + + role:log("carriage_dismantle", { + item_id = boxId, -- 道具id + item_type = itemData.type, -- 道具类型,具体见枚举表中道具类型枚举表 + item_level = 0, -- 道具等级 + item_number = 1, -- 道具变化数量的绝对值 + carriage_dismantle_type = quick and 1 or 0, -- 拆解方式,时间到期:0,钥匙开启:1 + carriage_dismantle_time = costTime, -- 拆解耗时,填写实际耗时 + carriage_dismantle_cost = costKey, -- 拆解花费钥匙数量,未使用填写0 + carriage_dismantle_rwd = json.encode(reward), -- 拆解获得物资,json格式记录,{'itemid1':2,'itemid2':3,…………..} + }) else return end @@ -652,6 +675,15 @@ function _M.storyBookRewardRpc(agent, data) storyStatus[storyId].s = -1 role:changeUpdates({{ type = "storyB", field = storyId, value = storyStatus[storyId] }}) local reward, change = role:award(storyBookData.gift, {log = {desc = "storybookReward", int1 = storyId}}) + + role:log("carriage_decals", { + carriage_video_type = storyBookData.type, --放映室类型,剧情CG:0, 角色CG:1, 主线剧情:2, 角色剧情:3, 活动剧情:4, 图鉴:5 + carriage_video_id = storyId, --放映室片段ID + carriage_video_coinid = reward[ItemId.Gold] and ItemId.Gold or 0, --放映奖励货币类型,无奖励则填写0 + carriage_video_coinnum = reward[ItemId.Gold] or 0, --放映奖励货币数量,无奖励则填写0 + carriage_video_item = json.encode(reward), --放映奖励其他物品数量,json格式记录,{'itemid1':10,'itemid2':5,…………..},无奖励则填写0 + }) + SendPacket(actionCodes.Role_storyBookRewardRpc, MsgPack.pack(role:packReward(reward, change))) return true end @@ -714,6 +746,12 @@ function _M.taskRpc(agent, data) local oldVal = role:getProperty("battlePoint") or 0 role:updateProperty({field = "battlePoint", value = oldVal + taskData.active}) + role:log("task_reward", { + task_reward_id = taskId, --任务奖励ID + task_reward_type = taskType, --任务奖励类型,见 任务奖励类型枚举表 + task_reward_detail = json.encode(reward), --任务奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} + }) + SendPacket(actionCodes.Role_taskRpc, MsgPack.pack(role:packReward(reward, change))) return true end @@ -803,6 +841,12 @@ function _M.achiveRpc(agent, data) end end + role:log("achievement", { + achievement_id = taskId, -- 成就id + achievement_type = achiveTask.type, -- 成就类型,具体枚举表中成就类型枚举表 + achievement_reward = json.encode(reward), -- 达成成就奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} + }) + SendPacket(actionCodes.Role_achiveRpc, MsgPack.pack(role:packReward(reward, change))) return true end @@ -921,6 +965,13 @@ function _M.chatRpc(agent, data) if not result then check[cmd]() end + + role:log("communication", { + publish_type = cmd, --发言类型,1,世界 2私聊 + publish_status = 0, --发送状态,发送成功:0,发送失败:1,被屏蔽:2,其他:3 + publish_receive_roleid = msg.roleId, --接收者角色ID + publish_text = content, --发言内容 + }) SendPacket(actionCodes.Role_chatRpc, MsgPack.pack({result = result, waitTime = waitTime})) return true end @@ -979,8 +1030,15 @@ function _M.drawCodeRpc(agent, data) if ret == 0 then local giftId = tonumber(result.giftId) role:setProperty("codeStr", codestr:setv(giftId, 1)) - local reward, change = role:award(result.gift, {log = {desc = "drawCode", key1 = code, int1 = giftId}}) + local reward, change = role:award(result.gift, {log = {desc = "drawCode", int1 = giftId}}) + role:log("get_gift", { + gift_id = giftId, -- 礼包ID + gift_key = code, -- 礼包key + gift_reward = json.encode(reward), -- 礼包奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} + gift_name = "", -- 礼包名称 + gift_reason = 0, -- 礼包发放原因,见发放原因枚举表 + }) SendPacket(actionCodes.Role_drawCodeRpc, MsgPack.pack({ result = ret, reward = reward, diff --git a/src/actions/StoreAction.lua b/src/actions/StoreAction.lua index 0545987..5d901ae 100644 --- a/src/actions/StoreAction.lua +++ b/src/actions/StoreAction.lua @@ -195,82 +195,6 @@ function _M.purchaseOrderResult(agent, data) end -function _M.dailyBuyRpc(agent , data) - local role = agent.role - local msg = MsgPack.unpack(data) - local id = msg.id - local count = msg.count or 1 - - local dataSet = csvdb["shop_diamondCsv"][id] - if not dataSet then return 1 end - - local dailySDC = role.dailyData:getProperty("dailySDC") - - if math.illegalNum(count, 1, (dataSet.limit == 0 and math.huge or dataSet.limit - (dailySDC[id] or 0))) then return 1 end - - local cost = dataSet.cost - - local dailySDD = role.dailyData:getProperty("dailySDD") - if dailySDD[id] then -- 折扣 - cost = math.ceil(cost * (1 - dataSet.disount / 100)) - end - - if not role:costDiamond({count = cost * count, log = {desc = "dailyShop", int1 = id, int2 = count}}) then - return 4 - end - - if dataSet.limit ~= 0 then - dailySDC[id] = (dailySDC[id] or 0) + count - role.dailyData:updateProperty({field = "dailySDC", value = dailySDC}) - end - local gift = {} - for itemId, count_ in pairs(dataSet.gift:toNumMap()) do - gift[itemId] = count_ * count - end - local reward = role:award(gift, {log = {desc = "dailyShop", int1 = id, int2 = count}}) - role:checkTaskEnter("ShopAll", {count = count}) - - role:log("role_action", {desc = "dailyShop", int1 = id, int2 = count}) - - SendPacket(actionCodes.Store_dailyBuyRpc, MsgPack.pack({reward = reward})) - return true -end - - -function _M.dinerBuyRpc(agent , data) - local role = agent.role - local msg = MsgPack.unpack(data) - local id = msg.id - local count = msg.count or 1 - - local dataSet = csvdb["shop_dinerCsv"][id] - if not dataSet then return end - - local dinerS = role:getProperty("dinerS") - if math.illegalNum(count, 1, (dataSet.limit == 0 and math.huge or dataSet.limit - (dinerS[id] or 0))) then return 1 end - - local cost = {[ItemId.DinerCoin] = dataSet.cost * count} - if not role:checkItemEnough(cost) then return end - - if dataSet.limit ~= 0 then - dinerS[id] = (dinerS[id] or 0) + count - role:updateProperty({field = "dinerS", value = dinerS}) - end - - role:costItems(cost, {log = {desc = "dinerShop", int1 = id, int2 = count}}) - - local gift = {} - for _id, _count in pairs(dataSet.gift:toNumMap()) do - gift[_id] = _count * count - end - local reward = role:award(gift, {log = {desc = "dinerShop", int1 = id, int2 = count}}) - - role:log("role_action", {desc = "dinerShop", int1 = id, int2 = count}) - - SendPacket(actionCodes.Store_dinerBuyRpc, MsgPack.pack({reward = reward})) - return true -end - function _M.shopBuyRpc(agent , data) local role = agent.role local msg = MsgPack.unpack(data) @@ -325,8 +249,17 @@ function _M.shopBuyRpc(agent , data) if dataSet.shop == 1 then role:checkTaskEnter("ShopAll", {count = count}) end - role:log("role_action", {desc = desc, int1 = id, int2 = count}) - + local costId, costCount = next(cost) + + role:log("shop_purchase", { + item_id = id, -- 道具id + item_type = 0, -- 道具类型,具体见枚举表中道具类型枚举表 + item_level = 0, -- 道具等级 + item_cnt = count, -- 购买数量技术 + currency_type = costId or 0, -- 购买道具消耗的货币类型,记录货币ID + shop_purchase_current = costCount or 0, -- 购买道具消耗的货币数量 + shop_id = dataSet.shop, -- 商店ID + }) SendPacket(actionCodes.Store_shopBuyRpc, MsgPack.pack({reward = reward})) return true end diff --git a/src/models/Activity.lua b/src/models/Activity.lua index 4b416de..5ead353 100644 --- a/src/models/Activity.lua +++ b/src/models/Activity.lua @@ -215,6 +215,13 @@ function Activity:checkWeeklyAct(actType, notify, count, pool) end if not curData[cfg.id] and curData[0] >= cfg.condition1 then if info.mailId then + + self.owner:log("activity", { + activity_id = cfg.id, -- 活动ID(或活动指定任务的ID) + activity_type = actType, -- 活动类型,见活动类型枚举表 + activity_reward = json.encode(cfg.reward:toNumMap()), -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} + }) + self.owner:sendMail(info.mailId, nil, cfg.reward, {cfg.condition1}) curData[cfg.id] = 1 end diff --git a/src/models/Diner.lua b/src/models/Diner.lua index 0dc7e9e..57cb7b1 100644 --- a/src/models/Diner.lua +++ b/src/models/Diner.lua @@ -304,6 +304,7 @@ function Diner:expediteSell(slot) lastCount = lastCount, reward = reward, popular = popular, + deltaTime = deltaTime, } end diff --git a/src/models/RoleLog.lua b/src/models/RoleLog.lua index 7e3928e..ac217fe 100644 --- a/src/models/RoleLog.lua +++ b/src/models/RoleLog.lua @@ -119,7 +119,7 @@ local MethodType = { onLogout = { -- 登出 logtime = true, --登录时长 }, - setLevel = { -- 设置等级 --TODO + setLevel = { -- 设置等级 level_before = true, -- 变动前的等级,可以跳级 level_changemain = true, -- 等级变动原因,副本通关:mission,领取奖励:reward level_changedetail = true, -- 等级变动原因明细,副本通关则记录关卡ID,领取奖励则记录奖励ID @@ -157,7 +157,7 @@ local MethodType = { mail_friend_id = true, -- 收件方账号id mail_friend_roleid = true, -- 收件方角色id }, - onItems = { --道具流通 --TODO + onItems = { --道具流通 item_id = true, -- 道具id item_sequenceid = "ucode", -- 道具变动关联ID,用于关联一次动作产生多条不同类型的日志,如一个礼包多个物品等情形 item_type = true, -- 道具类型,具体见枚举表中道具类型枚举表 @@ -203,13 +203,13 @@ local MethodType = { residence_time = true, --挂机或排名时长 residence_reward = true, --获得奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} }, - hero_rise = { --英雄觉醒 --TODO + hero_rise = { --英雄觉醒 hero_id = true, --英雄ID hero_rise_cost = true, --英雄觉醒消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} hero_rise_score = true, --英雄觉醒后评分提升 hero_rise_result = true, --英雄觉醒效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..} }, - hero_upgrade = { --英雄升级 --TODO + hero_upgrade = { --英雄升级 hero_id = true, -- 英雄ID hero_upgrade_cost = true, -- 英雄升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} hero_upgrade_result = true, -- 英雄升级效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..} @@ -217,34 +217,34 @@ local MethodType = { hero_upgrade_score = true, -- 英雄升级后评分 hero_upgrade_scoreget = true, -- 通过英雄升级提升的评分 }, - hero_break = { --英雄突破 --TODO + hero_break = { --英雄突破 hero_id = true, -- 英雄ID hero_break_cost = true, -- 英雄突破消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} hero_break_result = true, -- 英雄突破效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..} hero_break_level = true, -- 英雄突破后等级上限 }, - hero_talent = { --英雄天赋升级 --TODO + hero_talent = { --英雄天赋升级 hero_id = true, -- 英雄ID hero_talent_cost = true, -- 英雄天赋升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} hero_talent_levelbef = true, -- 英雄技能升级前等级 hero_talent_level = true, -- 英雄技能升级后等级 }, - hero_jewel = { --英雄铭文 --TODO + hero_jewel = { --英雄铭文 hero_id = true, -- 英雄ID - hero_jewel_sequence = true, -- 铭文装备编号,用以关联一次装备时产生的多条日志 + hero_jewel_sequence = "ucode", -- 铭文装备编号,用以关联一次装备时产生的多条日志 hero_jewel_id = true, -- 铭文ID hero_jewel_part = true, -- 铭文装备部位 hero_jewel_score = true, -- 铭文装备后的英雄分值 hero_jewel_scorebefore = true, -- 铭文装备前的英雄分值 hero_jewel_result = true, -- 铭文装备后效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..} }, - hero_note = { --英雄评价 --TODO + hero_note = { --英雄评价 hero_id = true, -- 英雄ID hero_note_action = true, -- 英雄评价界面操作,发布评论:0,点赞:1,反对:2 hero_note_id = true, -- 操作的评价ID hero_note_text = true, -- 操作的评价内容 }, - hero_show = { --展示英雄 --TODO + hero_show = { --展示英雄 hero_id = true, -- 英雄ID }, hero_recycle = { --英雄回收 @@ -252,17 +252,15 @@ local MethodType = { hero_recycle_reward = true, -- 回收后获得的奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} hero_recycle_cnt = true, -- 总回收英雄量 }, - gacha = { --英雄招募 --TODO + gacha = { --英雄招募 gacha_id = true, -- 卡池ID gacha_type = true, -- 卡池类型 gacha_up = true, -- 卡池UP角色 gacha_times = true, -- 抽卡次数 gacha_reward = true, -- 抽卡结果,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} - currency_type = true, -- 购买道具消耗的货币类型,记录货币ID - gacha_current = true, -- 购买道具消耗的货币数量 - gacha_cnt = true, -- 此卡池内的计数器 + currency = true, -- 消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} }, - equip_wear = { --装备穿戴与卸载 --TODO + equip_wear = { --装备穿戴与卸载 hero_id = true, --英雄ID equip_id = true, --装备ID equip_wear_action = true, --装备操作类型:装备:0,卸载:1 @@ -270,19 +268,17 @@ local MethodType = { equip_wear_result = true, --装备操作后结果,记录属性变化,json格式记录,{“aa”:1234,"bb":4567} equip_wear_change = true, --装备操作变化值,记录属性变化,记录正负值,json格式记录,{“aa”:1234,"bb":-45} equip_wear_mode = true, --用以区分自动装备还是手动装备,自动记录为0,手动记录为1 - equip_wear_seqid = true, --自动穿戴时记录的系列ID,用以关联一次性装备时候产生的多条记录 + equip_wear_seqid = "ucode", --自动穿戴时记录的系列ID,用以关联一次性装备时候产生的多条记录 }, - equip_upgrade = { --装备升级 --TODO - hero_id = true, -- 英雄ID + equip_upgrade = { --装备升级 equip_upgrade_part = true, -- 升级部位,记录部位ID equip_id = true, -- 升级后的装备ID equip_upgrade_amount = true, -- 升级获取的装备数量 equip_upgrade_usedid = true, -- 升级消耗的装备ID equip_upgrade_cost = true, -- 升级操作消耗装备数量 - equip_upgrade_currentid = true, -- 升级消耗的货币类型 equip_upgrade_current = true, -- 升级操作消耗货币数量 }, - carriage_dismantle = { --物资拆解 --TODO + carriage_dismantle = { --物资拆解 item_id = true, -- 道具id item_sequenceid = "ucode", -- 道具变动关联ID,用于关联一次动作产生多条不同类型的日志,如一个礼包多个物品等情形 item_type = true, -- 道具类型,具体见枚举表中道具类型枚举表 @@ -293,14 +289,14 @@ local MethodType = { carriage_dismantle_cost = true, -- 拆解花费钥匙数量,未使用填写0 carriage_dismantle_rwd = true, -- 拆解获得物资,json格式记录,{'itemid1':2,'itemid2':3,…………..} }, - carriage_logistics = { --后勤室 --TODO + carriage_logistics = { --后勤室 carriage_logistics_type = true, -- 后勤室制作类型ID,变异:0,通常:1,魔法:2 carriage_logistics_itemid = true, -- 后勤室升级物品或技能ID carriage_logistics_itemlv = true, -- 升级后物品或技能等级 carriage_logistics_gear = true, -- 后勤室升级花费齿轮数量 carriage_logistics_coin = true, -- 后勤室升级花费美食币数量 }, - carriage_decals = { --贴纸拆解 --TODO + carriage_decals = { --贴纸拆解 item_id = true, --道具id item_sequenceid = "ucode", --道具变动关联ID,用于关联一次动作产生多条不同类型的日志,如一个礼包多个物品等情形 item_type = true, --道具类型,具体见枚举表中道具类型枚举表 @@ -309,31 +305,31 @@ local MethodType = { carriage_decals_rwdid = true, --拆解获得物资ID carriage_decals_rwdnum = true, --拆解获得物资数量 }, - carriage_video = { --放映室 --TODO + carriage_video = { --放映室 carriage_video_type = true, --放映室类型,剧情CG:0, 角色CG:1, 主线剧情:2, 角色剧情:3, 活动剧情:4, 图鉴:5 carriage_video_id = true, --放映室片段ID carriage_video_coinid = true, --放映奖励货币类型,无奖励则填写0 carriage_video_coinnum = true, --放映奖励货币数量,无奖励则填写0 carriage_video_item = true, --放映奖励其他物品数量,json格式记录,{'itemid1':10,'itemid2':5,…………..},无奖励则填写0 }, - carriage_cook = { --调理室 --TODO + carriage_cook = { --调理室 item_id = true, -- 道具id item_level = true, -- 道具等级 item_type = true, -- 道具类型,具体见枚举表中道具类型枚举表 carriage_cook_amount = true, -- 制作总量 carriage_cook_cost = true, -- 制作消耗道具,json格式记录,{'itemid1':10,'itemid2':5,…………..} }, - activity = { --活动或指南奖励 --TODO + activity = { --活动或指南奖励 activity_id = true, -- 活动ID(或活动指定任务的ID) activity_type = true, -- 活动类型,见活动类型枚举表 activity_reward = true, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} }, - task_reward = { --任务奖励 --TODO + task_reward = { --任务奖励 task_reward_id = true, --任务奖励ID task_reward_type = true, --任务奖励类型,见 任务奖励类型枚举表 task_reward_detail = true, --任务奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} }, - shop_purchase = { --商店购买行为 --TODO + shop_purchase = { --商店购买行为 item_id = true, -- 道具id item_sequenceid = "ucode", -- 道具变动关联ID,用于关联一次动作产生多条不同类型的日志,如一个购买礼包多个物品等情形 item_type = true, -- 道具类型,具体见枚举表中道具类型枚举表 @@ -343,7 +339,13 @@ local MethodType = { shop_purchase_current = true, -- 购买道具消耗的货币数量 shop_id = true, -- 商店ID }, - friend_opt = { --好友操作 --TODO + --[[ + 100 添加好友 + 200 删除好友 + 300 屏蔽/拉黑 + 1000 其他 + --]] + friend_opt = { --好友操作 friend_opt_type = true, -- 好友操作类型,见枚举表中 好友操作类型枚举表 friend_accountid = true, -- 好友账户id friend_roleid = true, -- 好友账户下的角色id @@ -357,21 +359,20 @@ local MethodType = { friend_accountid = true, -- 好友账户id friend_roleid = true, -- 好友账户下的角色id }, - communication = { --玩家发言 --TODO + communication = { --玩家发言 publish_type = true, --发言类型,全部:0,公告:1,世界:2,联盟:3,私聊:4 publish_status = true, --发送状态,发送成功:0,发送失败:1,被屏蔽:2,其他:3 - publish_receive_accid = true, --接收者账户ID publish_receive_roleid = true, --接收者角色ID publish_text = true, --发言内容 }, - restaurant_up = { --摊位升级 --TODO + restaurant_up = { --摊位升级 restaurant_up_type = true, --升级部件类型,店面:0, 接客:1, 满意度:2, 宣传:3, 广告:4, 周边:5 restaurant_up_gear = true, --消耗齿轮数量 restaurant_up_coin = true, --花费美食币数量 restaurant_up_effectbef = true, --升级前加成 restaurant_up_effect = true, --升级后加成 }, - restaurant_sale = { --摊位售卖 --TODO + restaurant_sale = { --摊位售卖 item_id = true, -- 售卖物品ID restaurant_sale_seat = true, -- 售卖物品所在位置 restaurant_sale_time = true, -- 售卖时长 @@ -379,34 +380,30 @@ local MethodType = { restaurant_sale_coin = true, -- 售卖获得美食币 restaurant_sale_gear = true, -- 售卖获得齿轮 }, - restaurant_material = { --食材获取 --TODO + restaurant_material = { --食材获取 item_id = true, -- 获取物品ID - restaurant_material_seqid = true, -- 道具变动关联ID,用于关联一次动作产生多条不同类型的日志,如一次获取两件道具情况 + restaurant_material_seqid = "ucode", -- 道具变动关联ID,用于关联一次动作产生多条不同类型的日志,如一次获取两件道具情况 restaurant_material_start = true, -- 申请获取时间 restaurant_material_time = true, -- 申请到领取耗时 restaurant_material_num = true, -- 获取物品数量 }, - restaurant_order = { --订单任务 --TODO + restaurant_order = { --订单任务 restaurant_order_id = true, -- 订单任务ID restaurant_order_status = true, -- 订单任务状态,接受:0, 拒绝:1, 完成:2 - restaurant_order_start = true, -- 订单接收时间,timestamp格式记录 restaurant_order_rwd = true, -- 订单完成奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} restaurant_order_lv = true, -- 订单品质等级,普通:0, 稀有:1, 顶级:2, 豪华:3 }, - restaurant_collect = { --餐厅顾客图谱 --TODO + restaurant_collect = { --餐厅顾客图谱 restaurant_collect_id = true, -- 图谱收集ID restaurant_collect_rwd = true, -- 订单完成奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} restaurant_collect_plan = true, -- 收集进度,即解锁顾客,数字表示 }, - achievement = { --成就达成 --TODO + achievement = { --成就达成 achievement_id = true, -- 成就id achievement_type = true, -- 成就类型,具体枚举表中成就类型枚举表 - achievement_name = true, -- 成就名称 - achievement_score = true, -- 领取成就后成就点数 - achievement_subscore = true, -- 领取成就后小类成就点数 achievement_reward = true, -- 达成成就奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} }, - get_gift = { --礼包兑换 --TODO + get_gift = { --礼包兑换 gift_id = true, -- 礼包ID gift_key = true, -- 礼包key gift_reward = true, -- 礼包奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} @@ -493,7 +490,14 @@ function RoleLog.bind(Role) pcall(skynet.send, logd, "lua", "log", doc) end - function Role:logItems(itemId, before, after, reason, subreason, other) + function Role:logItems(itemId, before, after, log) + if not log then + print("logItems no log ", debug.traceback()) + end + local reason = log.desc + local subreason = log.int1 or 0 + local other = log.int2 or 0 + local reasonType = ItemReason[reason] if not reasonType then printError(string.format("LOG ERROR: onItems no reasonType [%s].", reason)) diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index b39f1ba..e75e2a0 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -258,12 +258,7 @@ function RolePlugin.bind(Role) items = items:incrv(params.itemId, params.count) end - if params.log then - local log = params.log - self:logItems(params.itemId, origin, nums, log.desc, log.sub, log.other) - else - print("addItem no log ", debug.traceback()) - end + self:logItems(params.itemId, origin, nums, params.log) self:setProperty("items", items) if not params.notNotify then @@ -333,13 +328,7 @@ function RolePlugin.bind(Role) self:incrProperty("diamond", count) end - if params.log then - local log = clone(params.log) - self:logItems(ItemId.Diamond, origin, count, log.desc, log.sub, log.other) - else - print("gainDiamond no log ", debug.traceback()) - end - + self:logItems(ItemId.Diamond, origin, count, params.log) self:notifyUpdateProperty("diamond", self:getAllDiamond()) return true end @@ -377,12 +366,8 @@ function RolePlugin.bind(Role) self:incrProperty(costFirst[2], -last) end - if params.log then - local log = clone(params.log) - self:logItems(ItemId.Diamond, origin, count, log.desc, log.sub, log.other) - else - print("costDiamond no log ", debug.traceback()) - end + + self:logItems(ItemId.Diamond, origin, count, params.log) self:notifyUpdateProperty("diamond", self:getAllDiamond()) return true @@ -418,12 +403,9 @@ function RolePlugin.bind(Role) local bin = MsgPack.pack(heroResponse) SendPacket(actionCodes.Hero_loadInfos, bin) end - if params.log then - local log = clone(params.log) - self:logItems(heroType + ItemStartId.Hero, 0, 1, log.desc, log.sub, log.other) - else - print("addHero no log ", debug.traceback()) - end + + self:logItems(heroType + ItemStartId.Hero, 0, 1, params.log) + return true, newHero end @@ -514,7 +496,8 @@ function RolePlugin.bind(Role) if not equipCsv then return end local equips = self:getProperty("equips") local curTypeEquips = equips[equipType] or {} - local curCount = (curTypeEquips[equipLv] or 0) + count + local oldCount = curTypeEquips[equipLv] or 0 + local curCount = oldCount + count -- 是否足够上层判断 if curCount < 0 then @@ -532,22 +515,7 @@ function RolePlugin.bind(Role) self:setProperty("equips", equips) - if pms.log then - local log = clone(pms.log) - if log["cint1"] or log["cint2"] or log["cint3"] then - print("addEquip error log have cint1 or cint2 or cint3 ", debug.traceback()) - end - log["cint1"] = equipType - log["cint2"] = equipLv - log["cint3"] = math.abs(count) - if count < 0 then - self:log("out_equip", log) - else - self:log("in_equip", log) - end - else - print("addEquip no log ", debug.traceback()) - end + self:logItems(equipCsv.id, oldCount, curCount, pms.log) if not pms.notNotify then self:changeUpdates({{type = "equips", field = {equipType, equipLv}, value = curCount, isOnlyToC = true}}) -- 通知客户端 @@ -607,20 +575,7 @@ function RolePlugin.bind(Role) end self:checkTaskEnter("AddRune", {id = params.id, type = params.type, rarity = data.rarity}, params.notNotify) - if params.log then - local log = clone(params.log) - if log["cint1"] or log["cint2"] or log["cint3"] then - print("addRune error log have cint1 or cint2 or cint3 ", debug.traceback()) - end - - log["cint1"] = runeUid - log["cint2"] = params.type - log["cint3"] = params.id - - self:log("in_rune", log) - else - print("addRune no log ", debug.traceback()) - end + self:logItems(params.id, 0, 1, params.log) return 0, newRune else @@ -636,20 +591,7 @@ function RolePlugin.bind(Role) local rune = self.runeBag[runeId] if rune and rune:getProperty("refer") == 0 then - if params.log then - local log = clone(params.log) - if log["cint1"] or log["cint2"] or log["cint3"] then - print("delRunes error log have cint1 or cint2 or cint3 ", debug.traceback()) - end - - log["cint1"] = runeId - log["cint2"] = rune:getProperty("type") - log["cint3"] = rune:getProperty("id") - - self:log("out_rune", log) - else - print("delRunes no log ", debug.traceback()) - end + self:logItems(rune:getProperty("id"), 1, 0, params.log) self.runeBag[runeId] = nil table.insert(bDel, runeId) @@ -895,19 +837,7 @@ function RolePlugin.bind(Role) count = count or 1 - if params.log then - local log = clone(params.log) - if log["cint1"] or log["cint2"] or log["cint3"] then - print("funcOpen error log have cint1 or cint2 or cint3 ", debug.traceback()) - end - - log["cint1"] = func - log["cint2"] = count - - self:log("func_open", log) - else - print("funcOpen no log ", debug.traceback()) - end + self:logItems(equipCsv.id, 0, count, params.log) if csvdb["itemCsv"][func] and csvdb["itemCsv"][func].type == ItemType.FuncOpen then local unlockData = csvdb["unlockCsv"][func] -- libgit2 0.21.2