ConditionManager.lua 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ConditionManager = {}
  2. local this = ConditionManager
  3. function ConditionManager.getParam(singleCondition)
  4. local strs = string.split(singleCondition, '#')
  5. local id = tonumber(strs[1])
  6. local param = string.replace(singleCondition, strs[1] .. '#', '') --strs[2]
  7. return id, param
  8. end
  9. function ConditionManager.Check(actor, conditionCfg)
  10. if string.isNullOrEmpty(conditionCfg) then
  11. return true
  12. end
  13. local groupStr = string.split(conditionCfg, '/')
  14. local result = false
  15. for i = 1, #groupStr do
  16. local singleStrs = string.split(groupStr[i], '&')
  17. local andResult = true
  18. for j = 1, #singleStrs do
  19. local id, param = this.getParam(singleStrs[j])
  20. local check = ConditionHandler:triggerCheck(id, actor, param)
  21. andResult = andResult and check
  22. end
  23. result = result or andResult
  24. if (result) then
  25. break
  26. end
  27. end
  28. return result
  29. end
  30. function checkfunc(actor, param)
  31. jprint("条件检测参数", param)
  32. local res = ConditionManager.Check(actor, param)
  33. jprint("条件检测结果", res)
  34. end