|
|
- GodModel = GodModel or BaseClass(BaseVo, true)
- local GodModel = GodModel
-
- function GodModel:__init()
- GodModel.Instance = self
- self:Reset()
- self:InitCFG()
- end
-
- function GodModel:Reset()
- self.god_base_data = false
- self.activity_common_info = false
- self.activity_limit_Info = false
- -------------------------
- self.last_use_time = false--上次召唤时间戳
- -------------------------
- self.select_equip_show_info = {suit_id = 0,pos = 0,color = 0}--座印背包选中信息{pos = 0,color = 0,suit_id = 0,god_id}
- self.slot_unlock_info = {}
-
- self.left_free_draw_times = 0--剩余的免费抽奖次数
-
- if not self.acitvity_cost_id then
- --抽奖消耗券
- local temp = Config.Godkv["lottery_single"].value_content
- temp = stringtotable(temp)[1]
- self.acitvity_cost_id = tonumber(temp[2])
- end
- end
-
- function GodModel:GetBagSuitDesList( index )
- if not self.bag_suit_des_list then
- self.bag_suit_des_list = {[1] = {id = 0,type_name = "所有类型"}}
- for k,v in pairs(Config.Godequipsuit) do
- if v.equip_num == 4 then
- table.insert( self.bag_suit_des_list, {id = v.suit_id,type_name = v.type_name} )
- end
- end
- local function sort_call( a,b )
- --从大到小
- return a.id < b.id
- end
- table.sort( self.bag_suit_des_list, sort_call )
- end
- if index then
- return self.bag_suit_des_list[index]
- else
- return self.bag_suit_des_list
- end
- end
-
- function GodModel:getInstance()
- if GodModel.Instance == nil then
- GodModel.Instance = GodModel.New()
- end
- return GodModel.Instance
- end
-
- function GodModel:InitCFG( )
- self.activity_limit_conf = nil
- self.activity_common_conf = nil
- self.god_cfg_map = {}--保存每神灵最低星数的配置,每神灵只有一条信息,key值是神灵ID
- for k,v in pairs(Config.God) do
- local cur_info = self.god_cfg_map[v.id]
- if not cur_info or cur_info.star > v.star then
- local info = DeepCopy(v)
- local skill_info = stringtotable(info.skills)
- info.skill = {}
- for k,v in ipairs(skill_info or {}) do
- table.insert(info.skill, v[1])
- end
- self.god_cfg_map[v.id] = info
- end
- end
- self.god_cfg_list_for_book = {}--按顺序保存每神灵最低星数的配置
- for k, v in pairs(self.god_cfg_map) do
- self.god_cfg_list_for_book[#self.god_cfg_list_for_book+1] = v
- end
- local sort_fun = function ( a, b )
- return a.order < b.order
- end
- table.sort(self.god_cfg_list_for_book, sort_fun)
-
- self.god_max_lv = {}
- for k,v in pairs(Config.Godlv) do
- if not self.god_max_lv[v.god_id] or self.god_max_lv[v.god_id] < v.lv then
- self.god_max_lv[v.god_id] = v.lv
- end
- end
- --座印套装信息
- self.god_suit_cfg = {}
- self.god_suit_list_for_show = {}
- for k,v in pairs(Config.Godequipsuit) do
- self.god_suit_cfg[v.suit_id] = self.god_suit_cfg[v.suit_id] or {}
- table.insert(self.god_suit_cfg[v.suit_id], v)
- end
- for k,v in pairs(self.god_suit_cfg) do
- table.insert(self.god_suit_list_for_show, v)
- end
- local sort_func = function ( a, b )
- return a[1].suit_id > b[1].suit_id
- end
- table.sort(self.god_suit_list_for_show, sort_func)
- for k,v in pairs(self.god_suit_cfg) do
- local sort_func = function ( a, b )
- return a.equip_num < b.equip_num
- end
- table.sort(v, sort_func)
- end
-
- --座印最高等级,以其星数为主键
- self.god_soul_epx_max_lv = {}
- for k,v in pairs(Config.Godequip) do
- if not self.god_soul_epx_max_lv[v.quality] or self.god_soul_epx_max_lv[v.quality] < v.lv then
- self.god_soul_epx_max_lv[v.quality] = v.lv
- end
- end
- --座印在某星某级时总共包含多少经验
- self.god_soul_sum_exp_map = {}
- for k,v in pairs(self.god_soul_epx_max_lv or {}) do
- self.god_soul_sum_exp_map[k] = self.god_soul_sum_exp_map[k] or {}
- self.god_soul_sum_exp_map[k][0] = 0
- for i=1,v do
- local last_lv_exp = i>1 and self.god_soul_sum_exp_map[k][i-1] or 0
- self.god_soul_sum_exp_map[k][i] = Config.Godequip[k.."@"..i].exp+last_lv_exp
- end
- end
-
- -- local discount_cfg = stringtotable(Config.Godkv["discount_day"].value_content)
- -- self.lottery_discount_cfg = {
- -- open_day = discount_cfg[1],
- -- discounts = discount_cfg[2],
- -- max_discount_num = discount_cfg[2][#discount_cfg[2]][2]
- -- }
-
- -- self.lottery_blessing_cfg = stringtotable(Config.Godkv["god_bless_num"].value_content)
-
- end
-
- function GodModel:GetGodConf( god_id,star )
- return Config.God[god_id.."@"..star]
- end
-
- function GodModel:GetGodBaseData( )
- return self.god_base_data
- end
- function GodModel:SetGodBaseData( value )
- self.god_base_data = value
- self:UpdateGuardInfo(self.god_base_data.list)
- end
- function GodModel:SetOneGodData( data )
- if not self.god_base_data then return end
- local have_set = false
- for k,v in pairs(self.god_base_data.list) do
- if v.id == data.id then
- self.god_base_data.list[k] = data
- have_set = true
- break
- end
- end
- if not have_set then
- table.insert(self.god_base_data.list,data)
- end
- self:UpdateGuardInfo(self.god_base_data.list)
- end
-
- --神座主界面左侧列表
- function GodModel:GetSortedGodList( is_show_skill_power )
- is_show_skill_power = false
- -------------------------
- local result_list = {}
- local fight_god = {}
- local guard_god = {}
- local other_god = {}
- local god_base_list = self.god_base_data and self.god_base_data.list or {}
- for k,v in pairs(god_base_list or {}) do
- v.__power_by_sort__ = k
- v.__power_by_sort__ = self:GetMyGodPower(v.id, is_show_skill_power)
- if self:IsFightPos(v.pos) then
- table.insert(fight_god, v)
- elseif self:IsGuardPos(v.pos) then
- table.insert(guard_god, v)
- else
- table.insert(other_god, v)
- end
- end
- local sort_by_power_func = function ( a, b )
- local a_power = a.__power_by_sort__ or 0
- local b_power = b.__power_by_sort__ or 0
- return a_power > b_power
- end
- table.sort(fight_god, sort_by_power_func)
- table.sort(guard_god, sort_by_power_func)
- table.sort(other_god, sort_by_power_func)
- result_list = TableConcat(result_list, fight_god)
- result_list = TableConcat(result_list, guard_god)
- result_list = TableConcat(result_list, other_god)
- return result_list
- end
-
- --获得单个神座的信息
- function GodModel:GetGodInfoById( god_id )
- if not self.god_base_data then return end
- for k,v in pairs(self.god_base_data.list) do
- if v.id == god_id then
- return v
- end
- end
- end
-
- --获得神座的阶数
- function GodModel:GetGodGrade( god_id )
- local data = self:GetGodInfoById(god_id)
- if data then
- return data.star
- end
- return 0
- end
-
- --获得神座的等级
- function GodModel:GetGodLv( god_id )
- local info = self:GetGodInfoById(god_id)
- return info and info.lv or 0
- end
-
- --是否已满级
- function GodModel:IsGodFullLv( god_id )
- return self:GetGodLv(god_id) >= (self.god_max_lv[god_id] or 1)
- end
-
- --获取某神身上的神装
- function GodModel:GetGodEquipList( god_id )
- if not god_id then return {} end
- return self.god_equips and self.god_equips[god_id] or {}
- end
-
- --获取某神身上的神装
- function GodModel:GetGodEquipListByOneGoodsId( goods_id )
- if not goods_id then return {} end
- for k,v in pairs(self.god_equips) do
- for a,b in pairs(v) do
- if b.goods_id == goods_id then
- return v,k
- end
- end
- end
- end
-
- --获取某神身上的神装
- function GodModel:GetGodEquipByPos( god_id, pos )
- if not god_id then return {} end
- return self.god_equips and self.god_equips[god_id] and self.god_equips[god_id][pos]
- end
-
- --cell=god_id*100+pos_id
- function GodModel:GetGodIDFromEquipCell( cell )
- return math.floor(cell/100)
- end
-
- --cell=god_id*100+pos_id
- function GodModel:GetPosIDFromEquipCell( cell )
- return cell%100
- end
-
- function GodModel:UpdateGodEquipGoods( vo )
- if vo.goods_num <= 0 then --删除物品
- --删除物品的话是通过15018发过来的,拿不到cell数据所以只好遍历,数量不多所以不怕
- for k,v in pairs(self.god_equips or {}) do
- for kk,vv in pairs(v or {}) do
- if vv.goods_id == vo.goods_id then
- v[kk] = nil
- break
- end
- end
- end
- else
- local cell = vo and vo.cell or 0--如果是神座已穿戴的装备的话cell=god_id*100+pos_id
- local god_id = self:GetGodIDFromEquipCell(cell)
- local pos_id = self:GetPosIDFromEquipCell(cell)
- self.god_equips[god_id] = self.god_equips[god_id] or {}
- GoodsModel:getInstance():SetBaseInfo(vo)
- self.god_equips[god_id][pos_id] = vo
- end
- end
-
- function GodModel:GetEquipByUID( uid )
- for k,v in pairs(self.god_equips or {}) do
- for kk,vv in pairs(v) do
- if vv.goods_id == uid then
- return vv
- end
- end
- end
- return nil
- end
-
- function GodModel:SetGodEquipList( list )
- self.god_equips = {}
- for i = 1, #list do
- if list and list[i] then
- self:UpdateGodEquipGoods(list[i])
- end
- end
- self:UpdateIsAllGodEquipBest()
- self:Fire(GodConst.UpdateGodDressedEquipChange)
- self:Fire(GodConst.UpdateRedDot, GodConst.TabID.Info)
- end
-
- --判断是否所有神座都已穿戴了最好的座印了,只有这样才可以显示座印可升级的红点
- function GodModel:UpdateIsAllGodEquipBest( )
- self.is_need_show_equip_can_upgrade_red = false
- for k,v in pairs(self:GetGodList()) do
- if self:IsNeedRedInfoByEquip(v.id) then
- --有座印可以穿或替换的话那就不需要显示座印可升级
- self.is_need_show_equip_can_upgrade_red = false
- return true--顺便担当红点函数
- end
- end
- self.is_need_show_equip_can_upgrade_red = true
- return false--顺便担当红点函数
- end
-
- --某神的座印是否需要红点
- function GodModel:IsNeedRedInfoByEquip( god_id )
- for i=1,6 do
- if self:IsGodEquipCanBetter(god_id, i) then
- return true
- end
- end
- end
-
- --某神的某部位座印是否能加强,即未穿时是否有可穿的,已穿时是否有更好的
- function GodModel:IsGodEquipCanBetter( god_id, equip_pos )
- local equip_goods_vo = self:GetGodEquipByPos(god_id, equip_pos)
- local equip_list_in_bag = GoodsModel.getInstance():GetGodEquipListByPos(equip_pos)
- if not equip_list_in_bag or #equip_list_in_bag <= 0 then
- --背包里没有座印
- return false, "背包里没有座印"
- end
- if equip_goods_vo then
- --已穿座印,找更好的
- local cur_suit_id = self:GetEquipSuit(equip_goods_vo.type_id)
- local max_color_in_bag, max_color_equip = self:GetMaxColorInSoulList(equip_list_in_bag, cur_suit_id)
- local is_can_replace = false
- local max_color_stage = GoodsModel:getInstance():GetOtherDataById(max_color_equip,GodConst.EquipStrenId) or 0
- local stage = GoodsModel:getInstance():GetOtherDataById(equip_goods_vo,GodConst.EquipStrenId) or 0
- stage = tonumber(stage)
- if (max_color_in_bag > equip_goods_vo.color) then
- is_can_replace = true
- elseif (max_color_in_bag == equip_goods_vo.color and max_color_equip and max_color_stage>stage) then
- is_can_replace = true
- end
- if is_can_replace then
- --背包里有更高星数的座印
- return true, GodConst.EquipStatus.WearBetter
- elseif self.is_need_show_equip_can_upgrade_red then
- local isFullLv = self:IsEquipFullLv(equip_goods_vo)
- if not isFullLv and self:HasExistInSoulListByMaxColor(1, equip_list_in_bag, cur_suit_id) then
- return true, GodConst.EquipStatus.UP
- end
- end
- else
- --未穿座印
- return true, GodConst.EquipStatus.Wear
- end
- return false
- end
-
- --判断背包里是否有这些座印,要求是品质小于等于传入的color
- function GodModel:HasExistInSoulListByMaxColor( color, list, suit_id )
- for k,v in pairs(list or {}) do
- local v_suit_id = self:GetEquipSuit(v.type_id)
- --只找相同套装的
- if v_suit_id == suit_id then
- if v.color and v.color <= color then
- return true
- end
- end
- end
- return false
- end
-
- function GodModel:IsEquipFullLv( equip_info )
- if not equip_info then return false end
- local curLv = GoodsModel:getInstance():GetOtherDataById(equip_info,GodConst.EquipStrenId) or 0
- local maxLv = self:GetEquipMaxLv(equip_info.type_id)
- return curLv >= maxLv
- end
-
- --从列表中找到最大的座印星数
- function GodModel:GetMaxColorInSoulList( list, suit_id )
- local result = 0
- local out_equip = nil
- local max_stage = 0
- for k,v in pairs(list or {}) do
- local v_suit_id = self:GetEquipSuit(v.type_id)
- --只找相同套装的
- if v_suit_id == suit_id then
- local stage = GoodsModel:getInstance():GetOtherDataById(v,GodConst.EquipStrenId) or 0
- stage = tonumber(stage)
- if v.color > result or (v.color==result and stage>max_stage) then
- result = v.color
- max_stage = stage
- out_equip = v
- end
- end
- end
- return result, out_equip
- end
-
- --获取在某星某级的情况下,增加某经验值可以让它提升到哪级哪经验
- function GodModel:GetNextEquipLvAndExp( soul_star, soul_lv, soul_exp, add_exp, max_lv )
- local sum_add_exp = add_exp+soul_exp
- local next_lv = soul_lv
- local next_exp = 0
- while sum_add_exp > 0 do
- local up_lv_need_exp = self:GetEquipUpLvNeedExp(soul_star, next_lv)
- if up_lv_need_exp <= 0 then
- break
- end
- local left_exp = sum_add_exp - up_lv_need_exp
- if left_exp >= 0 then
- --剩余经验够升级
- sum_add_exp = left_exp
- next_lv = next_lv + 1
- else
- --所剩经验不够升级
- break
- end
- if next_lv >= max_lv then
- break
- end
- end
- return next_lv, sum_add_exp
- end
-
- --获取座印升级所需经验
- function GodModel:GetEquipUpLvNeedExp( soul_star, cur_soul_lv )
- if not soul_star or not cur_soul_lv then return 0 end
-
- local max_lv = soul_star and self.god_soul_epx_max_lv[soul_star] or 0
- local next_lv = cur_soul_lv + 1
- if next_lv > max_lv then
- next_lv = max_lv
- end
- local lv_cfg = Config.Godequip[soul_star.."@"..next_lv]
- return lv_cfg and lv_cfg.exp or 0
- end
-
- function GodModel:GetEquipMaxLv( equip_type_id )
- local goods_vo = GoodsModel:getInstance():GetGoodsBasicByTypeId(equip_type_id)
- local color = goods_vo and goods_vo.color
- local max_lv = color and self.god_soul_epx_max_lv[color] or 0
- return max_lv
- end
-
- --获取神灵激活了哪些套装
- function GodModel:GetGodActivedSuit( god_id )
- local equip_list = self:GetGodEquipList(god_id)
- local suit_map = {}
- for k,v in pairs(equip_list or {}) do
- local suit_id = self:GetEquipSuit(v.type_id)
- suit_map[suit_id] = suit_map[suit_id] or 0
- suit_map[suit_id] = suit_map[suit_id] + 1
- end
- local result = {}
- for k,v in pairs(suit_map) do
- local suit_cfg = self.god_suit_cfg[k]
- for ii,vv in ipairs(suit_cfg or {}) do
- if v >= vv.equip_num then
- local ac_item = DeepCopy(vv)
- ac_item.god_id = god_id
- table.insert(result, ac_item)
- end
- end
- end
- return result
- end
-
- --获取座印属于哪个套装
- function GodModel:GetEquipSuit( equip_type_id )
- if not equip_type_id then return 0 end
- local cfg = Config.Godequipmanual[equip_type_id]
- return cfg and cfg.suit_id or 0
- end
-
- function GodModel:GetEquipTagId( equip_type_id )
- if not equip_type_id then return 1 end
- local cfg = Config.Godequipmanual[equip_type_id]
- local suit_id = cfg and cfg.suit_id or 1
- for k,v in pairs(Config.Godequipsuit) do
- if v.suit_id == suit_id then
- return v.type
- end
- end
- return 1
- end
-
- --获取自己某神灵的座印属性
- function GodModel:GetMyGodEquipAttr( god_id )
- local equip_list = self.god_equips and self.god_equips[god_id]
- local result = {}
- for k,v in pairs(equip_list or {}) do
- local stage = GoodsModel:getInstance():GetOtherDataById(v,GodConst.EquipStrenId) or 0
- local addition_attrlist = self:GetEquipSpAttrByVo( v )
- local attr_list = self:GetEquipAttr(v.type_id, stage, addition_attrlist)
- CombineAttrList(result, attr_list)
- end
- return result
- end
-
- --计算获得装备特殊属性实际加成
- function GodModel:GetEquipSpAttrByVo( goods_vo )
- if not goods_vo then return {} end
- local base_addition_attrlist = GoodsModel:getInstance():GetOtherDataById(goods_vo, GodConst.EquipSPAttrId) or {}
- base_addition_attrlist = stringtotable(base_addition_attrlist)
- local stage = GoodsModel:getInstance():GetOtherDataById(goods_vo,GodConst.EquipStrenId) or 0
- for k,v in pairs(base_addition_attrlist) do
- base_addition_attrlist[k][2] = math.max( math.floor(stage/5) - 1 , 0 ) * v[3] + v[2]
- end
- return base_addition_attrlist
- end
-
- --获取座印属性列表
- function GodModel:GetEquipAttr( equip_type_id, lv, addition_attr )
- if not equip_type_id then return {} end
- local result = {}
- local equip_cfg = Config.Godequipmanual[equip_type_id]
- local attr = equip_cfg and equip_cfg.attr or {}
- local attr_list = stringtotable(attr)
- --加上额外属性
- if addition_attr then
- if type(addition_attr) == "string" then
- addition_attr = stringtotable(addition_attr)
- end
- local addition_attr_new = {}
- for k,v in pairs(addition_attr) do
- table.insert(addition_attr_new, {v.attr_type or v[1], v.attr_value or v[2]})
- end
- CombineAttrList(attr_list, addition_attr_new)
- end
- for k,v in pairs(attr_list) do
- v[2] = v[2]+(lv or 0)*(v[3] or 0)
- end
- return attr_list
- end
-
- function GodModel:CombineAttrTwo( data )
- local temp = {}
- local index = 1
- for i,v in ipairs(data) do
- index = math.ceil( i/2 )
- temp[index] = temp[index] or {}
- temp[index][i%2 == 1 and 1 or 2] = v
- end
- return temp
- end
-
- --获取神灵技能信息列表,包含技能等级的
- function GodModel:GetGodSkillInfoList( god_id )
- local info = self:GetGodInfoById(god_id)
- return info.skill or {}
- end
-
- --获取某神某技能的等级
- function GodModel:GetGodSkillLv( god_id, skill_id )
- if not god_id or not skill_id then return 0 end
-
- local info = self:GetGodInfoById(god_id)
- for k,v in pairs(info.skill or {}) do
- if v.skill_id == skill_id then
- return v.skill_lv
- end
- end
- return 0
- end
-
- --获取神座升级所需要经验
- function GodModel:GetMaxExp( god_id, lv )
- lv = lv or 0
- local lv_cfg = Config.Godlv[god_id.."@"..lv+1]
- local result = lv_cfg and lv_cfg.exp or 0
- return result
- end
-
- function GodModel:GetGodUpLvCostCfg( )
- if not self.up_lv_cost_cfg then
- local data = stringtotable(Config.Godkv["lv_up_goods"].value_content)
- local function sort_call( a,b )
- return a[2] < b[2]
- end
- table.sort( data, sort_call )
- self.up_lv_cost_cfg = {}
- for i=1,3 do
- self.up_lv_cost_cfg[i] = data[i][1]
- end
- end
- return self.up_lv_cost_cfg
- end
-
- --获取某神的基础属性
- function GodModel:GetGodBaseAttr( god_id, lv, star )
- if not god_id or not lv or not star then return {} end
- local cfg = Config.God[god_id.."@"..star]
- local result = {}
- if cfg then
- result = stringtotable(cfg.attr)
- for k,v in pairs(result) do
- v[2] = v[2]+(lv-1)*v[3]
- end
- end
- return result
- end
-
- --神灵有额外的属性,ignore_suit_effect:是否忽略套装效果
- function GodModel:GetGodAdditionAttr( god_id, lv, star, ignore_suit_effect, role_info )
- role_info = role_info or RoleManager.Instance.mainRoleInfo
- if not god_id or not lv or not star then return {} end
- local cfg = Config.God[god_id.."@"..star]
- local result = {}
- if cfg then
- result = stringtotable(cfg.god_attr)
- for k,v in pairs(result) do
- v[2] = v[2]+(lv-1)*v[3]
- end
- for k,v in pairs(result) do
- if v[1] == 2 then
- v.attr_str = "神血"
- if not ignore_suit_effect then
- local isActivedSuitEffect = self:IsActivedSuitEffect(god_id, GodConst.SuitEffect.AddGodBlood, 2)
- if isActivedSuitEffect then
- v[2] = v[2] * stringtotable(Config.Godequipsuit["3@4"].effect)[1][2]
- end
- end
- v[2] = v[2]+(role_info.maxHp or 0)*0.20
- elseif v[1] == 1 then
- v.attr_str = "神攻"
- if not ignore_suit_effect then
- local isActivedSuitEffect = self:IsActivedSuitEffect(god_id, GodConst.SuitEffect.AddGodAttack, 2)
- if isActivedSuitEffect then
- v[2] = v[2] * stringtotable(Config.Godequipsuit["1@4"].effect)[1][2]
- end
- end
- v[2] = v[2]+role_info.att
- elseif v[1] == 4 then
- v.attr_str = "神防"
- if not ignore_suit_effect then
- local isActivedSuitEffect = self:IsActivedSuitEffect(god_id, GodConst.SuitEffect.AddGodDefend, 2)
- if isActivedSuitEffect then
- v[2] = v[2] * stringtotable(Config.Godequipsuit["2@4"].effect)[1][2]
- end
- end
- v[2] = v[2]+role_info.def
- end
- end
- end
- return result
- end
-
- --是否激活了某套装的特殊技能
- function GodModel:IsActivedSuitEffect( god_id, suit_id, suit_lv, ignore_guard )
- local isFightGod = self:IsGodGoFighted(god_id)
- local isGuard = self:IsGuardGod(god_id)
- if not isFightGod and not isGuard then
- --没上阵或不是神仆的话就不算
- return false
- end
- local isActived = false
- local equip_list = self:GetGodEquipList(god_id)
- local progress = self:GetSuitProgress(suit_id, equip_list)
- --suit_lv代表套装等级,1代表2件套,2代表4件套装
- suit_lv = suit_lv or #progress
- if progress and progress[suit_lv] then
- isActived = progress[suit_lv].had_actived
- end
- if not ignore_guard and isFightGod and not isActived then
- --是主神而且自己没激活的话就看看神仆有没有激活
- for i=1,GodConst.MaxGuardNum do
- local guard = self:GetGuardInfoByID(god_id, i)
- if guard then
- local isGuardActive = self:IsActivedSuitEffect(guard.guard_id, suit_id, suit_lv)
- if isGuardActive then
- --神仆激活了二件套
- isActived = true
- break
- end
- end
- end
- end
- return isActived
- end
-
- function GodModel:IsGodGoFighted( god_id )
- local god_info = self:GetGodInfoById(god_id)
- return god_info and self:IsFightPos(god_info.pos) or false
- end
-
- function GodModel:IsFightPos( pos )
- return pos~=0 and pos < GodConst.GuardStartPos
- end
-
- function GodModel:IsGuardGod( god_id )
- local god_info = self:GetGodInfoById(god_id)
- return god_info and self:IsGuardPos(god_info.pos) or false
- end
-
- function GodModel:IsGuardPos( pos )
- return pos >= GodConst.GuardStartPos
- end
-
- --获取座印包含的总经验值
- function GodModel:GetEquipSumExp( soul_id, soul_lv, exp, color )
- if not soul_id or not soul_lv or not exp then return 0 end
- local base_exp = Config.Godequipmanual[soul_id].exp
- if self.god_soul_sum_exp_map[color] and self.god_soul_sum_exp_map[color][soul_lv] then
- local sum_exp = self.god_soul_sum_exp_map[color][soul_lv]
- return (sum_exp+base_exp)+exp
- end
- return 0
- end
-
- --获取神灵某套装的激活进度,即返回该套装的三个激活条件,并标明已激活和未激活
- function GodModel:GetSuitProgress( suit_id, equip_list )
- if not suit_id then return {} end
-
- local has_soul_num = 0
- for k,v in pairs(equip_list or {}) do
- local v_suit_id = self:GetEquipSuit(v.type_id)
- if v_suit_id == suit_id then
- has_soul_num = has_soul_num + 1
- end
- end
- local suit_cfg = self.god_suit_cfg[suit_id]
- local result = suit_cfg and DeepCopy(suit_cfg) or {}
- for k,v in pairs(result) do
- v.had_actived = has_soul_num >= v.equip_num
- end
- return result
- end
-
- function GodModel:GetGuardInfo( )
- return self.guard_info
- end
-
- function GodModel:UpdateGuardInfo( god_list )
- local guard_info = {}
- for k,v in pairs(god_list) do
- if self:IsGuardPos(v.pos) then
- local fight_slot = self:GetFightSlotByPos(v.pos)
- local guard_slot = self:GetGuardPos(v.pos)
- local guard_id = v.id
- local guard_item_info = {}
- guard_item_info.guard_state = GodConst.GuardState.Guarding
- guard_item_info.guard_slot = guard_slot
- guard_item_info.guard_id = guard_id
- guard_info[fight_slot] = guard_info[fight_slot] or {}
- guard_info[fight_slot][guard_slot] = guard_item_info
- end
- end
- self.guard_info = guard_info
- end
-
- function GodModel:GetGuardPos( pos )
- if self:IsFightPos(pos) then
- return 0
- else
- return pos and pos%100 or 1
- end
- end
-
- function GodModel:GetGuardInfoByID( god_id, guard_slot)
- local fight_slot = self:GetGodFightSlot(god_id)
- if fight_slot > 0 then
- local data = self:GetGuardInfoBySlot(fight_slot, guard_slot)
- return data
- end
- return nil
- end
-
- --获取某战位的护法信息
- function GodModel:GetGuardInfoBySlot( fight_slot, guard_slot )
- if not fight_slot or not guard_slot or not self.guard_info then return end
- return self.guard_info[fight_slot] and self.guard_info[fight_slot][guard_slot] or {}
- end
-
- function GodModel:GetGodFightSlot( god_id )
- local god_info = self:GetGodInfoById(god_id)
- return god_info and self:GetFightSlotByPos(god_info.pos) or 0
- end
-
- --神座的出战位如果大于100的话说明是护佑战位,其百份位是护佑的主战位id,个位就是1,2号护佑位
- function GodModel:GetFightSlotByPos( pos )
- if self:IsFightPos(pos) then
- return pos
- else
- return pos and math.floor(pos/100) or 0
- end
- end
-
- --获取神灵激活的收集进度
- function GodModel:GetGodUpStarProgress( god_id, star, limit_to_condition )
- if not god_id or not star then return 0, 0, 0 end
-
- local next_star = star and (star + 1)
- if not next_star then return 0, 0, 0 end
- local cost_info = Config.God[god_id.."@"..next_star]
- cost_info = cost_info and stringtotable(cost_info.cost)
- if cost_info then
- --只要魂魄的进度
- local condition = 0
- local cur_pro = 0
- local cost_id = 0
- for k,v in pairs(cost_info) do
- local t_condition = v[3]
- condition = condition + t_condition
- local t_cost_id = v[2]
- local goods_num = GoodsModel:getInstance():GetTypeGoodsNum(t_cost_id)
- if limit_to_condition and goods_num > t_condition then
- goods_num = t_condition
- end
- cur_pro = cur_pro + goods_num
- if k == 1 then
- cost_id = t_cost_id
- end
- end
- return cur_pro, condition, cost_id
- end
- return 0, 0, 0
- end
-
- function GodModel:IsMaxStar( god_id, star )
- if not god_id or not star then return false end
- return Config.God[god_id.."@"..star+1]==nil and Config.God[god_id.."@"..star]~=nil
- end
-
- --获取神座的战力,如果已经激活的话就返回后端发过来的值,没有激活则计算初始战力
- function GodModel:GetMyGodPowerFromServerOrCFG( god_id )
- if not god_id then return 0 end
-
- local god_info = self:GetGodInfoById(god_id)
- if god_info then
- if god_info.power and god_info.power~=0 then
- return god_info.power
- else
- --有些战力后端算不了就会发0过来,这时就前端自己算
- return self:GetMyGodPower(god_id)
- end
- end
- return self:GetGodPower(god_id, 1, self:GetGodFirstStar(god_id), self:GetGodFirstSkillList(god_id))
- end
-
- --获取神灵激活的初始星数
- function GodModel:GetGodFirstStar( god_id )
- return self.god_cfg_map[god_id] and self.god_cfg_map[god_id].star or 0
- end
-
- function GodModel:GetGodFirstSkillList( god_id )
- local skill_cfg_list = self:GetGodSkillList(god_id)
- local skill_list = {}
- for i,v in ipairs(skill_cfg_list or {}) do
- table.insert(skill_list, {skill_id=v, skill_lv=1})
- end
- return skill_list
- end
-
- --获取神灵技能列表,静态的
- function GodModel:GetGodSkillList( god_id )
- local cfg = self.god_cfg_map[god_id]
- if not cfg then return {} end
- return cfg.skill
- end
-
- function GodModel:GetMyGodPower( god_id, is_show_skill_power )
- if is_show_skill_power==nil then
- is_show_skill_power = true
- end
- if not god_id then return 0 end
-
- local god_info = self:GetGodInfoById(god_id)
- if not god_info then return 0 end
- local skill_list = nil
- if is_show_skill_power then
- skill_list = self:GetGodSkillInfoList(god_id)
- end
- local equip_attr_list = self:GetMyGodEquipAttr(god_id)
- return self:GetGodPower(god_id, god_info.lv, god_info.star, skill_list, equip_attr_list)
- end
-
- --获取神座战力
- function GodModel:GetGodPower( god_id, lv, star, skill_list, equip_attr_list, role_info )
- local attr_list = self:GetGodBaseAttr(god_id, lv, star)
- local attr_power = GetFighting(attr_list)
- local addition_attr_list = self:GetGodAdditionAttr(god_id, lv, star, false, role_info)
- local addition_attr_power = self:GetGoFightPower(addition_attr_list)
- local skill_power = self:GetGodSkillPower(skill_list)
- local equip_power = 0
- if equip_attr_list then
- equip_power = GetFighting(equip_attr_list)
- end
- return attr_power+addition_attr_power+skill_power+equip_power
- end
-
- function GodModel:GetGoFightPower( god_go_fight_attr_list )
- local attr_factor = {
- [1]=0.1, [2]=0.01, [4]=0.1
- }
- local power = 0
- for k,v in pairs(god_go_fight_attr_list) do
- power = power + attr_factor[v[1]]*v[2]
- end
- return round(power)
- end
-
- function GodModel:GetGodSkillPower( skill_list )
- if not skill_list then return 0 end
- local power = 0
- for k,v in pairs(skill_list) do
- local _,temp_num = GetSkillAttrBySkill( v.skill_id, v.skill_lv, true ,true)
- power = power + temp_num
- end
- return power
- end
-
- function GodModel:GetEquipPower( equip_id, equip_lv, addition_attr )
- local attr_list = self:GetEquipAttr(equip_id, equip_lv, addition_attr)
- for k,v in pairs(attr_list) do
- v[3] = nil
- end
- return GetFighting(attr_list)
- end
-
- --获取某槽孔出战的神灵
- function GodModel:GetGoFightGod( fight_slot )
- local data = self.god_base_data and self.god_base_data.list or {}
- for k,v in pairs(data) do
- if v.pos == fight_slot then
- return v
- end
- end
- return nil
- end
-
- function GodModel:GetGodList( )
- return self.god_base_data and self.god_base_data.list or {}
- end
-
- --获取出战列表
- function GodModel:GetGoFightGodList( ignore_sort )
- local result = {}
- local data = self.god_base_data and self.god_base_data.list or {}
- for k,v in pairs(data) do
- if self:IsFightPos(v.pos) then
- table.insert(result, v)
- end
- end
- if not ignore_sort then
- local sort_func = function ( a, b )
- return a.pos < b.pos
- end
- table.sort(result, sort_func)
- end
- return result
- end
-
- --获取更小的空阵位
- function GodModel:GetSmallerEmptyPos( pos )
- local pos_empty_state = {true,true,true,true,true}--true为
- local data = self.god_base_data and self.god_base_data.list or {}
- for k,v in pairs(data) do
- if v.pos ~= 0 and v.pos < GodConst.GuardStartPos then
- --该主阵位不为空
- pos_empty_state[v.pos] = false
- end
- end
- for i=1,pos do
- if pos_empty_state[i] then
- return i
- end
- end
- return pos
- end
-
- --返回最多可出战多少神灵
- function GodModel:GetMaxGoFightGodNum( )
- local result = 3--前三个阵位是默认开启的
- if self:HasFightSlot4Unlock() then
- result = result + 1
- end
- if self:HasFightSlot5Unlock() then
- result = result + 1
- end
- return result
- end
-
- function GodModel:HasFightSlot4Unlock( )
- local data = self.god_base_data and self.god_base_data.list or {}
- for k,v in pairs(data) do
- local isActivedSuitEffect = self:IsActivedSuitEffect(v.id, GodConst.SuitEffect.AddGodGoFightPos)
- if isActivedSuitEffect then
- return true
- end
- end
- return false
- end
-
- function GodModel:HasFightSlot5Unlock( )
- if not self:IsSlotUnlock(5) then
- return false
- end
- return self:HasActiveFightSlot5Suit()
- end
-
- --是否满足开启阵位5的套装条件
- function GodModel:HasActiveFightSlot5Suit( )
- local hasActiveNum = 0
- for k,v in pairs(self:GetGodList()) do
- local isActivedSuitEffect = self:IsActivedSuitEffect(v.id, GodConst.SuitEffect.AddGodGoFightPos, 2, true)
- if isActivedSuitEffect then
- hasActiveNum = hasActiveNum + 1
- if hasActiveNum >= 2 then
- --需要任意两只神激活了四件套
- return true
- end
- end
- end
- return false
- end
-
- --注意此解锁信息仅仅代表花钱买了,真正的解锁还需要多一个条件的
- function GodModel:IsSlotUnlock( fight_slot )
- for k,v in pairs(self.slot_unlock_info or {}) do
- if v.pos == fight_slot then
- return true
- end
- end
- return false
- end
-
- function GodModel:SetSlotUnlockInfo( value )
- self.slot_unlock_info = value
- end
-
- --获取所有神灵的配置列表,图鉴有用到
- function GodModel:GetGodCfgListForBook( )
- return self.god_cfg_list_for_book
- end
-
- --神灵是否能激活
- function GodModel:IsGodCanActive( god_id )
- local god_info = self:GetGodInfoById( god_id )
- if god_info ~= nil then return false, "AlreadyActive" end
-
- local cur_pro, max_pro, cost_id = self:GetGodUpStarProgress(god_id, -1)
- return cur_pro >= max_pro, "NotEnoughCost", cost_id
- end
-
- function GodModel:GetSuitCfgList( )
- return self.god_suit_list_for_show or {}
- end
-
- function GodModel:GetGodName( god_id )
- return self.god_cfg_map[god_id] and Trim(self.god_cfg_map[god_id].name) or "未知神座"
- end
-
- function GodModel:GetRealPos( fight_slot, guard_slot )
- return fight_slot*100+guard_slot
- end
-
- --获取神座护佑时只算的属性百分比,默认是50%,激活套装有加成
- function GodModel:GetGuardAttrPercent( god_id )
- local percent = 0.5
- if self:IsActivedSuitEffect(god_id, GodConst.SuitEffect.AddGuardAttrPercent, 2, true) then
- percent = 0.8
- elseif self:IsActivedSuitEffect(god_id, GodConst.SuitEffect.AddGuardAttrPercent, 1, true) then
- percent = 0.6
- end
- return percent
- end
-
- function GodModel:GetTagResByGodId( god_id )
- local conf = self.god_cfg_map[god_id]
- local id = conf and conf.type or 1
- return GodConst.TagRes[id] and GodConst.TagRes[id] or GodConst.TagRes[1]
- end
-
- function GodModel:GetGodShowModelResID( god_id )
- -- do return 1001 end
- -------------------------
- local cfg = self.god_cfg_map[god_id]
- if cfg then
- if cfg.picture_id > 1005 or cfg.picture_id < 1000 then
- print('=======Msh:GodModel.lua[1088] =====缺失神座模型ID==', god_id)
- return 1000
- end
- return cfg.picture_id
- end
- return 0
- end
-
- function GodModel:GetGodPos( god_id )
- local data = self:GetGodInfoById(god_id)
- return data and data.pos or 0
- end
-
- function GodModel:GetSuitDesByInfo( des_1,des_2,is_active,str_tem )
- str_tem = str_tem or ":"
- des_1 = des_1 or ""
- des_2 = des_2 or ""
- if is_active then
- des_1 = HtmlColorTxt( Trim(des_1) , '#2cf86f') .. str_tem
- return des_1 .. Trim(des_2) --HtmlColorTxt( des_1 .. Trim(des_2) , '#40465a')
- else
- -- string.gsub( des_2, findString, replaceString, replaceTime )
- return HtmlColorTxt( Trim(des_1) .. str_tem .. Trim(des_2) , '#8b8b8b')
- end
- end
- -------------------------
- --神灵系统各标签是否需要红点
- function GodModel:IsNeedRed( tab_id )
- if not tab_id then return false end
-
- if tab_id == GodConst.TabID.Info then
- return self:IsNeedRedInfo()
- elseif tab_id == GodConst.TabID.GoFight then
- return self:IsNeedRedGoFight()
- elseif tab_id == GodConst.TabID.Book then
- return self:IsNeedRedBook() or self:IsNeedResSuitBook()
- elseif tab_id == GodConst.TabID.Activity then
- --宠物生活技能 每日免费抽奖一次
- local left_free_draw_times = self:GetGodLeftFreeDrawTimes()
- local free_red = left_free_draw_times > 0
-
- local num = GoodsModel:getInstance():GetTypeGoodsNum(self.acitvity_cost_id)
- return num>0 or self:IsActivityCommonRed() or self:IsActivityLimitRed() or free_red
- elseif tab_id == GodConst.TabID.Equip then
- --有座印可以穿或替换
- return self:UpdateIsAllGodEquipBest()
- end
- return false
- end
-
- function GodModel:IsActivityCommonRed( )
- local base_data = self:GetActivityCommonInfo()
- if not base_data then return false end
- for k,v in pairs(base_data.bless_award) do
- if v.state == 1 then
- return true
- end
- end
- return false
- end
-
- function GodModel:IsActivityLimitRed( )
- local base_data = self:GetActivityLimitInfo()
- if not base_data then return false end
- for k,v in pairs(base_data.bless_award) do
- if v.state == 1 then
- return true
- end
- end
- return false
- end
-
- --神灵信息标签是否需要红点
- function GodModel:IsNeedRedInfo( )
- for k,v in pairs(self:GetGodList() or {}) do
- if self:IsNeedRedInfoByGod(v.id) then
- return true
- end
- end
- return false
- end
-
- --神灵是否需要红点
- function GodModel:IsNeedRedInfoByGod( god_id )
- if self:IsGodCanUpLv(god_id) then
- --可以升级
- return true
- end
- if self:IsGodCanUpStar(god_id) then
- --可以升星
- return true
- end
- if self:IsGodAnySkillCanUpdate(god_id) then
- --可以升技能
- return true
- end
- return false
- end
-
- --神灵是否能升级,够升下经验也会返回真,不一定要够升一级的
- function GodModel:IsGodCanUpLv( god_id )
- if self:IsGodFullLv(god_id) then
- return false
- end
- local lv = self:GetGodLv(god_id)
- local up_lv_cost = self:GetGodUpLvCostCfg(god_id, lv)
- for k,v in pairs(up_lv_cost or {}) do
- local goods_num = GoodsModel:getInstance():GetTypeGoodsNum(v)
- if goods_num >= 1 then
- return true
- end
- end
- return false
- end
-
- --神灵是否能升星
- function GodModel:IsGodCanUpStar( god_id )
- local star = self:GetGodStar(god_id)
- if self:IsMaxStar(god_id, star) then
- return false,"MaxStar"
- end
- local next_star = self:GetGodNextStar(god_id, star, true)
- if not next_star then return false end
- local need_lv = self:GetGodStarNeedLv(god_id, next_star)
- if self:GetGodLv(god_id) < need_lv then
- --升星需要达到某个等级条件才行的
- return false, "LvNoEnough", need_lv
- end
- local cur_pro, max_pro = self:GetGodUpStarProgress(god_id, star)
- return cur_pro>=max_pro, "CostGoodsNum"
- end
-
- function GodModel:GetGodStar( god_id )
- local info = self:GetGodInfoById(god_id) or {}
- return info and info.star or 0
- end
-
- function GodModel:GetGodNextStar( god_id, star, return_nil_when_max )
- local next_star = star and (star + 1) or 0
- -- if star and star == 0 then
- -- --传入星数是0的话要帮它转为对应神灵的起始星数
- -- next_star = self:GetGodFirstStar(god_id)
- -- end
- local is_max = self:IsMaxStar(god_id, star)
- if not is_max or not return_nil_when_max then
- return next_star
- end
- return nil
- end
-
- --获取某神灵到达某星需要多少等级
- function GodModel:GetGodStarNeedLv( god_id, star )
- if not god_id or not star or not Config.God or not Config.God[god_id.."@"..star] then return 0 end
-
- return Config.God[god_id.."@"..star].need_lv
- end
-
- --某神是否有技能可升级
- function GodModel:IsGodAnySkillCanUpdate( god_id )
- if not god_id then return false end
- local info = self:GetGodInfoById(god_id) or {}
- for k,v in pairs(info.skill or {}) do
- if self:IsGodSkillCanUpdate(god_id, v.skill_id) then
- return true
- end
- end
- return false
- end
-
- --神灵的技能是否能升级
- function GodModel:IsGodSkillCanUpdate( god_id, skill_id )
- if self:IsGodSkillMaxLv(god_id, skill_id) then
- return false
- end
- if not self.skill_cost_goods_type_id then
- self.skill_cost_goods_type_id = stringtotable(Config.Godkv["skill_up_cost"].value_content)[1][2]
- end
- local goods_num = GoodsModel.getInstance():GetTypeGoodsNum(self.skill_cost_goods_type_id)
- return goods_num > 0
- end
-
- --技能是否已满级
- function GodModel:IsGodSkillMaxLv( god_id, skill_id )
- local star = self:GetGodStar(god_id)
- star = star or 1
- local skill_lv_cfg = Config.God[god_id.."@"..star]
- local cur_lv = self:GetGodSkillLv(god_id, skill_id)
- if skill_lv_cfg then
- return cur_lv >= (skill_lv_cfg.skill_max or 0)
- else
- if Config.God[god_id.."@5"] then
- --找不到配置的话先固定找5星的,但出了6星配置的话这里就提示下前端要修改
- Message.show("增加了神灵技能的等级限制配置啦!")
- end
- skill_lv_cfg = Config.God[god_id.."@5"] or {}
- return cur_lv >= (skill_lv_cfg.skill_max or 0)
- end
- return false
- end
-
- --神灵系统是否需要红点
- function GodModel:IsNeedRedAll( )
- for k,v in pairs(GodConst.TabID) do
- if self:IsNeedRed(v) then
- return true
- end
- end
- return false
- end
-
- --出战标签是否需要红点
- function GodModel:IsNeedRedGoFight( )
- if not self:HasAnyUnFightGod() then
- --没有任何可上阵的神灵
- return false
- end
- for i=1,GodConst.MaxFightNum do
- if self:IsFightSlotCanGo(i, true) then
- return true
- end
- end
- return false
- end
-
- --是否有神未出战
- function GodModel:HasAnyUnFightGod( )
- for k,v in pairs(self:GetGodList()) do
- if v.pos == 0 or v.pos >= GodConst.GuardStartPos then
- return true
- end
- end
- return false
- end
-
- --ignore_judge_unfight_god已经判断过有未出战神灵了,就不用再判断了
- function GodModel:IsFightSlotCanGo( fight_slot, ignore_judge_unfight_god )
- if self:GetGoFightGod(fight_slot) ~= nil then
- return false
- end
- if not ignore_judge_unfight_god then
- if not self:HasAnyUnFightGod() then
- --没有任何可上阵的神灵
- return false
- end
- end
- --前3个阵位是默认解锁的,后几个就要判断是否已经解锁过了
- if fight_slot <= 3 then
- return true
- elseif fight_slot == 4 then
- return self:HasFightSlot4Unlock()
- elseif fight_slot == 5 then
- return self:HasFightSlot5Unlock()
- end
- end
-
- --图鉴是否需要红点
- function GodModel:IsNeedRedBook( )
- for k,v in pairs(self.god_cfg_map) do
- if self:IsGodCanActive(v.id) then
- return true
- end
- end
- return false
- end
-
- function GodModel:IsNeedResSuitBook( )
- local setting = CookieWrapper.Instance:GetCookie(CookieLevelType.Account, CookieKey.GOD_BOOK_SUIT_SHOW_REDID)
- return not setting or setting~=1
- end
-
- function GodModel:SetShowedSuitBookRed( )
- CookieWrapper.Instance:SaveCookie(CookieLevelType.Account, CookieTimeType.TYPE_ALWAYS, CookieKey.GOD_BOOK_SUIT_SHOW_REDID, 1)
- CookieWrapper.Instance:WriteAll()
- GodController.Instance:GodCheckRedDot()
- end
-
- --从背包里获取soul_pos部位最好的座印信息,包括每套装的最高星和最高级数
- function GodModel:GetBestEquipInfoInBag( equip_pos, min_star )
- local equip_list_in_bag = GoodsModel.getInstance():GetGodEquipListByPos(equip_pos)
- local result = {}
- for k,v in pairs(equip_list_in_bag or {}) do
- local suit_id = self:GetEquipSuit(v.type_id)
- result[suit_id] = result[suit_id] or {}
- local star = v.color
- if star >= min_star and (not result[suit_id].max_star or star >= result[suit_id].max_star) then
- result[suit_id].max_star = star
- result[suit_id].max_lv = result[suit_id].max_lv or {}
- local stage_num = GoodsModel:getInstance():GetOtherDataById(v,GodConst.EquipStrenId) or 0
- if not result[suit_id].max_lv[star] or stage_num > result[suit_id].max_lv[star] then
- result[suit_id].max_lv[star] = stage_num
- end
- end
- end
- return result
- end
-
- function GodModel:ReqGoFightPos( pos, god_id )
- --请求上阵,如果
- pos = self:GetSmallerEmptyPos(pos)
- local target_pos_god = self:GetGoFightGod(pos)
- local is_new_pos_empty = target_pos_god==nil
- if is_new_pos_empty then
- --如果要上阵的是空阵位且该神原来的位置比新阵位靠前,那就不让上
- local old_pos = self:GetGodPos(god_id)
- if old_pos~=0 and old_pos<pos then
- Message.show("只能按顺序上阵")
- return
- end
- end
- self:Fire(GodConst.REQ_INFO_FIGHT, pos, god_id)
- end
-
- --普通抽奖信息
- function GodModel:GetActivityCommonInfo( )
- return self.activity_common_info
- -- local curTime = TimeUtil:getServerTime()
- -- return self.activity_common_info or {
- -- phase = 1,
- -- begin_time = curTime,
- -- end_time = curTime+86400*2,
- -- blessing = 3,
- -- bless_award = {
- -- },
- -- }
- end
- function GodModel:SetActivityCommonInfo( value )
- self.activity_common_info = value
- end
- --限时抽奖信息
- function GodModel:GetActivityLimitInfo( )
- return self.activity_limit_Info
- -- local curTime = TimeUtil:getServerTime()
- -- return self.activity_limit_Info or {
- -- phase = 1,
- -- begin_time = curTime,
- -- end_time = curTime+86400*2,
- -- blessing = 3,
- -- bless_award = {
- -- },
- -- counts = 0,
- -- counts_award = {
- -- },
- -- }
- end
- function GodModel:SetActivityLimitInfo( value )
- self.activity_limit_Info = value
- end
-
- function GodModel:GetLimitConfByPhase( phase )
- if not self.activity_limit_conf then
- self.activity_limit_conf = {}
- for k,v in pairs(Config.Godlotteryphase) do
- self.activity_limit_conf[v.phase] = v
- end
- end
- return self.activity_limit_conf[phase]
- end
-
- function GodModel:GetCommonConfByPhase( phase )
- self.activity_common_conf = false
- if not self.activity_common_conf then
- self.activity_common_conf = {}
- for k,v in pairs(Config.Godnormalphase) do
- self.activity_common_conf[v.phase] = v
- end
- end
- return self.activity_common_conf[phase]
- end
-
- --上次变身的时间
- function GodModel:GetBecomeGodTime( )
- local curTime = TimeUtil:getServerTime()
- return self.become_god_time or curTime
- end
-
- -- function GodModel:SetBecomeGodTime( value )
- -- self.become_god_time = value
- -- end
-
- -- function GodModel:SetCanBecomeGodTime( time )
- -- self.can_become_god_time = time
- -- end
-
- function GodModel:SetBecomeGodTime( time_list )
- self.become_god_time_list = self.become_god_time_list or {}
- if not time_list then return end
- for k,v in pairs(time_list) do
- self.become_god_time_list[v.pos] = v
- self.become_god_time_list[v.pos].can_become_time = v.time + self:GetBecomeGodCD()
- end
- end
-
- function GodModel:GetCanBecomeGodTimeByPos( pos )
- if self.become_god_time_list and
- self.become_god_time_list[pos] and
- self.become_god_time_list[pos].can_become_time then
- return self.become_god_time_list[pos].can_become_time
- end
- return 0
- end
-
- function GodModel:GetLastBecomeGodTimeByPos( pos )
- if self.become_god_time_list and
- self.become_god_time_list[pos] and
- self.become_god_time_list[pos].time then
- return self.become_god_time_list[pos].time
- end
- return 0
- end
-
- function GodModel:GetBecomeGodCD( )
- local god_cd = Config.Godkv["god_summon_cd"] and Config.Godkv["god_summon_cd"].value_content or 300 --需要等5分钟才可以变身
- if SceneManager.Instance:IsGodDungeon() then--唤神副本cd打折
- local discounts = Trim(Config.Goddunkv["cd_decrease"].val)
- god_cd = god_cd*discounts
- end
- return god_cd
- end
-
- function GodModel:GetBecomeGodProgress( )
- if not self.can_become_god_time or not GetModuleIsOpen(173,1) or #self:GetGoFightGodList(true) == 0 then return 0, 0 end
-
- local curTime = TimeUtil:getServerTime()
- local left_time = self.can_become_god_time-curTime
- local max_time = self:GetBecomeGodCD()
- local pass_time = max_time - left_time--已经等了多久
- if pass_time > max_time then
- pass_time = max_time
- end
- if pass_time < 0 then
- pass_time = 0
- end
- return pass_time, max_time
- end
-
- --神灵的持续时间
- function GodModel:GetGodDuration( god_id )
- local duration = Config.Godkv["god_summon_time"] and Config.Godkv["god_summon_time"].value_content or 20--初始就有20秒
- local isActivedSuitEffect = self:IsActivedSuitEffect(god_id, GodConst.SuitEffect.AddGodLifeTime, 1, true)
- if isActivedSuitEffect then
- --本神激活了二件套
- duration = duration+5
- end
- if self:IsActivedSuitEffectAddAllGodLifeTime() then
- --上阵的某神激活了四件套
- duration = duration+5
- end
- return duration
- end
-
- --是不是激活了4件套装
- function GodModel:IsActivedSuitEffectAddAllGodLifeTime( )
- local suit_lv = 2
- for k,v in pairs(self:GetGodList()) do
- --任意一位神灵激活4件套装的话,所有神灵都可以加成时间
- local isActivedSuitEffect = self:IsActivedSuitEffect(v.id, GodConst.SuitEffect.AddGodLifeTime, suit_lv)
- if isActivedSuitEffect then
- return true
- end
- end
- return false
- end
-
- function GodModel:GetOpenTask( sub_id,is_fade_show )
- self.open_task = self.open_task or {}
- local index = is_fade_show and 1 or 2
- if not self.open_task[index] then
- self.open_task[index] = 0
- sub_id = sub_id
- local _, base_conf = GetModuleOpenLevel( 173,sub_id,is_fade_show)
- if is_fade_show and base_conf and base_conf.icon_task and base_conf.icon_task ~= 0 then
- self.open_task[index] = base_conf.icon_task
- else
- self.open_task[index] = base_conf and base_conf.task_id or 0
- end
- end
- return self.open_task[index]
- end
-
- --获得座印套装名字列表
- function GodModel:GetSuitTypeNameList( )
- if not self.suit_name_list then
- self.suit_name_list = {}
- local have_list = {}
- local index = 1
- for k,v in pairs(Config.Godequipsuit) do
- if not have_list[v.suit_id] then
- self.suit_name_list[index] = {name = Trim(v.type_name),suit_id = v.suit_id}
- index = index + 1
- have_list[v.suit_id] = true
- end
- end
- local function sort_call( a,b )
- --从大到小
- return a.suit_id < b.suit_id
- end
- table.sort( self.suit_name_list, sort_call )
- end
- return self.suit_name_list
- end
-
-
- --抽奖每日免费剩余次数
- function GodModel:SetGodLeftFreeDrawTimes(vo)
- self.left_free_draw_times = vo.free_times
- end
-
- function GodModel:GetGodLeftFreeDrawTimes( )
- return self.left_free_draw_times
- end
-
- function GodModel:GetPreviewShowAwardData( )
- local base_data = self:GetActivityLimitInfo()
- if not base_data then return {} end
- if self.god_ac_pool and self.god_ac_pool[base_data.phase] then
- return self.god_ac_pool[base_data.phase]
- end
- self.god_ac_pool = self.god_ac_pool or {}
- local temp_tb = {}
- temp_tb.data = {}
- temp_tb.color_weight = {}
- temp_tb.total_weight = 0
- local goods_model = GoodsModel:getInstance()
- local lv = RoleManager.Instance.mainRoleInfo.level
- for k,v in pairs(Config.Godlimitpool) do
- if (v.phase == base_data.phase or v.phase == 0) and v.need_lv <= lv then
- local temp = stringtotable(v.awards)[1]
- local color = goods_model:GetGoodsColorNum( tonumber(temp[2]) )
- temp[4] = v.weight
- -- 奖励
- temp_tb.data[color] = temp_tb.data[color] or {}
- table.insert( temp_tb.data[color], temp )
- -- 总权重
- temp_tb.total_weight = temp_tb.total_weight + temp[4]
- -- 品质权重
- temp_tb.color_weight[color] = temp_tb.color_weight[color] or 0
- temp_tb.color_weight[color] = temp_tb.color_weight[color] + temp[4]
- end
- end
-
- local sort_func = function ( a, b )
- return a[4] < b[4]
- end
-
- for k,v in pairs(temp_tb.data) do
- table.sort(v, sort_func)
- end
- self.god_ac_pool[base_data.phase] = temp_tb
- return self.god_ac_pool[base_data.phase]
- end
-
- -- 获取星星资源
- function GodModel:GetStarResName( show_star )
- local style_a, style_b = 0, 0 -- 资源
- local temp_a = math.floor(show_star / 5) -- 整数
- local temp_b = show_star % 5 -- 余数
- if temp_b == 0 then
- style_a = temp_a
- style_b = temp_a
- else
- style_a = temp_a
- style_b = temp_a + 1
- end
- local res_a, res_b = false, false
- res_a = style_a == 0 and "god_star_0" or "god_star_" .. style_a .. "_1"
- res_b = style_b == 0 and "god_star_0" or "god_star_" .. style_b .. "_1"
- return res_a, res_b
- end
|