RoleScriptLog.lua 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. PlayOperation = {
  2. LOGOUT = "登出游戏",
  3. GO_TO_ATLANTIS = "前往亚特兰蒂斯",
  4. GO_TO_DEVIL_SQUARE = "进入恶魔广场",
  5. GO_TO_BLOODY_CASTLE = "进入血色城堡",
  6. GO_TO_BRAVE_CHALLENGE = "进入勇气试炼",
  7. MINUTE_HEART = "分钟心跳",
  8. }
  9. RoleScriptLog = {}
  10. local this = {}
  11. function RoleScriptLog.RoleMinuteHeart(actor)
  12. RoleScriptLog.Log(actor, PlayOperation.MINUTE_HEART, 1)
  13. end
  14. function RoleScriptLog.RoleLevelUp(actor, level)
  15. local needLevelCfg = ConfigDataManager.getTableValue("cfg_global", "value", "id", 400)
  16. local needLevelSplit = string.split(needLevelCfg, "#")
  17. local needLevel = tonumber(needLevelSplit[1])
  18. local mailId = tonumber(needLevelSplit[2])
  19. if tonumber(level) >= needLevel then
  20. local record = getplaydef(actor, PlayerDefKey.LEVEL_UP_TEST_MAIL_RECORD)
  21. if record == nil or type(record) ~= "table" then
  22. record = {}
  23. end
  24. local contains = table.contains(record, needLevel)
  25. if not contains then
  26. local itemStr = ConfigDataManager.getTableValue("cfg_global", "value", "id", 401)
  27. local itemMap = string.toIntIntMap(itemStr, "#", "|")
  28. sendconfigmailbyrid(actor, actor:toString(), mailId, itemMap)
  29. table.insert(record, needLevel)
  30. setplaydef(actor, PlayerDefKey.LEVEL_UP_TEST_MAIL_RECORD, record)
  31. end
  32. end
  33. end
  34. function RoleScriptLog.CreateRole(actor)
  35. local now = getbaseinfo("now")
  36. setplaydef(actor, PlayerDefKey.LAST_LOG_RECORD_TIME, now)
  37. setplaydef(actor, PlayerDefKey.ONLINE_DURATION, 0)
  38. end
  39. function RoleScriptLog.RoleLogin(actor)
  40. -- local now = getbaseinfo("now")
  41. local oldDuration = getplaydef(actor, PlayerDefKey.ONLINE_DURATION)
  42. if tonumber(oldDuration) == nil then
  43. setplaydef(actor, PlayerDefKey.ONLINE_DURATION, 0)
  44. end
  45. -- setplaydef(actor, PlayerDefKey.LAST_LOG_RECORD_TIME, now)
  46. end
  47. function RoleScriptLog.RoleLogout(actor)
  48. --todo 记录GM压测日志
  49. RoleScriptLog.Log(actor, PlayOperation.LOGOUT)
  50. end
  51. function RoleScriptLog.EnterMap(actor, lastMapCfgId, mapCfgId)
  52. if mapCfgId == 1008 or mapCfgId == 1108 then
  53. RoleScriptLog.Log(actor, PlayOperation.GO_TO_ATLANTIS)
  54. end
  55. end
  56. function RoleScriptLog.Log(actor, operation, timeAdd)
  57. if timeAdd == nil then
  58. timeAdd = 0
  59. end
  60. local oldDuration = getplaydef(actor, PlayerDefKey.ONLINE_DURATION)
  61. oldDuration = tonumber(oldDuration)
  62. if oldDuration == nil or oldDuration <= 0 then
  63. oldDuration = 0
  64. end
  65. -- local now = getbaseinfo("now")
  66. -- local lastLoginMills = getplaydef(actor, PlayerDefKey.LAST_LOG_RECORD_TIME)
  67. -- if tonumber(lastLoginMills) == nil then
  68. -- lastLoginMills = now
  69. -- end
  70. -- local thisDuration = math.round(math.max(0, (now - lastLoginMills) / 60000))
  71. local newDuration = oldDuration + timeAdd
  72. setplaydef(actor, PlayerDefKey.ONLINE_DURATION, newDuration)
  73. -- setplaydef(actor, PlayerDefKey.LAST_LOG_RECORD_TIME, now)
  74. logplayoperation(actor, operation, newDuration)
  75. end
  76. -- 注册等级提升事件
  77. -- LevelUpEventListerTable:eventLister("0", "压测日志", RoleScriptLog.RoleLevelUp, 5000)