EquipProxy.lua 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. local RemoteProxy = requireProxy("remote/RemoteProxy")
  2. local proxyUtils = requireProxy("proxyUtils")
  3. local EquipProxy = class("EquipProxy", RemoteProxy)
  4. EquipProxy.NAME = global.ProxyTable.Equip
  5. function EquipProxy:ctor()
  6. EquipProxy.super.ctor(self)
  7. self._equipDataByMakeIndex = {} --item
  8. self._equipPosData = {}--makeindex
  9. self.EquipPosData = requireConfig("EquipPosTypeConfig")
  10. self.EquipPosType = self.EquipPosData.EquipPosTypeConfig
  11. self.ModelViewEquipOff = {}
  12. self.ModelViewHairOff = {}
  13. self.ItemBelongType = global.MMO.ITEM_FROM_BELONG_EQUIP
  14. self.posfight = {}
  15. self.suitnum = {}
  16. self.lastTakeOnPos = {}
  17. self.bestRingsOpen = false
  18. self.equipQuality = {
  19. DEFAULT_EQUIP = 1, --战装
  20. GOD_MAGIC_EQUIP = 2, --魔神装
  21. FASHION_EQUIP = 3 --神器(魔神武器衣服)
  22. }
  23. self:loadJson()
  24. end
  25. function EquipProxy:loadJson()
  26. local cjson = require("cjson")
  27. -- 装备偏移
  28. local function loadEquipOffset(filename, index)
  29. if global.FileUtilCtl:isFileExist(filename) then
  30. local jsonStr = global.FileUtilCtl:getDataFromFileEx(filename)
  31. local jsonData = {}
  32. xpcall(function()
  33. jsonData = cjson.decode(jsonStr)
  34. end,
  35. function()
  36. if global.isDebugMode or global.isGMMode then
  37. ShowSystemTips(string.format("json文件格式错误: %s", filename))
  38. end
  39. end
  40. )
  41. for key, value in pairs(jsonData) do
  42. local offValue = {
  43. x = value.x,
  44. y = value.y
  45. }
  46. if global.isWinPlayMode then
  47. if value.x1 then
  48. offValue.x = value.x1
  49. end
  50. if value.y1 then
  51. offValue.y = value.y1
  52. end
  53. end
  54. self.ModelViewEquipOff[tonumber(key) + index * 10000] = offValue
  55. end
  56. end
  57. end
  58. for i = 0, 10 do
  59. local filename = string.format("res/player_show/player_show_%s/equip_offest.txt", i)
  60. if global.FileUtilCtl:isFileExist(filename) then
  61. loadEquipOffset(filename, i)
  62. end
  63. end
  64. -- 头发偏移
  65. local function loadHairOffset(filename)
  66. if global.FileUtilCtl:isFileExist(filename) then
  67. local jsonStr = global.FileUtilCtl:getDataFromFileEx(filename)
  68. local jsonData = {}
  69. xpcall(function()
  70. jsonData = cjson.decode(jsonStr)
  71. end,
  72. function()
  73. if global.isDebugMode or global.isGMMode then
  74. ShowSystemTips(string.format("json文件格式错误: %s", filename))
  75. end
  76. end
  77. )
  78. for key, value in pairs(jsonData) do
  79. local offValue = {
  80. x = value.x,
  81. y = value.y
  82. }
  83. if global.isWinPlayMode then
  84. if value.x1 then
  85. offValue.x = value.x1
  86. end
  87. if value.y1 then
  88. offValue.y = value.y1
  89. end
  90. end
  91. self.ModelViewHairOff[tonumber(key)] = offValue
  92. end
  93. end
  94. end
  95. loadHairOffset("data_config/hair_offest.txt")
  96. end
  97. function EquipProxy:GetEquipModelOffSet()
  98. return self.ModelViewEquipOff
  99. end
  100. function EquipProxy:GetModelHairOffSet()
  101. return self.ModelViewHairOff
  102. end
  103. function EquipProxy:GetEquipPosByStdMode(StdMode)
  104. local posList = self.EquipPosData.EquipPosByStdMode[StdMode]
  105. if posList and next(posList) then
  106. for k, pos in pairs(posList) do
  107. local equip = self:GetEquipDataByPos(pos)
  108. if not equip then
  109. return pos
  110. end
  111. end
  112. return posList[1]
  113. end
  114. return nil
  115. end
  116. -- tips部位列表
  117. function EquipProxy:GetTipsEquipPosByStdModeList(StdMode)
  118. if self.EquipPosData.TipsEquipPosByStdMode[StdMode] then
  119. return self.EquipPosData.TipsEquipPosByStdMode[StdMode]
  120. end
  121. return self:GetEquipPosByStdModeList(StdMode)
  122. end
  123. function EquipProxy:GetEquipPosByStdModeList(StdMode)
  124. return self.EquipPosData.EquipPosByStdMode[StdMode]
  125. end
  126. function EquipProxy:GetEquipMappingConfig(pos)
  127. return self.EquipPosData.EquipPosMapping[pos]
  128. end
  129. -- 反向
  130. function EquipProxy:GetDeEquipMappingConfig(pos)
  131. if not pos then
  132. return nil
  133. end
  134. for belongPos, v in pairs(self.EquipPosData.EquipPosMapping) do
  135. for k, position in pairs(v) do
  136. if position == pos then
  137. return belongPos
  138. end
  139. end
  140. end
  141. return nil
  142. end
  143. function EquipProxy:IsShowEquipItems(pos)
  144. local equipPos = pos or 0
  145. local noShowItem = {
  146. [self.EquipPosType.Equip_Type_Dress] = true,
  147. [self.EquipPosType.Equip_Type_Weapon] = true,
  148. [self.EquipPosType.Equip_Type_Helmet] = true,
  149. [self.EquipPosType.Equip_Type_Cap] = true,
  150. [self.EquipPosType.Equip_Type_Shield] = true,
  151. [self.EquipPosType.Equip_Type_Veil] = true,
  152. [self.EquipPosType.Equip_Type_Super_Dress] = true,
  153. [self.EquipPosType.Equip_Type_Super_Weapon] = true,
  154. [self.EquipPosType.Equip_Type_Super_Helmet] = true,
  155. [self.EquipPosType.Equip_Type_Super_Cap] = true,
  156. [self.EquipPosType.Equip_Type_Super_Shield] = true,
  157. [self.EquipPosType.Equip_Type_Super_Veil] = true,
  158. [self.EquipPosType.Equip_Fashion_Dress] = true,
  159. [self.EquipPosType.Equip_Fashion_Weapon] = true,
  160. }
  161. return not noShowItem[pos]
  162. end
  163. function EquipProxy:GetEquipTypeConfig()
  164. return self.EquipPosType
  165. end
  166. function EquipProxy:ClearEquipData()
  167. self._equipDataByMakeIndex = {}
  168. self._equipPosData = {}
  169. end
  170. function EquipProxy:GetEquipData()
  171. return self._equipDataByMakeIndex
  172. end
  173. function EquipProxy:GetEquipPosData()
  174. return self._equipPosData
  175. end
  176. function EquipProxy:GetEquipDataByMakeIndex(makeIndex)
  177. return self._equipDataByMakeIndex[makeIndex]
  178. end
  179. function EquipProxy:FindEquipDataByPos(pos)
  180. if not self._equipPosData[pos] then
  181. return nil
  182. end
  183. return self:GetEquipDataByMakeIndex(self._equipPosData[pos])
  184. end
  185. function EquipProxy:GetEquipDataByPos(pos, beginOnMoving)
  186. local data = self:FindEquipDataByPos(pos)
  187. if beginOnMoving then
  188. local list = self:GetEquipMappingConfig(pos) -- 单显示位置 多个装备位置共享
  189. if list then
  190. data = nil
  191. for _, v in ipairs(list) do
  192. data = self:FindEquipDataByPos(v)
  193. if data then
  194. break
  195. end
  196. end
  197. end
  198. end
  199. return data
  200. end
  201. function EquipProxy:GetEquipDataByName(Name)
  202. local list = {}
  203. local data = self:GetEquipData()
  204. if not Name or Name == "" or not data or next(data) == nil then
  205. return list
  206. end
  207. local originName = nil
  208. for k, v in pairs(data) do
  209. originName = v.originName or v.Name
  210. if originName == Name then
  211. table.insert(list, v)
  212. end
  213. end
  214. return list
  215. end
  216. function EquipProxy:GetEquipDataPosDataList(pos)
  217. local data = {}
  218. local list = self:GetEquipMappingConfig(pos) -- 单显示位置 多个装备位置共享
  219. if list then
  220. for _, v in ipairs(list) do
  221. local equipData = self:FindEquipDataByPos(v)
  222. if equipData then
  223. table.insert(data, equipData)
  224. end
  225. end
  226. else
  227. local equipData = self:FindEquipDataByPos(pos)
  228. if equipData then
  229. table.insert(data, equipData)
  230. end
  231. end
  232. if next(data) == nil then
  233. data = nil
  234. end
  235. return data
  236. end
  237. -- 战力对比 checkPosData: 指定部位数据战力对比( {[1]={data, pos}})
  238. function EquipProxy:GetMinPowerPosByStdMode(StdMode, param, checkPosData)
  239. local StdMode = StdMode or 0
  240. local onEquipMinPower = 0
  241. local minPowerPos = -1
  242. local hasEquip = true
  243. local pos = checkPosData or self:GetEquipPosByStdModeList(StdMode)
  244. if not pos or next(pos) == nil then
  245. print("this StdMode is not a equip")
  246. return minPowerPos, onEquipMinPower
  247. end
  248. if param.checkPos then
  249. local index = table.indexof(pos, param.checkPos)
  250. if index then
  251. local fristPos = pos[1]
  252. pos[1] = param.checkPos
  253. pos[index] = fristPos
  254. end
  255. end
  256. local isCheckPos = false
  257. if checkPosData then
  258. isCheckPos = true
  259. end
  260. for k, v in ipairs(pos) do
  261. local equipData = isCheckPos and v.data or self:GetEquipDataByPos(v)
  262. if not equipData then
  263. minPowerPos = isCheckPos and v.pos or v
  264. onEquipMinPower = 0
  265. hasEquip = false
  266. break
  267. end
  268. local equipPower = GUIFunction:GetEquipPower(equipData, param)
  269. if onEquipMinPower == 0 or equipPower < onEquipMinPower then
  270. onEquipMinPower = equipPower
  271. minPowerPos = isCheckPos and v.pos or v
  272. if StdMode == 25 then
  273. break
  274. end
  275. end
  276. end
  277. return minPowerPos, onEquipMinPower, hasEquip
  278. end
  279. function EquipProxy:GetEquipTakeOnPosByStdMode(StdMode, param)
  280. local StdMode = StdMode or 0
  281. local onEquipMinPower = 0
  282. local minPowerPos = -1
  283. local hasEquip = true
  284. local pos = self:GetEquipPosByStdModeList(StdMode)
  285. if not pos or next(pos) == nil then
  286. print("this StdMode is not a equip")
  287. return minPowerPos, onEquipMinPower
  288. end
  289. local posCount = #pos
  290. if posCount > 1 then
  291. for k, v in pairs(pos) do
  292. local equipData = self:GetEquipDataByPos(v)
  293. if not equipData then
  294. minPowerPos = v
  295. onEquipMinPower = 0
  296. hasEquip = false
  297. break
  298. end
  299. end
  300. if hasEquip then -- 如果没有空位
  301. if not self.lastTakeOnPos[pos[1]] then
  302. self.lastTakeOnPos[pos[1]] = 1
  303. else
  304. self.lastTakeOnPos[pos[1]] = self.lastTakeOnPos[pos[1]] + 1
  305. if self.lastTakeOnPos[pos[1]] > posCount then
  306. self.lastTakeOnPos[pos[1]] = 1
  307. end
  308. end
  309. local chooseIndex = self.lastTakeOnPos[pos[1]] or 1
  310. local choosePos = pos[chooseIndex] or pos[1]
  311. local equipData = self:GetEquipDataByPos(choosePos)
  312. if equipData then
  313. local equipPower = GUIFunction:GetEquipPower(equipData, param)
  314. onEquipMinPower = equipPower
  315. minPowerPos = choosePos
  316. else
  317. minPowerPos = choosePos
  318. onEquipMinPower = 0
  319. hasEquip = false
  320. end
  321. end
  322. else -- 单位置 直接为改位置
  323. local onlyPos = pos[1]
  324. local equipData = self:GetEquipDataByPos(onlyPos)
  325. minPowerPos = onlyPos
  326. if not equipData then
  327. onEquipMinPower = 0
  328. hasEquip = false
  329. else
  330. local equipPower = GUIFunction:GetEquipPower(equipData, param)
  331. onEquipMinPower = equipPower
  332. end
  333. end
  334. return minPowerPos, onEquipMinPower, hasEquip
  335. end
  336. function EquipProxy:CheckEquipNeedSex(item, sex)
  337. if not item or not next(item) then
  338. return false
  339. end
  340. local PlayerPropertyProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerProperty)
  341. local stdMode = item.StdMode
  342. local sexOk = true
  343. local needSex = sex and sex or PlayerPropertyProxy:GetRoleSex()
  344. local equipNeedSexConfig = self.EquipPosData.EquipSexNeed or {}
  345. if equipNeedSexConfig[stdMode] and equipNeedSexConfig[stdMode] ~= needSex then
  346. sexOk = false
  347. end
  348. return sexOk
  349. end
  350. function EquipProxy:CheckEquipWeight(onItem, pos)
  351. if not onItem or not next(onItem) or not pos or pos < 0 then
  352. return false
  353. end
  354. local offItem = self:GetEquipDataByPos(pos)
  355. local PlayerPropertyProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerProperty)
  356. local equipNeedSexConfig = self.EquipPosData.EquipHandWeightType or {}
  357. local AttType = GUIFunction:PShowAttType()
  358. local maxWeightType = AttType.Max_Wear_Weight
  359. local nowWeightType = AttType.Wear_Weight
  360. if equipNeedSexConfig[onItem.StdMode] then
  361. maxWeightType = AttType.Max_Hand_Weight
  362. nowWeightType = AttType.Hand_Weight
  363. end
  364. local onItemWeight = onItem.Weight
  365. local offItemWeight = offItem and offItem.Weight or 0
  366. local playerMaxWeight = PlayerPropertyProxy:GetRoleAttByAttType(maxWeightType) or 0
  367. local nowWearWeight = PlayerPropertyProxy:GetRoleAttByAttType(nowWeightType) or 0
  368. local afterEquip = onItemWeight - offItemWeight + nowWearWeight
  369. return afterEquip <= playerMaxWeight
  370. end
  371. --检测附身符使用 (因为护身符可以穿戴在右手镯,当附身符有穿戴,双击以及自动使用时不能穿戴,只能拖拽穿戴)
  372. function EquipProxy:CheckBujukUse(item, putPos)
  373. -- body
  374. if item and item.StdMode then
  375. if item.StdMode == 25 then
  376. return true, 9
  377. end
  378. return true
  379. end
  380. return false
  381. end
  382. function EquipProxy:CheckBestRingsSpace()
  383. for pos = self.EquipPosType.Equip_Type_BestRing1, self.EquipPosType.Equip_Type_BestRing12 do
  384. local data = self:GetEquipDataByPos(pos)
  385. if not data then
  386. return pos
  387. end
  388. end
  389. return false
  390. end
  391. function EquipProxy:GetBestRingsOpenState()
  392. return self.bestRingsOpen
  393. end
  394. function EquipProxy:SetBestRingsOpenState(state)
  395. self.bestRingsOpen = state
  396. end
  397. function EquipProxy:AddEquipData(item, isInit)
  398. local MakeIndex = item.MakeIndex
  399. local Where = item.Where
  400. -- 当前位置已有装备,先删除
  401. local lastItem = self:GetEquipDataByPos(item.Where)
  402. if lastItem then
  403. self:DelEquipData(lastItem)
  404. end
  405. -- 数据存储
  406. self._equipDataByMakeIndex[MakeIndex] = item
  407. self._equipPosData[Where] = MakeIndex
  408. local ItemManagerProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemManagerProxy)
  409. ItemManagerProxy:SetItemBelong(item.MakeIndex, self.ItemBelongType)
  410. if not isInit then
  411. local sData = {}
  412. sData.MakeIndex = item.MakeIndex
  413. sData.Where = item.Where
  414. sData.opera = global.MMO.Operator_Add
  415. sData.ItemData = item
  416. global.Facade:sendNotification(global.NoticeTable.PlayEquip_Oper_Data, sData)
  417. SLBridge:onLUAEvent(LUA_EVENT_PLAYER_EQUIP_CHANGE, sData)
  418. end
  419. end
  420. function EquipProxy:DelEquipData(item)
  421. local MakeIndex = item.MakeIndex
  422. local oldItem = self:GetEquipDataByMakeIndex(MakeIndex)
  423. if not oldItem then
  424. return
  425. end
  426. -- local AutoUseItemProxy = global.Facade:retrieveProxy(global.ProxyTable.AutoUseItemProxy)
  427. -- AutoUseItemProxy:AddEquipOffMakeIndex(item.MakeIndex)
  428. -- 存储数据
  429. local Where = item.Where
  430. self._equipPosData[Where] = nil
  431. self._equipDataByMakeIndex[MakeIndex] = nil
  432. local ItemManagerProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemManagerProxy)
  433. ItemManagerProxy:SetItemBelong(MakeIndex, nil)
  434. local sData = {}
  435. sData.MakeIndex = MakeIndex
  436. sData.Where = Where
  437. sData.opera = global.MMO.Operator_Sub
  438. sData.ItemData = item
  439. global.Facade:sendNotification(global.NoticeTable.PlayEquip_Oper_Data, sData)
  440. SLBridge:onLUAEvent(LUA_EVENT_PLAYER_EQUIP_CHANGE, sData)
  441. end
  442. function EquipProxy:ChangeEquipData(item, bagDelayUpdate, isChangeLook)
  443. local MakeIndex = item.MakeIndex
  444. local Where = item.Where
  445. local oldItem = self:GetEquipDataByMakeIndex(MakeIndex)
  446. if not oldItem then
  447. return
  448. end
  449. -- 数据存储
  450. self._equipDataByMakeIndex[MakeIndex] = item
  451. local sData = {}
  452. sData.MakeIndex = MakeIndex
  453. sData.Where = Where
  454. sData.opera = global.MMO.Operator_Change
  455. sData.bagDelayUpdate = bagDelayUpdate
  456. sData.isChangeLook = isChangeLook
  457. global.Facade:sendNotification(global.NoticeTable.PlayEquip_Oper_Data, sData)
  458. SLBridge:onLUAEvent(LUA_EVENT_PLAYER_EQUIP_CHANGE, sData)
  459. end
  460. --法阵
  461. function EquipProxy:SetEmbattle(data)
  462. self.embattle = {}
  463. if data and data ~= 0 then
  464. self.embattle[1] = H16Bit(data)
  465. self.embattle[2] = L16Bit(data)
  466. end
  467. end
  468. function EquipProxy:GetEmbattle()
  469. return self.embattle
  470. end
  471. function EquipProxy:handle_MSG_SC_EQUIP_Embattle_RESPONSE(msg)
  472. local header = msg:GetHeader()
  473. local recog = header.recog
  474. self:SetEmbattle(recog)
  475. global.Facade:sendNotification(global.NoticeTable.Layer_Embattle_Refresh)
  476. SLBridge:onLUAEvent(LUA_EVENT_PLAYER_EMBATTLE_CHANGE)
  477. end
  478. -- --更换iconID
  479. function EquipProxy:ChangeEquipLook(MakeIndex)
  480. if not MakeIndex then
  481. return
  482. end
  483. local item = self:GetEquipDataByMakeIndex(MakeIndex)
  484. if not item then
  485. return
  486. end
  487. local ItemConfigProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemConfigProxy)
  488. item.Looks, item.bEffect, item.sEffect = ItemConfigProxy:GetChangeItemLook(item.MakeIndex, item.Index)
  489. self:ChangeEquipData(item, nil, true)
  490. end
  491. -- 自定义装备使用
  492. function EquipProxy:SetCustUserItem(custUserItem)
  493. if not custUserItem or string.len(custUserItem) <= 0 then
  494. return
  495. end
  496. local ItemsConfig = requireConfig("ItemsConfig")
  497. ItemsConfig.EquipMapByStdMode = {}
  498. ItemsConfig.EquipMapByStdMode = clone(ItemsConfig.EquipMapByStdModeTemp)
  499. self.EquipPosData.EquipPosByStdMode = {}
  500. self.EquipPosData.EquipPosByStdMode = clone(self.EquipPosData.EquipPosByStdModeTemp)
  501. local itemArray = string.split(custUserItem, "#")
  502. for i, v in ipairs(itemArray) do
  503. local posArray = string.split(v, "=")
  504. local pos = posArray[1] and tonumber(posArray[1]) or nil
  505. local stdModeStr = posArray[2]
  506. if stdModeStr and string.len(stdModeStr) > 0 then
  507. local StdModeArray = string.split(stdModeStr, ",")
  508. for _i, _StdMode in ipairs(StdModeArray) do
  509. local StdMode = _StdMode and tonumber(_StdMode) or nil
  510. if StdMode and pos then
  511. if not self.EquipPosData.EquipPosByStdMode[StdMode] then
  512. self.EquipPosData.EquipPosByStdMode[StdMode] = {}
  513. end
  514. table.insert(self.EquipPosData.EquipPosByStdMode[StdMode], pos)
  515. ItemsConfig.EquipMapByStdMode[StdMode] = true
  516. end
  517. end
  518. end
  519. end
  520. end
  521. function EquipProxy:handle_MSG_SC_PLAYER_EQUIP_ON_FAIL(msg)
  522. local header = msg:GetHeader()
  523. local data = {}
  524. data.isSuccess = false
  525. data.header = header
  526. global.Facade:sendNotification(global.NoticeTable.TakeOnResponse, data)
  527. ssr.ssrBridge:OnTakeOnEquip(data.isSuccess)
  528. end
  529. function EquipProxy:handle_MSG_SC_PLAYER_EQUIP_ON_SUCCESS(msg)
  530. local header = msg:GetHeader()
  531. local data = {}
  532. data.isSuccess = true
  533. data.header = header
  534. data.pos = header.recog
  535. global.Facade:sendNotification(global.NoticeTable.TakeOnResponse, data)
  536. ssr.ssrBridge:OnTakeOnEquip(data.isSuccess, data.pos)
  537. end
  538. function EquipProxy:handle_MSG_SC_PLAYER_EQUIP_OFF_SUCCESS(msg)
  539. local header = msg:GetHeader()
  540. ssr.ssrBridge:OnTakeOffEquip(true, header.recog)
  541. global.Facade:sendNotification(global.NoticeTable.TakeOffResponse, {isSuccess = true, pos = header.recog})
  542. end
  543. function EquipProxy:handle_MSG_SC_PLAYER_EQUIP_OFF_FAIL(msg)
  544. ssr.ssrBridge:OnTakeOffEquip({isSuccess = false})
  545. global.Facade:sendNotification(global.NoticeTable.TakeOffResponse, {isSuccess = false, header = msg:GetHeader()})
  546. end
  547. function EquipProxy:handle_MSG_SC_PALYER_EQUIP_INFO(msg)
  548. local jsonData = ParseRawMsgToJson(msg)
  549. if not jsonData or next(jsonData) == nil then
  550. return
  551. end
  552. for k, equip in pairs(jsonData) do
  553. if equip and equip ~= "" then
  554. equip = ChangeItemServersSendDatas(equip)
  555. self:AddEquipData(equip, true)
  556. end
  557. end
  558. global.Facade:sendNotification(global.NoticeTable.PlayEquip_Oper_Init)
  559. ssr.ssrBridge:OnPlayerEquipInit()
  560. SLBridge:onLUAEvent(LUA_EVENT_PLAYER_EQUIP_CHANGE, {opera = global.MMO.Operator_Init})
  561. end
  562. function EquipProxy:RequestBestRingsOpenState()
  563. LuaSendMsg(global.MsgType.MSG_CS_PLAYER_EQUIP_BEST_RINGS_STATE, 0, 0, 0, 0)
  564. end
  565. -- 获取装备条件
  566. function EquipProxy:GetEquipCondition( pos )
  567. if not self.equipConditions then
  568. self.equipConditions = {}
  569. local equipConditions = SL:GetMetaValue("GAME_DATA","zhanguxianshi") or ""
  570. if equipConditions and equipConditions ~= "" then
  571. local paramStr = string.split(equipConditions, "-")
  572. for i,v in ipairs(paramStr) do
  573. local equipPosAndCondtions = v
  574. if equipPosAndCondtions and equipPosAndCondtions ~= "" then
  575. local param = string.split(equipPosAndCondtions, "&")
  576. local equipPos = tonumber(param[1])
  577. local conditions = param[2]
  578. if equipPos then
  579. self.equipConditions[equipPos] = conditions
  580. end
  581. end
  582. end
  583. end
  584. end
  585. return self.equipConditions[pos]
  586. end
  587. function EquipProxy:CheckEquipCondition( pos,lookPlayer )
  588. local equipCondition = self:GetEquipCondition( pos )
  589. if equipCondition then
  590. local checkConditions = equipCondition or ""
  591. local ConditionProxy = global.Facade:retrieveProxy(global.ProxyTable.ConditionProxy)
  592. if ConditionProxy:CheckCondition(checkConditions) then
  593. return true
  594. else
  595. return false
  596. end
  597. end
  598. return true
  599. end
  600. function EquipProxy:handle_MSG_SC_PLAYER_EQUIP_BEST_RINGS_STATE(msg)
  601. local header = msg:GetHeader()
  602. local state = header.recog == 1
  603. local isOpen = false
  604. if self.bestRingsOpen and state then
  605. isOpen = true
  606. end
  607. self:SetBestRingsOpenState(state)
  608. global.Facade:sendNotification(global.NoticeTable.Layer_PlayerBestRing_State, { isOpen = isOpen })
  609. SLBridge:onLUAEvent(LUA_EVENT_BESTRINGBOX_STATE, {isOpen = isOpen})
  610. end
  611. function EquipProxy:onRegister()
  612. EquipProxy.super.onRegister(self)
  613. end
  614. function EquipProxy:RegisterMsgHandler()
  615. EquipProxy.super.RegisterMsgHandler(self)
  616. local msgType = global.MsgType
  617. --初始化装备信息
  618. LuaRegisterMsgHandler(msgType.MSG_SC_PALYER_EQUIP_INFO, handler(self, self.handle_MSG_SC_PALYER_EQUIP_INFO))
  619. -- 装备穿上确认-成功
  620. LuaRegisterMsgHandler(msgType.MSG_SC_PLAYER_EQUIP_ON_SUCCESS, handler(self, self.handle_MSG_SC_PLAYER_EQUIP_ON_SUCCESS))
  621. -- 装备穿上确认-失败
  622. LuaRegisterMsgHandler(msgType.MSG_SC_PLAYER_EQUIP_ON_FAIL, handler(self, self.handle_MSG_SC_PLAYER_EQUIP_ON_FAIL))
  623. -- 装备脱下确认-成功
  624. LuaRegisterMsgHandler(msgType.MSG_SC_PLAYER_EQUIP_OFF_SUCCESS, handler(self, self.handle_MSG_SC_PLAYER_EQUIP_OFF_SUCCESS))
  625. -- 装备脱下确认-失败
  626. LuaRegisterMsgHandler(msgType.MSG_SC_PLAYER_EQUIP_OFF_FAIL, handler(self, self.handle_MSG_SC_PLAYER_EQUIP_OFF_FAIL))
  627. -- 首饰盒开启状态
  628. LuaRegisterMsgHandler(msgType.MSG_SC_PLAYER_EQUIP_BEST_RINGS_STATE, handler(self, self.handle_MSG_SC_PLAYER_EQUIP_BEST_RINGS_STATE))
  629. -- 法阵
  630. LuaRegisterMsgHandler(msgType.MSG_SC_EQUIP_Embattle_RESPONSE,handler(self, self.handle_MSG_SC_EQUIP_Embattle_RESPONSE) )
  631. end
  632. return EquipProxy