CareerUnlock.lua 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. --处理职业解锁
  2. CareerUnlock = {}
  3. function CareerUnlock.unlock(actor, currLevel)
  4. --jprint("当前等级", currLevel)
  5. local configList = ConfigDataManager.getList("cfg_character_create")
  6. for _, config in pairs(configList) do
  7. local unlockLevel = table.getValue(config, "conditionlv")
  8. if not string.isNullOrEmpty(unlockLevel) then
  9. local unlockLevelNum = tonumber(unlockLevel)
  10. local id = tonumber(table.getValue(config, "id"))
  11. --print("比较", unlockLevel, currLevel,id)
  12. if unlockLevelNum > 0 and currLevel >= unlockLevelNum then
  13. local uid = getbaseinfo(actor, "uid")
  14. unlockusercareer(actor, id, uid)
  15. end
  16. end
  17. end
  18. end
  19. -- ------------------------------------------------------------- --
  20. CareerChange = {}
  21. local ChangeCareerItemType = 3
  22. local ChangeCareerItemSubType = 95
  23. local LevelCmd = "@setLv %s"
  24. local CareerCmd = "@transferCareer %s"
  25. -- 该物品为测试道具 无需仔细校验
  26. function CareerChange.useItemChangeCareer(actor, itemId)
  27. local config = ConfigDataManager.getById("cfg_item", itemId)
  28. if table.isEmpty(config) then
  29. return
  30. end
  31. local type = tonumber(config['type'])
  32. local subType = tonumber(config['subtype'])
  33. if type ~= ChangeCareerItemType or subType ~= ChangeCareerItemSubType then
  34. return
  35. end
  36. local useParamStr = config['useparam']
  37. if not useParamStr then
  38. return
  39. end
  40. local useParam = string.split(useParamStr, "#")
  41. local level = getbaseinfo(actor, "level")
  42. if tonumber(level) < tonumber(useParam[1]) then
  43. local levelGmCmd = string.format(LevelCmd, useParam[1])
  44. gmexecute(actor, levelGmCmd)
  45. end
  46. local careerGmCmd = string.format(CareerCmd, useParam[2])
  47. gmexecute(actor, careerGmCmd)
  48. end