ItemManagerProxy.lua 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. local RemoteProxy = requireProxy("remote/RemoteProxy")
  2. local ItemManagerProxy = class("ItemManagerProxy", RemoteProxy)
  3. ItemManagerProxy.NAME = global.ProxyTable.ItemManagerProxy
  4. --README: 储存下道具来源,道具归属等信息
  5. ItemManagerProxy.ItemType = {
  6. DruaAndSomething = 1, -- 道具表 StdMode 0~3 的道具
  7. SkillBook = 2, -- 技能书
  8. Equip = 3, -- 装备
  9. Bundle = 4, -- 困束
  10. Box = 5, -- 盒子
  11. TreasureMap = 6, -- StdMode 为 101 的道具
  12. FashionItem = 7, -- 时装道具
  13. MonsterCard = 8, -- 怪物卡片
  14. SomethingCanUse = 9, -- StdMode 为 49 的道具
  15. BoxKey = 10, -- 箱子钥匙
  16. Collimator = 11, -- 准星道具
  17. WishBox = 12, -- StdMode 为 96 的道具
  18. NewPet = 13, -- 宠物系统,道具使用
  19. Other = 99 -- 其他
  20. }
  21. function ItemManagerProxy:ctor()
  22. ItemManagerProxy.super.ctor(self)
  23. self.itemDataFrom = {}
  24. end
  25. function ItemManagerProxy:GetItemSettingType()
  26. return clone(self.ItemType)
  27. end
  28. function ItemManagerProxy:SetItemBelong(MakeIndex, from)
  29. self.itemDataFrom[MakeIndex] = from
  30. end
  31. function ItemManagerProxy:GetItemBelong(MakeIndex)
  32. return self.itemDataFrom[MakeIndex]
  33. end
  34. function ItemManagerProxy:CleanItemBelongs()
  35. self.itemDataFrom = {}
  36. end
  37. function ItemManagerProxy:GetItemTypeByStdMode(stdMode)
  38. local AttrConfigProxy = global.Facade:retrieveProxy(global.ProxyTable.AttrConfigProxy)
  39. local equipMap = AttrConfigProxy:GetItemsConfigEquipMapByStdMode()
  40. local stdMode = stdMode or 0
  41. local type = self.ItemType.Other
  42. if stdMode >= 0 and stdMode <= 3 then
  43. type = self.ItemType.DruaAndSomething
  44. elseif stdMode == 4 then
  45. type = self.ItemType.SkillBook
  46. elseif equipMap[stdMode] or stdMode == 25 then --特殊 护身符
  47. type = self.ItemType.Equip
  48. elseif stdMode == 31 then -- 困 束
  49. type = self.ItemType.Bundle
  50. elseif stdMode == 200 then -- 盒子
  51. type = self.ItemType.Box
  52. elseif stdMode == 101 then
  53. type = self.ItemType.TreasureMap
  54. elseif stdMode == 102 then
  55. type = self.ItemType.FashionItem
  56. elseif stdMode == 103 then
  57. type = self.ItemType.MonsterCard
  58. elseif stdMode == 49 then
  59. type = self.ItemType.SomethingCanUse
  60. elseif stdMode == 40 then
  61. type = self.ItemType.BoxKey
  62. elseif stdMode == 47 then --准星道具
  63. type = self.ItemType.Collimator
  64. elseif stdMode == 201 then --新宠物系统
  65. type = self.ItemType.NewPet
  66. end
  67. return type
  68. end
  69. function ItemManagerProxy:IsBestRings(item)
  70. return item.StdMode > 99 and item.StdMode < 112
  71. end
  72. function ItemManagerProxy:IsCityStoneByIndex(Index)
  73. for k, v in pairs(SL:GetMetaValue("GAME_DATA","cityStone")) do
  74. if v == Index then
  75. return true
  76. end
  77. end
  78. return false
  79. end
  80. function ItemManagerProxy:IsRandStoneByIndex(Index)
  81. for k, v in pairs(SL:GetMetaValue("GAME_DATA","randStone")) do
  82. if v == Index then
  83. return true
  84. end
  85. end
  86. return false
  87. end
  88. function ItemManagerProxy:IsCityStone(item)
  89. if item and next(item) then
  90. for k, v in pairs(SL:GetMetaValue("GAME_DATA","cityStone")) do
  91. if v == item.Index then
  92. return true
  93. end
  94. end
  95. end
  96. return false
  97. end
  98. function ItemManagerProxy:IsRandStone(item)
  99. if item and next(item) then
  100. for k, v in pairs(SL:GetMetaValue("GAME_DATA","randStone")) do
  101. if v == item.Index then
  102. return true
  103. end
  104. end
  105. end
  106. return false
  107. end
  108. --是否是时装道具
  109. function ItemManagerProxy:IsFashionEquip(item)
  110. if item and item.StdMode then
  111. local fashionStdMode = {[66] = true, [67] = true, [68] = true, [69] = true}
  112. if fashionStdMode[item.StdMode] then
  113. return true
  114. end
  115. end
  116. return false
  117. end
  118. function ItemManagerProxy:GetItemType(item)
  119. if not item or not next(item) then
  120. return self.ItemType.Other
  121. end
  122. local type = self:GetItemTypeByStdMode(item.StdMode)
  123. return type
  124. end
  125. function ItemManagerProxy:RemoveItems(itemList)
  126. if not itemList or next(itemList) == nil then
  127. return
  128. end
  129. for _, MakeIndex in pairs(itemList) do
  130. local itemBelong = self:GetItemBelong(MakeIndex)
  131. if not itemBelong then
  132. return
  133. end
  134. if itemBelong == global.MMO.ITEM_FROM_BELONG_BAG then
  135. local BagProxy = global.Facade:retrieveProxy(global.ProxyTable.Bag)
  136. local itemData = BagProxy:GetItemDataByMakeIndex(MakeIndex)
  137. if itemData then
  138. BagProxy:DelItemData(itemData, true)
  139. end
  140. elseif itemBelong == global.MMO.ITEM_FROM_BELONG_EQUIP then
  141. local EquipProxy = global.Facade:retrieveProxy(global.ProxyTable.Equip)
  142. local itemData = EquipProxy:GetEquipDataByMakeIndex(MakeIndex)
  143. if itemData then
  144. EquipProxy:DelEquipData(itemData)
  145. end
  146. elseif itemBelong == global.MMO.ITEM_FROM_BELONG_QUICKUSE then
  147. local QuickUseProxy = global.Facade:retrieveProxy(global.ProxyTable.QuickUseProxy)
  148. local pos = QuickUseProxy:GetQucikUsePosByMakeIndex(MakeIndex)
  149. local itemData = QuickUseProxy:GetQucikUseDataByMakeIndex(MakeIndex)
  150. if pos and itemData then
  151. local BagProxy = global.Facade:retrieveProxy(global.ProxyTable.Bag)
  152. BagProxy:ShowGetOrCostItems(-(itemData.OverLap or 1), itemData.Name)
  153. QuickUseProxy:SetQuickUsePosData(pos, itemData, true)
  154. end
  155. elseif itemBelong == global.MMO.ITEM_FROM_BELONG_HEROBAG then
  156. local HeroBagProxy = global.Facade:retrieveProxy(global.ProxyTable.HeroBagProxy)
  157. local itemData = HeroBagProxy:GetItemDataByMakeIndex(MakeIndex)
  158. if itemData then
  159. HeroBagProxy:DelItemData(itemData, true)
  160. end
  161. elseif itemBelong == global.MMO.ITEM_FROM_BELONG_HEROEQUIP then
  162. local HeroEquipProxy = global.Facade:retrieveProxy(global.ProxyTable.HeroEquipProxy)
  163. local itemData = HeroEquipProxy:GetEquipDataByMakeIndex(MakeIndex)
  164. if itemData then
  165. HeroEquipProxy:DelEquipData(itemData)
  166. end
  167. end
  168. end
  169. end
  170. function ItemManagerProxy:GetItemDataByMakeIndex(MakeIndex)
  171. local itemData = nil
  172. if MakeIndex then
  173. local itemBelong = self:GetItemBelong(MakeIndex)
  174. if itemBelong then
  175. if itemBelong == global.MMO.ITEM_FROM_BELONG_BAG then
  176. local BagProxy = global.Facade:retrieveProxy(global.ProxyTable.Bag)
  177. itemData = BagProxy:GetItemDataByMakeIndex(MakeIndex)
  178. elseif itemBelong == global.MMO.ITEM_FROM_BELONG_EQUIP then
  179. local EquipProxy = global.Facade:retrieveProxy(global.ProxyTable.Equip)
  180. itemData = EquipProxy:GetEquipDataByMakeIndex(MakeIndex)
  181. elseif itemBelong == global.MMO.ITEM_FROM_BELONG_QUICKUSE then
  182. local QuickUseProxy = global.Facade:retrieveProxy(global.ProxyTable.QuickUseProxy)
  183. itemData = QuickUseProxy:GetQucikUseDataByMakeIndex(MakeIndex)
  184. elseif itemBelong == global.MMO.ITEM_FROM_BELONG_HEROBAG then
  185. local HeroBagProxy = global.Facade:retrieveProxy(global.ProxyTable.HeroBagProxy)
  186. itemData = HeroBagProxy:GetItemDataByMakeIndex(MakeIndex)
  187. elseif itemBelong == global.MMO.ITEM_FROM_BELONG_HEROEQUIP then
  188. local HeroEquipProxy = global.Facade:retrieveProxy(global.ProxyTable.HeroEquipProxy)
  189. itemData = HeroEquipProxy:GetEquipDataByMakeIndex(MakeIndex)
  190. end
  191. end
  192. end
  193. return itemData
  194. end
  195. function ItemManagerProxy:onRegister()
  196. ItemManagerProxy.super.onRegister(self)
  197. end
  198. return ItemManagerProxy