Commit c6f3e36c4818dbd5cea07c15fc1eee4a5c44a7da
1 parent
39bcd7ca
错误的语法
Showing
2 changed files
with
39 additions
and
63 deletions
Show diff stats
src/models/RoleLog.lua
@@ -491,6 +491,26 @@ function RoleLog.bind(Role) | @@ -491,6 +491,26 @@ function RoleLog.bind(Role) | ||
491 | pcall(skynet.send, logd, "lua", "log", doc) | 491 | pcall(skynet.send, logd, "lua", "log", doc) |
492 | end | 492 | end |
493 | 493 | ||
494 | + function Role:logItems(itemId, before, after, reason, subreason, other) | ||
495 | + local reasonType = ItemReason[reason] | ||
496 | + if not reasonType then | ||
497 | + printError(string.format("LOG ERROR: onItems no reasonType [%s].", reason)) | ||
498 | + end | ||
499 | + local itemData = csvdb["itemCsv"][itemId] | ||
500 | + if not itemData then return end | ||
501 | + self:log("onItems", { | ||
502 | + item_id = itemId, -- 道具id | ||
503 | + item_type = itemData.type, -- 道具类型,具体见枚举表中道具类型枚举表 | ||
504 | + item_level = 0, -- 道具等级 | ||
505 | + item_number = math.abs(after - before), -- 道具变化数量的绝对值 | ||
506 | + action_type = after - before > 0 and 1 or 0, -- 变化类型(玩家获取:1,玩家消耗:0) | ||
507 | + item_before = before, -- 道具变化前的数量 | ||
508 | + item_after = after, -- 道具变化后的数量 | ||
509 | + item_reason = reasonType, -- 道具流动一级原因,如抽卡、装备强化、副本掉落,可参考道具动作类型枚举表 | ||
510 | + item_subreason = subreason, -- 道具流动二级原因,抽卡:卡池ID,装备强化:装备ID,副本掉落:副本ID | ||
511 | + item_other = other, -- 其他(可包含阶数,强化等级,随机属性) | ||
512 | + }) | ||
513 | + end | ||
494 | 514 | ||
495 | function Role:startActionUcode() | 515 | function Role:startActionUcode() |
496 | if not self._uniqueCount then | 516 | if not self._uniqueCount then |
src/models/RolePlugin.lua
@@ -224,12 +224,18 @@ function RolePlugin.bind(Role) | @@ -224,12 +224,18 @@ function RolePlugin.bind(Role) | ||
224 | end | 224 | end |
225 | end | 225 | end |
226 | if level > oldLevel then | 226 | if level > oldLevel then |
227 | - self:log("setLevel", { | ||
228 | - level_before = oldLevel, | ||
229 | - level_changemain = params.level_changemain, | ||
230 | - level_changedetail = 0, | ||
231 | - level_reward = "{}", | ||
232 | - }) | 227 | + if params.log then |
228 | + local log = params.log | ||
229 | + self:log("setLevel", { | ||
230 | + level_before = oldLevel, | ||
231 | + level_changemain = log.desc, | ||
232 | + level_changedetail = log.sub, | ||
233 | + level_reward = "{}", | ||
234 | + }) | ||
235 | + else | ||
236 | + print("addPlayExp no log ", debug.traceback()) | ||
237 | + end | ||
238 | + | ||
233 | end | 239 | end |
234 | 240 | ||
235 | self:updateProperties({level = level, exp = newExp}) | 241 | self:updateProperties({level = level, exp = newExp}) |
@@ -253,17 +259,8 @@ function RolePlugin.bind(Role) | @@ -253,17 +259,8 @@ function RolePlugin.bind(Role) | ||
253 | end | 259 | end |
254 | 260 | ||
255 | if params.log then | 261 | if params.log then |
256 | - local log = clone(params.log) | ||
257 | - if log["cint1"] or log["cint2"] then | ||
258 | - print("addItem error log have cint1 or cint2 ", debug.traceback()) | ||
259 | - end | ||
260 | - log["cint1"] = params.itemId | ||
261 | - log["cint2"] = math.abs(params.count) | ||
262 | - if params.count <= 0 then | ||
263 | - self:log("out_item", log) | ||
264 | - else | ||
265 | - self:log("in_item", log) | ||
266 | - end | 262 | + local log = params.log |
263 | + self:logItems(params.itemId, origin, nums, log.desc, log.sub, log.other) | ||
267 | else | 264 | else |
268 | print("addItem no log ", debug.traceback()) | 265 | print("addItem no log ", debug.traceback()) |
269 | end | 266 | end |
@@ -338,12 +335,7 @@ function RolePlugin.bind(Role) | @@ -338,12 +335,7 @@ function RolePlugin.bind(Role) | ||
338 | 335 | ||
339 | if params.log then | 336 | if params.log then |
340 | local log = clone(params.log) | 337 | local log = clone(params.log) |
341 | - if log["cint1"] or log["cint2"] or log["cint3"] then | ||
342 | - print("costDiamond error log have cint1 or cint2 or cint3 ", debug.traceback()) | ||
343 | - end | ||
344 | - log["cint1"] = origin | ||
345 | - log["cint2"] = count | ||
346 | - self:log("in_diamond", log) | 338 | + self:logItems(ItemId.Diamond, origin, count, log.desc, log.sub, log.other) |
347 | else | 339 | else |
348 | print("gainDiamond no log ", debug.traceback()) | 340 | print("gainDiamond no log ", debug.traceback()) |
349 | end | 341 | end |
@@ -352,6 +344,7 @@ function RolePlugin.bind(Role) | @@ -352,6 +344,7 @@ function RolePlugin.bind(Role) | ||
352 | return true | 344 | return true |
353 | end | 345 | end |
354 | 346 | ||
347 | + | ||
355 | function Role:costDiamond(params) | 348 | function Role:costDiamond(params) |
356 | if not params or type(params) ~= "table" then return false end | 349 | if not params or type(params) ~= "table" then return false end |
357 | local count = tonum(params.count) | 350 | local count = tonum(params.count) |
@@ -386,12 +379,7 @@ function RolePlugin.bind(Role) | @@ -386,12 +379,7 @@ function RolePlugin.bind(Role) | ||
386 | 379 | ||
387 | if params.log then | 380 | if params.log then |
388 | local log = clone(params.log) | 381 | local log = clone(params.log) |
389 | - if log["cint1"] or log["cint2"] or log["cint3"] then | ||
390 | - print("costDiamond error log have cint1 or cint2 or cint3 ", debug.traceback()) | ||
391 | - end | ||
392 | - log["cint1"] = origin | ||
393 | - log["cint2"] = count | ||
394 | - self:log("out_diamond", log) | 382 | + self:logItems(ItemId.Diamond, origin, count, log.desc, log.sub, log.other) |
395 | else | 383 | else |
396 | print("costDiamond no log ", debug.traceback()) | 384 | print("costDiamond no log ", debug.traceback()) |
397 | end | 385 | end |
@@ -432,12 +420,7 @@ function RolePlugin.bind(Role) | @@ -432,12 +420,7 @@ function RolePlugin.bind(Role) | ||
432 | end | 420 | end |
433 | if params.log then | 421 | if params.log then |
434 | local log = clone(params.log) | 422 | local log = clone(params.log) |
435 | - if log["cint1"] or log["cint2"] or log["cint3"] then | ||
436 | - print("addHero error log have cint1 or cint2 or cint3 ", debug.traceback()) | ||
437 | - end | ||
438 | - log["cint1"] = heroId | ||
439 | - log["cint2"] = heroType | ||
440 | - self:log("in_hero", log) | 423 | + self:logItems(heroType + ItemStartId.Hero, 0, 1, log.desc, log.sub, log.other) |
441 | else | 424 | else |
442 | print("addHero no log ", debug.traceback()) | 425 | print("addHero no log ", debug.traceback()) |
443 | end | 426 | end |
@@ -453,33 +436,6 @@ function RolePlugin.bind(Role) | @@ -453,33 +436,6 @@ function RolePlugin.bind(Role) | ||
453 | end | 436 | end |
454 | end | 437 | end |
455 | 438 | ||
456 | - function Role:delHero(heroId, params) | ||
457 | - params = params or {} | ||
458 | - local roleId = self:getProperty('id') | ||
459 | - local hero = self.heros[heroId] | ||
460 | - local heroType = hero:getProperty("type") | ||
461 | - if not hero then return end | ||
462 | - | ||
463 | - self.heros[heroId] = nil | ||
464 | - redisproxy:pipelining(function (red) | ||
465 | - red:del(string.format(R_HERO, roleId, heroId)) | ||
466 | - red:srem(string.format(R_HEROS, roleId), heroId) | ||
467 | - end) | ||
468 | - | ||
469 | - if params.log then | ||
470 | - local log = clone(params.log) | ||
471 | - if log["cint1"] or log["cint2"] or log["cint3"] then | ||
472 | - print("delHero error log have cint1 or cint2 or cint3 ", debug.traceback()) | ||
473 | - end | ||
474 | - log["cint1"] = heroId | ||
475 | - log["cint2"] = heroType | ||
476 | - self:log("out_hero", log) | ||
477 | - else | ||
478 | - print("delHero no log ", debug.traceback()) | ||
479 | - end | ||
480 | - | ||
481 | - SendPacket(actionCodes.Hero_loadInfos, MsgPack.pack({{id = heroId, bDel = true}})) | ||
482 | - end | ||
483 | 439 | ||
484 | function Role:loadHeros() | 440 | function Role:loadHeros() |
485 | local roleId = self:getProperty("id") | 441 | local roleId = self:getProperty("id") |
@@ -1514,7 +1470,7 @@ function RolePlugin.bind(Role) | @@ -1514,7 +1470,7 @@ function RolePlugin.bind(Role) | ||
1514 | return | 1470 | return |
1515 | end | 1471 | end |
1516 | 1472 | ||
1517 | - local order_type = self.getProperty("rmbC") > 0 and 0 or 1 | 1473 | + local order_type = self:getProperty("rmbC") > 0 and 0 or 1 |
1518 | local status, reward = self:recharge({ | 1474 | local status, reward = self:recharge({ |
1519 | id = rechargeId | 1475 | id = rechargeId |
1520 | }) | 1476 | }) |