RoleSetting.lua 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. RoleSetting = {}
  2. local this = {}
  3. local roleSettingKey = "T$role_type_value_settings"
  4. local RoleSettingType = {
  5. enableCombo = 37, -- 是否开启连击显示
  6. showVip = 38, -- 是否开启VIP显示
  7. }
  8. function RoleSetting.login(actor)
  9. sendluamsg(actor,LuaMessageIdToClient.RES_ROLE_SETTINGS, this.getStates(actor))
  10. end
  11. function RoleSetting.updateState(actor, msg)
  12. local type = msg.type or 0
  13. local value = msg.value
  14. for RoleType, typeValue in pairs(RoleSettingType) do
  15. if tonumber(type) == typeValue then
  16. local states = this.getStates(actor)
  17. states[type] = value
  18. setplaydef(actor, roleSettingKey, states)
  19. end
  20. end
  21. sendluamsg(actor,LuaMessageIdToClient.RES_ROLE_SETTINGS, this.getStates(actor))
  22. end
  23. function this.getStates(actor)
  24. return getplaydef(actor, roleSettingKey) or {}
  25. end
  26. --- func desc 获取目标vip等级
  27. ---@param actor any
  28. function RoleSetting.getTargetVipLv(actor, targetRids)
  29. if table.isNullOrEmpty(targetRids) then
  30. return
  31. end
  32. local info = {}
  33. for _, targetRid in ipairs(targetRids) do
  34. local lv = VipGiftPack.getTargetVipLv(actor, targetRid)
  35. info[targetRid] = lv
  36. end
  37. sendluamsg(actor, LuaMessageIdToClient.RES_TARGET_VIP_LV, info)
  38. end