ExpeditionBuff.lua 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. local ExpeditionBuff = class("ExpeditionBuff")
  2. function ExpeditionBuff:ctor(id,ratio,cd,type,extendPara,fun)
  3. self.buffId = id
  4. self.buffRatio = ratio
  5. self.buffCd = cd
  6. self.buffType = type
  7. self.extendPara = extendPara
  8. self.funList = {}
  9. self:AddFun(fun)
  10. end
  11. function ExpeditionBuff:AddFun(funs)
  12. if funs == nil then
  13. return
  14. end
  15. for i = 1, #funs do
  16. local funParam = funs[i]
  17. local fun = self:FindFunById(funParam[1])
  18. if fun == nil then
  19. self.funList[#self.funList+1] = DeepCopy(funParam)
  20. else
  21. fun[2] = fun[2] + funParam[2]
  22. end
  23. end
  24. end
  25. function ExpeditionBuff:FindFunById(funId)
  26. if self.funList == nil then
  27. return nil
  28. end
  29. for i = 1, #self.funList do
  30. if self.funList[i][1] == funId then
  31. return self.funList[i]
  32. end
  33. end
  34. return nil
  35. end
  36. function ExpeditionBuff:ConvertFunToStr()
  37. if self.funList == nil or #self.funList == 0 then
  38. return ""
  39. end
  40. local funListStr = ""
  41. for i = 1, #self.funList do
  42. local fun = self.funList[i]
  43. if #fun > 0 then
  44. local funStr = ""
  45. for j = 1, #fun do
  46. if j == 1 then
  47. funStr = tostring(fun[j])
  48. else
  49. funStr = funStr .. ":" .. fun[j]
  50. end
  51. end
  52. if i == 1 then
  53. funListStr = funStr
  54. else
  55. funListStr = funListStr .. ";" .. funStr
  56. end
  57. end
  58. end
  59. return funListStr
  60. end
  61. return ExpeditionBuff