源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3228 lines
108 KiB

пре 4 недеља
  1. EquipModel = EquipModel or BaseClass(BaseVo, true)
  2. local EquipModel = EquipModel
  3. local stringtotable = stringtotable
  4. EquipModel.REQUEST_CCMD_EVENT = "EquipModel.REQUEST_CCMD_EVENT"--请求协议
  5. EquipModel.OPEN_MAIN_VIEW = "EquipModel.OPEN_MAIN_VIEW"--打开主界面
  6. EquipModel.CLOSE_MAIN_VIEW = "EquipModel.CLOSE_MAIN_VIEW"--关闭主界面
  7. EquipModel.UPDATE_DYNAMIC_DETAILS = "EquipModel.UPDATE_DYNAMIC_DETAILS"--更新动态杀怪
  8. EquipModel.UPDATE_VIEW_RED = "EquipModel.UPDATE_VIEW_RED"--更新红点
  9. EquipModel.EQUIP_ITEM_BE_CLICK = "EquipModel.EQUIP_ITEM_BE_CLICK"--装备道具点击
  10. EquipModel.OPEN_STRENGTH_SUIT_VIEW = "EquipModel.OPEN_STRENGTH_SUIT_VIEW"--打开精炼套装界面
  11. EquipModel.OPEN_STAR_SUIT_VIEW = "EquipModel.OPEN_STAR_SUIT_VIEW"--打开星级套装界面
  12. EquipModel.OPEN_EQUIP_STAR_TIP_VIEW = "EquipModel.OPEN_EQUIP_STAR_TIP_VIEW"--打开星级套装Tip界面
  13. EquipModel.INFO_UPDATE = "EquipModel.INFO_UPDATE"--请求协议
  14. EquipModel.UPDATE_RED_EQUIP_INFO = "EquipModel.UPDATE_RED_EQUIP_INFO"--红装成功刷新
  15. EquipModel.OPEN_EQUIP_INHERIT_TIP_VIEW = "EquipModel.OPEN_EQUIP_INHERIT_TIP_VIEW"--打开继承选择装备界面
  16. EquipModel.INHERIT_TIP_CHOOSE_EQUIP = "EquipModel.INHERIT_TIP_CHOOSE_EQUIP"--打继承选中装备
  17. EquipModel.OPEN_EQUIP_EVOLUTION_AWARD_TIP_VIEW = "EquipModel.OPEN_EQUIP_EVOLUTION_AWARD_TIP_VIEW"--升星购买装备展示界面
  18. EquipModel.EVOLUTION_SUCCUSCE = "EquipModel.EVOLUTION_SUCCUSCE"--升星成功
  19. EquipModel.OPEN_GEMSTONES_CHOOSE_VIEW = "EquipModel.OPEN_GEMSTONES_CHOOSE_VIEW"--打开宝石选择界面
  20. EquipModel.OPEN_GEMSTONES_STATE_VIEW = "EquipModel.OPEN_GEMSTONES_STATE_VIEW"--打开宝石操作界面
  21. EquipModel.OPEN_GEMSTONE_SUIT_VIEW = "EquipModel.OPEN_GEMSTONE_SUIT_VIEW"--打开宝石套装界面
  22. EquipModel.OPEN_EVOLUSTION_CHOOSE_VIEW = "EquipModel.OPEN_EVOLUSTION_CHOOSE_VIEW"--打开升星装备选择界面
  23. EquipModel.OPEN_EVOLUSTION_TIP_VIEW = "EquipModel.OPEN_EVOLUSTION_TIP_VIEW"--打开升星装备选择界面
  24. EquipModel.EVOLUTION_EQUIP_CHOOSE = "EquipModel.EVOLUTION_EQUIP_CHOOSE"--升星装备选择更新
  25. EquipModel.EVOLUTION_UPDATE_EQUIP_MARKET_COST = "EquipModel.EVOLUTION_UPDATE_EQUIP_MARKET_COST"--升星装备市场购买刷新
  26. EquipModel.OPEN_DRACONIC_CHOOSE_VIEW = "EquipModel.OPEN_DRACONIC_CHOOSE_VIEW"
  27. EquipModel.OPEN_TOOL_MAIN_VIEW = "EquipModel.OPEN_TOOL_MAIN_VIEW"--打开装备工坊主界面
  28. EquipModel.OPEN_DRACONIC_ATTR_SHOW_VIEW = "EquipModel.OPEN_DRACONIC_ATTR_SHOW_VIEW"--打开刻印属性展示界面
  29. EquipModel.CHANGE_MAIN_BG_RES = "EquipModel.CHANGE_MAIN_BG_RES"--改变背景图
  30. EquipModel.OPEN_EQUIP_INHERIT_WEAR_TIP_VIEW = "EquipModel.OPEN_EQUIP_INHERIT_WEAR_TIP_VIEW"--打开装备继承预览界面
  31. EquipModel.UPDATE_EQUIP_MAX_SERIES = "EquipModel.UPDATE_EQUIP_MAX_SERIES"--刷新装备装备最大套装数
  32. EquipModel.OPEN_GEMSTONE_AUTO_VIEW = "EquipModel.OPEN_GEMSTONE_AUTO_VIEW"--宝石一键镶嵌表现界面
  33. EquipModel.OPEN_EVOLUTION_SCUCCESS_VIEW = "OPEN_EVOLUTION_SCUCCESS_VIEW"--打开升星成功界面
  34. EquipModel.PLAY_GEMSTONE_EFFECT = "PLAY_GEMSTONE_EFFECT"--播放宝石界面特效
  35. EquipModel.OPEN_EQUIP_BASE_TIPS_VIEW = "EquipModel.OPEN_EQUIP_BASE_TIPS_VIEW"--装备精炼升星基础提示界面
  36. EquipModel.PLAY_GEMSTONE_AUTO_EFFECT = "EquipModel.PLAY_GEMSTONE_AUTO_EFFECT"--播放宝石自动镶嵌特效
  37. EquipModel.CLOSE_EVOLUTION_SCUCCESS_VIEW = "EquipModel.CLOSE_EVOLUTION_SCUCCESS_VIEW"--关闭升星成功界面
  38. EquipModel.CLOSE_EVOLUSTION_TIP_VIEW = "EquipModel.CLOSE_EVOLUSTION_TIP_VIEW"--关闭升星二次确认界面
  39. EquipModel.UPDATE_EQUIP_TOOL_TIPS_EXP_LV = "EquipModel.UPDATE_EQUIP_TOOL_TIPS_EXP_LV"--更新守护饰品tip的经验值和等级(可成长装备)
  40. EquipModel.OPEN_EVOLUSTION_ATTR_FIND_VIEW = "EquipModel.OPEN_EVOLUSTION_ATTR_FIND_VIEW"--打开升星属性查找界面
  41. EquipModel.UPDATE_EQUIP_POWER = "EquipModel.UPDATE_EQUIP_POWER"--更新装备战力
  42. EquipModel.UPDATE_STAR_SUIT_EFFECT = "EquipModel.UPDATE_STAR_SUIT_EFFECT"--更新星级套装
  43. --页签
  44. EquipModel.MainTab = {
  45. Strengthen = 1,--精炼
  46. Evolution = 2,--升星
  47. Inherit = 3,--继承
  48. UpQuality = 4,--升品
  49. RedEquip = 5,--红装
  50. Draconic = 6,--刻印
  51. Gemstone = 7,--宝石
  52. }
  53. EquipModel.EquipPosIndex = {--装备位置索引
  54. 1,6,2,7,3,8,4,9,5,10
  55. }
  56. EquipModel.EquipType = {
  57. Weapon = 1,--武器
  58. Head = 2,--头盔
  59. Body = 3,--身甲
  60. Shoulder = 4,--披风
  61. Hand = 5,--手甲
  62. Leg = 6,--护腿
  63. Shoes = 7,--鞋子
  64. Necklace = 8,--项链
  65. LeftRing = 9,--戒指
  66. RightRing = 10,--耳饰
  67. Guard = 11,--守护
  68. Fetter = 12,--羁绊
  69. }
  70. --防御
  71. EquipModel.DefEquipType = {
  72. [2] = true,--头盔
  73. [3] = true,--身甲
  74. [4] = true,--披风
  75. [6] = true,--护腿
  76. [7] = true,--鞋子
  77. }
  78. --饰品
  79. EquipModel.NecklaceEquipType = {
  80. [5] = true,--手甲
  81. [8] = true,--项链
  82. [9] = true,--戒指
  83. [10] = true,--耳饰
  84. }
  85. --装备局部百分比属性列表
  86. EquipModel.STypeAttr = {
  87. [221] = 1,--武器攻击
  88. [223] = 2,--防具生命
  89. [224] = 4,--防具防御
  90. [225] = 1,--饰品攻击
  91. }
  92. EquipModel.EquipTypeName = {
  93. "武器",
  94. "头盔",
  95. "身甲",
  96. "披风",
  97. "手甲",
  98. "护腿",
  99. "鞋子",
  100. "项链",
  101. "戒指",
  102. "耳饰",
  103. "守护",
  104. }
  105. --合成配置主类型
  106. EquipModel.ComposeType = {
  107. EquipUpQuality = 1,--升品
  108. }
  109. --升星数等于高级属性数减2
  110. EquipModel.Evolution_Level_offer = 2
  111. --外部提示穿戴等级限制
  112. EquipModel.TipWearLevelLimit = 96
  113. --宝石最大等级
  114. EquipModel.GemstoneMaxLevel = 9
  115. EquipModel.EvoAttrColor = {
  116. "<color=#66abff>高级</color>",
  117. "<color=#f558ff>超级</color>",
  118. "<color=#feb940>至尊</color>",
  119. "<color=#ff203a>绝世</color>",
  120. }
  121. --装备升品展示的10件装备equip_suit_type , 8不是装备= =。
  122. --2020/1/7: 又改回来了= =。 这个保留着吧,以防万一
  123. EquipModel.EmpowerEquipTransId = {
  124. 1,--武器
  125. 2,--头盔
  126. 3,--身甲
  127. 4,--披风
  128. 5,--手甲
  129. 6,--护腿
  130. 7,--鞋子
  131. 8,--项链
  132. 9,--戒指
  133. 10--耳饰
  134. }
  135. --装备宝石主类型
  136. EquipModel.GemsType = {
  137. Attark = 1,--攻击
  138. Def = 2,--防御
  139. Life = 3,--生命
  140. }
  141. --装备宝石主类型名字
  142. EquipModel.GemsTypeName = {
  143. [1] = "红宝石",
  144. [2] = "蓝宝石",
  145. [3] = "绿宝石",
  146. }
  147. --装备套件页签bg宽度
  148. EquipModel.TabLenth = {
  149. [1] = 130,
  150. [2] = 180,
  151. [3] = 223,
  152. [4] = 270,
  153. [5] = 326,
  154. [6] = 370,
  155. }
  156. --宝石一键镶嵌展示效果
  157. EquipModel.StoneAotuShowList = {
  158. 109002,109003,109004,109012,109013,109014,109022,109023,109024,109025,109005,
  159. }
  160. --装备升品等级对应名字
  161. EquipModel.ReqEquipLvName = {
  162. [1] = "红色",
  163. [2] = "粉色",
  164. [3] = "彩色",
  165. }
  166. --装备升品等级对应名字颜色循环列表
  167. EquipModel.ColorList = {
  168. [1] = "#ff3939",--红
  169. [2] = "#ffc038",--黄
  170. [3] = "#46f33d",--灰
  171. [4] = "#40eef9",--绿
  172. [5] = "#4e47e7",--蓝
  173. [6] = "#cd47ff",
  174. }
  175. function EquipModel:__init()
  176. EquipModel.Instance = self
  177. self:Reset()
  178. end
  179. function EquipModel:Reset()
  180. self.goods_model = GoodsModel:getInstance()
  181. self.equip_sum_stars = 0--装备总星级
  182. self.equip_activie_stars = 0--装备激活星级
  183. self.equip_sum_power = 0--装备总战力
  184. self.equip_force_strength = false--是否正在一键精炼
  185. self.gems_lv_list = {}--装备激活宝石等级列表
  186. self.gems_suit_red_list = {}--装备激活宝石套装红点列表
  187. self.equip_pos_info = {}--装备位置列表信息15200
  188. self.can_strength_info = {}--穿戴装备精炼列表
  189. self.can_up_quality_info = {}--能否升品信息
  190. self.red_dot_info = {}--红点列表
  191. self.equip_red_equip_pos_list = {} -- 15200升品寻宝pos_list
  192. self.red_dot_redEquip_info = {}--红装红点信息
  193. self.gemstone_info_list = {}--15213宝石镶嵌信息
  194. self.equip_gemsstone_red_list = {}
  195. self.gem_next_level_list = {}--宝石下一阶段
  196. self.gems_can_tip = false--宝石能否提示tips
  197. self.redEquip_server_info = {}
  198. self.equip_sum_power = 0
  199. self.no_show_faker_evo = false--默认展示弱红点一次
  200. self.draconic_red_info = {}--刻印装备位置红点
  201. self.cur_max_series = 1 --当前已经开启的最大套代数
  202. self.series_to_turn_cfg = {} --最大套装代数 转 转生数配置
  203. self.turn_to_series_cfg = {} --转生数 转 最大套装代数配置
  204. self.equipment_cfg = {}--装备基础配置初始化
  205. self.equipment_suit_cfg = {}--装备套装配置初始化
  206. self.equipment_gems_suit_cfg = {}--装备宝石套件配置
  207. self.equipment_draconic_cfg = {}--装备刻印属性(暂不知道什么时候需要)
  208. self.red_equip_cfg_list = {}--红装配置
  209. self.suit_attr_active_list = {}--装备更新新套装属性激活
  210. self.suit_attr_active_red_series_list = {}--装备更新新套装属性激活Red
  211. self.suit_attr_red_bool = false
  212. self.need_equip_duibi = false--默认不需要装备对比
  213. self:InitEquipCfg()
  214. end
  215. function EquipModel:getInstance()
  216. if EquipModel.Instance == nil then
  217. EquipModel.Instance = EquipModel.New()
  218. end
  219. return EquipModel.Instance
  220. end
  221. --初始化需要的配置
  222. function EquipModel:InitEquipCfg( )
  223. --装备属性评分库
  224. self.equipment_attr_rating_cfg = {}
  225. local equipment_attr_rating_cfg_list = Config.Equipattrrating
  226. for k,v in pairs(equipment_attr_rating_cfg_list) do
  227. if not self.equipment_attr_rating_cfg[v.attr_id] then
  228. self.equipment_attr_rating_cfg[v.attr_id] = {}
  229. end
  230. self.equipment_attr_rating_cfg[v.attr_id][v.power_section] = v
  231. end
  232. --装备宝石配置
  233. self.equipment_gems_cfg = {}
  234. self.equipment_gems_series_cfg = {}
  235. self.equipment_gems_lv_cfg = {}--专门用于宝石越级升级的红点(这个宝石表操作逻辑很多直接初始化最好数量也不多)
  236. local equipment_gems_cfg = DeepCopy(Config.Equipmentgems)
  237. for k,v in pairs(equipment_gems_cfg) do
  238. v.attr = stringtotable(v.attr)
  239. self.equipment_gems_cfg[v.goods_id] = v
  240. if not self.equipment_gems_series_cfg[v.type] then
  241. self.equipment_gems_series_cfg[v.type] = {}
  242. end
  243. self.equipment_gems_series_cfg[v.type][v.goods_id] = v
  244. if not self.equipment_gems_lv_cfg[v.type] then
  245. self.equipment_gems_lv_cfg[v.type] = {}
  246. end
  247. self.equipment_gems_lv_cfg[v.type][v.lv] = v
  248. end
  249. self.equip_cfg_max_star = 0--装备星级配置最大星级
  250. for k,v in pairs(Config.Equipmentstartotal) do
  251. self.equip_cfg_max_star = self.equip_cfg_max_star < v.stars and v.stars or self.equip_cfg_max_star
  252. end
  253. end
  254. --初始化装备升星概率表
  255. function EquipModel:InitEquipEvolutionRatioCfg( )
  256. --装备升星属性概率
  257. self.equipment_evolution_ratio_cfg = {}
  258. local equipment_evolution_ratio_cfg = Config.Equipmentgreatratio
  259. for k,v in pairs(equipment_evolution_ratio_cfg) do
  260. if not self.equipment_evolution_ratio_cfg[v.color] then
  261. self.equipment_evolution_ratio_cfg[v.color] = {}
  262. end
  263. if not self.equipment_evolution_ratio_cfg[v.color][v.series] then
  264. self.equipment_evolution_ratio_cfg[v.color][v.series] = {}
  265. end
  266. if not self.equipment_evolution_ratio_cfg[v.color][v.series][v.target_series] then
  267. self.equipment_evolution_ratio_cfg[v.color][v.series][v.target_series] = {}
  268. end
  269. if not self.equipment_evolution_ratio_cfg[v.color][v.series][v.target_series][v.target_lv] then
  270. self.equipment_evolution_ratio_cfg[v.color][v.series][v.target_series][v.target_lv] = {}
  271. end
  272. self.equipment_evolution_ratio_cfg[v.color][v.series][v.target_series][v.target_lv] = v
  273. end
  274. end
  275. --刷新主界面装备图标红点
  276. function EquipModel:CheckMainIconRedDot( )
  277. local show = false
  278. for k,v in pairs(self.red_dot_info) do
  279. if v == true then
  280. show = v
  281. break
  282. end
  283. end
  284. GlobalEventSystem:Fire(EventName.SHOW_FUNCTION_RED_POINT, 152, show)
  285. local tool_show = false
  286. for k,v in pairs(self.red_dot_info) do
  287. if k == EquipModel.MainTab.Draconic then--升品和刻印进装备工坊了
  288. if v == true then
  289. tool_show = v
  290. break
  291. end
  292. end
  293. end
  294. GlobalEventSystem:Fire(EventName.SHOW_FUNCTION_RED_POINT, 154, tool_show)
  295. end
  296. --这样写红点 每次调全局的只要调两次
  297. function EquipModel:IsNeedRedAll( )
  298. self.red_dot_info[EquipModel.MainTab.Strengthen] = self:CheckStrengthenRedDot()
  299. self.red_dot_info[EquipModel.MainTab.RedEquip] = self:CheckRedEquipRedDot()
  300. self.red_dot_info[EquipModel.MainTab.Evolution] = self:CheckEvolutionRedDot()
  301. -- self.red_dot_info[EquipModel.MainTab.UpQuality] = self:CheckUpQualityRedDot()
  302. self.red_dot_info[EquipModel.MainTab.Inherit] = self:CheckInheritDot()
  303. -- self.red_dot_info[EquipModel.MainTab.Draconic] = self:CheckDraconicDot()
  304. self.red_dot_info[EquipModel.MainTab.Gemstone] = self:CheckGemstoneDot()
  305. self:CheckMainIconRedDot()
  306. end
  307. --红点刷新
  308. function EquipModel:IsNeedRed( tab_type,is_all,not_refresh_view,refresh_gem_suit )
  309. if not is_all then--全刷新就不判断等级了
  310. local can_refresh = self:CheckLevel(tab_type)
  311. if not can_refresh then return end
  312. end
  313. local bool = false
  314. if tab_type == EquipModel.MainTab.Strengthen then--精炼
  315. bool = self:CheckStrengthenRedDot()
  316. elseif tab_type == EquipModel.MainTab.Evolution then--升星
  317. bool = self:CheckEvolutionRedDot()
  318. elseif tab_type == EquipModel.MainTab.Inherit then--继承
  319. bool = self:CheckInheritDot()
  320. elseif tab_type == EquipModel.MainTab.UpQuality then--升品
  321. -- bool = self:CheckUpQualityRedDot()--转移到合成功能了
  322. ComposeModel:getInstance():IsNeedRed(ComposeModel.MainTab.Guard)--守护
  323. ComposeModel:getInstance():IsNeedRed(ComposeModel.MainTab.Ornaments)--饰品
  324. elseif tab_type == EquipModel.MainTab.RedEquip then--红装
  325. bool = self:CheckRedEquipRedDot()
  326. elseif tab_type == EquipModel.MainTab.Draconic then--刻印
  327. -- bool = self:CheckDraconicDot()
  328. elseif tab_type == EquipModel.MainTab.Gemstone then--宝石
  329. bool = self:CheckGemstoneDot(refresh_gem_suit)
  330. ComposeModel:getInstance():IsNeedRed(ComposeModel.MainTab.Gemstone)--宝石
  331. end
  332. self.red_dot_info[tab_type] = bool
  333. if not not_refresh_view then
  334. self:Fire(EquipModel.UPDATE_VIEW_RED,tab_type,bool)
  335. end
  336. if not is_all then
  337. self:CheckMainIconRedDot()
  338. end
  339. -- print("huangcong:EquipModel [222]: ",bool,tab_type)
  340. -- PrintTable(self.red_dot_info)
  341. end
  342. --检查等级
  343. function EquipModel:CheckLevel( tab_type )
  344. local level = RoleManager:getInstance():GetMainRoleVo().level
  345. if tab_type == EquipModel.MainTab.Strengthen and level >= Config.Modulesub["152@1"].open_lv then--精炼
  346. return true
  347. elseif tab_type == EquipModel.MainTab.Evolution and level >= Config.Modulesub["152@2"].open_lv then--升星
  348. return true
  349. elseif tab_type == EquipModel.MainTab.Inherit and level >= Config.Modulesub["152@3"].open_lv then--继承
  350. return true
  351. elseif tab_type == EquipModel.MainTab.UpQuality and level >= Config.Modulesub["152@4"].open_lv then--升品
  352. return true
  353. elseif tab_type == EquipModel.MainTab.RedEquip and level >= Config.Modulesub["154@1"].open_lv then--红装
  354. return true
  355. elseif tab_type == EquipModel.MainTab.Draconic and level >= Config.Modulesub["154@2"].open_lv then--刻印
  356. return true
  357. elseif tab_type == EquipModel.MainTab.Gemstone and level >= Config.Modulesub["152@7"].open_lv then--宝石
  358. return true
  359. end
  360. return false
  361. end
  362. --检查精炼红点
  363. function EquipModel:CheckStrengthenRedDot( )
  364. local have_red = false
  365. self:GetEquipCanStrength()--更新精炼数据
  366. for k,v in pairs(self.can_strength_info) do
  367. for kk,vv in pairs(v) do
  368. if vv then
  369. have_red = vv
  370. break
  371. end
  372. end
  373. end
  374. return have_red
  375. end
  376. --检查红装红点
  377. function EquipModel:CheckRedEquipRedDot( )
  378. if not GetModuleIsOpen(154,1) then return false end
  379. local boolRed = false
  380. self.red_dot_redEquip_info = {}
  381. -- 三个升级条件
  382. -- 升级至红色品质装备的条件是 当前装备已经是橙色装备
  383. local condition_2 = self:RedEquipCheckAllSeriesLv(3,1)-- 升级至粉色品质装备的条件是 前3代装备全部提升到红色
  384. local condition_3 = self:RedEquipCheckAllSeriesLv(4,2)-- 升级至彩色品质装备的条件是 前4代装备全部提升到粉色
  385. local wear_equip_suit_list = self.goods_model.wear_equip_suit_list or {}
  386. local lv = 0
  387. local info = nil
  388. for k,v in pairs(wear_equip_suit_list) do
  389. if not self.red_dot_redEquip_info[k] then
  390. self.red_dot_redEquip_info[k] = {}
  391. end
  392. for kk,vv in pairs(v) do
  393. lv = 0
  394. info = self:GetRedEquipInfo(k,kk)
  395. if info and info.lv then
  396. lv = info.lv
  397. end
  398. local item_cfg = self:GetRedEquipCfg(k,kk,lv + 1)--取的是下一级的配置
  399. if item_cfg and item_cfg.cost then
  400. if self.goods_model:GetEnough(item_cfg.cost) == true then--首先消耗材料满足再进入判断
  401. if item_cfg.condition and item_cfg.condition[1] == "equip_color" then--装备品质色
  402. if wear_equip_suit_list[k] and wear_equip_suit_list[k][kk] and wear_equip_suit_list[k][kk].color >= 4 then
  403. self.red_dot_redEquip_info[k][kk] = true
  404. boolRed = true
  405. end
  406. elseif item_cfg.condition and item_cfg.condition[1] == "all_series_lv" then--套件等级条件
  407. if item_cfg.condition[2] == 3 and condition_2 then--条件二
  408. self.red_dot_redEquip_info[k][kk] = true
  409. boolRed = true
  410. elseif item_cfg.condition[2] == 4 and condition_3 then--条件三
  411. self.red_dot_redEquip_info[k][kk] = true
  412. boolRed = true
  413. end
  414. end
  415. end
  416. end
  417. end
  418. end
  419. if not boolRed and GetModuleIsOpen(414) then
  420. boolRed = EmpowerModel:GetInstance():GetEmpowerRedDotList()[EmpowerConst.EmpowerViewType.EmpowerShop]
  421. end
  422. if not boolRed and GetModuleIsOpen(414) then
  423. local info = EmpowerModel:GetInstance().grid_game_info
  424. boolRed = info and info.free_count > 0 or false
  425. end
  426. -- print("huangcong:EquipModel [start:448] :", self.red_dot_redEquip_info)
  427. -- PrintTable(self.red_dot_redEquip_info)
  428. -- print("huangcong:EquipModel [end]")
  429. return boolRed
  430. end
  431. function EquipModel:GetRedEquipRedDot()
  432. return self.red_dot_redEquip_info
  433. end
  434. --获得红装红点通过suit和equiptype
  435. function EquipModel:GetRedEquipRedDotBySuitAndEquipType(suit,equip_type)
  436. if self.red_dot_redEquip_info[suit] then
  437. return self.red_dot_redEquip_info[suit][equip_type]
  438. end
  439. return false
  440. end
  441. --补齐列表为显示等级0
  442. function EquipModel:SetRedEquipPosList(vo)
  443. local list = vo
  444. for k1,v1 in pairs(self.EmpowerEquipTransId) do
  445. local isHave = false
  446. for k,v in pairs(vo) do
  447. if v.pos == v1 then
  448. isHave = true
  449. end
  450. end
  451. if isHave == false then
  452. local subList = {}
  453. subList.pos = v1
  454. subList.power_lv = 0
  455. table.insert(list, subList)
  456. end
  457. end
  458. self.equip_red_equip_pos_list = list
  459. end
  460. function EquipModel:GetRedEquipPosList()
  461. return self.equip_red_equip_pos_list
  462. end
  463. --装备位置信息
  464. function EquipModel:SetEquipPosInfoList(list)
  465. if not list then return end
  466. self.equip_pos_info = {}
  467. for i,v in ipairs(list) do
  468. local carve_list = {}
  469. for ii,vv in ipairs(v.carve_list) do
  470. carve_list[vv.goods_id] = vv
  471. end
  472. v.carve_list = carve_list
  473. self.equip_pos_info[v.pos] = v
  474. end
  475. end
  476. function EquipModel:GetEquipPosInfoList(pos)
  477. return self.equip_pos_info[pos]
  478. end
  479. function EquipModel:IsExistEmpowerPosAndLvReturnCost(series,pos,getLv)
  480. local cfg = self:GetRedEquipCfg(series,pos,getLv)
  481. if cfg then
  482. return true,cfg.cost
  483. end
  484. return false
  485. end
  486. --获取最高阶的每一件装备
  487. function EquipModel:GetMaxEquipList( )
  488. local need_list = {}
  489. local compare_list = {}
  490. local maxLen = NewMainRoleModel:getInstance():GetRoleReinMaxTurn()
  491. for k1,v1 in pairs(self.goods_model.wear_equip_suit_list) do
  492. for k,v in pairs(v1) do
  493. if compare_list[v.equip_suit_type] then
  494. if compare_list[v.equip_suit_type] < v.cell then
  495. compare_list[v.equip_suit_type] = v.cell
  496. need_list[v.equip_suit_type] = v
  497. end
  498. else
  499. compare_list[v.equip_suit_type] = v.cell
  500. need_list[v.equip_suit_type] = v
  501. end
  502. end
  503. end
  504. return need_list
  505. end
  506. --检查升品的红点
  507. function EquipModel:CheckUpQualityRedDot( )
  508. local have_red = false
  509. for k,v in pairs(self.can_up_quality_info) do
  510. for kk,vv in pairs(v) do
  511. if vv then
  512. have_red = vv
  513. break
  514. end
  515. end
  516. end
  517. return have_red
  518. end
  519. --检查继承红点
  520. function EquipModel:CheckInheritDot( )
  521. local bag_goods_list = self.goods_model.bag_goods_list
  522. for k,v in pairs(bag_goods_list) do
  523. local goods_vo = v
  524. if goods_vo and goods_vo.type == GoodsModel.TYPE.EQUIP and goods_vo.goods_num > 0 then
  525. local equip_cfg = self:GetEquipmentCfg(goods_vo.type_id)
  526. if equip_cfg and equip_cfg.series ~= 99 then
  527. --当前同等位置穿戴的装备数据
  528. local cur_wear_data = nil
  529. local can_inherit = false
  530. if self.goods_model.wear_equip_suit_list[equip_cfg.series]
  531. and self.goods_model.wear_equip_suit_list[equip_cfg.series][equip_cfg.equip_type]
  532. then
  533. cur_wear_data = self.goods_model.wear_equip_suit_list[equip_cfg.series][equip_cfg.equip_type]
  534. local cur_wear_strength_level = 0--当前装备精炼等级
  535. local cur_wear_evoblution_level = 0--当前升星等级
  536. for k,v in pairs(cur_wear_data.other_data) do
  537. if v.type == GoodsModel.GoodsInfoType.EquipmentLv then
  538. cur_wear_strength_level = tonumber(v.info)
  539. elseif v.type == GoodsModel.GoodsInfoType.EquipEvoLevel and equip_cfg.equip_type < EquipModel.EquipType.Necklace then
  540. cur_wear_evoblution_level = tonumber(v.info)
  541. end
  542. end
  543. --品质小于当前的装备并且是紫色装备或以上
  544. --当前穿戴的装备升星和精炼都是0才给红点
  545. local goods_strength_level = 0
  546. local goods_evolution_level = 0
  547. if goods_vo.color > 2 and goods_vo.color < cur_wear_data.color
  548. and cur_wear_evoblution_level < 3 and cur_wear_strength_level == 0 then
  549. for k,v in pairs(goods_vo.other_data) do
  550. if v.type == GoodsModel.GoodsInfoType.EquipmentLv then
  551. goods_strength_level = tonumber(v.info)
  552. elseif v.type == GoodsModel.GoodsInfoType.EquipEvoLevel and equip_cfg.equip_type < EquipModel.EquipType.Necklace then
  553. goods_evolution_level = tonumber(v.info)
  554. end
  555. end
  556. --非首饰可以继承升星
  557. if equip_cfg.equip_type < EquipModel.EquipType.Necklace then
  558. --当前装备高级属性必须大于1
  559. if goods_evolution_level > 1 then
  560. return true
  561. end
  562. --当前装备精炼等级必须大于1
  563. if goods_strength_level > 0 then
  564. return true
  565. end
  566. --首饰只能继承精炼等级
  567. elseif equip_cfg.equip_type >= EquipModel.EquipType.Necklace and equip_cfg.equip_type <= EquipModel.EquipType.RightRing then
  568. if goods_strength_level > 0 then
  569. return true
  570. end
  571. end
  572. end
  573. end
  574. end
  575. end
  576. end
  577. return false
  578. end
  579. --检查升星红点
  580. function EquipModel:CheckEvolutionRedDot( )
  581. local have_red = false
  582. self:GetEquipCanEvolution()--更新升星数据
  583. local anim_percent = 95
  584. local life_skill_active = PetModel:getInstance():IsLifeSkillActived(PetConst.LifeSkill.EquipEvolutionSuccessRateUp)
  585. local life_skill_ratio = PetModel:getInstance():GetPetLifeSkillRatio(PetConst.LifeSkill.EquipEvolutionSuccessRateUp)
  586. local vip_card_ratio = VipModel.getInstance():VipCardEquipEvolutionRatio(true)
  587. local add_life_skill_ratio = 0
  588. if life_skill_active then
  589. add_life_skill_ratio = life_skill_ratio
  590. end
  591. anim_percent = anim_percent - add_life_skill_ratio - vip_card_ratio---目标升星概率需要减去宠物和月卡加成的
  592. for k,v in pairs(self.can_evolution_info) do
  593. for kk,vv in pairs(v) do
  594. local evolution_level = self:GetEquipEvolutionLevel(vv.goods_vo) + 1--当前装备升星等级
  595. if vv.radio and vv.cost_enoght and (not vv.is_faker or vv.is_faker and not self.no_show_faker_evo) then--强红点/弱红点
  596. if vv.radio >= anim_percent then
  597. have_red = true
  598. break
  599. elseif self.bag_evoluton_radio_list[k] and self.bag_evoluton_radio_list[k][evolution_level]
  600. and self.bag_evoluton_radio_list[k][evolution_level]/100 + vv.radio >= anim_percent then
  601. have_red = true
  602. break
  603. end
  604. end
  605. end
  606. end
  607. if not have_red then
  608. have_red = self:GetCurHaveStarRedDot()
  609. end
  610. return have_red
  611. end
  612. function EquipModel:CheckEvolutionStrengthStarRedDot( )
  613. local have_red = self:GetCurHaveStarRedDot()
  614. return have_red
  615. end
  616. --得到升星套件标签红点
  617. function EquipModel:GetEvolutionSuitTabRedInfo( )
  618. local info = {}
  619. if self.can_evolution_info then
  620. local anim_percent = 95
  621. local life_skill_active = PetModel:getInstance():IsLifeSkillActived(PetConst.LifeSkill.EquipEvolutionSuccessRateUp)
  622. local life_skill_ratio = PetModel:getInstance():GetPetLifeSkillRatio(PetConst.LifeSkill.EquipEvolutionSuccessRateUp)
  623. local vip_card_ratio = VipModel.getInstance():VipCardEquipEvolutionRatio(true)
  624. local add_life_skill_ratio = 0
  625. if life_skill_active then
  626. add_life_skill_ratio = life_skill_ratio
  627. end
  628. anim_percent = anim_percent - add_life_skill_ratio - vip_card_ratio---目标升星概率需要减去宠物和月卡加成的
  629. for k,v in pairs(self.can_evolution_info) do
  630. for kk,vv in pairs(v) do
  631. local evolution_level = self:GetEquipEvolutionLevel(vv.goods_vo) + 1--当前装备升星等级
  632. if vv.radio and vv.cost_enoght and (not vv.is_faker or vv.is_faker and not self.no_show_faker_evo) then
  633. if vv.radio >= anim_percent then
  634. info[k] = true
  635. break
  636. elseif self.bag_evoluton_radio_list[k] and self.bag_evoluton_radio_list[k][evolution_level]
  637. and self.bag_evoluton_radio_list[k][evolution_level]/100 + vv.radio >= anim_percent then
  638. info[k] = true
  639. break
  640. end
  641. end
  642. end
  643. end
  644. end
  645. return info
  646. end
  647. --检查刻印红点
  648. function EquipModel:CheckDraconicDot( )
  649. return false
  650. end
  651. --[检查宝石红点主界面]
  652. function EquipModel:CheckGemstoneDot( refresh_gem_suit )
  653. local show = false
  654. if not refresh_gem_suit then
  655. local bag_goods_list = self.goods_model.bag_goods_list
  656. local server_info = self:GetGemstoneSeriesInfo()--宝石镶嵌信息
  657. local wear_equip_suit_list = self.goods_model.wear_equip_suit_list
  658. local equip_gemsstone_red_list = {}--装备宝石红点列表
  659. --背包中所有装备套件的宝石红点列表
  660. if server_info and bag_goods_list and wear_equip_suit_list then
  661. local bag_gem_list = {}
  662. local wear_gem_list = {}
  663. for k,v in pairs(bag_goods_list) do
  664. if v.type == 1 and v.subtype == 23 and v.pos == 2 and v.goods_num >= 1 then--宝石类
  665. local cfg = Config.Equipmentgems[v.type_id]
  666. if cfg then
  667. bag_gem_list[#bag_gem_list + 1] = cfg
  668. end
  669. end
  670. end
  671. if #bag_gem_list > 0 then--背包中有宝石
  672. --先判断没有宝石装满的情况
  673. for k,v in pairs(wear_equip_suit_list) do
  674. for kk,vv in pairs(v) do
  675. if kk ~= EquipModel.EquipType.Guard then
  676. if not equip_gemsstone_red_list[k] then
  677. equip_gemsstone_red_list[k] = {}
  678. end
  679. if not equip_gemsstone_red_list[k][kk] then
  680. if not server_info[k] or not server_info[k][kk] then--有装备却没有宝石数据直接为true
  681. equip_gemsstone_red_list[k][kk] = true
  682. show = true
  683. elseif TableSize(server_info[k][kk]) < 3 then--有装备却宝石没有装满直接为true
  684. for i=1,3 do--确定是那种类型的宝石没有
  685. if not server_info[k][kk][i] and not equip_gemsstone_red_list[k][kk] then
  686. for kkk,vvv in pairs(bag_gem_list) do
  687. if vvv.type == i then
  688. equip_gemsstone_red_list[k][kk] = true
  689. show = true
  690. break
  691. end
  692. end
  693. end
  694. end
  695. end
  696. end
  697. end
  698. end
  699. end
  700. if not show then--先给镶嵌红点 再给其他的红点
  701. --如果宝石装满了返回宝石等级高的
  702. for k,v in pairs(wear_equip_suit_list) do
  703. for kk,vv in pairs(v) do
  704. if kk ~= EquipModel.EquipType.Guard then
  705. if not equip_gemsstone_red_list[k][kk] then
  706. for kkk,vvv in pairs(server_info[k][kk]) do
  707. for kkkk,vvvv in pairs(bag_gem_list) do
  708. if vvvv.type == vvv.type and vvvv.lv > vvv.lv then
  709. equip_gemsstone_red_list[k][kk] = true
  710. show = true
  711. break
  712. end
  713. end
  714. if self:CheckGemstoneViewDot(vvv.goods_id) then
  715. equip_gemsstone_red_list[k][kk] = true
  716. show = true
  717. end
  718. end
  719. end
  720. end
  721. end
  722. end
  723. end
  724. --如果可以升级也需要添加红点
  725. end
  726. end
  727. self.equip_gemsstone_red_list = equip_gemsstone_red_list
  728. end
  729. for k,v in pairs(self.equip_gemsstone_red_list) do
  730. if show then break end
  731. for kk,vv in pairs(v) do
  732. if vv then
  733. show = true
  734. break
  735. end
  736. end
  737. end
  738. local suit_show = self:CheckGemstoneSeriesRedDot()
  739. if not show then--如果还没有红点就检查宝石套装的红点
  740. show = suit_show
  741. end
  742. return show
  743. end
  744. --检查装备宝石是否有红点
  745. function EquipModel:CheckGemstoneViewDot( type_id )
  746. local show = false
  747. local bag_goods_list = self.goods_model.bag_goods_list
  748. --背包中所有装备套件的宝石红点列表
  749. if bag_goods_list and type_id then
  750. local bag_gem_list = {}
  751. for k,v in pairs(bag_goods_list) do
  752. if v.type == 1 and v.subtype == 23 and v.pos == 2 and v.goods_num >= 1 then--宝石类
  753. local cfg = Config.Equipmentgems[v.type_id]
  754. if cfg then
  755. bag_gem_list[#bag_gem_list + 1] = cfg
  756. end
  757. end
  758. end
  759. if #bag_gem_list > 0 then--背包中有宝石
  760. --先判断有没有比他高级的宝石
  761. local cfg = Config.Equipmentgems[type_id]
  762. if cfg then
  763. for k,v in pairs(bag_gem_list) do
  764. if v.type == cfg.type and v.lv > cfg.lv then
  765. show = true
  766. break
  767. end
  768. end
  769. else
  770. print("huangcong:EquipModel [start:778]宝石配置不存在 :", type_id)
  771. end
  772. --判断是否能升级
  773. if not show then
  774. show = self:CheckGemstoneCanLevel(type_id)
  775. end
  776. end
  777. end
  778. return show
  779. end
  780. --检查宝石是否能升级
  781. function EquipModel:CheckGemstoneCanLevel( type_id )
  782. if not type_id then return false end
  783. local show = false
  784. --寻找接下来能合成宝石的情况从高到低
  785. local num = self.goods_model:GetTypeGoodsNum(type_id)
  786. local gem_type = Config.Equipmentgems[type_id].type
  787. local gem_cur_lv = Config.Equipmentgems[type_id].lv
  788. if gem_cur_lv >= EquipModel.GemstoneMaxLevel then return false end
  789. --递归方法
  790. local function findGemstoneCanLevel( gem_cur_lv,need_num )
  791. if gem_cur_lv <= 1 then return false end
  792. local show = false
  793. local need_last_gems_num = need_num
  794. local last_cfg = self.equipment_gems_lv_cfg[gem_type][gem_cur_lv - 1]
  795. if last_cfg then
  796. local last_gems_num = self.goods_model:GetTypeGoodsNum(last_cfg.goods_id)
  797. if last_gems_num >= need_last_gems_num then
  798. show = true
  799. else
  800. show = findGemstoneCanLevel(gem_cur_lv - 1,(need_num - last_gems_num)*3)
  801. end
  802. end
  803. return show
  804. end
  805. --先判断同等级的是否数量大于2
  806. if num >= 2 then
  807. show = true
  808. --没有的话去寻找下一个等级的宝石看能不能凑齐2个同等级的
  809. elseif gem_cur_lv > 1 then
  810. local offer_num = 2 - num
  811. local need_last_gems_num = offer_num*3
  812. local last_cfg = self.equipment_gems_lv_cfg[gem_type][gem_cur_lv - 1]
  813. if last_cfg then
  814. local last_gems_num = self.goods_model:GetTypeGoodsNum(last_cfg.goods_id)
  815. if last_gems_num >= need_last_gems_num then
  816. show = true
  817. end
  818. end
  819. if not show then
  820. show = findGemstoneCanLevel(gem_cur_lv,need_last_gems_num)
  821. end
  822. end
  823. return show
  824. end
  825. --检查宝石是否替换
  826. function EquipModel:CheckGemstoneCanReplace( type_id )
  827. local show = false
  828. local bag_goods_list = self.goods_model.bag_goods_list
  829. --背包中所有装备套件的宝石红点列表
  830. if bag_goods_list and type_id then
  831. local bag_gem_list = {}
  832. for k,v in pairs(bag_goods_list) do
  833. if v.type == 1 and v.subtype == 23 and v.pos == 2 and v.goods_num >= 1 then--宝石类
  834. local cfg = Config.Equipmentgems[v.type_id]
  835. if cfg then
  836. bag_gem_list[#bag_gem_list + 1] = cfg
  837. end
  838. end
  839. end
  840. if #bag_gem_list > 0 then--背包中有宝石
  841. --先判断有没有比他高级的宝石
  842. local cfg = Config.Equipmentgems[type_id]
  843. if cfg then
  844. for k,v in pairs(bag_gem_list) do
  845. if v.type == cfg.type and v.lv > cfg.lv then
  846. show = true
  847. break
  848. end
  849. end
  850. else
  851. print("huangcong:EquipModel [start:778]宝石配置不存在 :", type_id)
  852. end
  853. end
  854. end
  855. return show
  856. end
  857. --是否是玩家背包中的装备物品
  858. function EquipModel:IsInEquipList(goods_id)--物品唯一ID
  859. local is_bag = true
  860. for k,v in pairs(self.goods_model.wear_equip_suit_list) do
  861. for kk,vv in pairs(v) do
  862. if vv.goods_id == goods_id then
  863. is_bag = false
  864. break
  865. end
  866. end
  867. end
  868. return is_bag
  869. end
  870. --是否是穿戴装备
  871. function EquipModel:IsWearEquip( goods_id )
  872. local wear_equip = self.goods_model.wear_equip_dic[goods_id] --传进来的物品id不是已穿戴列表中的
  873. wear_equip = wear_equip or MateModel:GetInstance():GetIsMateShipByTypeId(goods_id)--羁绊信物默认穿戴中
  874. return wear_equip and true or false
  875. end
  876. --判断是否需要显示装备对比tips
  877. function EquipModel:ShowCompareTips(type_id, goods_id)
  878. local show = false
  879. local have_equip_data = nil
  880. local wear_equip = self.goods_model.wear_equip_dic[goods_id] --传进来的物品id不是已穿戴列表中的
  881. if wear_equip == nil then
  882. local equip_cfg = self:GetEquipmentCfg(type_id)
  883. if equip_cfg and equip_cfg.equip_type ~= EquipModel.EquipType.Guard then
  884. local equip_series_list = self.goods_model.wear_equip_suit_list[equip_cfg.series] --在已穿戴列表中能找到与传进来的类型相同的装备
  885. if equip_series_list and equip_series_list[equip_cfg.equip_type] then
  886. show = true
  887. have_equip_data = equip_series_list[equip_cfg.equip_type]
  888. end
  889. else
  890. if self.cur_choose_suit ~= nil then
  891. local equip_series_list = self.goods_model.wear_equip_suit_list[self.cur_choose_suit]
  892. if equip_series_list and equip_series_list[equip_cfg.equip_type] then
  893. show = true
  894. have_equip_data = equip_series_list[equip_cfg.equip_type]
  895. end
  896. end
  897. end
  898. end
  899. return show, have_equip_data
  900. end
  901. function EquipModel:InitEquipmentCfg( )
  902. if TableSize(self.equipment_cfg) == 0 then
  903. local equipment_cfg_list = DeepCopy(Config.Equipment)
  904. for k,v in pairs(equipment_cfg_list) do
  905. v.career = stringtotable(v.career)
  906. v.base_attr = stringtotable(v.base_attr)
  907. v.great_attr_list = stringtotable(v.great_attr_list)
  908. v.attr_show = stringtotable(v.attr_show)
  909. v.skill = stringtotable(v.skill)
  910. v.suit = stringtotable(v.suit)
  911. v.evolution_offer_ratio = stringtotable(v.evolution_offer_ratio)
  912. self.equipment_cfg[v.goods_id] = v
  913. end
  914. end
  915. end
  916. --获得装备基本信息配置
  917. function EquipModel:GetEquipmentCfg( goods_id )
  918. self:InitEquipmentCfg()
  919. if self.equipment_cfg[goods_id] then
  920. return self.equipment_cfg[goods_id]
  921. else
  922. local is_mate = MateModel:GetInstance():GetIsMateShipByTypeId( goods_id )
  923. if is_mate then
  924. --羁绊信物的数据
  925. local goods_basic = self.goods_model:GetGoodsBasicByTypeId( goods_id )
  926. local model_save_temp_mate = self.mate_show_tool_tip_data
  927. if model_save_temp_mate then
  928. my_mate_conf = MateModel:GetInstance():GetShipConf(model_save_temp_mate.stage,model_save_temp_mate.star)
  929. else
  930. my_mate_conf = MateModel:GetInstance():GetCurShipConf()
  931. end
  932. if goods_basic and my_mate_conf then
  933. local data = {goods_id = goods_id}
  934. data.base_attr = stringtotable(my_mate_conf.attr)
  935. data.name = my_mate_conf.name
  936. data.series = 99
  937. data.color = goods_basic.color
  938. data.career = {[1] = 1,[2] = 2,[3] = 3,[4] = 4}
  939. data.equip_type = 12
  940. return data
  941. end
  942. end
  943. -- print("没有装备配置哦!", goods_id)
  944. end
  945. end
  946. --获得装备套件配置
  947. function EquipModel:GetEquipmentSuitCfg( series,type )--1装备2首饰
  948. if TableSize(self.equipment_suit_cfg) == 0 then
  949. local equipment_suit_cfg_list = DeepCopy(Config.Equipmentsuit)
  950. for k,v in pairs(equipment_suit_cfg_list) do
  951. v.stage_attr = stringtotable(v.stage_attr)
  952. v.attr = stringtotable(v.attr)
  953. v.suit_equip = stringtotable(v.suit_equip)
  954. if not self.equipment_suit_cfg[v.series] then
  955. self.equipment_suit_cfg[v.series] = {}
  956. end
  957. if not self.equipment_suit_cfg[v.series][v.type] then
  958. self.equipment_suit_cfg[v.series][v.type] = {}
  959. end
  960. self.equipment_suit_cfg[v.series][v.type][#self.equipment_suit_cfg[v.series][v.type] + 1] = v
  961. end
  962. local sort_func = function ( a, b )
  963. return a.suit_num < b.suit_num
  964. end
  965. for series,v in pairs(self.equipment_suit_cfg) do
  966. for type,vv in pairs(v) do
  967. table.sort(vv, sort_func)
  968. end
  969. for type,vv in pairs(v) do
  970. local suit_num_max = vv[#vv] and vv[#vv].suit_num
  971. for k,vvv in ipairs(vv) do
  972. vvv.suit_num_max = suit_num_max
  973. end
  974. end
  975. end
  976. end
  977. if self.equipment_suit_cfg[series] and self.equipment_suit_cfg[series][type] then
  978. return self.equipment_suit_cfg[series][type]
  979. else
  980. print("没有该套件信息哦", series,type)
  981. end
  982. end
  983. --获得装备高级属性配置
  984. function EquipModel:GetEquipmentGreatAttrCfg( attr_id )
  985. local data = Config.Equipmentgreatattr[attr_id]
  986. if data then
  987. data = DeepCopy(data)
  988. data.attr = stringtotable(data.attr)
  989. return data
  990. else
  991. print("没有该高级属性条目哦", attr_id)
  992. end
  993. end
  994. --获得装备属性评分power可能是查看他人战力
  995. function EquipModel:GetEquipAttrRatingCfg( attr_id,attr_value,power )
  996. if self.equipment_attr_rating_cfg[attr_id] and attr_id and attr_value then
  997. local fight = power or RoleManager.Instance.mainRoleInfo.fighting
  998. for k,v in pairs(self.equipment_attr_rating_cfg[attr_id]) do
  999. if v.min_power <= fight and fight <= v.max_power then
  1000. return attr_value*v.rating
  1001. end
  1002. end
  1003. else
  1004. print('没有该属性的评分哦,不是特殊属性吧!', attr_id,attr_value)
  1005. end
  1006. end
  1007. --获得装备精炼属性的配置
  1008. function EquipModel:GetEquipStrengthAttrCfg( type_id,lv )
  1009. if not type_id or not lv then return end
  1010. local equip_cfg = self:GetEquipmentCfg(type_id)
  1011. if equip_cfg then
  1012. local series = equip_cfg.series
  1013. local equip_type = equip_cfg.equip_type
  1014. local key = series.."@"..equip_type.."@"..lv
  1015. if Config.Equipmentstrength[key] then
  1016. local data = DeepCopy(Config.Equipmentstrength[key])
  1017. data.attr = stringtotable(data.attr)
  1018. data.cost = stringtotable(data.cost)
  1019. return data
  1020. end
  1021. else
  1022. print('没有精炼属性的装备哦!', type_id,lv)
  1023. end
  1024. end
  1025. --获得装备精炼当前套装最大精炼等级
  1026. function EquipModel:GetEquipStrengSuitMaxLevel( series )
  1027. local max_level = 0
  1028. for k,v in pairs(Config.Equipmentstrengthtotal) do
  1029. if v.series == series then
  1030. max_level = max_level < v.lv and v.lv or max_level
  1031. end
  1032. end
  1033. return max_level
  1034. end
  1035. --获得升星属性的配置
  1036. function EquipModel:GetEquipEvolutionCfg( type_id,lv )
  1037. local equip_cfg = self:GetEquipmentCfg(type_id)
  1038. if equip_cfg then
  1039. local series = equip_cfg.series
  1040. local equip_type = equip_cfg.equip_type
  1041. local key = series.."@"..equip_type.."@"..lv
  1042. local cfg = Config.Equipmentgreat[key]
  1043. if cfg then
  1044. cfg = DeepCopy(cfg)
  1045. cfg.attr = stringtotable(cfg.attr)
  1046. cfg.cost = stringtotable(cfg.cost)
  1047. cfg.great_attr = stringtotable(cfg.great_attr)
  1048. cfg.great_attr_list = stringtotable(cfg.great_attr_list)
  1049. return cfg
  1050. end
  1051. else
  1052. -- print('没有配置的装备哦!', type_id,lv)
  1053. end
  1054. end
  1055. --获得装备提供升星概率的配置
  1056. function EquipModel:GetEquipEvolutionRatioCfg( type_id,target_series,target_lv )
  1057. if not type_id then return end
  1058. local equip_cfg = self:GetEquipmentCfg(type_id)
  1059. if equip_cfg and equip_cfg.equip_type <= EquipModel.EquipType.Shoes then
  1060. local goods_basic = self.goods_model:GetGoodsBasicByTypeId(type_id)
  1061. if goods_basic and goods_basic.color >= 3 then
  1062. local color = goods_basic.color
  1063. local series = equip_cfg.series
  1064. if target_series and target_lv then
  1065. local key_value = string.format("%s@%s@%s@%s",series,color,target_series,target_lv)
  1066. if Config.Equipmentgreatratio[key_value] then
  1067. return Config.Equipmentgreatratio[key_value]
  1068. else
  1069. print('没有升星属性概率的装备哦!', type_id,target_series,target_lv)
  1070. end
  1071. elseif not target_series then
  1072. if not self.equipment_evolution_ratio_cfg then--没找到初始化一次配置表
  1073. self:InitEquipEvolutionRatioCfg()
  1074. end
  1075. if self.equipment_evolution_ratio_cfg[color][series] and self.equipment_evolution_ratio_cfg[color][series] then
  1076. return self.equipment_evolution_ratio_cfg[color][series]
  1077. else
  1078. print('没有升星属性概率的装备哦!', type_id,target_series,target_lv)
  1079. end
  1080. end
  1081. end
  1082. else--不是装备
  1083. -- print('没有配置的装备哦!', type_id,lv)
  1084. end
  1085. end
  1086. --获得装备的所有高级属性Id列表
  1087. function EquipModel:GetEquipZhuoYueAttrIdList( type_id )
  1088. local equip_cfg = self:GetEquipmentCfg(type_id)
  1089. local attr_list = {}
  1090. if equip_cfg then
  1091. if equip_cfg.equip_type >= EquipModel.EquipType.Necklace then--首饰拿这些
  1092. for k,v in ipairs(equip_cfg.great_attr_list) do
  1093. attr_list[#attr_list + 1] = v
  1094. end
  1095. else
  1096. local attr_cfg_list = {}
  1097. for k,v in pairs(Config.Equipmentgreat) do
  1098. if v.series == equip_cfg.series and v.equip_type == equip_cfg.equip_type then
  1099. local data = DeepCopy(v)
  1100. data.attr = stringtotable(data.attr)
  1101. attr_cfg_list[#attr_cfg_list + 1] = data
  1102. end
  1103. end
  1104. local sort_func = function ( a, b )
  1105. return a.up_num < b.up_num
  1106. end
  1107. table.sort(attr_cfg_list, sort_func)
  1108. for k,v in ipairs(attr_cfg_list) do
  1109. attr_list[#attr_list + 1] = v.attr[1]
  1110. end
  1111. end
  1112. end
  1113. return attr_list
  1114. end
  1115. --获得升星最大等级
  1116. function EquipModel:GetEvoMaxLevel( type_id )
  1117. local equip_cfg = self:GetEquipmentCfg(type_id)
  1118. local max_star_level = 0
  1119. if equip_cfg then
  1120. if equip_cfg.equip_type >= EquipModel.EquipType.Necklace then--首饰拿这些
  1121. max_star_level = #equip_cfg.great_attr_list
  1122. else
  1123. for k,v in pairs(Config.Equipmentgreat) do
  1124. if v.series == equip_cfg.series and v.equip_type == equip_cfg.equip_type then
  1125. max_star_level = max_star_level + 1
  1126. end
  1127. end
  1128. end
  1129. end
  1130. return max_star_level
  1131. end
  1132. --判断是否是特殊装备属性评分
  1133. function EquipModel:GetIsEquipAttrRating( attr_id )
  1134. if self.equipment_attr_rating_cfg[attr_id] and attr_id then
  1135. return true
  1136. end
  1137. return false
  1138. end
  1139. --计算装备评分
  1140. --is_bag背包里面要计算精炼等级带来的评分
  1141. function EquipModel:MathEquipScore( goods_vo,goods_id,power )
  1142. local attr_info = {}
  1143. local empower_lv = 0
  1144. local equip_score = 0--评分
  1145. local haved_power = false--是否是已有战力
  1146. local equip_cfg = self:GetEquipmentCfg(goods_id)
  1147. if goods_vo and goods_vo.power and goods_vo.power~=nil and goods_vo.power ~= "" then
  1148. power = tonumber(goods_vo.power)
  1149. end
  1150. power = power ~= nil and power > 0 and power or RoleManager.Instance.mainRoleInfo.fighting
  1151. -- print("huangcong:EquipModel [start:1254] :", power)
  1152. --基础属性
  1153. if equip_cfg and equip_cfg.base_attr and TableSize(equip_cfg.base_attr) ~= 0 then
  1154. for k,v in pairs(equip_cfg.base_attr) do
  1155. attr_info[#attr_info + 1] = v
  1156. end
  1157. end
  1158. -- print("huangcong:EquipModel [start:243] attr_info:", attr_info)
  1159. -- PrintTable(attr_info)
  1160. -- print("huangcong:EquipModel [end]")
  1161. --高级属性
  1162. local zhuoyue_attr = {}
  1163. --精炼等级
  1164. local strengthen_level = 0
  1165. local star_evolution_lv = equip_cfg.color >= 3 and 1 or 0--星级升星属性等级
  1166. if goods_vo then
  1167. haved_power = goods_vo.pos == 1
  1168. for k,v in pairs(goods_vo.other_data or {}) do
  1169. if v.type == GoodsModel.GoodsInfoType.EquipEvoLevel and equip_cfg.equip_type < EquipModel.EquipType.Necklace then--非首饰读特殊属性
  1170. star_evolution_lv = tonumber(v.info)
  1171. elseif v.type == GoodsModel.GoodsInfoType.EquipmentLv then
  1172. strengthen_level = tonumber(v.info)
  1173. elseif v.type == GoodsModel.GoodsInfoType.EquipEmpower then--赋能等级
  1174. empower_lv = tonumber(v.info)
  1175. end
  1176. end
  1177. if haved_power then
  1178. local server_info = self:GetRedEquipInfo(equip_cfg.series,equip_cfg.equip_type)
  1179. if server_info then
  1180. empower_lv = server_info and server_info.lv or 0
  1181. if goods_vo.empower_lv then
  1182. empower_lv = goods_vo.empower_lv
  1183. end
  1184. end
  1185. end
  1186. if empower_lv and empower_lv > 0 then
  1187. local empower_cfg = self:GetRedEquipCfg(equip_cfg.series,equip_cfg.equip_type,empower_lv)--基础属性
  1188. if empower_cfg and empower_cfg.attr then
  1189. for k,v in pairs(empower_cfg.attr) do
  1190. attr_info[#attr_info + 1] = v
  1191. end
  1192. end
  1193. end
  1194. --获得精炼属性
  1195. if strengthen_level ~= 0 then
  1196. local strength_level_cfg = self:GetEquipStrengthAttrCfg(goods_id,strengthen_level)
  1197. if strength_level_cfg and strength_level_cfg.attr then
  1198. for k,v in pairs(strength_level_cfg.attr) do
  1199. attr_info[#attr_info + 1] = v
  1200. end
  1201. end
  1202. end
  1203. -- print("huangcong:EquipModel [start:278] attr_info:", attr_info,strengthen_level)
  1204. -- PrintTable(attr_info)
  1205. -- print("huangcong:EquipModel [end]")
  1206. local sort_func = function ( a, b )
  1207. if a.type ~= b.type then
  1208. return a.type > b.type
  1209. else
  1210. return a.id > b.id
  1211. end
  1212. end
  1213. table.sort(zhuoyue_attr, sort_func)
  1214. end
  1215. if equip_cfg.equip_type >= EquipModel.EquipType.Necklace then--首饰展示预览升星属性
  1216. for k,attr_cfg in pairs(equip_cfg.great_attr_list or {}) do
  1217. zhuoyue_attr[#zhuoyue_attr + 1] = {[1] = attr_cfg}
  1218. end
  1219. else
  1220. local equip_evo_cfg = self:GetEquipEvolutionCfg(equip_cfg.goods_id,star_evolution_lv)
  1221. if equip_evo_cfg and equip_evo_cfg.great_attr_list then
  1222. for i,attr_cfg in ipairs(equip_evo_cfg.great_attr_list) do
  1223. zhuoyue_attr[#zhuoyue_attr + 1] = {[1] = attr_cfg}
  1224. end
  1225. end
  1226. end
  1227. if zhuoyue_attr and TableSize(zhuoyue_attr) ~= 0 then
  1228. for k,v in pairs(zhuoyue_attr) do
  1229. attr_info[#attr_info + 1] = v[1]
  1230. end
  1231. end
  1232. --获得总属性列表了!
  1233. for k,v in pairs(attr_info) do
  1234. if self:GetIsEquipAttrRating(v[1]) then
  1235. equip_score = equip_score + self:GetEquipAttrRatingCfg(v[1],v[2],power)
  1236. else
  1237. equip_score = equip_score + GetPropOneAddNum(v[1])*v[2]
  1238. end
  1239. end
  1240. return math.floor(equip_score)
  1241. end
  1242. --获得装备awarditem具体数据
  1243. function EquipModel:GetBagEquipAwaraItemInfo( goods_vo )
  1244. local attr_info = {}
  1245. local strengthen_level = 0--精炼等级
  1246. local star = 0--卓越星级
  1247. local evolution_level = 0
  1248. local star_color = 1
  1249. if goods_vo then
  1250. --高级属性
  1251. local equip_cfg = self:GetEquipmentCfg(goods_vo.type_id)
  1252. --精炼等级
  1253. if equip_cfg then
  1254. evolution_level = equip_cfg.color >= 3 and 1 or 0
  1255. for k,v in pairs(goods_vo.other_data or {}) do
  1256. if v.type == GoodsModel.GoodsInfoType.EquipEvoLevel then--高级属性
  1257. evolution_level = tonumber(v.info)
  1258. elseif v.type == GoodsModel.GoodsInfoType.EquipmentLv then--精炼等级
  1259. strengthen_level = tonumber(v.info)
  1260. end
  1261. end
  1262. if equip_cfg and equip_cfg.equip_type >= EquipModel.EquipType.Necklace then
  1263. evolution_level = #equip_cfg.great_attr_list
  1264. for k,v in pairs(equip_cfg.great_attr_list) do
  1265. if v[3] then
  1266. star_color = star_color < v[3] and v[3] or star_color
  1267. end
  1268. end
  1269. else
  1270. local equip_evo_cfg = self:GetEquipEvolutionCfg(goods_vo.type_id,evolution_level)
  1271. if equip_evo_cfg and equip_evo_cfg.great_attr_list then
  1272. for k,v in pairs(equip_evo_cfg.great_attr_list) do
  1273. if v[3] then
  1274. star_color = star_color < v[3] and v[3] or star_color
  1275. end
  1276. end
  1277. end
  1278. end
  1279. end
  1280. star = evolution_level
  1281. end
  1282. local data = {}
  1283. data.star_color = star_color
  1284. data.star = star
  1285. data.evolution_level = evolution_level
  1286. data.strengthen_level = strengthen_level
  1287. data.goods_vo = goods_vo
  1288. -- print("huangcong:EquipModel [start:363] data:", data)
  1289. -- PrintTable(data)
  1290. -- print("huangcong:EquipModel [end]")
  1291. return data
  1292. end
  1293. --获得当前的套件激活信息
  1294. function EquipModel:GetCurSuitInfo( equip_list,tab_id )
  1295. -- local turn = RoleManager:getInstance():GetMainRoleVo().turn--暂时取消限制
  1296. local cur_wear_equip_list = equip_list or self.goods_model.wear_equip_suit_list
  1297. local suit_info = {}
  1298. for k,v in pairs(cur_wear_equip_list) do
  1299. if not tab_id then
  1300. suit_info[k] = TableSize(v) / 11
  1301. elseif tab_id == EquipModel.MainTab.Evolution then
  1302. local len = 0
  1303. if TableSize(v) > 0 then
  1304. for equip_type,vv in pairs(v) do
  1305. if equip_type < EquipModel.EquipType.Necklace then
  1306. len = len + 1
  1307. end
  1308. end
  1309. suit_info[k] = len / 7
  1310. end
  1311. end
  1312. end
  1313. return suit_info
  1314. end
  1315. --获得当前套件装备是否可以精炼
  1316. --只能说装备是真的要遍历很多东西最好把数据保存起来
  1317. function EquipModel:GetEquipCanStrength( )
  1318. --是否能精炼
  1319. local can_strength_info = {}
  1320. --首饰类是否能升品
  1321. local can_up_quality_info = {}
  1322. local necklace_up_info = {}
  1323. local wear_equip_suit_list = self.goods_model.wear_equip_suit_list
  1324. local equip_star_sum = 0
  1325. -- print("huangcong:EquipModel [start:1363] :", wear_equip_suit_list)
  1326. -- PrintTable(wear_equip_suit_list)
  1327. -- print("huangcong:EquipModel [end]")
  1328. if wear_equip_suit_list then
  1329. --能否精炼列表
  1330. for k,v in pairs(wear_equip_suit_list) do
  1331. for kk,vv in pairs(v) do
  1332. local strengthen_level = 0--当前装备等级
  1333. for kkk,vvv in pairs(vv.other_data or {}) do
  1334. if vvv.type == GoodsModel.GoodsInfoType.EquipmentLv then
  1335. strengthen_level = tonumber(vvv.info)
  1336. elseif vvv.type == GoodsModel.GoodsInfoType.EquipEvoLevel then
  1337. equip_star_sum = tonumber(vvv.info) + equip_star_sum
  1338. end
  1339. end
  1340. local base_cfg = self:GetEquipStrengthAttrCfg(vv.type_id,strengthen_level + 1)
  1341. if base_cfg then
  1342. local cost_list = {}
  1343. for kkk,vvv in ipairs(base_cfg.cost) do
  1344. local num = self.goods_model:GetTypeGoodsNum(vvv[2]) or 0
  1345. cost_list[kkk] = {num,vvv[2],vvv[3]}
  1346. end
  1347. local can_strength = self:CanStrength(cost_list)
  1348. if not can_strength_info[k] then
  1349. can_strength_info[k] = {}
  1350. end
  1351. can_strength_info[k][vv.equip_suit_type] = can_strength
  1352. end
  1353. --判断首饰类才能升品--这里是拿已穿戴的
  1354. if vv.equip_suit_type >= EquipModel.EquipType.Necklace then
  1355. local equip_cfg = self:GetEquipmentCfg(vv.type_id)
  1356. if equip_cfg and equip_cfg.equip_type and vv.goods_num > 0 then
  1357. equip_star_sum = #equip_cfg.great_attr_list + equip_star_sum
  1358. end
  1359. local compose_cfg = ComposeModel:getInstance():GetEvolutionComposeCfg(vv.type_id)
  1360. local limit_level = compose_cfg and compose_cfg.open_lv or 0
  1361. local cost_list = RoleManager.Instance.mainRoleInfo.level >= limit_level and compose_cfg and compose_cfg.cost_goods or {}
  1362. if cost_list and #cost_list > 0 then
  1363. local can_up_quality = true
  1364. for kkk,vvv in ipairs(cost_list) do
  1365. local goods_num = self.goods_model:GetTypeGoodsNum(vvv[2]) or 0
  1366. if goods_num < vvv[3] then
  1367. can_up_quality = false
  1368. end
  1369. end
  1370. if not can_up_quality_info[k] then
  1371. can_up_quality_info[k] = {}
  1372. end
  1373. can_up_quality_info[k][vv.equip_suit_type] = {can_up = can_up_quality,type_id = vv.type_id}
  1374. --这里是首饰的二次构造红点 因为要显示到具体的哪一个但是不需要知道哪一代
  1375. if not necklace_up_info[vv.type_id] then
  1376. necklace_up_info[vv.type_id] = can_up_quality
  1377. end
  1378. end
  1379. end
  1380. end
  1381. end
  1382. end
  1383. --这里再判断一次首饰的红点
  1384. local bag_goods_list = self.goods_model.bag_goods_list
  1385. for k,v in pairs(bag_goods_list) do
  1386. local equip_cfg = self:GetEquipmentCfg(v.type_id)
  1387. if equip_cfg and equip_cfg.equip_type and equip_cfg.equip_type >= EquipModel.EquipType.Necklace and v.goods_num > 0 then
  1388. local compose_cfg = ComposeModel:getInstance():GetEvolutionComposeCfg(v.type_id)
  1389. local limit_level = compose_cfg and compose_cfg.open_lv or 0
  1390. local cost_list = RoleManager.Instance.mainRoleInfo.level >= limit_level and compose_cfg and compose_cfg.cost_goods or {}
  1391. local series = equip_cfg.series
  1392. if cost_list and #cost_list > 0 then
  1393. local can_up_quality = true
  1394. for kkk,vvv in ipairs(cost_list) do
  1395. local goods_num = self:EquipGoodsNumById(vvv[2]) or 0
  1396. if goods_num < vvv[3] then
  1397. can_up_quality = false
  1398. end
  1399. end
  1400. --这里是首饰的二次构造红点 因为要显示到具体的哪一个但是不需要知道哪一代
  1401. if not necklace_up_info[v.type_id] then
  1402. necklace_up_info[v.type_id] = can_up_quality
  1403. end
  1404. end
  1405. end
  1406. end
  1407. if self.equip_sum_stars ~= 0 and equip_star_sum > self.equip_sum_stars then--星级提升
  1408. local tip_data = {}
  1409. tip_data.id = EquipModel.MainTab.Evolution
  1410. tip_data.star = equip_star_sum
  1411. local strengthtotal_cfg = Config.Equipmentstartotal[equip_star_sum]
  1412. if strengthtotal_cfg then
  1413. strengthtotal_cfg = DeepCopy(strengthtotal_cfg)
  1414. strengthtotal_cfg.stage_attr = stringtotable(strengthtotal_cfg.stage_attr)
  1415. tip_data.attr = strengthtotal_cfg.stage_attr
  1416. end
  1417. print("huangcong:EquipModel [start:1457] :", tip_data)
  1418. PrintTable(tip_data)
  1419. print("huangcong:EquipModel [end]")
  1420. if TableSize(tip_data.attr) <= 0 then
  1421. tip_data.is_skill_select = true
  1422. end
  1423. self:Fire(EquipModel.OPEN_EQUIP_BASE_TIPS_VIEW,tip_data)
  1424. end
  1425. self.equip_sum_stars = equip_star_sum
  1426. self.can_strength_info = can_strength_info
  1427. self.can_up_quality_info = can_up_quality_info
  1428. self.necklace_up_info = necklace_up_info--首饰升品信息
  1429. -- print("huangcong:EquipModel [start:1457] :", self.necklace_up_info)
  1430. -- PrintTable(self.necklace_up_info)
  1431. -- print("huangcong:EquipModel [end]")
  1432. -- print("huangcong:EquipModel [start:832] :", self.can_strength_info)
  1433. -- PrintTable(self.can_strength_info)
  1434. -- print("huangcong:EquipModel [end]")
  1435. end
  1436. function EquipModel:GetEquipCanStrengthByPos( series,pos )
  1437. -- PrintTable(self.can_strength_info)
  1438. -- print("huangcong:EquipModel [end]")
  1439. if self.can_strength_info[series] then
  1440. return self.can_strength_info[series][pos]
  1441. end
  1442. return false
  1443. end
  1444. --获取身上穿戴的装备能升品
  1445. function EquipModel:GetEquipCanUpQualityByPos( series,pos,type_id,cost_list )
  1446. if not self.can_up_quality_info then return false end
  1447. if series ~= 99 then
  1448. if self.can_up_quality_info and self.can_up_quality_info[series] and self.can_up_quality_info[series][pos] then
  1449. return self.can_up_quality_info[series][pos].can_up
  1450. end
  1451. else
  1452. -- for k,v in pairs(self.can_up_quality_info) do
  1453. -- for kk,vv in pairs(v) do
  1454. -- if vv.type_id == type_id then
  1455. -- return vv.can_up
  1456. -- end
  1457. -- end
  1458. -- end
  1459. local bool = self:GetBagEquipCanUpQualityByTypeId(type_id)
  1460. if not bool and cost_list then
  1461. for i,v in ipairs(cost_list) do
  1462. bool = self:GetBagEquipCanUpQualityByTypeId(v[2])
  1463. if bool then
  1464. return true
  1465. end
  1466. end
  1467. end
  1468. end
  1469. if not have_red and self.necklace_up_info and self.necklace_up_info[type_id] then
  1470. return true
  1471. end
  1472. return false
  1473. end
  1474. --获取背包上穿戴的装备能升品
  1475. function EquipModel:GetBagEquipCanUpQualityByTypeId( type_id )
  1476. if not self.necklace_up_info then return false end
  1477. return self.necklace_up_info[type_id] or false
  1478. end
  1479. --装备能否精炼顺便计算差多少钱
  1480. function EquipModel:CanStrength( cost_list )
  1481. if not cost_list then return end
  1482. local can_strength = true
  1483. local price = 0
  1484. local offer_cost = {}--返回差多少材料
  1485. for k,v in pairs(cost_list) do
  1486. if v[1] < v[3] then
  1487. can_strength = false
  1488. local goods_price, sell_price, price_type = self.goods_model:GetGoodsPrice(v[2])
  1489. price = (v[3] - v[1])*goods_price + price
  1490. offer_cost[v[2]] = v[3] - v[1]
  1491. end
  1492. end
  1493. return can_strength,price,offer_cost,price_type
  1494. end
  1495. --获得当前套件装备是否可以升星
  1496. function EquipModel:GetEquipCanEvolution( )
  1497. --升星红点列表
  1498. local can_evolution_info = {}
  1499. local wear_equip_suit_list = self.goods_model.wear_equip_suit_list
  1500. local cur_suit = EquipModel.getInstance():GetCurrentOpenSuitSeries()
  1501. if wear_equip_suit_list then
  1502. --能否升星列表
  1503. for k,v in pairs(wear_equip_suit_list) do
  1504. for kk,vv in pairs(v) do
  1505. --首饰类加上守护不做升星
  1506. if vv.equip_suit_type <= EquipModel.EquipType.Shoes and vv.goods_num > 0 then
  1507. local evolution_level = 0--当前装备升星等级
  1508. for kkk,vvv in pairs(vv.other_data or {}) do
  1509. if vvv.type == GoodsModel.GoodsInfoType.EquipEvoLevel then
  1510. evolution_level = tonumber(vvv.info) or 0
  1511. break
  1512. end
  1513. end
  1514. evolution_level = evolution_level >= 1 and evolution_level or 1
  1515. local base_cfg = self:GetEquipEvolutionCfg(vv.type_id,evolution_level + 1)
  1516. if base_cfg and vv.color >= 3 then
  1517. local cost_list = {}
  1518. for kkk,vvv in ipairs(base_cfg.cost) do
  1519. local num = self.goods_model:GetTypeGoodsNum(vvv[2]) or 0
  1520. cost_list[kkk] = {num,vvv[2],vvv[3]}
  1521. end
  1522. local cost_enoght,price,offer_cost,price_type = self:CanStrength(cost_list,true)
  1523. local is_enoght = cost_enoght
  1524. local is_faker = false
  1525. if not is_enoght then
  1526. local cost_price_list = {}
  1527. for i,v in ipairs(cost_list) do
  1528. local goods_price, sell_price, price_type = self.goods_model:GetGoodsPrice(v[2])
  1529. cost_price_list[price_type] = cost_price_list[price_type] or 0
  1530. if v[3] - v[1] > 0 then
  1531. cost_price_list[price_type] = goods_price*(v[3] - v[1])
  1532. end
  1533. end
  1534. is_enoght = true
  1535. is_faker = true
  1536. for price_type,v in pairs(cost_price_list) do
  1537. if price_type == 3 and RoleManager.Instance.mainRoleInfo.tong<v then--材料钱满足也行
  1538. is_enoght = false
  1539. is_faker = false
  1540. elseif price_type == 1 and RoleManager.Instance.mainRoleInfo.jin<v then--材料钱满足也行
  1541. is_enoght = false
  1542. is_faker = false
  1543. end
  1544. end
  1545. end
  1546. if not can_evolution_info[k] then
  1547. can_evolution_info[k] = {}
  1548. end
  1549. can_evolution_info[k][vv.equip_suit_type] = {radio = base_cfg.ratio/100 or 0,cost_enoght = is_enoght, goods_vo = vv, is_faker = is_faker}
  1550. end
  1551. end
  1552. end
  1553. end
  1554. end
  1555. local bag_goods_list = self.goods_model.bag_goods_list
  1556. --背包中所有装备套件的概率加成列表
  1557. local bag_evoluton_radio_list = {}
  1558. for k,v in pairs(bag_goods_list) do
  1559. if v.type == GoodsModel.TYPE.EQUIP and v.goods_num > 0 and self:SelfCareerIsOk(v.type_id) then
  1560. local equip_cfg = self:GetEquipmentCfg(v.type_id)
  1561. if self:SelfCareerIsOk(v.type_id)--职业相同
  1562. and equip_cfg.series <= cur_suit--代数解锁
  1563. and not self:EquipCanShowGoodsTip(v)--可操作
  1564. then
  1565. local equip_radio_cfg = self:GetEquipEvolutionRatioCfg(v.type_id)
  1566. if equip_radio_cfg then
  1567. for kk,vv in pairs(equip_radio_cfg) do
  1568. for kkk,vvv in pairs(vv) do
  1569. if not bag_evoluton_radio_list[kk] then
  1570. bag_evoluton_radio_list[kk] = {}
  1571. end
  1572. if not bag_evoluton_radio_list[kk][vvv.target_lv] then
  1573. bag_evoluton_radio_list[kk][vvv.target_lv] = 0
  1574. end
  1575. bag_evoluton_radio_list[kk][vvv.target_lv] = vvv.ratio + bag_evoluton_radio_list[kk][vvv.target_lv]
  1576. end
  1577. end
  1578. end
  1579. end
  1580. end
  1581. end
  1582. -- print("huangcong:EquipModel [start:413] :", bag_evoluton_radio_list)
  1583. -- PrintTable(bag_evoluton_radio_list)
  1584. -- print("huangcong:EquipModel [end]")
  1585. self.can_evolution_info = can_evolution_info
  1586. self.bag_evoluton_radio_list = bag_evoluton_radio_list
  1587. end
  1588. --获得背包装备列表并按照套件排列
  1589. --type_id是否需要当前的装备能升星的列表
  1590. function EquipModel:GetBagEquipList( type_id,goods_vo )
  1591. local bag_goods_list = self.goods_model.bag_goods_list
  1592. local career = RoleManager.Instance.mainRoleInfo.career
  1593. local equip_list = {}
  1594. --升星的装备背包表
  1595. local evolution_equip_list = {}
  1596. local cur_suit = self:GetCurrentOpenSuitSeries()
  1597. for k,v in pairs(bag_goods_list) do
  1598. if v.type == GoodsModel.TYPE.EQUIP and v.goods_num > 0 then
  1599. local equip_cfg = self:GetEquipmentCfg(v.type_id)
  1600. --职业不符合
  1601. local have_career = false
  1602. for i,v in ipairs(equip_cfg.career) do
  1603. if v == career then
  1604. have_career = true
  1605. break
  1606. end
  1607. end
  1608. if equip_cfg and equip_cfg.equip_type <= EquipModel.EquipType.Shoes
  1609. and have_career
  1610. and equip_cfg.series <= cur_suit
  1611. and not self:EquipCanShowGoodsTip(v) then
  1612. local series = equip_cfg.series
  1613. if not equip_list[equip_cfg.series] then
  1614. equip_list[equip_cfg.series] = {}
  1615. end
  1616. equip_list[equip_cfg.series][#equip_list[equip_cfg.series] + 1] = v
  1617. end
  1618. end
  1619. end
  1620. -- print("huangcong:EquipModel [start:680] :", equip_list)
  1621. -- PrintTable(equip_list)
  1622. -- print("huangcong:EquipModel [end]")
  1623. if type_id and goods_vo then
  1624. local need_evolution_equip_cfg = self:GetEquipmentCfg(type_id)
  1625. if need_evolution_equip_cfg then
  1626. local series = need_evolution_equip_cfg.series
  1627. local target_lv = self:GetEquipEvolutionLevel(goods_vo) + 1--当前装备升星等级
  1628. for k,v in pairs(equip_list) do
  1629. for kk,vv in pairs(v) do
  1630. local equip_cfg = self:GetEquipmentCfg(vv.type_id)
  1631. local equip_radio_cfg = self:GetEquipEvolutionRatioCfg(vv.type_id,series,target_lv)
  1632. if equip_radio_cfg then
  1633. if not evolution_equip_list[k] then
  1634. evolution_equip_list[k] = {}
  1635. end
  1636. vv.evolution_ratio = equip_radio_cfg.ratio/100
  1637. evolution_equip_list[k][#evolution_equip_list[k] + 1] = vv
  1638. end
  1639. end
  1640. end
  1641. end
  1642. end
  1643. -- print("huangcong:EquipModel [start:471] :", type_id)
  1644. -- PrintTable(equip_list)
  1645. -- print("huangcong:EquipModel [end]")
  1646. -- print("huangcong:EquipModel [start:561] :", type_id)
  1647. -- PrintTable(evolution_equip_list)
  1648. -- print("huangcong:EquipModel [end]")
  1649. return equip_list,evolution_equip_list
  1650. end
  1651. --判断装备是否具备精炼的的品质
  1652. function EquipModel:EquipIsStrength( goods_vo )
  1653. if goods_vo and goods_vo.equip_suit_type and goods_vo.equip_suit_type ~= EquipModel.EquipType.Guard then--守护不做精炼
  1654. return true
  1655. end
  1656. return false
  1657. end
  1658. --判断装备是否具备升星的品质
  1659. function EquipModel:EquipIsEvolution( goods_vo )
  1660. if goods_vo and goods_vo.equip_suit_type and goods_vo.equip_suit_type and (goods_vo.equip_suit_type <= EquipModel.EquipType.Shoes) then--首饰类不做升星
  1661. local evolution_level = self:GetEquipEvolutionLevel(goods_vo) + 1--当前装备升星等级
  1662. local base_cfg = self:GetEquipEvolutionCfg(goods_vo.type_id,evolution_level)
  1663. if base_cfg then
  1664. return true
  1665. end
  1666. end
  1667. return false
  1668. end
  1669. --判断装备是否具备升品的品质
  1670. function EquipModel:EquipIsUpQuality( goods_vo )
  1671. if goods_vo and goods_vo.equip_suit_type and goods_vo.equip_suit_type >= EquipModel.EquipType.Necklace then--首饰类才能升品
  1672. local compose_cfg = ComposeModel:getInstance():GetEvolutionComposeCfg(goods_vo.type_id)
  1673. local limit_level = compose_cfg and compose_cfg.open_lv or 0
  1674. if compose_cfg and RoleManager.Instance.mainRoleInfo.level >= limit_level then
  1675. return true
  1676. end
  1677. end
  1678. return false
  1679. end
  1680. --得到装备升星的升星等级
  1681. function EquipModel:GetEquipEvolutionLevel( goods_vo )
  1682. if goods_vo and goods_vo.equip_suit_type and goods_vo.equip_suit_type <= EquipModel.EquipType.Shoes and goods_vo.color>=3 then--首饰类不做升星
  1683. local evolution_level = 0--当前装备升星等级
  1684. for kkk,vvv in pairs(goods_vo.other_data or {}) do
  1685. if vvv.type == GoodsModel.GoodsInfoType.EquipEvoLevel then
  1686. evolution_level = tonumber(vvv.info)
  1687. end
  1688. end
  1689. evolution_level = evolution_level >= 1 and evolution_level or 1
  1690. return evolution_level
  1691. end
  1692. return 0
  1693. end
  1694. --判断装备是否能否升星
  1695. function EquipModel:EquipIsCanEvolution( series,pos,goods_vo,no_cost_enoght )
  1696. local level_is_ok = self:CheckLevel(EquipModel.MainTab.Evolution)
  1697. if series and pos and pos <= EquipModel.EquipType.Shoes and level_is_ok then--首饰类不做升星
  1698. if self.can_evolution_info and self.can_evolution_info[series] and self.can_evolution_info[series][pos] and (self.can_evolution_info[series][pos].cost_enoght or no_cost_enoght) then
  1699. local evolution_level = self:GetEquipEvolutionLevel(goods_vo) + 1--当前装备升星等级
  1700. local radio = self.can_evolution_info[series][pos].radio
  1701. if self.bag_evoluton_radio_list[series] and self.bag_evoluton_radio_list[series][evolution_level] then
  1702. radio = radio + self.bag_evoluton_radio_list[series][evolution_level]/100
  1703. end
  1704. local anim_percent = 95
  1705. local life_skill_active = PetModel:getInstance():IsLifeSkillActived(PetConst.LifeSkill.EquipEvolutionSuccessRateUp)
  1706. local life_skill_ratio = PetModel:getInstance():GetPetLifeSkillRatio(PetConst.LifeSkill.EquipEvolutionSuccessRateUp)
  1707. local vip_card_ratio = VipModel.getInstance():VipCardEquipEvolutionRatio(true)
  1708. local add_life_skill_ratio = 0
  1709. if life_skill_active then
  1710. add_life_skill_ratio = life_skill_ratio
  1711. end
  1712. anim_percent = anim_percent - add_life_skill_ratio - vip_card_ratio---目标升星概率需要减去宠物和月卡加成的
  1713. local cost_enought = false
  1714. if self.can_evolution_info[series] and self.can_evolution_info[series][pos] then
  1715. cost_enought = self.can_evolution_info[series][pos].cost_enoght and (not self.can_evolution_info[series][pos].is_faker or self.can_evolution_info[series][pos].is_faker and not self.no_show_faker_evo)
  1716. end
  1717. return radio >= anim_percent and cost_enought
  1718. end
  1719. end
  1720. return false
  1721. end
  1722. --获得套件装备精炼数据【用于精炼套装界面EquipStrengthenSuitView】
  1723. function EquipModel:GetEquipStrengthInfo( suit_id )
  1724. local strength_info = {}
  1725. local wear_equip_suit_list = self.goods_model.wear_equip_suit_list
  1726. if wear_equip_suit_list and wear_equip_suit_list[suit_id] then
  1727. for k,v in pairs(wear_equip_suit_list[suit_id]) do
  1728. if v.equip_suit_type ~= EquipModel.EquipType.Guard and not strength_info[v.equip_suit_type] then
  1729. local strengthen_level = 0--当前装备等级
  1730. for kkk,vvv in pairs(v.other_data or {}) do
  1731. if vvv.type == GoodsModel.GoodsInfoType.EquipmentLv then
  1732. strengthen_level = tonumber(vvv.info)
  1733. break
  1734. end
  1735. end
  1736. strength_info[v.equip_suit_type] = strengthen_level
  1737. end
  1738. end
  1739. end
  1740. -- print("huangcong:EquipModel [start:413] :", can_strength_info)
  1741. -- PrintTable(can_strength_info)
  1742. -- print("huangcong:EquipModel [end]")
  1743. return strength_info
  1744. end
  1745. --得到装备套装的配置
  1746. function EquipModel:GetStrengthTotalCfg( series )
  1747. local streng_total_cfg_list = {}
  1748. streng_total_cfg_list[series] = {}
  1749. for k,v in pairs(Config.Equipmentstrengthtotal) do
  1750. if v.series == series then
  1751. local data = DeepCopy(v)
  1752. data.attr = stringtotable(data.attr)
  1753. streng_total_cfg_list[series][data.lv] = data
  1754. end
  1755. end
  1756. return streng_total_cfg_list[series]
  1757. end
  1758. --得到星级套装的配置
  1759. --all是获得所有
  1760. function EquipModel:GetStarTotalCfg( star_lv,all )
  1761. if not all then
  1762. local cfg = Config.Equipmentstartotal[star_lv]
  1763. if cfg then
  1764. cfg = DeepCopy(cfg)
  1765. cfg.stage_attr = stringtotable(cfg.stage_attr)
  1766. cfg.attr = stringtotable(cfg.attr)
  1767. cfg.stage_skill = stringtotable(cfg.stage_skill)
  1768. cfg.skill = stringtotable(cfg.skill)
  1769. end
  1770. return cfg
  1771. elseif all then
  1772. local equipment_startotal_cfg_list = {}
  1773. local equipment_startotal_cfg = DeepCopy(Config.Equipmentstartotal)
  1774. for k,v in pairs(equipment_startotal_cfg) do
  1775. v.stage_attr = stringtotable(v.stage_attr)
  1776. v.attr = stringtotable(v.attr)
  1777. v.stage_skill = stringtotable(v.stage_skill)
  1778. v.skill = stringtotable(v.skill)
  1779. equipment_startotal_cfg_list[v.stars] = v
  1780. end
  1781. return equipment_startotal_cfg_list
  1782. end
  1783. print("没有该星级的套装:", star_lv)
  1784. end
  1785. --得到星星还有红点可以激活吗
  1786. function EquipModel:GetCurHaveStarRedDot( )
  1787. if self.equip_activie_stars and self.equip_sum_stars then
  1788. if self.equip_sum_stars > self.equip_activie_stars then
  1789. for k,v in pairsByKeys(Config.Equipmentstartotal) do
  1790. if v.stars > self.equip_activie_stars and v.stars <= self.equip_sum_stars then--配置星级大于激活星级并且小于装备总星级
  1791. return true
  1792. end
  1793. end
  1794. end
  1795. end
  1796. return false
  1797. end
  1798. --设置装备激活星级数量
  1799. function EquipModel:SetEquipActiveStarNum( star )
  1800. self.equip_activie_stars = star
  1801. end
  1802. --得到升品合成配置
  1803. function EquipModel:GetUpQualityComposeList( cost_list )
  1804. local compose_list = {}
  1805. local compose_req_list = {}
  1806. if cost_list and TableSize(cost_list) > 0 then
  1807. local bag_goods_list = self.goods_model.bag_goods_list
  1808. for k,v in pairs(bag_goods_list) do
  1809. for kk,vv in pairs(cost_list) do
  1810. local cur_goods_num = 0
  1811. for kkk,vvv in pairs(compose_list) do--如果消耗物品不足要继续拿下一个堆叠的物品
  1812. if vvv[2] == v.type_id then
  1813. cur_goods_num = vvv[3] + cur_goods_num
  1814. end
  1815. end
  1816. if vv[2] == v.type_id and cur_goods_num < vv[3] then
  1817. if v.goods_num + cur_goods_num >= vv[3] then
  1818. compose_list[#compose_list + 1] = {v.goods_id,v.type_id,vv[3] - cur_goods_num}
  1819. else
  1820. compose_list[#compose_list + 1] = {v.goods_id,v.type_id,v.goods_num}
  1821. end
  1822. end
  1823. end
  1824. end
  1825. end
  1826. -- print("huangcong:EquipModel [start:929] :",compose_list)
  1827. -- PrintTable(compose_list)
  1828. -- print("huangcong:EquipModel [end]")
  1829. return compose_list
  1830. end
  1831. --获得装备数量 包括身上穿的
  1832. function EquipModel:EquipGoodsNumById( type_id )
  1833. local goods_num,_,goods_vo_list = self.goods_model:GetTypeGoodsNum(type_id) or 0
  1834. local goods_vo = nil
  1835. goods_vo_list = goods_vo_list or {}
  1836. local equip_cfg = self:GetEquipmentCfg(type_id)
  1837. if equip_cfg then
  1838. local wear_equip_suit_list = self.goods_model.wear_equip_suit_list
  1839. if equip_cfg.series ~= 99 then
  1840. local series = equip_cfg.series
  1841. local pos = equip_cfg.equip_type
  1842. if wear_equip_suit_list[series] and wear_equip_suit_list[series][pos] then
  1843. if wear_equip_suit_list[series][pos].type_id == type_id then
  1844. goods_vo = wear_equip_suit_list[series][pos]
  1845. goods_vo_list[#goods_vo_list + 1] = goods_vo
  1846. end
  1847. end
  1848. else
  1849. for k,v in pairs(wear_equip_suit_list) do
  1850. if not goods_vo then
  1851. for kk,vv in pairs(v) do
  1852. if vv.type_id == type_id then
  1853. goods_vo = vv
  1854. goods_vo_list[#goods_vo_list + 1] = goods_vo
  1855. break
  1856. end
  1857. end
  1858. else
  1859. break
  1860. end
  1861. end
  1862. end
  1863. end
  1864. if goods_vo and goods_vo.goods_num > 0 then
  1865. goods_num = goods_num + 1
  1866. end
  1867. return goods_num,goods_vo_list
  1868. end
  1869. --穿戴装备要判断继承
  1870. function EquipModel:WearEquip( goods_vo,is_quick )
  1871. if not goods_vo or not goods_vo.color then return end
  1872. local equip_cfg = self:GetEquipmentCfg(goods_vo.type_id)
  1873. if not equip_cfg or not equip_cfg.color then return end
  1874. local len,list = NewMainRoleModel:getInstance():GetRoleReinMaxTurn()
  1875. if Config.Equipmentseriesopen[equip_cfg.series] then
  1876. local series_limit_cfg = Config.Equipmentseriesopen[equip_cfg.series]
  1877. if not series_limit_cfg then
  1878. print("huangcong:EquipModel [start:1324] 没有套件限制配置:", equip_cfg.type_id,equip_cfg.series)
  1879. return
  1880. end
  1881. if series_limit_cfg.open_lv > RoleManager.Instance.mainRoleInfo.level then
  1882. Message.show(series_limit_cfg.open_lv.."级开放第"..ChineseNumber(equip_cfg.series).."代装备","fault")
  1883. return
  1884. end
  1885. end
  1886. --当前同等位置穿戴的装备数据
  1887. local cur_wear_data = nil
  1888. local can_inherit = false
  1889. if self.goods_model.wear_equip_suit_list[equip_cfg.series]
  1890. and self.goods_model.wear_equip_suit_list[equip_cfg.series][equip_cfg.equip_type]
  1891. then
  1892. cur_wear_data = self.goods_model.wear_equip_suit_list[equip_cfg.series][equip_cfg.equip_type]
  1893. if not cur_wear_data or not cur_wear_data.color then return end
  1894. local cur_goods_strength_level = 0
  1895. for k,v in pairs(goods_vo.other_data) do
  1896. if v.type == GoodsModel.GoodsInfoType.EquipmentLv then
  1897. cur_goods_strength_level = tonumber(v.info)
  1898. break
  1899. end
  1900. end
  1901. --品质大于当前的装备
  1902. if equip_cfg.color > 3 and goods_vo.color > cur_wear_data.color then
  1903. for k,v in pairs(cur_wear_data.other_data) do
  1904. if cur_goods_strength_level == 0 then
  1905. if equip_cfg.equip_type < EquipModel.EquipType.Necklace then
  1906. local evolution_level = equip_cfg.color >= 3 and 1 or 0
  1907. if v.type == GoodsModel.GoodsInfoType.EquipEvoLevel then
  1908. evolution_level = tonumber(v.info) or 0
  1909. --当前装备高级属性必须大于1
  1910. if evolution_level > 1 then
  1911. can_inherit = true
  1912. break
  1913. end
  1914. elseif v.type == GoodsModel.GoodsInfoType.EquipmentLv then
  1915. local strengthen_level = tonumber(v.info)
  1916. if strengthen_level > 0 then
  1917. can_inherit = true
  1918. break
  1919. end
  1920. end
  1921. --首饰只能继承精炼等级
  1922. elseif equip_cfg.equip_type >= EquipModel.EquipType.Necklace and equip_cfg.equip_type <= EquipModel.EquipType.RightRing then
  1923. if v.type == GoodsModel.GoodsInfoType.EquipmentLv then
  1924. local strengthen_level = tonumber(v.info)
  1925. if strengthen_level > 0 then
  1926. can_inherit = true
  1927. break
  1928. end
  1929. end
  1930. end
  1931. end
  1932. end
  1933. end
  1934. end
  1935. local function cancel( ... )
  1936. -- self:Fire(EquipModel.REQUEST_CCMD_EVENT,15205,self.choose_equip_list[1].goods_id
  1937. -- ,self.choose_equip_list[1].pos,self.equip_data.goods_vo.goods_id,self.equip_data.goods_vo.pos)
  1938. end
  1939. local function ok( ... )
  1940. -- if equip_cfg.equip_type == EquipModel.EquipType.Guard then--如果是守护
  1941. -- if self.cur_choose_suit == 99 or not self.cur_choose_suit or is_quick then--如果是守护要特殊处理帮玩家选择守护
  1942. -- local len,list,really_turn = NewMainRoleModel:getInstance():GetRoleReinMaxTurn()
  1943. -- for i=1,really_turn do
  1944. -- if not self.goods_model.wear_equip_suit_list[i]
  1945. -- or not self.goods_model.wear_equip_suit_list[i][EquipModel.EquipType.Guard] then
  1946. -- self:Fire(EquipModel.REQUEST_CCMD_EVENT,15201,i,equip_cfg.equip_type,goods_vo.goods_id)
  1947. -- break
  1948. -- end
  1949. -- end
  1950. -- else
  1951. -- self:Fire(EquipModel.REQUEST_CCMD_EVENT,15201,self.cur_choose_suit, equip_cfg.equip_type, goods_vo.goods_id)
  1952. -- end
  1953. -- else
  1954. self:Fire(EquipModel.REQUEST_CCMD_EVENT,15201,equip_cfg.series,equip_cfg.equip_type,goods_vo.goods_id)
  1955. -- end
  1956. end
  1957. if not cur_wear_data or not can_inherit then
  1958. ok()
  1959. else
  1960. local equip_list_vo = {}
  1961. equip_list_vo[1] = cur_wear_data
  1962. equip_list_vo[2] = goods_vo
  1963. equip_list_vo[3] = ok
  1964. self:Fire(EquipModel.OPEN_EQUIP_INHERIT_WEAR_TIP_VIEW,equip_list_vo)
  1965. -- Alert.show("穿戴当前装备后,将<color=#fa1022>消耗原装备</color>并<color=#fa1022>自动继承</color>原先装备的<color=#fa1022>精炼等级</color>和<color=#fa1022>升星等级</color>,确认穿戴?",Alert.Type.Two,cancel,nil,"继承","取消")
  1966. end
  1967. end
  1968. -- [1,3]男性可用
  1969. -- [2,4]女性可用
  1970. -- [1,2]异剑士可用
  1971. -- [3,4]战灵师可用
  1972. -- [1,2,3,4]全职业可用
  1973. function EquipModel:GetCareerDesc( career_data )
  1974. local data = {}
  1975. for i,v in ipairs(career_data) do
  1976. data[v] = true
  1977. end
  1978. if TableSize(data) == 4 then
  1979. return "全职业可用"
  1980. elseif data[1] and data[3] then
  1981. return "鬼猎/暗鸦"
  1982. elseif data[2] and data[4] then
  1983. return "夙星/梦枭"
  1984. elseif data[1] and data[2] then
  1985. return "鬼猎/夙星"
  1986. elseif data[3] and data[4] then
  1987. return "暗鸦/梦枭"
  1988. end
  1989. end
  1990. --职业是否OK
  1991. function EquipModel:SelfCareerIsOk( type_id )
  1992. local career = RoleManager.Instance.mainRoleInfo.career
  1993. local equip_cfg = self:GetEquipmentCfg(type_id)
  1994. --职业不符合
  1995. local have_career = false
  1996. if equip_cfg then
  1997. for i,v in ipairs(equip_cfg.career) do
  1998. if v == career then
  1999. have_career = true
  2000. break
  2001. end
  2002. end
  2003. end
  2004. return have_career
  2005. end
  2006. --装备能否弹提示(对比传的是真实的物品信息)
  2007. function EquipModel:EquipCanShowGoodsTip( goods_vo )
  2008. local equip_cfg = self:GetEquipmentCfg(goods_vo.type_id)
  2009. if not equip_cfg then return false end
  2010. local wear_equip_suit_list = self.goods_model.wear_equip_suit_list
  2011. local len,list,really_turn = NewMainRoleModel:getInstance():GetRoleReinMaxTurn()
  2012. local level = RoleManager.Instance.mainRoleInfo.level
  2013. local career = RoleManager.Instance.mainRoleInfo.career
  2014. local series = equip_cfg.series
  2015. local pos = equip_cfg.equip_type
  2016. if goods_vo and goods_vo.goods_num <= 0 then
  2017. return false
  2018. end
  2019. --职业不符合
  2020. local have_career = false
  2021. for i,v in ipairs(equip_cfg.career) do
  2022. if v == career then
  2023. have_career = true
  2024. break
  2025. end
  2026. end
  2027. if not have_career then
  2028. return false,0
  2029. end
  2030. --转生不够无法装备
  2031. if series > EquipModel.getInstance():GetCurrentOpenSuitSeries() then
  2032. return false
  2033. end
  2034. --等级不足
  2035. if level < equip_cfg.lv then
  2036. return false
  2037. end
  2038. --守护要特殊处理没有装满守护就要弹出
  2039. if equip_cfg.equip_type == EquipModel.EquipType.Guard then
  2040. local cur_wear_num = 0
  2041. local score_list = {}
  2042. for k,v in pairs(wear_equip_suit_list) do
  2043. for kk,vv in pairs(v) do
  2044. if vv.equip_suit_type == EquipModel.EquipType.Guard then
  2045. cur_wear_num = cur_wear_num + 1
  2046. score_list[k] = self:MathEquipScore(vv,vv.type_id)
  2047. end
  2048. end
  2049. end
  2050. if cur_wear_num < really_turn then
  2051. return true,1
  2052. end
  2053. --如果都装满了 就要比拼评分了
  2054. -- local score = self:MathEquipScore(goods_vo,goods_vo.type_id)
  2055. -- for k,v in pairs(score_list) do
  2056. -- if score > v then
  2057. -- return true,1
  2058. -- end
  2059. -- end
  2060. return false--守护就不走下面的逻辑了
  2061. end
  2062. -- --同位置就比评分
  2063. -- local pos = equip_cfg.equip_type
  2064. -- if wear_equip_suit_list[series] and wear_equip_suit_list[series][pos] then--同位置比评分
  2065. -- local cur_wear_goods_vo = wear_equip_suit_list[series][pos]
  2066. -- local score = self:MathEquipScore(goods_vo,goods_vo.type_id)
  2067. -- local cur_wear_score = self:MathEquipScore(cur_wear_goods_vo,cur_wear_goods_vo.type_id)
  2068. -- if score > cur_wear_score then
  2069. -- return true,1
  2070. -- -- elseif score == cur_wear_score then
  2071. -- -- return false
  2072. -- end
  2073. -- else--否则就装备
  2074. -- return true,1
  2075. -- end
  2076. --同位置比品质
  2077. local pos = equip_cfg.equip_type
  2078. if wear_equip_suit_list[series] and wear_equip_suit_list[series][pos] then--同位置比评分
  2079. local cur_wear_goods_vo = wear_equip_suit_list[series][pos]
  2080. local goods_color = goods_vo.color
  2081. local cur_wear_goods_color = cur_wear_goods_vo.color
  2082. if goods_color > cur_wear_goods_color then
  2083. return true,1
  2084. end
  2085. else--否则就装备
  2086. return true,1
  2087. end
  2088. return false,2
  2089. end
  2090. --能否展示tips的按钮
  2091. function EquipModel:CanShowTipsBtn( )
  2092. if (BagController.Instance.BagView and BagController.Instance.BagView:HasOpen())
  2093. or (MarketController.Instance.market_view and MarketController.Instance.market_view:HasOpen())
  2094. or CapsuleEggModel:getInstance():IsShowCapsuleEggTakeOutBtn() then
  2095. return true
  2096. end
  2097. return false
  2098. end
  2099. --检查当前套件所有装备继承红点(因为逻辑很多 所以只在界面里面调用)
  2100. function EquipModel:CheckInheritSeriesDot( series )
  2101. local bag_goods_list = self.goods_model.bag_goods_list
  2102. -- print("huangcong:EquipModel [start:1519] :", bag_goods_list)
  2103. -- PrintTable(bag_goods_list)
  2104. -- print("huangcong:EquipModel [end]")
  2105. local series_list = {}
  2106. for k,v in pairs(bag_goods_list) do
  2107. local goods_vo = v
  2108. if goods_vo and goods_vo.type == GoodsModel.TYPE.EQUIP and goods_vo.goods_num > 0 then
  2109. local equip_cfg = self:GetEquipmentCfg(goods_vo.type_id)
  2110. if equip_cfg and equip_cfg.series ~= 99 and equip_cfg.series == series and not series_list[equip_cfg.equip_type] then
  2111. --当前同等位置穿戴的装备数据
  2112. local cur_wear_data = nil
  2113. local can_inherit = false
  2114. if self.goods_model.wear_equip_suit_list[equip_cfg.series]
  2115. and self.goods_model.wear_equip_suit_list[equip_cfg.series][equip_cfg.equip_type]
  2116. then
  2117. cur_wear_data = self.goods_model.wear_equip_suit_list[equip_cfg.series][equip_cfg.equip_type]
  2118. local cur_wear_strength_level = 0--当前装备精炼等级
  2119. local cur_wear_evoblution_level = 0--当前升星等级
  2120. for k,v in pairs(cur_wear_data.other_data) do
  2121. if v.type == GoodsModel.GoodsInfoType.EquipmentLv then
  2122. cur_wear_strength_level = tonumber(v.info)
  2123. elseif v.type == GoodsModel.GoodsInfoType.EquipEvoLevel then
  2124. cur_wear_evoblution_level = tonumber(v.info) or 0
  2125. end
  2126. end
  2127. --品质小于当前的装备并且是紫色装备或以上
  2128. --当前穿戴的装备升星和精炼都是0才给红点
  2129. local goods_strength_level = 0
  2130. local goods_evolution_level = 0
  2131. if goods_vo.color > 2 and goods_vo.color < cur_wear_data.color
  2132. and cur_wear_evoblution_level < 3 and cur_wear_strength_level == 0 then
  2133. for k,v in pairs(goods_vo.other_data) do
  2134. if v.type == GoodsModel.GoodsInfoType.EquipmentLv then
  2135. goods_strength_level = tonumber(v.info)
  2136. elseif v.type == GoodsModel.GoodsInfoType.EquipEvoLevel then
  2137. goods_evolution_level = tonumber(v.info) or 0
  2138. end
  2139. end
  2140. --非首饰可以继承升星
  2141. if equip_cfg.equip_type < EquipModel.EquipType.Necklace then
  2142. --当前装备高级属性必须大于1
  2143. if goods_evolution_level > 1 then
  2144. series_list[equip_cfg.equip_type] = true
  2145. end
  2146. --当前装备精炼等级必须大于1
  2147. if goods_strength_level > 0 then
  2148. series_list[equip_cfg.equip_type] = true
  2149. end
  2150. --首饰只能继承精炼等级
  2151. elseif equip_cfg.equip_type >= EquipModel.EquipType.Necklace and equip_cfg.equip_type <= EquipModel.EquipType.RightRing then
  2152. if goods_strength_level > 0 then
  2153. series_list[equip_cfg.equip_type] = true
  2154. end
  2155. end
  2156. end
  2157. end
  2158. end
  2159. end
  2160. end
  2161. -- print("huangcong:EquipModel [start:1556] :", series)
  2162. -- PrintTable(series_list)
  2163. -- print("huangcong:EquipModel [end]")
  2164. return series_list
  2165. end
  2166. --检查守护升品的红点
  2167. function EquipModel:CheckGuardRedDot( )
  2168. --首饰类是否能升品
  2169. if not self.can_up_quality_info then
  2170. self.can_up_quality_info = {}
  2171. end
  2172. local wear_equip_suit_list = self.goods_model.wear_equip_suit_list
  2173. local equip_star_sum = 0
  2174. if wear_equip_suit_list then
  2175. --能否精炼列表
  2176. for k,v in pairs(wear_equip_suit_list) do
  2177. for kk,vv in pairs(v) do
  2178. --判断首饰类才能升品
  2179. if vv.equip_suit_type == EquipModel.EquipType.Guard then
  2180. local compose_cfg = ComposeModel:getInstance():GetEvolutionComposeCfg(vv.type_id)
  2181. local limit_level = compose_cfg and compose_cfg.open_lv or 0
  2182. local cost_list = RoleManager.Instance.mainRoleInfo.level >= limit_level and compose_cfg and compose_cfg.cost_goods or {}
  2183. if cost_list and #cost_list > 0 then
  2184. local can_up_quality = true
  2185. for kkk,vvv in ipairs(cost_list) do
  2186. local goods_num = self.goods_model:GetTypeGoodsNum(vvv[2]) or 0
  2187. if goods_num < vvv[3] then
  2188. can_up_quality = false
  2189. end
  2190. end
  2191. if not self.can_up_quality_info[k] then
  2192. self.can_up_quality_info[k] = {}
  2193. end
  2194. self.can_up_quality_info[k][vv.equip_suit_type] = {can_up = can_up_quality,type_id = vv.type_id}
  2195. end
  2196. end
  2197. end
  2198. end
  2199. end
  2200. local have_red = false
  2201. for k,v in pairs(self.can_up_quality_info) do
  2202. for kk,vv in pairs(v) do
  2203. if kk == EquipModel.EquipType.Guard and vv and vv.can_up then
  2204. have_red = vv.can_up
  2205. break
  2206. end
  2207. end
  2208. end
  2209. if not have_red and self.necklace_up_info then
  2210. for k,v in pairs(self.necklace_up_info) do
  2211. local equip_cfg = self:GetEquipmentCfg(k)
  2212. if equip_cfg and equip_cfg.equip_type == EquipModel.EquipType.Guard then
  2213. if v then
  2214. return true
  2215. end
  2216. end
  2217. end
  2218. end
  2219. return have_red
  2220. end
  2221. --检查饰品升品的红点
  2222. function EquipModel:CheckOrnamentRedDot( )
  2223. local have_red = false
  2224. for k,v in pairs(self.can_up_quality_info) do
  2225. for kk,vv in pairs(v) do
  2226. if kk ~= EquipModel.EquipType.Guard and vv.can_up then
  2227. have_red = vv.can_up
  2228. break
  2229. end
  2230. end
  2231. end
  2232. if not have_red then
  2233. for k,v in pairs(self.necklace_up_info) do
  2234. local equip_cfg = self:GetEquipmentCfg(k)
  2235. if equip_cfg and equip_cfg.equip_type ~= EquipModel.EquipType.Guard then
  2236. if v then
  2237. return true
  2238. end
  2239. end
  2240. end
  2241. end
  2242. -- print("huangcong:EquipModel [start:2249] :", self.necklace_up_info)
  2243. -- PrintTable(self.necklace_up_info)
  2244. -- print("huangcong:EquipModel [end]")
  2245. return have_red
  2246. end
  2247. --获得刻印配置
  2248. function EquipModel:GetDraconicCfg( equip_type,type_id )
  2249. if TableSize(self.equipment_draconic_cfg) == 0 then--装备刻印属性(暂不知道什么时候需要)这里初始化一次即可
  2250. local equipment_draconic_cfg = DeepCopy(Config.Equipmentcarve)
  2251. for k,v in pairs(equipment_draconic_cfg) do
  2252. v.attr = stringtotable(v.attr)
  2253. if not self.equipment_draconic_cfg[v.equip_type] then
  2254. self.equipment_draconic_cfg[v.equip_type] = {}
  2255. end
  2256. self.equipment_draconic_cfg[v.equip_type][v.goods_id] = v
  2257. end
  2258. end
  2259. if equip_type and not type_id then
  2260. return self.equipment_draconic_cfg[equip_type]
  2261. elseif equip_type and type_id then
  2262. return self.equipment_draconic_cfg[equip_type][type_id]
  2263. end
  2264. end
  2265. --获得宝石配置通过type_id
  2266. function EquipModel:GetGemsCfgByTypeId( type_id )
  2267. return self.equipment_gems_cfg[type_id]
  2268. end
  2269. --获得宝石配置通过series,gems_type
  2270. function EquipModel:GetGemsCfgByGemsType( gems_type )
  2271. return self.equipment_gems_series_cfg[gems_type]
  2272. end
  2273. --获得宝石套件配置
  2274. function EquipModel:GetGemsSuitCfg( series,lv )
  2275. if TableSize(self.equipment_gems_suit_cfg) == 0 then--这样写收益最大因为开始就要判断红点而且判断的次数会比较频繁
  2276. local equipment_gems_suit_cfg = DeepCopy(Config.Equipmentgemstotal)
  2277. for k,v in pairs(equipment_gems_suit_cfg) do
  2278. v.attr = stringtotable(v.attr)
  2279. v.total_attr = stringtotable(v.total_attr)
  2280. if not self.equipment_gems_suit_cfg[v.series] then
  2281. self.equipment_gems_suit_cfg[v.series] = {}
  2282. end
  2283. self.equipment_gems_suit_cfg[v.series][v.lv] = v
  2284. end
  2285. end
  2286. if series and lv and self.equipment_gems_suit_cfg[series] then
  2287. return self.equipment_gems_suit_cfg[series][lv]
  2288. elseif series and self.equipment_gems_suit_cfg[series] then
  2289. return self.equipment_gems_suit_cfg[series]
  2290. end
  2291. end
  2292. --宝石镶嵌信息
  2293. function EquipModel:SetGemstoneInfo( series_list )
  2294. self.gemstone_info_list = {}
  2295. for i,v in ipairs(series_list) do
  2296. if not self.gemstone_info_list[v.series] then
  2297. self.gemstone_info_list[v.series] = {}
  2298. end
  2299. local gems_list = {}
  2300. for ii,vv in ipairs(v.gems) do
  2301. local cfg = self:GetGemsCfgByTypeId(vv.goods_id)
  2302. if cfg then
  2303. gems_list[cfg.type] = cfg
  2304. end
  2305. end
  2306. self.gemstone_info_list[v.series][v.pos] = gems_list
  2307. end
  2308. end
  2309. --宝石镶嵌信息
  2310. function EquipModel:SetGemstoneOneInfo( scmd )
  2311. if not self.gemstone_info_list[scmd.series] then
  2312. self.gemstone_info_list[scmd.series] = {}
  2313. end
  2314. local gems_list = {}
  2315. for ii,vv in ipairs(scmd.gems) do
  2316. local cfg = self:GetGemsCfgByTypeId(vv.goods_id)
  2317. if cfg then
  2318. gems_list[cfg.type] = cfg
  2319. end
  2320. end
  2321. self.gemstone_info_list[scmd.series][scmd.pos] = gems_list
  2322. end
  2323. --获得宝石套件属性信息
  2324. function EquipModel:GetGemstoneSeriesInfo( series,pos )
  2325. if series and not pos then
  2326. return self.gemstone_info_list[series]
  2327. elseif series and pos and self.gemstone_info_list[series] then
  2328. return self.gemstone_info_list[series][pos]
  2329. elseif not series and not pos then
  2330. return self.gemstone_info_list
  2331. end
  2332. end
  2333. --计算全身装备镶嵌宝石总战力
  2334. function EquipModel:MathGemstonePower( )
  2335. local sum_power = 0
  2336. for k,v in pairs(self.gemstone_info_list) do
  2337. for kk,vv in pairs(v) do
  2338. for kkk,vvv in pairs(vv) do
  2339. if vvv.attr and vvv.attr[1] then--属性
  2340. sum_power = sum_power + GetFighting(vvv.attr,true)
  2341. end
  2342. end
  2343. end
  2344. end
  2345. return sum_power
  2346. end
  2347. --计算当前代装备镶嵌宝石总战力
  2348. function EquipModel:MathSeriesGemstonePower( series )
  2349. local sum_power = 0
  2350. local list = self.gemstone_info_list[series]
  2351. if list and TableSize(list) > 0 then
  2352. for kk,vv in pairs(list) do
  2353. for kkk,vvv in pairs(vv) do
  2354. if vvv.attr and vvv.attr[1] then--属性
  2355. sum_power = sum_power + GetFighting(vvv.attr,true)
  2356. end
  2357. end
  2358. end
  2359. end
  2360. return sum_power
  2361. end
  2362. --得到当前选择套数装备镶嵌宝石总等级
  2363. function EquipModel:GetGemstoneLvBySeries( series )
  2364. local sum_lv = 0
  2365. if self.gemstone_info_list[series] then
  2366. for k,v in pairs(self.gemstone_info_list[series]) do
  2367. for kk,vv in pairs(v) do
  2368. sum_lv = sum_lv + vv.lv
  2369. end
  2370. end
  2371. end
  2372. return sum_lv
  2373. end
  2374. --得到宝石套装信息
  2375. function EquipModel:GetGemstoneSuitInfo( series )
  2376. local gemstone_info = self:GetGemstoneSeriesInfo(series)
  2377. local list = {}
  2378. for i=1,11 do
  2379. if i ~= EquipModel.EquipType.Guard then
  2380. if not gemstone_info or not gemstone_info[i] then
  2381. list[i] = 0
  2382. else
  2383. local lv = 0
  2384. if gemstone_info[i] then
  2385. for kk,vv in pairs(gemstone_info[i]) do
  2386. if Config.Equipmentgems[vv.goods_id] then
  2387. lv = lv + Config.Equipmentgems[vv.goods_id].lv
  2388. end
  2389. end
  2390. end
  2391. list[i] = lv
  2392. end
  2393. end
  2394. end
  2395. return list
  2396. end
  2397. --升星装备选择列表
  2398. function EquipModel:SetEvolutionEquipChooseList( choose_list )
  2399. self.evolution_choose_equip_list = choose_list
  2400. end
  2401. function EquipModel:GetEvolutionEquipChooseList( )
  2402. return self.evolution_choose_equip_list
  2403. end
  2404. --升星商城购买列表
  2405. function EquipModel:SetEvolutionMarketBuy( market_buy )
  2406. self.equip_evolution_market_buy = market_buy
  2407. end
  2408. function EquipModel:GetEvolutionMarketBuy( )
  2409. return self.equip_evolution_market_buy
  2410. end
  2411. --获得红装消耗配置
  2412. function EquipModel:GetRedEquipCfg( series,pos,lv )
  2413. if not series then
  2414. print("huangcong:EquipModel [start:2383] 套数不存在:")
  2415. return
  2416. end
  2417. if TableSize(self.red_equip_cfg_list) == 0 then--这里初始化一次
  2418. local red_equip_cfg_list = DeepCopy(Config.Equipmentempower)
  2419. for k,v in pairs(red_equip_cfg_list) do--红装
  2420. v.attr = stringtotable(v.attr)
  2421. v.cost = stringtotable(v.cost)
  2422. v.condition = stringtotable(v.condition)
  2423. if not self.red_equip_cfg_list[v.series] then
  2424. self.red_equip_cfg_list[v.series] = {}
  2425. end
  2426. if not self.red_equip_cfg_list[v.series][v.pos] then
  2427. self.red_equip_cfg_list[v.series][v.pos] = {}
  2428. end
  2429. self.red_equip_cfg_list[v.series][v.pos][v.lv] = v
  2430. end
  2431. end
  2432. if self.red_equip_cfg_list[series] and self.red_equip_cfg_list[series][pos] then
  2433. if pos and not lv then
  2434. return self.red_equip_cfg_list[series][pos]
  2435. elseif pos and lv then
  2436. return self.red_equip_cfg_list[series][pos][lv]
  2437. end
  2438. end
  2439. end
  2440. --获得刻印总属性展览
  2441. function EquipModel:GetDraconicAttrData( )
  2442. local info = self.equip_pos_info
  2443. local attr_cfg = {}
  2444. for k,v in pairs(info) do
  2445. if v.carve_id and v.carve_id ~= 0 then
  2446. local cfg = self:GetDraconicCfg(k,v.carve_id)
  2447. if cfg then
  2448. attr_cfg[#attr_cfg + 1] = cfg.attr
  2449. end
  2450. end
  2451. end
  2452. local attr_list = {}
  2453. for k,v in pairs(attr_cfg) do
  2454. for kk,vv in pairs(v) do
  2455. if not attr_list[vv[1]] then
  2456. attr_list[vv[1]] = {vv[1],vv[2]}
  2457. else
  2458. attr_list[vv[1]] = {vv[1],vv[2] + attr_list[vv[1]][2]}
  2459. end
  2460. end
  2461. end
  2462. -- print("huangcong:EquipModel [start:2204] :", attr_list)
  2463. -- PrintTable(attr_list)
  2464. -- print("huangcong:EquipModel [end]")
  2465. return attr_list
  2466. end
  2467. --获取装备红点
  2468. function EquipModel:GetEquipRedDotByType(tab_type)
  2469. if not tab_type then return false end
  2470. return self.red_dot_info[tab_type]
  2471. end
  2472. --获取跟随守护的id
  2473. function EquipModel:GetFollowGuardId( )
  2474. local type_id = RoleManager.Instance.mainRoleInfo.evil_type_id
  2475. local evil_id = 0
  2476. if type_id ~= 0 then
  2477. local basic = self.goods_model:GetGoodsBasicByTypeId(type_id)
  2478. evil_id = basic.model_id
  2479. end
  2480. return evil_id
  2481. end
  2482. --展示装备获取途径tip
  2483. function EquipModel:ShowEquipGetWayTip( transform,index,equip_suit_id )
  2484. if not transform then return end
  2485. local ui_tf = panelMgr:GetParent("UI").transform
  2486. local pos = ui_tf:InverseTransformPoint(transform.position)
  2487. local w = ScreenWidth
  2488. local h = ScreenHeight
  2489. pos.x = w / 2 + pos.x
  2490. pos.y = h / 2 + pos.y
  2491. local key = index .. "@" .. equip_suit_id .. "@" ..index
  2492. local cfg = Config.Equipmentempty[key]
  2493. if cfg then
  2494. BagModel:getInstance():Fire(BagModel.EQUIP_ITEM_GET_WAY_TIPS, cfg,pos.x,pos.y)
  2495. else
  2496. print(">>>>> unfinfd config Equipmentempty ", index, equip_suit_id )
  2497. end
  2498. end
  2499. --装备是否可穿
  2500. function EquipModel:IsCanWear(type_id)
  2501. local career = RoleManager.Instance.mainRoleInfo.career
  2502. local equip_cfg = self:GetEquipmentCfg(type_id)
  2503. local have_career = false
  2504. for i,v in ipairs(equip_cfg.career) do
  2505. if v == career then
  2506. have_career = true
  2507. break
  2508. end
  2509. end
  2510. return have_career
  2511. end
  2512. --装备是否可穿
  2513. function EquipModel:GetEquipPos(type_id)
  2514. local equip_cfg = self:GetEquipmentCfg(type_id)
  2515. return equip_cfg.equip_type
  2516. end
  2517. --当前已经开启的最大套装数
  2518. function EquipModel:GetCurrentOpenSuitSeries()
  2519. local my_turn = RoleManager:getInstance():GetMainRoleVo().turn
  2520. self.cur_max_series = self:GetEquipTurnToSeries(my_turn)
  2521. return self.cur_max_series
  2522. end
  2523. --通过代数获取装备转生术
  2524. function EquipModel:GetEquipSeriesToTurn(series)
  2525. local turn = 1
  2526. if not self.series_to_turn_cfg[series] then
  2527. if series == 1 then
  2528. self.series_to_turn_cfg[series] = 0
  2529. else
  2530. local cfg = Config.Transfer
  2531. for k,v in pairs(cfg) do
  2532. if v.equipment_series == series then
  2533. self.series_to_turn_cfg[series] = v.id
  2534. break
  2535. end
  2536. end
  2537. end
  2538. end
  2539. turn = self.series_to_turn_cfg[series]
  2540. return turn
  2541. end
  2542. --通过转生数获取装备代数
  2543. function EquipModel:GetEquipTurnToSeries(turn)
  2544. local series = 1
  2545. if not self.turn_to_series_cfg[turn] then
  2546. if turn == 0 then
  2547. self.turn_to_series_cfg[turn] = 1
  2548. else
  2549. local cfg = Config.Transfer
  2550. for k,v in pairs(cfg) do
  2551. if v.id == turn and v.stage == 5 then
  2552. self.turn_to_series_cfg[turn] = v.equipment_series
  2553. break
  2554. end
  2555. end
  2556. end
  2557. end
  2558. series = self.turn_to_series_cfg[turn]
  2559. return series
  2560. end
  2561. --当前可以激活的最大套装数
  2562. function EquipModel:GetCanActiveMaxSeries()
  2563. local max = 1
  2564. local level = RoleManager.Instance.mainRoleInfo.level
  2565. local config = Config.Equipmentseriesopen
  2566. for i,v in ipairs(config) do
  2567. if level >= v.open_lv and (v.task_id == 0 or TaskModel:getInstance():IsTaskFinished(v.task_id)) then
  2568. max = v.series
  2569. end
  2570. end
  2571. return max
  2572. end
  2573. --对应套是否可以开启
  2574. function EquipModel:CehckTargetSeriesCanOpen(series)
  2575. local str = ""
  2576. local my_turn = RoleManager.Instance.mainRoleInfo.turn
  2577. local need_turn = self:GetEquipSeriesToTurn(series)
  2578. if my_turn < need_turn then
  2579. local cfg = Config.Transfercareer
  2580. local career = RoleManager:getInstance():GetMainRoleVo().career
  2581. local career_str = " "
  2582. for k,v in pairs(cfg) do
  2583. if v.career == career and v.transfer_id == need_turn then
  2584. career_str = " " .. Trim(v.name) .. " "
  2585. break
  2586. end
  2587. end
  2588. str = string.format("完成 %s转职业%s可激活", WordManager:getHanZiNumber(need_turn), career_str)
  2589. end
  2590. return str
  2591. end
  2592. --获取最大套装数
  2593. function EquipModel:GetMaxSuitSeries()
  2594. local config = Config.Equipmentseriesopen
  2595. return config and #config or 0
  2596. end
  2597. --是否能够被吞噬
  2598. function EquipModel:IsCanSwallow(goods_basic)
  2599. local v = goods_basic
  2600. return v.type == GoodsModel.TYPE.EQUIP and v.subtype ~= 8 and v.subtype ~= 9 and v.subtype ~= 10 and v.subtype ~= 11
  2601. end
  2602. --是否能够被吞噬
  2603. function EquipModel:GuardIsCanSetFollow(type_id, goods_id)
  2604. local b = false
  2605. local equip_cfg = self:GetEquipmentCfg(type_id)
  2606. if equip_cfg and equip_cfg.equip_type == EquipModel.EquipType.Guard then
  2607. if type_id ~= RoleManager.Instance.mainRoleInfo.evil_type_id then
  2608. b = true
  2609. end
  2610. end
  2611. return b
  2612. end
  2613. --设置装备宝石激活的等级列表
  2614. function EquipModel:SetEquipGemActiveList( scmd )
  2615. self.gems_lv_list = {}
  2616. if scmd.gems_lv_list and #scmd.gems_lv_list > 0 then
  2617. for i,v in pairs(scmd.gems_lv_list) do
  2618. self.gems_lv_list[v.series] = v.gems_lv
  2619. end
  2620. end
  2621. self:IsNeedRed(EquipModel.MainTab.Gemstone,nil,nil,true)
  2622. end
  2623. --得到宝石激活等级
  2624. function EquipModel:GetEquipGemActiveLvBySeries( series )
  2625. return self.gems_lv_list[series] or 0
  2626. end
  2627. function EquipModel:CheckGemstoneSeriesRedDot( )
  2628. local show = false
  2629. self.gems_suit_red_list = {}
  2630. local len = NewMainRoleModel:getInstance():GetRoleReinMaxTurn()
  2631. local active_gems_num = 0
  2632. local sum_gems_num = 0
  2633. local next_level = 0
  2634. for i=1,len do
  2635. next_level = 0
  2636. active_gems_num = self:GetEquipGemActiveLvBySeries(i)
  2637. sum_gems_num = self:GetGemstoneLvBySeries(i)
  2638. local strengthtotal_cfg = self:GetGemsSuitCfg(i)
  2639. local cur_gems_attr = nil
  2640. for kk,vv in pairsByKeys(strengthtotal_cfg) do
  2641. if vv.lv > active_gems_num then
  2642. next_level = vv.lv
  2643. break
  2644. else
  2645. cur_gems_attr = vv.attr
  2646. end
  2647. end
  2648. self.gems_suit_red_list[i] = next_level ~= 0 and next_level <= sum_gems_num
  2649. if next_level ~= 0 and next_level <= sum_gems_num then
  2650. show = true
  2651. end
  2652. if not self.gem_next_level_list[i] then
  2653. self.gem_next_level_list[i] = {}
  2654. end
  2655. --判断星级套装是否要玩家主动去激活
  2656. for kk,vv in pairsByKeys(strengthtotal_cfg) do
  2657. if vv.lv <= sum_gems_num and not self.gem_next_level_list[i][vv.lv] then
  2658. self.gem_next_level_list[i][vv.lv] = true
  2659. if self.gems_can_tip then
  2660. local tip_data = {}
  2661. tip_data.id = EquipModel.MainTab.Gemstone
  2662. tip_data.star = vv.lv
  2663. tip_data.attr = vv.attr
  2664. tip_data.equip_suit_id = i
  2665. print("huangcong:EquipModel [start:2736] :", tip_data)
  2666. PrintTable(tip_data)
  2667. print("huangcong:EquipModel [end]")
  2668. self:Fire(EquipModel.OPEN_EQUIP_BASE_TIPS_VIEW,tip_data)
  2669. break
  2670. end
  2671. end
  2672. end
  2673. end
  2674. return show
  2675. end
  2676. --获得宝石镶嵌配置信息EquipToolTips宝石专用
  2677. function EquipModel:GetGemstoneEquipToolTipsInfo( gems_info )
  2678. local gems_list = {}
  2679. for ii,vv in ipairs(gems_info) do
  2680. local cfg = self:GetGemsCfgByTypeId(vv[2])
  2681. if cfg then
  2682. gems_list[cfg.type] = cfg
  2683. end
  2684. end
  2685. return gems_list
  2686. end
  2687. --获得当前装备最大套数
  2688. function EquipModel:GetCurHaveEquipMaxSuit( )
  2689. return self.goods_model.have_equip_max_suit or 1
  2690. end
  2691. --背包是否有宝石镶嵌
  2692. function EquipModel:BagHaveGemstoneSet( gems_type )
  2693. if not gems_type then return false end
  2694. if self.equipment_gems_series_cfg[gems_type] then
  2695. for i,v in pairs(self.equipment_gems_series_cfg[gems_type]) do
  2696. local num = self.goods_model:GetTypeGoodsNum(v.goods_id)
  2697. if num > 0 then
  2698. return true
  2699. end
  2700. end
  2701. --如果背包没有宝石则展示对应类型的1级宝石
  2702. for i,v in pairsByKeys(self.equipment_gems_series_cfg[gems_type]) do
  2703. UIToolTipMgr:getInstance():AppendGoodsTips(v.goods_id, nil, nil,nil,nil,nil,nil,true)
  2704. return false
  2705. end
  2706. end
  2707. return false
  2708. end
  2709. --设置红装(升品)信息
  2710. function EquipModel:SetRedEquipInfo( series_list )
  2711. self.redEquip_server_info = {}
  2712. for i,v in pairs(series_list) do
  2713. if not self.redEquip_server_info[v.series] then
  2714. self.redEquip_server_info[v.series] = {}
  2715. end
  2716. self.redEquip_server_info[v.series][v.pos] = v
  2717. end
  2718. -- print("huangcong:EquipModel [start:2640] :", self.redEquip_server_info)
  2719. -- PrintTable(self.redEquip_server_info)
  2720. -- print("huangcong:EquipModel [end]")
  2721. end
  2722. --获得红装(升品)信息
  2723. function EquipModel:GetRedEquipInfo( series,pos )
  2724. if series and pos and self.redEquip_server_info[series] then
  2725. return self.redEquip_server_info[series][pos]
  2726. elseif series and not pos and self.redEquip_server_info[series] then
  2727. return self.redEquip_server_info[series]
  2728. else
  2729. return self.redEquip_server_info
  2730. end
  2731. end
  2732. --检查升品所有套装等级是否满足条件
  2733. function EquipModel:RedEquipCheckAllSeriesLv( series,lv )
  2734. if not series or not lv then return false end
  2735. for i=1,series do
  2736. if self.redEquip_server_info[i] and TableSize(self.redEquip_server_info[i]) >= 7 then
  2737. for k,v in ipairs(self.redEquip_server_info[i]) do
  2738. if v.lv < lv and v.pos <= 7 then
  2739. return false
  2740. end
  2741. end
  2742. else
  2743. return false
  2744. end
  2745. end
  2746. return true
  2747. end
  2748. --获得红装商城同一个部位最低升品装备数量
  2749. function EquipModel:GetRedEquipShopCostlimitNum( equip_pos )
  2750. local list = self.goods_model.wear_equip_suit_list
  2751. local limit_cost = nil
  2752. local power_lv = 0--当前升品等级
  2753. local equip_info = nil
  2754. local strength_cfg = nil
  2755. local cost_list = nil
  2756. for equip_suit_id,v in pairs(list) do
  2757. local equip_info = v[equip_pos]
  2758. if equip_info and equip_info.color >= 4 then -- 橙装以上才能升品哟
  2759. local server_info = self:GetRedEquipInfo(equip_suit_id,equip_pos)
  2760. power_lv = 0--当前升品等级
  2761. if server_info then power_lv = server_info and server_info.lv or 0 end
  2762. strength_cfg = self:GetRedEquipCfg(equip_suit_id,equip_pos,power_lv + 1)--基础属性
  2763. if strength_cfg then
  2764. cost_list = strength_cfg.cost
  2765. if not limit_cost then
  2766. limit_cost = cost_list[1][3]
  2767. else
  2768. limit_cost = limit_cost > cost_list[1][3] and cost_list[1][3] or limit_cost
  2769. end
  2770. end
  2771. end
  2772. end
  2773. if not limit_cost then--没有这件装备或者没有橙装
  2774. local len,list = EquipModel.getInstance():GetCurrentOpenSuitSeries()
  2775. for i=1,len do
  2776. strength_cfg = self:GetRedEquipCfg(i,equip_pos,1)--基础属性
  2777. if strength_cfg then
  2778. cost_list = strength_cfg.cost
  2779. if not limit_cost then
  2780. limit_cost = cost_list[1][3]
  2781. else
  2782. limit_cost = limit_cost > cost_list[1][3] and cost_list[1][3] or limit_cost
  2783. end
  2784. end
  2785. end
  2786. end
  2787. return limit_cost
  2788. end
  2789. --获得商城道具ID装备位置
  2790. function EquipModel:GetShopGoodsIdEquipPos( goods_id )
  2791. if TableSize(self.red_equip_cfg_list) == 0 then--这里初始化一次
  2792. local red_equip_cfg_list = DeepCopy(Config.Equipmentempower)
  2793. for k,v in pairs(red_equip_cfg_list) do--红装
  2794. v.attr = stringtotable(v.attr)
  2795. v.cost = stringtotable(v.cost)
  2796. v.condition = stringtotable(v.condition)
  2797. if not self.red_equip_cfg_list[v.series] then
  2798. self.red_equip_cfg_list[v.series] = {}
  2799. end
  2800. if not self.red_equip_cfg_list[v.series][v.pos] then
  2801. self.red_equip_cfg_list[v.series][v.pos] = {}
  2802. end
  2803. self.red_equip_cfg_list[v.series][v.pos][v.lv] = v
  2804. end
  2805. end
  2806. for k,v in pairs(self.red_equip_cfg_list) do
  2807. for kk,vv in pairs(v) do
  2808. for kkk,vvv in pairs(vv) do
  2809. if vvv.cost and vvv.cost[1] and vvv.cost[1][2] == goods_id then
  2810. return vvv.pos
  2811. end
  2812. end
  2813. end
  2814. end
  2815. end
  2816. function EquipModel:GetEquipType( type_id )
  2817. local cfg = Config.Equipment[type_id]
  2818. if cfg then
  2819. return cfg.equip_type
  2820. end
  2821. end
  2822. --设置装备升星自动购买cookie
  2823. function EquipModel:SetEquipEvolutionAotuBuyCookie( bool )
  2824. CookieWrapper.Instance:SaveCookie(CookieLevelType.Account,CookieTimeType.TYPE_ALWAYS,CookieKey.EQUIP_AOTU_BUY_SHOP,bool)
  2825. CookieWrapper.Instance:WriteAll()
  2826. end
  2827. --获得装备升星自动购买cookie
  2828. function EquipModel:GetEquipEvolutionAotuBuyCookie( )
  2829. local bool = CookieWrapper.Instance:GetCookie(CookieLevelType.Account,CookieKey.EQUIP_AOTU_BUY_SHOP) or false
  2830. return bool
  2831. end
  2832. --计算升星属性战力
  2833. function EquipModel:MathGreatAttrFighting( attr_list,bool )
  2834. local new_list = {}
  2835. local fight_num = 0
  2836. for k,v in ipairs(attr_list) do
  2837. local data = {v[1],v[2]}
  2838. new_list[#new_list + 1] = data
  2839. end
  2840. -- print("huangcong:EquipModel [start:2977] :", attr_list)
  2841. -- PrintTable(attr_list)
  2842. -- print("huangcong:EquipModel [end]")
  2843. new_list = self:ChangeEquipSAttr(new_list)
  2844. -- print("huangcong:EquipModel [start:2981] :转化后的终极属性", new_list)
  2845. -- PrintTable(new_list)
  2846. new_list = ComposeAttr(new_list)
  2847. fight_num = GetFighting(new_list,bool or false)
  2848. return fight_num or 0
  2849. end
  2850. --饰品: 戒指 项链 耳饰 手套
  2851. --防具:头部 身体 披风 裤子 脚
  2852. --武器:武器
  2853. --[转换装备属性]
  2854. -- EquipModel.DefEquipType
  2855. -- EquipModel.NecklaceEquipType
  2856. function EquipModel:ChangeEquipSAttr( attr_list )--221
  2857. local wear_equip_suit_list = self.goods_model.wear_equip_suit_list or {}
  2858. local weapon_atk = 0--武器攻击
  2859. local def_hp = 0--防具生命
  2860. local necklace_atk = 0--饰品攻击
  2861. local necklace_def = 0--饰品防御
  2862. local weapon_attr_list = {}--武器属性列表
  2863. local def_attr_list = {}--防具属性列表
  2864. local necklace_attr_list = {}--饰品属性列表
  2865. for series,equip_series_list in pairs(wear_equip_suit_list) do
  2866. for equip_type,goods_vo in pairs(equip_series_list) do
  2867. local equip_cfg = self:GetEquipmentCfg(goods_vo.type_id)
  2868. if equip_cfg and equip_cfg.base_attr then
  2869. if equip_cfg.equip_type == 1 then--武器
  2870. for k,v in ipairs(equip_cfg.base_attr) do
  2871. if not weapon_attr_list[v[1]] then
  2872. weapon_attr_list[v[1]] = 0
  2873. end
  2874. weapon_attr_list[v[1]] = weapon_attr_list[v[1]] + v[2]
  2875. end
  2876. elseif EquipModel.DefEquipType[equip_cfg.equip_type] then--防具
  2877. for k,v in ipairs(equip_cfg.base_attr) do
  2878. if not def_attr_list[v[1]] then
  2879. def_attr_list[v[1]] = 0
  2880. end
  2881. def_attr_list[v[1]] = def_attr_list[v[1]] + v[2]
  2882. end
  2883. elseif EquipModel.NecklaceEquipType[equip_cfg.equip_type] then--饰品
  2884. for k,v in ipairs(equip_cfg.base_attr) do
  2885. if not necklace_attr_list[v[1]] then
  2886. necklace_attr_list[v[1]] = 0
  2887. end
  2888. necklace_attr_list[v[1]] = necklace_attr_list[v[1]] + v[2]
  2889. end
  2890. end
  2891. end
  2892. end
  2893. end
  2894. local new_attr_list = {}
  2895. local attr_id = nil
  2896. for k,v in ipairs(attr_list) do
  2897. local attr_id = EquipModel.STypeAttr[v[1]]
  2898. if attr_id then--如果是局部百分比属性
  2899. if v[1] == 221 and weapon_attr_list[attr_id] then--武器攻击
  2900. new_attr_list[#new_attr_list + 1] = {attr_id,round(v[2]/10000*weapon_attr_list[attr_id])}
  2901. elseif (v[1] == 223 or v[1] == 224) and def_attr_list[attr_id] then--防具生命/防具防御
  2902. new_attr_list[#new_attr_list + 1] = {attr_id,round(v[2]/10000*def_attr_list[attr_id])}
  2903. elseif v[1] == 225 and necklace_attr_list[attr_id] then--饰品攻击
  2904. new_attr_list[#new_attr_list + 1] = {attr_id,round(v[2]/10000*necklace_attr_list[attr_id])}
  2905. end
  2906. else
  2907. new_attr_list[#new_attr_list + 1] = v
  2908. end
  2909. end
  2910. -- print("huangcong:EquipModel [start:3044] :", def_attr_list)
  2911. -- PrintTable(def_attr_list)
  2912. -- print("huangcong:EquipModel [end]")
  2913. -- print("huangcong:EquipModel [start:3045] :", attr_list)
  2914. -- PrintTable(attr_list)
  2915. -- print("huangcong:EquipModel [end]")
  2916. -- print("huangcong:EquipModel [start:3047] :", new_attr_list)
  2917. -- PrintTable(new_attr_list)
  2918. -- print("huangcong:EquipModel [end]")
  2919. return new_attr_list
  2920. end
  2921. --装备更新新套装属性激活
  2922. function EquipModel:UpdateNewSuitAttrActive( is_init )
  2923. self.suit_attr_active_list = self.suit_attr_active_list or {}
  2924. local red_bool = false
  2925. local wear_equip_suit_list = self.goods_model.wear_equip_suit_list or {}
  2926. for series,v in pairs(wear_equip_suit_list) do
  2927. if not self.suit_attr_active_list[series] then
  2928. self.suit_attr_active_list[series] = {}
  2929. end
  2930. local cur_suit_id_num1,suit_equip_pos_list1 = self.goods_model:GetEquipSuitNum(series,1)--装备套装
  2931. local suit_cfg_list1 = self:GetEquipmentSuitCfg(series,1)
  2932. if suit_cfg_list1 then
  2933. local active_num_list1 = {}--新激活数量
  2934. for k,vv in pairs(suit_cfg_list1) do
  2935. if vv.suit_num <= cur_suit_id_num1 then
  2936. active_num_list1[#active_num_list1 + 1] = {vv.suit_num,false,true}--先默认未激活吧第三个参数是否是已经查看
  2937. end
  2938. end
  2939. if is_init then--初始化或者没有数据的时候
  2940. self.suit_attr_active_list[series][1] = active_num_list1
  2941. elseif not self.suit_attr_active_list[series][1] then--后面新增了
  2942. for k,v in pairs(active_num_list1) do
  2943. v = {v[1],true,false}
  2944. end
  2945. self.suit_attr_active_list[series][1] = active_num_list1
  2946. elseif #self.suit_attr_active_list[series][1] < #active_num_list1 then --开始对比
  2947. local new_list = {}
  2948. for i=1,#active_num_list1 do
  2949. if i <= #self.suit_attr_active_list[series][1] then
  2950. new_list[#new_list + 1] = self.suit_attr_active_list[series][1][i]
  2951. else
  2952. new_list[#new_list + 1] = {active_num_list1[i][1],true,false}
  2953. end
  2954. end
  2955. self.suit_attr_active_list[series][1] = new_list
  2956. end
  2957. end
  2958. local cur_suit_id_num2,suit_equip_pos_list2 = self.goods_model:GetEquipSuitNum(series,2)--饰品套装
  2959. local suit_cfg_list2 = self:GetEquipmentSuitCfg(series,2)
  2960. if suit_cfg_list2 then
  2961. local active_num_list2 = {}--新激活数量
  2962. for k,vv in pairs(suit_cfg_list2) do
  2963. if vv.suit_num <= cur_suit_id_num2 then
  2964. active_num_list2[#active_num_list2 + 1] = {vv.suit_num,false,true}--先默认未激活吧第三个参数是否是已经查看
  2965. end
  2966. end
  2967. if is_init then
  2968. self.suit_attr_active_list[series][2] = active_num_list2
  2969. elseif not self.suit_attr_active_list[series][2] then--初始化或者没有数据的时候
  2970. for k,v in pairs(active_num_list2) do
  2971. v = {v[1],true,false}
  2972. end
  2973. self.suit_attr_active_list[series][2] = active_num_list2
  2974. elseif #self.suit_attr_active_list[series][2] < #active_num_list2 then --开始对比
  2975. local new_list = {}
  2976. for i=1,#active_num_list2 do
  2977. if i <= #self.suit_attr_active_list[series][2] then
  2978. new_list[#new_list + 1] = self.suit_attr_active_list[series][2][i]
  2979. else
  2980. new_list[#new_list + 1] = {active_num_list2[i][1],true,false}
  2981. end
  2982. end
  2983. self.suit_attr_active_list[series][2] = new_list
  2984. end
  2985. end
  2986. end
  2987. self.suit_attr_active_red_series_list = {}
  2988. -- print("huangcong:EquipModel [start:3130] :", self.suit_attr_active_list)
  2989. -- PrintTable(self.suit_attr_active_list)
  2990. -- print("huangcong:EquipModel [end]")
  2991. for series,v in pairs(self.suit_attr_active_list) do
  2992. for equip_attr_type,vv in pairs(v) do
  2993. for kkk,vvv in pairs(vv) do
  2994. if vvv[2] then
  2995. self.suit_attr_active_red_series_list[series] = true
  2996. red_bool = true
  2997. end
  2998. end
  2999. end
  3000. end
  3001. self.suit_attr_red_bool = red_bool
  3002. GlobalEventSystem:Fire(EventName.UPDATE_BAG_RED)
  3003. end
  3004. --获得当前属性是否是最新属性是否查看过
  3005. function EquipModel:GetNewSuitAttrActiveInfo( series,equip_attr_type,suit_num )
  3006. if self.suit_attr_active_list[series] and self.suit_attr_active_list[series][equip_attr_type] then
  3007. for k,v in pairs(self.suit_attr_active_list[series][equip_attr_type]) do
  3008. if v[1] == suit_num then
  3009. return v[3]
  3010. end
  3011. end
  3012. end
  3013. return true
  3014. end
  3015. --获得套装属性红点信息
  3016. function EquipModel:GetSuitAttrRedBool( )
  3017. return self.suit_attr_red_bool
  3018. end