UIGuildCreateCtr.lua 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. local UIGuildCreateCtr = class("UIGuildCreateCtr", require("UICtrBase"))
  2. function UIGuildCreateCtr:Init(view)
  3. self.view = view
  4. end
  5. function UIGuildCreateCtr:SetData(data)
  6. self.asyncIdx = 0
  7. self.data = data
  8. self:InitData()
  9. end
  10. function UIGuildCreateCtr:GetAsyncIdx()
  11. self.asyncIdx = self.asyncIdx + 1
  12. return self.asyncIdx
  13. end
  14. function UIGuildCreateCtr:GetData()
  15. return self.data
  16. end
  17. function UIGuildCreateCtr:OnDispose()
  18. self.data = nil
  19. self.view = nil
  20. self.nameMinLength = nil
  21. self.nameMaxLength = nil
  22. self.badgeId = nil
  23. self.guildName = nil
  24. self.costItemCfgId = nil
  25. self.costNum = nil
  26. end
  27. function UIGuildCreateCtr:IsInGuild()
  28. return false
  29. end
  30. function UIGuildCreateCtr:InitData()
  31. self.nameMinLength = 1
  32. self.nameMaxLength = 8
  33. local nameLimitStr = GlobalConfig.Instance:GetConfigStrValue(213)
  34. if nameLimitStr then
  35. local nameLimitArr = string.split(nameLimitStr, ':')
  36. if nameLimitArr and #nameLimitArr >= 2 then
  37. self.nameMinLength = tonumber(nameLimitArr[1])
  38. self.nameMaxLength = tonumber(nameLimitArr[2])
  39. end
  40. end
  41. self.badgeId = GlobalConfig.Instance:GetConfigIntValue(217)
  42. self.costItemCfgId = 1
  43. self.costNum = 100
  44. local costStr = GlobalConfig.Instance:GetConfigStrValue(210)
  45. if costStr then
  46. local costStrArr = string.split(costStr, ':')
  47. if costStrArr then
  48. if costStrArr[1] then
  49. self.costItemCfgId = tonumber(costStrArr[1])
  50. end
  51. if costStrArr[2] then
  52. self.costNum = tonumber(costStrArr[2])
  53. end
  54. end
  55. end
  56. end
  57. function UIGuildCreateCtr:GetBadgeId()
  58. return self.badgeId
  59. end
  60. function UIGuildCreateCtr:SetBadgeId(badgeId)
  61. if self.badgeId == badgeId then
  62. return false
  63. end
  64. self.badgeId = badgeId
  65. return true
  66. end
  67. function UIGuildCreateCtr:GetGuildName()
  68. return self.guildName or ''
  69. end
  70. function UIGuildCreateCtr:SetGuildName(guildName)
  71. if self.guildName == guildName then
  72. return false
  73. end
  74. self.guildName = guildName
  75. return true
  76. end
  77. function UIGuildCreateCtr:GetCostInfo()
  78. return self.costItemCfgId, self.costNum
  79. end
  80. function UIGuildCreateCtr:GetNameLengthMin()
  81. return self.nameMinLength
  82. end
  83. function UIGuildCreateCtr:GetNameLengthMax()
  84. return self.nameMaxLength
  85. end
  86. function UIGuildCreateCtr:GetOwnResCountByItemId(itemCfgId)
  87. return CommonUtil.GetOwnResCountByItemId(itemCfgId)
  88. end
  89. function UIGuildCreateCtr:SendCreateGuildReq()
  90. if not self.guildName then
  91. return 523
  92. end
  93. local len = GetActualStringLength(self.guildName)
  94. local min = self:GetNameLengthMin()
  95. local max = self:GetNameLengthMax()
  96. if len < min or len > max then
  97. return 522
  98. end
  99. if not SDKMgr.Instance:CheckName(self.guildName) then
  100. return 'ShieldTips02'
  101. end
  102. if CommonUtil.GetOwnResCountByItemId(self.costItemCfgId) < self.costNum then
  103. return 514
  104. end
  105. if not ManagerContainer.DataMgr.GuildDataMgr:SendBuildGuildReq(self.guildName, self.badgeId) then
  106. return 100007
  107. end
  108. return 0
  109. end
  110. return UIGuildCreateCtr