Commit c6f3e36c4818dbd5cea07c15fc1eee4a5c44a7da

Authored by zhouhaihai
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 491 pcall(skynet.send, logd, "lua", "log", doc)
492 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 515 function Role:startActionUcode()
496 516 if not self._uniqueCount then
... ...
src/models/RolePlugin.lua
... ... @@ -224,12 +224,18 @@ function RolePlugin.bind(Role)
224 224 end
225 225 end
226 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 239 end
234 240  
235 241 self:updateProperties({level = level, exp = newExp})
... ... @@ -253,17 +259,8 @@ function RolePlugin.bind(Role)
253 259 end
254 260  
255 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 264 else
268 265 print("addItem no log ", debug.traceback())
269 266 end
... ... @@ -338,12 +335,7 @@ function RolePlugin.bind(Role)
338 335  
339 336 if params.log then
340 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 339 else
348 340 print("gainDiamond no log ", debug.traceback())
349 341 end
... ... @@ -352,6 +344,7 @@ function RolePlugin.bind(Role)
352 344 return true
353 345 end
354 346  
  347 +
355 348 function Role:costDiamond(params)
356 349 if not params or type(params) ~= "table" then return false end
357 350 local count = tonum(params.count)
... ... @@ -386,12 +379,7 @@ function RolePlugin.bind(Role)
386 379  
387 380 if params.log then
388 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 383 else
396 384 print("costDiamond no log ", debug.traceback())
397 385 end
... ... @@ -432,12 +420,7 @@ function RolePlugin.bind(Role)
432 420 end
433 421 if params.log then
434 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 424 else
442 425 print("addHero no log ", debug.traceback())
443 426 end
... ... @@ -453,33 +436,6 @@ function RolePlugin.bind(Role)
453 436 end
454 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 440 function Role:loadHeros()
485 441 local roleId = self:getProperty("id")
... ... @@ -1514,7 +1470,7 @@ function RolePlugin.bind(Role)
1514 1470 return
1515 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 1474 local status, reward = self:recharge({
1519 1475 id = rechargeId
1520 1476 })
... ...