源战役客户端
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

1657 wiersze
48 KiB

1 miesiąc temu
  1. GodModel = GodModel or BaseClass(BaseVo, true)
  2. local GodModel = GodModel
  3. function GodModel:__init()
  4. GodModel.Instance = self
  5. self:Reset()
  6. self:InitCFG()
  7. end
  8. function GodModel:Reset()
  9. self.god_base_data = false
  10. self.activity_common_info = false
  11. self.activity_limit_Info = false
  12. -------------------------
  13. self.last_use_time = false--上次召唤时间戳
  14. -------------------------
  15. self.select_equip_show_info = {suit_id = 0,pos = 0,color = 0}--座印背包选中信息{pos = 0,color = 0,suit_id = 0,god_id}
  16. self.slot_unlock_info = {}
  17. self.left_free_draw_times = 0--剩余的免费抽奖次数
  18. if not self.acitvity_cost_id then
  19. --抽奖消耗券
  20. local temp = Config.Godkv["lottery_single"].value_content
  21. temp = stringtotable(temp)[1]
  22. self.acitvity_cost_id = tonumber(temp[2])
  23. end
  24. end
  25. function GodModel:GetBagSuitDesList( index )
  26. if not self.bag_suit_des_list then
  27. self.bag_suit_des_list = {[1] = {id = 0,type_name = "所有类型"}}
  28. for k,v in pairs(Config.Godequipsuit) do
  29. if v.equip_num == 4 then
  30. table.insert( self.bag_suit_des_list, {id = v.suit_id,type_name = v.type_name} )
  31. end
  32. end
  33. local function sort_call( a,b )
  34. --从大到小
  35. return a.id < b.id
  36. end
  37. table.sort( self.bag_suit_des_list, sort_call )
  38. end
  39. if index then
  40. return self.bag_suit_des_list[index]
  41. else
  42. return self.bag_suit_des_list
  43. end
  44. end
  45. function GodModel:getInstance()
  46. if GodModel.Instance == nil then
  47. GodModel.Instance = GodModel.New()
  48. end
  49. return GodModel.Instance
  50. end
  51. function GodModel:InitCFG( )
  52. self.activity_limit_conf = nil
  53. self.activity_common_conf = nil
  54. self.god_cfg_map = {}--保存每神灵最低星数的配置,每神灵只有一条信息,key值是神灵ID
  55. for k,v in pairs(Config.God) do
  56. local cur_info = self.god_cfg_map[v.id]
  57. if not cur_info or cur_info.star > v.star then
  58. local info = DeepCopy(v)
  59. local skill_info = stringtotable(info.skills)
  60. info.skill = {}
  61. for k,v in ipairs(skill_info or {}) do
  62. table.insert(info.skill, v[1])
  63. end
  64. self.god_cfg_map[v.id] = info
  65. end
  66. end
  67. self.god_cfg_list_for_book = {}--按顺序保存每神灵最低星数的配置
  68. for k, v in pairs(self.god_cfg_map) do
  69. self.god_cfg_list_for_book[#self.god_cfg_list_for_book+1] = v
  70. end
  71. local sort_fun = function ( a, b )
  72. return a.order < b.order
  73. end
  74. table.sort(self.god_cfg_list_for_book, sort_fun)
  75. self.god_max_lv = {}
  76. for k,v in pairs(Config.Godlv) do
  77. if not self.god_max_lv[v.god_id] or self.god_max_lv[v.god_id] < v.lv then
  78. self.god_max_lv[v.god_id] = v.lv
  79. end
  80. end
  81. --座印套装信息
  82. self.god_suit_cfg = {}
  83. self.god_suit_list_for_show = {}
  84. for k,v in pairs(Config.Godequipsuit) do
  85. self.god_suit_cfg[v.suit_id] = self.god_suit_cfg[v.suit_id] or {}
  86. table.insert(self.god_suit_cfg[v.suit_id], v)
  87. end
  88. for k,v in pairs(self.god_suit_cfg) do
  89. table.insert(self.god_suit_list_for_show, v)
  90. end
  91. local sort_func = function ( a, b )
  92. return a[1].suit_id > b[1].suit_id
  93. end
  94. table.sort(self.god_suit_list_for_show, sort_func)
  95. for k,v in pairs(self.god_suit_cfg) do
  96. local sort_func = function ( a, b )
  97. return a.equip_num < b.equip_num
  98. end
  99. table.sort(v, sort_func)
  100. end
  101. --座印最高等级,以其星数为主键
  102. self.god_soul_epx_max_lv = {}
  103. for k,v in pairs(Config.Godequip) do
  104. if not self.god_soul_epx_max_lv[v.quality] or self.god_soul_epx_max_lv[v.quality] < v.lv then
  105. self.god_soul_epx_max_lv[v.quality] = v.lv
  106. end
  107. end
  108. --座印在某星某级时总共包含多少经验
  109. self.god_soul_sum_exp_map = {}
  110. for k,v in pairs(self.god_soul_epx_max_lv or {}) do
  111. self.god_soul_sum_exp_map[k] = self.god_soul_sum_exp_map[k] or {}
  112. self.god_soul_sum_exp_map[k][0] = 0
  113. for i=1,v do
  114. local last_lv_exp = i>1 and self.god_soul_sum_exp_map[k][i-1] or 0
  115. self.god_soul_sum_exp_map[k][i] = Config.Godequip[k.."@"..i].exp+last_lv_exp
  116. end
  117. end
  118. -- local discount_cfg = stringtotable(Config.Godkv["discount_day"].value_content)
  119. -- self.lottery_discount_cfg = {
  120. -- open_day = discount_cfg[1],
  121. -- discounts = discount_cfg[2],
  122. -- max_discount_num = discount_cfg[2][#discount_cfg[2]][2]
  123. -- }
  124. -- self.lottery_blessing_cfg = stringtotable(Config.Godkv["god_bless_num"].value_content)
  125. end
  126. function GodModel:GetGodConf( god_id,star )
  127. return Config.God[god_id.."@"..star]
  128. end
  129. function GodModel:GetGodBaseData( )
  130. return self.god_base_data
  131. end
  132. function GodModel:SetGodBaseData( value )
  133. self.god_base_data = value
  134. self:UpdateGuardInfo(self.god_base_data.list)
  135. end
  136. function GodModel:SetOneGodData( data )
  137. if not self.god_base_data then return end
  138. local have_set = false
  139. for k,v in pairs(self.god_base_data.list) do
  140. if v.id == data.id then
  141. self.god_base_data.list[k] = data
  142. have_set = true
  143. break
  144. end
  145. end
  146. if not have_set then
  147. table.insert(self.god_base_data.list,data)
  148. end
  149. self:UpdateGuardInfo(self.god_base_data.list)
  150. end
  151. --神座主界面左侧列表
  152. function GodModel:GetSortedGodList( is_show_skill_power )
  153. is_show_skill_power = false
  154. -------------------------
  155. local result_list = {}
  156. local fight_god = {}
  157. local guard_god = {}
  158. local other_god = {}
  159. local god_base_list = self.god_base_data and self.god_base_data.list or {}
  160. for k,v in pairs(god_base_list or {}) do
  161. v.__power_by_sort__ = k
  162. v.__power_by_sort__ = self:GetMyGodPower(v.id, is_show_skill_power)
  163. if self:IsFightPos(v.pos) then
  164. table.insert(fight_god, v)
  165. elseif self:IsGuardPos(v.pos) then
  166. table.insert(guard_god, v)
  167. else
  168. table.insert(other_god, v)
  169. end
  170. end
  171. local sort_by_power_func = function ( a, b )
  172. local a_power = a.__power_by_sort__ or 0
  173. local b_power = b.__power_by_sort__ or 0
  174. return a_power > b_power
  175. end
  176. table.sort(fight_god, sort_by_power_func)
  177. table.sort(guard_god, sort_by_power_func)
  178. table.sort(other_god, sort_by_power_func)
  179. result_list = TableConcat(result_list, fight_god)
  180. result_list = TableConcat(result_list, guard_god)
  181. result_list = TableConcat(result_list, other_god)
  182. return result_list
  183. end
  184. --获得单个神座的信息
  185. function GodModel:GetGodInfoById( god_id )
  186. if not self.god_base_data then return end
  187. for k,v in pairs(self.god_base_data.list) do
  188. if v.id == god_id then
  189. return v
  190. end
  191. end
  192. end
  193. --获得神座的阶数
  194. function GodModel:GetGodGrade( god_id )
  195. local data = self:GetGodInfoById(god_id)
  196. if data then
  197. return data.star
  198. end
  199. return 0
  200. end
  201. --获得神座的等级
  202. function GodModel:GetGodLv( god_id )
  203. local info = self:GetGodInfoById(god_id)
  204. return info and info.lv or 0
  205. end
  206. --是否已满级
  207. function GodModel:IsGodFullLv( god_id )
  208. return self:GetGodLv(god_id) >= (self.god_max_lv[god_id] or 1)
  209. end
  210. --获取某神身上的神装
  211. function GodModel:GetGodEquipList( god_id )
  212. if not god_id then return {} end
  213. return self.god_equips and self.god_equips[god_id] or {}
  214. end
  215. --获取某神身上的神装
  216. function GodModel:GetGodEquipListByOneGoodsId( goods_id )
  217. if not goods_id then return {} end
  218. for k,v in pairs(self.god_equips) do
  219. for a,b in pairs(v) do
  220. if b.goods_id == goods_id then
  221. return v,k
  222. end
  223. end
  224. end
  225. end
  226. --获取某神身上的神装
  227. function GodModel:GetGodEquipByPos( god_id, pos )
  228. if not god_id then return {} end
  229. return self.god_equips and self.god_equips[god_id] and self.god_equips[god_id][pos]
  230. end
  231. --cell=god_id*100+pos_id
  232. function GodModel:GetGodIDFromEquipCell( cell )
  233. return math.floor(cell/100)
  234. end
  235. --cell=god_id*100+pos_id
  236. function GodModel:GetPosIDFromEquipCell( cell )
  237. return cell%100
  238. end
  239. function GodModel:UpdateGodEquipGoods( vo )
  240. if vo.goods_num <= 0 then --删除物品
  241. --删除物品的话是通过15018发过来的,拿不到cell数据所以只好遍历,数量不多所以不怕
  242. for k,v in pairs(self.god_equips or {}) do
  243. for kk,vv in pairs(v or {}) do
  244. if vv.goods_id == vo.goods_id then
  245. v[kk] = nil
  246. break
  247. end
  248. end
  249. end
  250. else
  251. local cell = vo and vo.cell or 0--如果是神座已穿戴的装备的话cell=god_id*100+pos_id
  252. local god_id = self:GetGodIDFromEquipCell(cell)
  253. local pos_id = self:GetPosIDFromEquipCell(cell)
  254. self.god_equips[god_id] = self.god_equips[god_id] or {}
  255. GoodsModel:getInstance():SetBaseInfo(vo)
  256. self.god_equips[god_id][pos_id] = vo
  257. end
  258. end
  259. function GodModel:GetEquipByUID( uid )
  260. for k,v in pairs(self.god_equips or {}) do
  261. for kk,vv in pairs(v) do
  262. if vv.goods_id == uid then
  263. return vv
  264. end
  265. end
  266. end
  267. return nil
  268. end
  269. function GodModel:SetGodEquipList( list )
  270. self.god_equips = {}
  271. for i = 1, #list do
  272. if list and list[i] then
  273. self:UpdateGodEquipGoods(list[i])
  274. end
  275. end
  276. self:UpdateIsAllGodEquipBest()
  277. self:Fire(GodConst.UpdateGodDressedEquipChange)
  278. self:Fire(GodConst.UpdateRedDot, GodConst.TabID.Info)
  279. end
  280. --判断是否所有神座都已穿戴了最好的座印了,只有这样才可以显示座印可升级的红点
  281. function GodModel:UpdateIsAllGodEquipBest( )
  282. self.is_need_show_equip_can_upgrade_red = false
  283. for k,v in pairs(self:GetGodList()) do
  284. if self:IsNeedRedInfoByEquip(v.id) then
  285. --有座印可以穿或替换的话那就不需要显示座印可升级
  286. self.is_need_show_equip_can_upgrade_red = false
  287. return true--顺便担当红点函数
  288. end
  289. end
  290. self.is_need_show_equip_can_upgrade_red = true
  291. return false--顺便担当红点函数
  292. end
  293. --某神的座印是否需要红点
  294. function GodModel:IsNeedRedInfoByEquip( god_id )
  295. for i=1,6 do
  296. if self:IsGodEquipCanBetter(god_id, i) then
  297. return true
  298. end
  299. end
  300. end
  301. --某神的某部位座印是否能加强,即未穿时是否有可穿的,已穿时是否有更好的
  302. function GodModel:IsGodEquipCanBetter( god_id, equip_pos )
  303. local equip_goods_vo = self:GetGodEquipByPos(god_id, equip_pos)
  304. local equip_list_in_bag = GoodsModel.getInstance():GetGodEquipListByPos(equip_pos)
  305. if not equip_list_in_bag or #equip_list_in_bag <= 0 then
  306. --背包里没有座印
  307. return false, "背包里没有座印"
  308. end
  309. if equip_goods_vo then
  310. --已穿座印,找更好的
  311. local cur_suit_id = self:GetEquipSuit(equip_goods_vo.type_id)
  312. local max_color_in_bag, max_color_equip = self:GetMaxColorInSoulList(equip_list_in_bag, cur_suit_id)
  313. local is_can_replace = false
  314. local max_color_stage = GoodsModel:getInstance():GetOtherDataById(max_color_equip,GodConst.EquipStrenId) or 0
  315. local stage = GoodsModel:getInstance():GetOtherDataById(equip_goods_vo,GodConst.EquipStrenId) or 0
  316. stage = tonumber(stage)
  317. if (max_color_in_bag > equip_goods_vo.color) then
  318. is_can_replace = true
  319. elseif (max_color_in_bag == equip_goods_vo.color and max_color_equip and max_color_stage>stage) then
  320. is_can_replace = true
  321. end
  322. if is_can_replace then
  323. --背包里有更高星数的座印
  324. return true, GodConst.EquipStatus.WearBetter
  325. elseif self.is_need_show_equip_can_upgrade_red then
  326. local isFullLv = self:IsEquipFullLv(equip_goods_vo)
  327. if not isFullLv and self:HasExistInSoulListByMaxColor(1, equip_list_in_bag, cur_suit_id) then
  328. return true, GodConst.EquipStatus.UP
  329. end
  330. end
  331. else
  332. --未穿座印
  333. return true, GodConst.EquipStatus.Wear
  334. end
  335. return false
  336. end
  337. --判断背包里是否有这些座印,要求是品质小于等于传入的color
  338. function GodModel:HasExistInSoulListByMaxColor( color, list, suit_id )
  339. for k,v in pairs(list or {}) do
  340. local v_suit_id = self:GetEquipSuit(v.type_id)
  341. --只找相同套装的
  342. if v_suit_id == suit_id then
  343. if v.color and v.color <= color then
  344. return true
  345. end
  346. end
  347. end
  348. return false
  349. end
  350. function GodModel:IsEquipFullLv( equip_info )
  351. if not equip_info then return false end
  352. local curLv = GoodsModel:getInstance():GetOtherDataById(equip_info,GodConst.EquipStrenId) or 0
  353. local maxLv = self:GetEquipMaxLv(equip_info.type_id)
  354. return curLv >= maxLv
  355. end
  356. --从列表中找到最大的座印星数
  357. function GodModel:GetMaxColorInSoulList( list, suit_id )
  358. local result = 0
  359. local out_equip = nil
  360. local max_stage = 0
  361. for k,v in pairs(list or {}) do
  362. local v_suit_id = self:GetEquipSuit(v.type_id)
  363. --只找相同套装的
  364. if v_suit_id == suit_id then
  365. local stage = GoodsModel:getInstance():GetOtherDataById(v,GodConst.EquipStrenId) or 0
  366. stage = tonumber(stage)
  367. if v.color > result or (v.color==result and stage>max_stage) then
  368. result = v.color
  369. max_stage = stage
  370. out_equip = v
  371. end
  372. end
  373. end
  374. return result, out_equip
  375. end
  376. --获取在某星某级的情况下,增加某经验值可以让它提升到哪级哪经验
  377. function GodModel:GetNextEquipLvAndExp( soul_star, soul_lv, soul_exp, add_exp, max_lv )
  378. local sum_add_exp = add_exp+soul_exp
  379. local next_lv = soul_lv
  380. local next_exp = 0
  381. while sum_add_exp > 0 do
  382. local up_lv_need_exp = self:GetEquipUpLvNeedExp(soul_star, next_lv)
  383. if up_lv_need_exp <= 0 then
  384. break
  385. end
  386. local left_exp = sum_add_exp - up_lv_need_exp
  387. if left_exp >= 0 then
  388. --剩余经验够升级
  389. sum_add_exp = left_exp
  390. next_lv = next_lv + 1
  391. else
  392. --所剩经验不够升级
  393. break
  394. end
  395. if next_lv >= max_lv then
  396. break
  397. end
  398. end
  399. return next_lv, sum_add_exp
  400. end
  401. --获取座印升级所需经验
  402. function GodModel:GetEquipUpLvNeedExp( soul_star, cur_soul_lv )
  403. if not soul_star or not cur_soul_lv then return 0 end
  404. local max_lv = soul_star and self.god_soul_epx_max_lv[soul_star] or 0
  405. local next_lv = cur_soul_lv + 1
  406. if next_lv > max_lv then
  407. next_lv = max_lv
  408. end
  409. local lv_cfg = Config.Godequip[soul_star.."@"..next_lv]
  410. return lv_cfg and lv_cfg.exp or 0
  411. end
  412. function GodModel:GetEquipMaxLv( equip_type_id )
  413. local goods_vo = GoodsModel:getInstance():GetGoodsBasicByTypeId(equip_type_id)
  414. local color = goods_vo and goods_vo.color
  415. local max_lv = color and self.god_soul_epx_max_lv[color] or 0
  416. return max_lv
  417. end
  418. --获取神灵激活了哪些套装
  419. function GodModel:GetGodActivedSuit( god_id )
  420. local equip_list = self:GetGodEquipList(god_id)
  421. local suit_map = {}
  422. for k,v in pairs(equip_list or {}) do
  423. local suit_id = self:GetEquipSuit(v.type_id)
  424. suit_map[suit_id] = suit_map[suit_id] or 0
  425. suit_map[suit_id] = suit_map[suit_id] + 1
  426. end
  427. local result = {}
  428. for k,v in pairs(suit_map) do
  429. local suit_cfg = self.god_suit_cfg[k]
  430. for ii,vv in ipairs(suit_cfg or {}) do
  431. if v >= vv.equip_num then
  432. local ac_item = DeepCopy(vv)
  433. ac_item.god_id = god_id
  434. table.insert(result, ac_item)
  435. end
  436. end
  437. end
  438. return result
  439. end
  440. --获取座印属于哪个套装
  441. function GodModel:GetEquipSuit( equip_type_id )
  442. if not equip_type_id then return 0 end
  443. local cfg = Config.Godequipmanual[equip_type_id]
  444. return cfg and cfg.suit_id or 0
  445. end
  446. function GodModel:GetEquipTagId( equip_type_id )
  447. if not equip_type_id then return 1 end
  448. local cfg = Config.Godequipmanual[equip_type_id]
  449. local suit_id = cfg and cfg.suit_id or 1
  450. for k,v in pairs(Config.Godequipsuit) do
  451. if v.suit_id == suit_id then
  452. return v.type
  453. end
  454. end
  455. return 1
  456. end
  457. --获取自己某神灵的座印属性
  458. function GodModel:GetMyGodEquipAttr( god_id )
  459. local equip_list = self.god_equips and self.god_equips[god_id]
  460. local result = {}
  461. for k,v in pairs(equip_list or {}) do
  462. local stage = GoodsModel:getInstance():GetOtherDataById(v,GodConst.EquipStrenId) or 0
  463. local addition_attrlist = self:GetEquipSpAttrByVo( v )
  464. local attr_list = self:GetEquipAttr(v.type_id, stage, addition_attrlist)
  465. CombineAttrList(result, attr_list)
  466. end
  467. return result
  468. end
  469. --计算获得装备特殊属性实际加成
  470. function GodModel:GetEquipSpAttrByVo( goods_vo )
  471. if not goods_vo then return {} end
  472. local base_addition_attrlist = GoodsModel:getInstance():GetOtherDataById(goods_vo, GodConst.EquipSPAttrId) or {}
  473. base_addition_attrlist = stringtotable(base_addition_attrlist)
  474. local stage = GoodsModel:getInstance():GetOtherDataById(goods_vo,GodConst.EquipStrenId) or 0
  475. for k,v in pairs(base_addition_attrlist) do
  476. base_addition_attrlist[k][2] = math.max( math.floor(stage/5) - 1 , 0 ) * v[3] + v[2]
  477. end
  478. return base_addition_attrlist
  479. end
  480. --获取座印属性列表
  481. function GodModel:GetEquipAttr( equip_type_id, lv, addition_attr )
  482. if not equip_type_id then return {} end
  483. local result = {}
  484. local equip_cfg = Config.Godequipmanual[equip_type_id]
  485. local attr = equip_cfg and equip_cfg.attr or {}
  486. local attr_list = stringtotable(attr)
  487. --加上额外属性
  488. if addition_attr then
  489. if type(addition_attr) == "string" then
  490. addition_attr = stringtotable(addition_attr)
  491. end
  492. local addition_attr_new = {}
  493. for k,v in pairs(addition_attr) do
  494. table.insert(addition_attr_new, {v.attr_type or v[1], v.attr_value or v[2]})
  495. end
  496. CombineAttrList(attr_list, addition_attr_new)
  497. end
  498. for k,v in pairs(attr_list) do
  499. v[2] = v[2]+(lv or 0)*(v[3] or 0)
  500. end
  501. return attr_list
  502. end
  503. function GodModel:CombineAttrTwo( data )
  504. local temp = {}
  505. local index = 1
  506. for i,v in ipairs(data) do
  507. index = math.ceil( i/2 )
  508. temp[index] = temp[index] or {}
  509. temp[index][i%2 == 1 and 1 or 2] = v
  510. end
  511. return temp
  512. end
  513. --获取神灵技能信息列表,包含技能等级的
  514. function GodModel:GetGodSkillInfoList( god_id )
  515. local info = self:GetGodInfoById(god_id)
  516. return info.skill or {}
  517. end
  518. --获取某神某技能的等级
  519. function GodModel:GetGodSkillLv( god_id, skill_id )
  520. if not god_id or not skill_id then return 0 end
  521. local info = self:GetGodInfoById(god_id)
  522. for k,v in pairs(info.skill or {}) do
  523. if v.skill_id == skill_id then
  524. return v.skill_lv
  525. end
  526. end
  527. return 0
  528. end
  529. --获取神座升级所需要经验
  530. function GodModel:GetMaxExp( god_id, lv )
  531. lv = lv or 0
  532. local lv_cfg = Config.Godlv[god_id.."@"..lv+1]
  533. local result = lv_cfg and lv_cfg.exp or 0
  534. return result
  535. end
  536. function GodModel:GetGodUpLvCostCfg( )
  537. if not self.up_lv_cost_cfg then
  538. local data = stringtotable(Config.Godkv["lv_up_goods"].value_content)
  539. local function sort_call( a,b )
  540. return a[2] < b[2]
  541. end
  542. table.sort( data, sort_call )
  543. self.up_lv_cost_cfg = {}
  544. for i=1,3 do
  545. self.up_lv_cost_cfg[i] = data[i][1]
  546. end
  547. end
  548. return self.up_lv_cost_cfg
  549. end
  550. --获取某神的基础属性
  551. function GodModel:GetGodBaseAttr( god_id, lv, star )
  552. if not god_id or not lv or not star then return {} end
  553. local cfg = Config.God[god_id.."@"..star]
  554. local result = {}
  555. if cfg then
  556. result = stringtotable(cfg.attr)
  557. for k,v in pairs(result) do
  558. v[2] = v[2]+(lv-1)*v[3]
  559. end
  560. end
  561. return result
  562. end
  563. --神灵有额外的属性,ignore_suit_effect:是否忽略套装效果
  564. function GodModel:GetGodAdditionAttr( god_id, lv, star, ignore_suit_effect, role_info )
  565. role_info = role_info or RoleManager.Instance.mainRoleInfo
  566. if not god_id or not lv or not star then return {} end
  567. local cfg = Config.God[god_id.."@"..star]
  568. local result = {}
  569. if cfg then
  570. result = stringtotable(cfg.god_attr)
  571. for k,v in pairs(result) do
  572. v[2] = v[2]+(lv-1)*v[3]
  573. end
  574. for k,v in pairs(result) do
  575. if v[1] == 2 then
  576. v.attr_str = "神血"
  577. if not ignore_suit_effect then
  578. local isActivedSuitEffect = self:IsActivedSuitEffect(god_id, GodConst.SuitEffect.AddGodBlood, 2)
  579. if isActivedSuitEffect then
  580. v[2] = v[2] * stringtotable(Config.Godequipsuit["3@4"].effect)[1][2]
  581. end
  582. end
  583. v[2] = v[2]+(role_info.maxHp or 0)*0.20
  584. elseif v[1] == 1 then
  585. v.attr_str = "神攻"
  586. if not ignore_suit_effect then
  587. local isActivedSuitEffect = self:IsActivedSuitEffect(god_id, GodConst.SuitEffect.AddGodAttack, 2)
  588. if isActivedSuitEffect then
  589. v[2] = v[2] * stringtotable(Config.Godequipsuit["1@4"].effect)[1][2]
  590. end
  591. end
  592. v[2] = v[2]+role_info.att
  593. elseif v[1] == 4 then
  594. v.attr_str = "神防"
  595. if not ignore_suit_effect then
  596. local isActivedSuitEffect = self:IsActivedSuitEffect(god_id, GodConst.SuitEffect.AddGodDefend, 2)
  597. if isActivedSuitEffect then
  598. v[2] = v[2] * stringtotable(Config.Godequipsuit["2@4"].effect)[1][2]
  599. end
  600. end
  601. v[2] = v[2]+role_info.def
  602. end
  603. end
  604. end
  605. return result
  606. end
  607. --是否激活了某套装的特殊技能
  608. function GodModel:IsActivedSuitEffect( god_id, suit_id, suit_lv, ignore_guard )
  609. local isFightGod = self:IsGodGoFighted(god_id)
  610. local isGuard = self:IsGuardGod(god_id)
  611. if not isFightGod and not isGuard then
  612. --没上阵或不是神仆的话就不算
  613. return false
  614. end
  615. local isActived = false
  616. local equip_list = self:GetGodEquipList(god_id)
  617. local progress = self:GetSuitProgress(suit_id, equip_list)
  618. --suit_lv代表套装等级,1代表2件套,2代表4件套装
  619. suit_lv = suit_lv or #progress
  620. if progress and progress[suit_lv] then
  621. isActived = progress[suit_lv].had_actived
  622. end
  623. if not ignore_guard and isFightGod and not isActived then
  624. --是主神而且自己没激活的话就看看神仆有没有激活
  625. for i=1,GodConst.MaxGuardNum do
  626. local guard = self:GetGuardInfoByID(god_id, i)
  627. if guard then
  628. local isGuardActive = self:IsActivedSuitEffect(guard.guard_id, suit_id, suit_lv)
  629. if isGuardActive then
  630. --神仆激活了二件套
  631. isActived = true
  632. break
  633. end
  634. end
  635. end
  636. end
  637. return isActived
  638. end
  639. function GodModel:IsGodGoFighted( god_id )
  640. local god_info = self:GetGodInfoById(god_id)
  641. return god_info and self:IsFightPos(god_info.pos) or false
  642. end
  643. function GodModel:IsFightPos( pos )
  644. return pos~=0 and pos < GodConst.GuardStartPos
  645. end
  646. function GodModel:IsGuardGod( god_id )
  647. local god_info = self:GetGodInfoById(god_id)
  648. return god_info and self:IsGuardPos(god_info.pos) or false
  649. end
  650. function GodModel:IsGuardPos( pos )
  651. return pos >= GodConst.GuardStartPos
  652. end
  653. --获取座印包含的总经验值
  654. function GodModel:GetEquipSumExp( soul_id, soul_lv, exp, color )
  655. if not soul_id or not soul_lv or not exp then return 0 end
  656. local base_exp = Config.Godequipmanual[soul_id].exp
  657. if self.god_soul_sum_exp_map[color] and self.god_soul_sum_exp_map[color][soul_lv] then
  658. local sum_exp = self.god_soul_sum_exp_map[color][soul_lv]
  659. return (sum_exp+base_exp)+exp
  660. end
  661. return 0
  662. end
  663. --获取神灵某套装的激活进度,即返回该套装的三个激活条件,并标明已激活和未激活
  664. function GodModel:GetSuitProgress( suit_id, equip_list )
  665. if not suit_id then return {} end
  666. local has_soul_num = 0
  667. for k,v in pairs(equip_list or {}) do
  668. local v_suit_id = self:GetEquipSuit(v.type_id)
  669. if v_suit_id == suit_id then
  670. has_soul_num = has_soul_num + 1
  671. end
  672. end
  673. local suit_cfg = self.god_suit_cfg[suit_id]
  674. local result = suit_cfg and DeepCopy(suit_cfg) or {}
  675. for k,v in pairs(result) do
  676. v.had_actived = has_soul_num >= v.equip_num
  677. end
  678. return result
  679. end
  680. function GodModel:GetGuardInfo( )
  681. return self.guard_info
  682. end
  683. function GodModel:UpdateGuardInfo( god_list )
  684. local guard_info = {}
  685. for k,v in pairs(god_list) do
  686. if self:IsGuardPos(v.pos) then
  687. local fight_slot = self:GetFightSlotByPos(v.pos)
  688. local guard_slot = self:GetGuardPos(v.pos)
  689. local guard_id = v.id
  690. local guard_item_info = {}
  691. guard_item_info.guard_state = GodConst.GuardState.Guarding
  692. guard_item_info.guard_slot = guard_slot
  693. guard_item_info.guard_id = guard_id
  694. guard_info[fight_slot] = guard_info[fight_slot] or {}
  695. guard_info[fight_slot][guard_slot] = guard_item_info
  696. end
  697. end
  698. self.guard_info = guard_info
  699. end
  700. function GodModel:GetGuardPos( pos )
  701. if self:IsFightPos(pos) then
  702. return 0
  703. else
  704. return pos and pos%100 or 1
  705. end
  706. end
  707. function GodModel:GetGuardInfoByID( god_id, guard_slot)
  708. local fight_slot = self:GetGodFightSlot(god_id)
  709. if fight_slot > 0 then
  710. local data = self:GetGuardInfoBySlot(fight_slot, guard_slot)
  711. return data
  712. end
  713. return nil
  714. end
  715. --获取某战位的护法信息
  716. function GodModel:GetGuardInfoBySlot( fight_slot, guard_slot )
  717. if not fight_slot or not guard_slot or not self.guard_info then return end
  718. return self.guard_info[fight_slot] and self.guard_info[fight_slot][guard_slot] or {}
  719. end
  720. function GodModel:GetGodFightSlot( god_id )
  721. local god_info = self:GetGodInfoById(god_id)
  722. return god_info and self:GetFightSlotByPos(god_info.pos) or 0
  723. end
  724. --神座的出战位如果大于100的话说明是护佑战位,其百份位是护佑的主战位id,个位就是1,2号护佑位
  725. function GodModel:GetFightSlotByPos( pos )
  726. if self:IsFightPos(pos) then
  727. return pos
  728. else
  729. return pos and math.floor(pos/100) or 0
  730. end
  731. end
  732. --获取神灵激活的收集进度
  733. function GodModel:GetGodUpStarProgress( god_id, star, limit_to_condition )
  734. if not god_id or not star then return 0, 0, 0 end
  735. local next_star = star and (star + 1)
  736. if not next_star then return 0, 0, 0 end
  737. local cost_info = Config.God[god_id.."@"..next_star]
  738. cost_info = cost_info and stringtotable(cost_info.cost)
  739. if cost_info then
  740. --只要魂魄的进度
  741. local condition = 0
  742. local cur_pro = 0
  743. local cost_id = 0
  744. for k,v in pairs(cost_info) do
  745. local t_condition = v[3]
  746. condition = condition + t_condition
  747. local t_cost_id = v[2]
  748. local goods_num = GoodsModel:getInstance():GetTypeGoodsNum(t_cost_id)
  749. if limit_to_condition and goods_num > t_condition then
  750. goods_num = t_condition
  751. end
  752. cur_pro = cur_pro + goods_num
  753. if k == 1 then
  754. cost_id = t_cost_id
  755. end
  756. end
  757. return cur_pro, condition, cost_id
  758. end
  759. return 0, 0, 0
  760. end
  761. function GodModel:IsMaxStar( god_id, star )
  762. if not god_id or not star then return false end
  763. return Config.God[god_id.."@"..star+1]==nil and Config.God[god_id.."@"..star]~=nil
  764. end
  765. --获取神座的战力,如果已经激活的话就返回后端发过来的值,没有激活则计算初始战力
  766. function GodModel:GetMyGodPowerFromServerOrCFG( god_id )
  767. if not god_id then return 0 end
  768. local god_info = self:GetGodInfoById(god_id)
  769. if god_info then
  770. if god_info.power and god_info.power~=0 then
  771. return god_info.power
  772. else
  773. --有些战力后端算不了就会发0过来,这时就前端自己算
  774. return self:GetMyGodPower(god_id)
  775. end
  776. end
  777. return self:GetGodPower(god_id, 1, self:GetGodFirstStar(god_id), self:GetGodFirstSkillList(god_id))
  778. end
  779. --获取神灵激活的初始星数
  780. function GodModel:GetGodFirstStar( god_id )
  781. return self.god_cfg_map[god_id] and self.god_cfg_map[god_id].star or 0
  782. end
  783. function GodModel:GetGodFirstSkillList( god_id )
  784. local skill_cfg_list = self:GetGodSkillList(god_id)
  785. local skill_list = {}
  786. for i,v in ipairs(skill_cfg_list or {}) do
  787. table.insert(skill_list, {skill_id=v, skill_lv=1})
  788. end
  789. return skill_list
  790. end
  791. --获取神灵技能列表,静态的
  792. function GodModel:GetGodSkillList( god_id )
  793. local cfg = self.god_cfg_map[god_id]
  794. if not cfg then return {} end
  795. return cfg.skill
  796. end
  797. function GodModel:GetMyGodPower( god_id, is_show_skill_power )
  798. if is_show_skill_power==nil then
  799. is_show_skill_power = true
  800. end
  801. if not god_id then return 0 end
  802. local god_info = self:GetGodInfoById(god_id)
  803. if not god_info then return 0 end
  804. local skill_list = nil
  805. if is_show_skill_power then
  806. skill_list = self:GetGodSkillInfoList(god_id)
  807. end
  808. local equip_attr_list = self:GetMyGodEquipAttr(god_id)
  809. return self:GetGodPower(god_id, god_info.lv, god_info.star, skill_list, equip_attr_list)
  810. end
  811. --获取神座战力
  812. function GodModel:GetGodPower( god_id, lv, star, skill_list, equip_attr_list, role_info )
  813. local attr_list = self:GetGodBaseAttr(god_id, lv, star)
  814. local attr_power = GetFighting(attr_list)
  815. local addition_attr_list = self:GetGodAdditionAttr(god_id, lv, star, false, role_info)
  816. local addition_attr_power = self:GetGoFightPower(addition_attr_list)
  817. local skill_power = self:GetGodSkillPower(skill_list)
  818. local equip_power = 0
  819. if equip_attr_list then
  820. equip_power = GetFighting(equip_attr_list)
  821. end
  822. return attr_power+addition_attr_power+skill_power+equip_power
  823. end
  824. function GodModel:GetGoFightPower( god_go_fight_attr_list )
  825. local attr_factor = {
  826. [1]=0.1, [2]=0.01, [4]=0.1
  827. }
  828. local power = 0
  829. for k,v in pairs(god_go_fight_attr_list) do
  830. power = power + attr_factor[v[1]]*v[2]
  831. end
  832. return round(power)
  833. end
  834. function GodModel:GetGodSkillPower( skill_list )
  835. if not skill_list then return 0 end
  836. local power = 0
  837. for k,v in pairs(skill_list) do
  838. local _,temp_num = GetSkillAttrBySkill( v.skill_id, v.skill_lv, true ,true)
  839. power = power + temp_num
  840. end
  841. return power
  842. end
  843. function GodModel:GetEquipPower( equip_id, equip_lv, addition_attr )
  844. local attr_list = self:GetEquipAttr(equip_id, equip_lv, addition_attr)
  845. for k,v in pairs(attr_list) do
  846. v[3] = nil
  847. end
  848. return GetFighting(attr_list)
  849. end
  850. --获取某槽孔出战的神灵
  851. function GodModel:GetGoFightGod( fight_slot )
  852. local data = self.god_base_data and self.god_base_data.list or {}
  853. for k,v in pairs(data) do
  854. if v.pos == fight_slot then
  855. return v
  856. end
  857. end
  858. return nil
  859. end
  860. function GodModel:GetGodList( )
  861. return self.god_base_data and self.god_base_data.list or {}
  862. end
  863. --获取出战列表
  864. function GodModel:GetGoFightGodList( ignore_sort )
  865. local result = {}
  866. local data = self.god_base_data and self.god_base_data.list or {}
  867. for k,v in pairs(data) do
  868. if self:IsFightPos(v.pos) then
  869. table.insert(result, v)
  870. end
  871. end
  872. if not ignore_sort then
  873. local sort_func = function ( a, b )
  874. return a.pos < b.pos
  875. end
  876. table.sort(result, sort_func)
  877. end
  878. return result
  879. end
  880. --获取更小的空阵位
  881. function GodModel:GetSmallerEmptyPos( pos )
  882. local pos_empty_state = {true,true,true,true,true}--true为
  883. local data = self.god_base_data and self.god_base_data.list or {}
  884. for k,v in pairs(data) do
  885. if v.pos ~= 0 and v.pos < GodConst.GuardStartPos then
  886. --该主阵位不为空
  887. pos_empty_state[v.pos] = false
  888. end
  889. end
  890. for i=1,pos do
  891. if pos_empty_state[i] then
  892. return i
  893. end
  894. end
  895. return pos
  896. end
  897. --返回最多可出战多少神灵
  898. function GodModel:GetMaxGoFightGodNum( )
  899. local result = 3--前三个阵位是默认开启的
  900. if self:HasFightSlot4Unlock() then
  901. result = result + 1
  902. end
  903. if self:HasFightSlot5Unlock() then
  904. result = result + 1
  905. end
  906. return result
  907. end
  908. function GodModel:HasFightSlot4Unlock( )
  909. local data = self.god_base_data and self.god_base_data.list or {}
  910. for k,v in pairs(data) do
  911. local isActivedSuitEffect = self:IsActivedSuitEffect(v.id, GodConst.SuitEffect.AddGodGoFightPos)
  912. if isActivedSuitEffect then
  913. return true
  914. end
  915. end
  916. return false
  917. end
  918. function GodModel:HasFightSlot5Unlock( )
  919. if not self:IsSlotUnlock(5) then
  920. return false
  921. end
  922. return self:HasActiveFightSlot5Suit()
  923. end
  924. --是否满足开启阵位5的套装条件
  925. function GodModel:HasActiveFightSlot5Suit( )
  926. local hasActiveNum = 0
  927. for k,v in pairs(self:GetGodList()) do
  928. local isActivedSuitEffect = self:IsActivedSuitEffect(v.id, GodConst.SuitEffect.AddGodGoFightPos, 2, true)
  929. if isActivedSuitEffect then
  930. hasActiveNum = hasActiveNum + 1
  931. if hasActiveNum >= 2 then
  932. --需要任意两只神激活了四件套
  933. return true
  934. end
  935. end
  936. end
  937. return false
  938. end
  939. --注意此解锁信息仅仅代表花钱买了,真正的解锁还需要多一个条件的
  940. function GodModel:IsSlotUnlock( fight_slot )
  941. for k,v in pairs(self.slot_unlock_info or {}) do
  942. if v.pos == fight_slot then
  943. return true
  944. end
  945. end
  946. return false
  947. end
  948. function GodModel:SetSlotUnlockInfo( value )
  949. self.slot_unlock_info = value
  950. end
  951. --获取所有神灵的配置列表,图鉴有用到
  952. function GodModel:GetGodCfgListForBook( )
  953. return self.god_cfg_list_for_book
  954. end
  955. --神灵是否能激活
  956. function GodModel:IsGodCanActive( god_id )
  957. local god_info = self:GetGodInfoById( god_id )
  958. if god_info ~= nil then return false, "AlreadyActive" end
  959. local cur_pro, max_pro, cost_id = self:GetGodUpStarProgress(god_id, -1)
  960. return cur_pro >= max_pro, "NotEnoughCost", cost_id
  961. end
  962. function GodModel:GetSuitCfgList( )
  963. return self.god_suit_list_for_show or {}
  964. end
  965. function GodModel:GetGodName( god_id )
  966. return self.god_cfg_map[god_id] and Trim(self.god_cfg_map[god_id].name) or "未知神座"
  967. end
  968. function GodModel:GetRealPos( fight_slot, guard_slot )
  969. return fight_slot*100+guard_slot
  970. end
  971. --获取神座护佑时只算的属性百分比,默认是50%,激活套装有加成
  972. function GodModel:GetGuardAttrPercent( god_id )
  973. local percent = 0.5
  974. if self:IsActivedSuitEffect(god_id, GodConst.SuitEffect.AddGuardAttrPercent, 2, true) then
  975. percent = 0.8
  976. elseif self:IsActivedSuitEffect(god_id, GodConst.SuitEffect.AddGuardAttrPercent, 1, true) then
  977. percent = 0.6
  978. end
  979. return percent
  980. end
  981. function GodModel:GetTagResByGodId( god_id )
  982. local conf = self.god_cfg_map[god_id]
  983. local id = conf and conf.type or 1
  984. return GodConst.TagRes[id] and GodConst.TagRes[id] or GodConst.TagRes[1]
  985. end
  986. function GodModel:GetGodShowModelResID( god_id )
  987. -- do return 1001 end
  988. -------------------------
  989. local cfg = self.god_cfg_map[god_id]
  990. if cfg then
  991. if cfg.picture_id > 1005 or cfg.picture_id < 1000 then
  992. print('=======Msh:GodModel.lua[1088] =====缺失神座模型ID==', god_id)
  993. return 1000
  994. end
  995. return cfg.picture_id
  996. end
  997. return 0
  998. end
  999. function GodModel:GetGodPos( god_id )
  1000. local data = self:GetGodInfoById(god_id)
  1001. return data and data.pos or 0
  1002. end
  1003. function GodModel:GetSuitDesByInfo( des_1,des_2,is_active,str_tem )
  1004. str_tem = str_tem or ""
  1005. des_1 = des_1 or ""
  1006. des_2 = des_2 or ""
  1007. if is_active then
  1008. des_1 = HtmlColorTxt( Trim(des_1) , '#2cf86f') .. str_tem
  1009. return des_1 .. Trim(des_2) --HtmlColorTxt( des_1 .. Trim(des_2) , '#40465a')
  1010. else
  1011. -- string.gsub( des_2, findString, replaceString, replaceTime )
  1012. return HtmlColorTxt( Trim(des_1) .. str_tem .. Trim(des_2) , '#8b8b8b')
  1013. end
  1014. end
  1015. -------------------------
  1016. --神灵系统各标签是否需要红点
  1017. function GodModel:IsNeedRed( tab_id )
  1018. if not tab_id then return false end
  1019. if tab_id == GodConst.TabID.Info then
  1020. return self:IsNeedRedInfo()
  1021. elseif tab_id == GodConst.TabID.GoFight then
  1022. return self:IsNeedRedGoFight()
  1023. elseif tab_id == GodConst.TabID.Book then
  1024. return self:IsNeedRedBook() or self:IsNeedResSuitBook()
  1025. elseif tab_id == GodConst.TabID.Activity then
  1026. --宠物生活技能 每日免费抽奖一次
  1027. local left_free_draw_times = self:GetGodLeftFreeDrawTimes()
  1028. local free_red = left_free_draw_times > 0
  1029. local num = GoodsModel:getInstance():GetTypeGoodsNum(self.acitvity_cost_id)
  1030. return num>0 or self:IsActivityCommonRed() or self:IsActivityLimitRed() or free_red
  1031. elseif tab_id == GodConst.TabID.Equip then
  1032. --有座印可以穿或替换
  1033. return self:UpdateIsAllGodEquipBest()
  1034. end
  1035. return false
  1036. end
  1037. function GodModel:IsActivityCommonRed( )
  1038. local base_data = self:GetActivityCommonInfo()
  1039. if not base_data then return false end
  1040. for k,v in pairs(base_data.bless_award) do
  1041. if v.state == 1 then
  1042. return true
  1043. end
  1044. end
  1045. return false
  1046. end
  1047. function GodModel:IsActivityLimitRed( )
  1048. local base_data = self:GetActivityLimitInfo()
  1049. if not base_data then return false end
  1050. for k,v in pairs(base_data.bless_award) do
  1051. if v.state == 1 then
  1052. return true
  1053. end
  1054. end
  1055. return false
  1056. end
  1057. --神灵信息标签是否需要红点
  1058. function GodModel:IsNeedRedInfo( )
  1059. for k,v in pairs(self:GetGodList() or {}) do
  1060. if self:IsNeedRedInfoByGod(v.id) then
  1061. return true
  1062. end
  1063. end
  1064. return false
  1065. end
  1066. --神灵是否需要红点
  1067. function GodModel:IsNeedRedInfoByGod( god_id )
  1068. if self:IsGodCanUpLv(god_id) then
  1069. --可以升级
  1070. return true
  1071. end
  1072. if self:IsGodCanUpStar(god_id) then
  1073. --可以升星
  1074. return true
  1075. end
  1076. if self:IsGodAnySkillCanUpdate(god_id) then
  1077. --可以升技能
  1078. return true
  1079. end
  1080. return false
  1081. end
  1082. --神灵是否能升级,够升下经验也会返回真,不一定要够升一级的
  1083. function GodModel:IsGodCanUpLv( god_id )
  1084. if self:IsGodFullLv(god_id) then
  1085. return false
  1086. end
  1087. local lv = self:GetGodLv(god_id)
  1088. local up_lv_cost = self:GetGodUpLvCostCfg(god_id, lv)
  1089. for k,v in pairs(up_lv_cost or {}) do
  1090. local goods_num = GoodsModel:getInstance():GetTypeGoodsNum(v)
  1091. if goods_num >= 1 then
  1092. return true
  1093. end
  1094. end
  1095. return false
  1096. end
  1097. --神灵是否能升星
  1098. function GodModel:IsGodCanUpStar( god_id )
  1099. local star = self:GetGodStar(god_id)
  1100. if self:IsMaxStar(god_id, star) then
  1101. return false,"MaxStar"
  1102. end
  1103. local next_star = self:GetGodNextStar(god_id, star, true)
  1104. if not next_star then return false end
  1105. local need_lv = self:GetGodStarNeedLv(god_id, next_star)
  1106. if self:GetGodLv(god_id) < need_lv then
  1107. --升星需要达到某个等级条件才行的
  1108. return false, "LvNoEnough", need_lv
  1109. end
  1110. local cur_pro, max_pro = self:GetGodUpStarProgress(god_id, star)
  1111. return cur_pro>=max_pro, "CostGoodsNum"
  1112. end
  1113. function GodModel:GetGodStar( god_id )
  1114. local info = self:GetGodInfoById(god_id) or {}
  1115. return info and info.star or 0
  1116. end
  1117. function GodModel:GetGodNextStar( god_id, star, return_nil_when_max )
  1118. local next_star = star and (star + 1) or 0
  1119. -- if star and star == 0 then
  1120. -- --传入星数是0的话要帮它转为对应神灵的起始星数
  1121. -- next_star = self:GetGodFirstStar(god_id)
  1122. -- end
  1123. local is_max = self:IsMaxStar(god_id, star)
  1124. if not is_max or not return_nil_when_max then
  1125. return next_star
  1126. end
  1127. return nil
  1128. end
  1129. --获取某神灵到达某星需要多少等级
  1130. function GodModel:GetGodStarNeedLv( god_id, star )
  1131. if not god_id or not star or not Config.God or not Config.God[god_id.."@"..star] then return 0 end
  1132. return Config.God[god_id.."@"..star].need_lv
  1133. end
  1134. --某神是否有技能可升级
  1135. function GodModel:IsGodAnySkillCanUpdate( god_id )
  1136. if not god_id then return false end
  1137. local info = self:GetGodInfoById(god_id) or {}
  1138. for k,v in pairs(info.skill or {}) do
  1139. if self:IsGodSkillCanUpdate(god_id, v.skill_id) then
  1140. return true
  1141. end
  1142. end
  1143. return false
  1144. end
  1145. --神灵的技能是否能升级
  1146. function GodModel:IsGodSkillCanUpdate( god_id, skill_id )
  1147. if self:IsGodSkillMaxLv(god_id, skill_id) then
  1148. return false
  1149. end
  1150. if not self.skill_cost_goods_type_id then
  1151. self.skill_cost_goods_type_id = stringtotable(Config.Godkv["skill_up_cost"].value_content)[1][2]
  1152. end
  1153. local goods_num = GoodsModel.getInstance():GetTypeGoodsNum(self.skill_cost_goods_type_id)
  1154. return goods_num > 0
  1155. end
  1156. --技能是否已满级
  1157. function GodModel:IsGodSkillMaxLv( god_id, skill_id )
  1158. local star = self:GetGodStar(god_id)
  1159. star = star or 1
  1160. local skill_lv_cfg = Config.God[god_id.."@"..star]
  1161. local cur_lv = self:GetGodSkillLv(god_id, skill_id)
  1162. if skill_lv_cfg then
  1163. return cur_lv >= (skill_lv_cfg.skill_max or 0)
  1164. else
  1165. if Config.God[god_id.."@5"] then
  1166. --找不到配置的话先固定找5星的,但出了6星配置的话这里就提示下前端要修改
  1167. Message.show("增加了神灵技能的等级限制配置啦!")
  1168. end
  1169. skill_lv_cfg = Config.God[god_id.."@5"] or {}
  1170. return cur_lv >= (skill_lv_cfg.skill_max or 0)
  1171. end
  1172. return false
  1173. end
  1174. --神灵系统是否需要红点
  1175. function GodModel:IsNeedRedAll( )
  1176. for k,v in pairs(GodConst.TabID) do
  1177. if self:IsNeedRed(v) then
  1178. return true
  1179. end
  1180. end
  1181. return false
  1182. end
  1183. --出战标签是否需要红点
  1184. function GodModel:IsNeedRedGoFight( )
  1185. if not self:HasAnyUnFightGod() then
  1186. --没有任何可上阵的神灵
  1187. return false
  1188. end
  1189. for i=1,GodConst.MaxFightNum do
  1190. if self:IsFightSlotCanGo(i, true) then
  1191. return true
  1192. end
  1193. end
  1194. return false
  1195. end
  1196. --是否有神未出战
  1197. function GodModel:HasAnyUnFightGod( )
  1198. for k,v in pairs(self:GetGodList()) do
  1199. if v.pos == 0 or v.pos >= GodConst.GuardStartPos then
  1200. return true
  1201. end
  1202. end
  1203. return false
  1204. end
  1205. --ignore_judge_unfight_god已经判断过有未出战神灵了,就不用再判断了
  1206. function GodModel:IsFightSlotCanGo( fight_slot, ignore_judge_unfight_god )
  1207. if self:GetGoFightGod(fight_slot) ~= nil then
  1208. return false
  1209. end
  1210. if not ignore_judge_unfight_god then
  1211. if not self:HasAnyUnFightGod() then
  1212. --没有任何可上阵的神灵
  1213. return false
  1214. end
  1215. end
  1216. --前3个阵位是默认解锁的,后几个就要判断是否已经解锁过了
  1217. if fight_slot <= 3 then
  1218. return true
  1219. elseif fight_slot == 4 then
  1220. return self:HasFightSlot4Unlock()
  1221. elseif fight_slot == 5 then
  1222. return self:HasFightSlot5Unlock()
  1223. end
  1224. end
  1225. --图鉴是否需要红点
  1226. function GodModel:IsNeedRedBook( )
  1227. for k,v in pairs(self.god_cfg_map) do
  1228. if self:IsGodCanActive(v.id) then
  1229. return true
  1230. end
  1231. end
  1232. return false
  1233. end
  1234. function GodModel:IsNeedResSuitBook( )
  1235. local setting = CookieWrapper.Instance:GetCookie(CookieLevelType.Account, CookieKey.GOD_BOOK_SUIT_SHOW_REDID)
  1236. return not setting or setting~=1
  1237. end
  1238. function GodModel:SetShowedSuitBookRed( )
  1239. CookieWrapper.Instance:SaveCookie(CookieLevelType.Account, CookieTimeType.TYPE_ALWAYS, CookieKey.GOD_BOOK_SUIT_SHOW_REDID, 1)
  1240. CookieWrapper.Instance:WriteAll()
  1241. GodController.Instance:GodCheckRedDot()
  1242. end
  1243. --从背包里获取soul_pos部位最好的座印信息,包括每套装的最高星和最高级数
  1244. function GodModel:GetBestEquipInfoInBag( equip_pos, min_star )
  1245. local equip_list_in_bag = GoodsModel.getInstance():GetGodEquipListByPos(equip_pos)
  1246. local result = {}
  1247. for k,v in pairs(equip_list_in_bag or {}) do
  1248. local suit_id = self:GetEquipSuit(v.type_id)
  1249. result[suit_id] = result[suit_id] or {}
  1250. local star = v.color
  1251. if star >= min_star and (not result[suit_id].max_star or star >= result[suit_id].max_star) then
  1252. result[suit_id].max_star = star
  1253. result[suit_id].max_lv = result[suit_id].max_lv or {}
  1254. local stage_num = GoodsModel:getInstance():GetOtherDataById(v,GodConst.EquipStrenId) or 0
  1255. if not result[suit_id].max_lv[star] or stage_num > result[suit_id].max_lv[star] then
  1256. result[suit_id].max_lv[star] = stage_num
  1257. end
  1258. end
  1259. end
  1260. return result
  1261. end
  1262. function GodModel:ReqGoFightPos( pos, god_id )
  1263. --请求上阵,如果
  1264. pos = self:GetSmallerEmptyPos(pos)
  1265. local target_pos_god = self:GetGoFightGod(pos)
  1266. local is_new_pos_empty = target_pos_god==nil
  1267. if is_new_pos_empty then
  1268. --如果要上阵的是空阵位且该神原来的位置比新阵位靠前,那就不让上
  1269. local old_pos = self:GetGodPos(god_id)
  1270. if old_pos~=0 and old_pos<pos then
  1271. Message.show("只能按顺序上阵")
  1272. return
  1273. end
  1274. end
  1275. self:Fire(GodConst.REQ_INFO_FIGHT, pos, god_id)
  1276. end
  1277. --普通抽奖信息
  1278. function GodModel:GetActivityCommonInfo( )
  1279. return self.activity_common_info
  1280. -- local curTime = TimeUtil:getServerTime()
  1281. -- return self.activity_common_info or {
  1282. -- phase = 1,
  1283. -- begin_time = curTime,
  1284. -- end_time = curTime+86400*2,
  1285. -- blessing = 3,
  1286. -- bless_award = {
  1287. -- },
  1288. -- }
  1289. end
  1290. function GodModel:SetActivityCommonInfo( value )
  1291. self.activity_common_info = value
  1292. end
  1293. --限时抽奖信息
  1294. function GodModel:GetActivityLimitInfo( )
  1295. return self.activity_limit_Info
  1296. -- local curTime = TimeUtil:getServerTime()
  1297. -- return self.activity_limit_Info or {
  1298. -- phase = 1,
  1299. -- begin_time = curTime,
  1300. -- end_time = curTime+86400*2,
  1301. -- blessing = 3,
  1302. -- bless_award = {
  1303. -- },
  1304. -- counts = 0,
  1305. -- counts_award = {
  1306. -- },
  1307. -- }
  1308. end
  1309. function GodModel:SetActivityLimitInfo( value )
  1310. self.activity_limit_Info = value
  1311. end
  1312. function GodModel:GetLimitConfByPhase( phase )
  1313. if not self.activity_limit_conf then
  1314. self.activity_limit_conf = {}
  1315. for k,v in pairs(Config.Godlotteryphase) do
  1316. self.activity_limit_conf[v.phase] = v
  1317. end
  1318. end
  1319. return self.activity_limit_conf[phase]
  1320. end
  1321. function GodModel:GetCommonConfByPhase( phase )
  1322. self.activity_common_conf = false
  1323. if not self.activity_common_conf then
  1324. self.activity_common_conf = {}
  1325. for k,v in pairs(Config.Godnormalphase) do
  1326. self.activity_common_conf[v.phase] = v
  1327. end
  1328. end
  1329. return self.activity_common_conf[phase]
  1330. end
  1331. --上次变身的时间
  1332. function GodModel:GetBecomeGodTime( )
  1333. local curTime = TimeUtil:getServerTime()
  1334. return self.become_god_time or curTime
  1335. end
  1336. -- function GodModel:SetBecomeGodTime( value )
  1337. -- self.become_god_time = value
  1338. -- end
  1339. -- function GodModel:SetCanBecomeGodTime( time )
  1340. -- self.can_become_god_time = time
  1341. -- end
  1342. function GodModel:SetBecomeGodTime( time_list )
  1343. self.become_god_time_list = self.become_god_time_list or {}
  1344. if not time_list then return end
  1345. for k,v in pairs(time_list) do
  1346. self.become_god_time_list[v.pos] = v
  1347. self.become_god_time_list[v.pos].can_become_time = v.time + self:GetBecomeGodCD()
  1348. end
  1349. end
  1350. function GodModel:GetCanBecomeGodTimeByPos( pos )
  1351. if self.become_god_time_list and
  1352. self.become_god_time_list[pos] and
  1353. self.become_god_time_list[pos].can_become_time then
  1354. return self.become_god_time_list[pos].can_become_time
  1355. end
  1356. return 0
  1357. end
  1358. function GodModel:GetLastBecomeGodTimeByPos( pos )
  1359. if self.become_god_time_list and
  1360. self.become_god_time_list[pos] and
  1361. self.become_god_time_list[pos].time then
  1362. return self.become_god_time_list[pos].time
  1363. end
  1364. return 0
  1365. end
  1366. function GodModel:GetBecomeGodCD( )
  1367. local god_cd = Config.Godkv["god_summon_cd"] and Config.Godkv["god_summon_cd"].value_content or 300 --需要等5分钟才可以变身
  1368. if SceneManager.Instance:IsGodDungeon() then--唤神副本cd打折
  1369. local discounts = Trim(Config.Goddunkv["cd_decrease"].val)
  1370. god_cd = god_cd*discounts
  1371. end
  1372. return god_cd
  1373. end
  1374. function GodModel:GetBecomeGodProgress( )
  1375. if not self.can_become_god_time or not GetModuleIsOpen(173,1) or #self:GetGoFightGodList(true) == 0 then return 0, 0 end
  1376. local curTime = TimeUtil:getServerTime()
  1377. local left_time = self.can_become_god_time-curTime
  1378. local max_time = self:GetBecomeGodCD()
  1379. local pass_time = max_time - left_time--已经等了多久
  1380. if pass_time > max_time then
  1381. pass_time = max_time
  1382. end
  1383. if pass_time < 0 then
  1384. pass_time = 0
  1385. end
  1386. return pass_time, max_time
  1387. end
  1388. --神灵的持续时间
  1389. function GodModel:GetGodDuration( god_id )
  1390. local duration = Config.Godkv["god_summon_time"] and Config.Godkv["god_summon_time"].value_content or 20--初始就有20秒
  1391. local isActivedSuitEffect = self:IsActivedSuitEffect(god_id, GodConst.SuitEffect.AddGodLifeTime, 1, true)
  1392. if isActivedSuitEffect then
  1393. --本神激活了二件套
  1394. duration = duration+5
  1395. end
  1396. if self:IsActivedSuitEffectAddAllGodLifeTime() then
  1397. --上阵的某神激活了四件套
  1398. duration = duration+5
  1399. end
  1400. return duration
  1401. end
  1402. --是不是激活了4件套装
  1403. function GodModel:IsActivedSuitEffectAddAllGodLifeTime( )
  1404. local suit_lv = 2
  1405. for k,v in pairs(self:GetGodList()) do
  1406. --任意一位神灵激活4件套装的话,所有神灵都可以加成时间
  1407. local isActivedSuitEffect = self:IsActivedSuitEffect(v.id, GodConst.SuitEffect.AddGodLifeTime, suit_lv)
  1408. if isActivedSuitEffect then
  1409. return true
  1410. end
  1411. end
  1412. return false
  1413. end
  1414. function GodModel:GetOpenTask( sub_id,is_fade_show )
  1415. self.open_task = self.open_task or {}
  1416. local index = is_fade_show and 1 or 2
  1417. if not self.open_task[index] then
  1418. self.open_task[index] = 0
  1419. sub_id = sub_id
  1420. local _, base_conf = GetModuleOpenLevel( 173,sub_id,is_fade_show)
  1421. if is_fade_show and base_conf and base_conf.icon_task and base_conf.icon_task ~= 0 then
  1422. self.open_task[index] = base_conf.icon_task
  1423. else
  1424. self.open_task[index] = base_conf and base_conf.task_id or 0
  1425. end
  1426. end
  1427. return self.open_task[index]
  1428. end
  1429. --获得座印套装名字列表
  1430. function GodModel:GetSuitTypeNameList( )
  1431. if not self.suit_name_list then
  1432. self.suit_name_list = {}
  1433. local have_list = {}
  1434. local index = 1
  1435. for k,v in pairs(Config.Godequipsuit) do
  1436. if not have_list[v.suit_id] then
  1437. self.suit_name_list[index] = {name = Trim(v.type_name),suit_id = v.suit_id}
  1438. index = index + 1
  1439. have_list[v.suit_id] = true
  1440. end
  1441. end
  1442. local function sort_call( a,b )
  1443. --从大到小
  1444. return a.suit_id < b.suit_id
  1445. end
  1446. table.sort( self.suit_name_list, sort_call )
  1447. end
  1448. return self.suit_name_list
  1449. end
  1450. --抽奖每日免费剩余次数
  1451. function GodModel:SetGodLeftFreeDrawTimes(vo)
  1452. self.left_free_draw_times = vo.free_times
  1453. end
  1454. function GodModel:GetGodLeftFreeDrawTimes( )
  1455. return self.left_free_draw_times
  1456. end
  1457. function GodModel:GetPreviewShowAwardData( )
  1458. local base_data = self:GetActivityLimitInfo()
  1459. if not base_data then return {} end
  1460. if self.god_ac_pool and self.god_ac_pool[base_data.phase] then
  1461. return self.god_ac_pool[base_data.phase]
  1462. end
  1463. self.god_ac_pool = self.god_ac_pool or {}
  1464. local temp_tb = {}
  1465. temp_tb.data = {}
  1466. temp_tb.color_weight = {}
  1467. temp_tb.total_weight = 0
  1468. local goods_model = GoodsModel:getInstance()
  1469. local lv = RoleManager.Instance.mainRoleInfo.level
  1470. for k,v in pairs(Config.Godlimitpool) do
  1471. if (v.phase == base_data.phase or v.phase == 0) and v.need_lv <= lv then
  1472. local temp = stringtotable(v.awards)[1]
  1473. local color = goods_model:GetGoodsColorNum( tonumber(temp[2]) )
  1474. temp[4] = v.weight
  1475. -- 奖励
  1476. temp_tb.data[color] = temp_tb.data[color] or {}
  1477. table.insert( temp_tb.data[color], temp )
  1478. -- 总权重
  1479. temp_tb.total_weight = temp_tb.total_weight + temp[4]
  1480. -- 品质权重
  1481. temp_tb.color_weight[color] = temp_tb.color_weight[color] or 0
  1482. temp_tb.color_weight[color] = temp_tb.color_weight[color] + temp[4]
  1483. end
  1484. end
  1485. local sort_func = function ( a, b )
  1486. return a[4] < b[4]
  1487. end
  1488. for k,v in pairs(temp_tb.data) do
  1489. table.sort(v, sort_func)
  1490. end
  1491. self.god_ac_pool[base_data.phase] = temp_tb
  1492. return self.god_ac_pool[base_data.phase]
  1493. end
  1494. -- 获取星星资源
  1495. function GodModel:GetStarResName( show_star )
  1496. local style_a, style_b = 0, 0 -- 资源
  1497. local temp_a = math.floor(show_star / 5) -- 整数
  1498. local temp_b = show_star % 5 -- 余数
  1499. if temp_b == 0 then
  1500. style_a = temp_a
  1501. style_b = temp_a
  1502. else
  1503. style_a = temp_a
  1504. style_b = temp_a + 1
  1505. end
  1506. local res_a, res_b = false, false
  1507. res_a = style_a == 0 and "god_star_0" or "god_star_" .. style_a .. "_1"
  1508. res_b = style_b == 0 and "god_star_0" or "god_star_" .. style_b .. "_1"
  1509. return res_a, res_b
  1510. end