|
|
- --[[
- 合成跳转配置备注:
- 1.菜单id填大标签id。
- 2.要跳转到装备部位,填部位id(具体合成id的上一级)
- --]]
-
- ComposeModel = ComposeModel or BaseClass(EventDispatcher)
-
- local ComposeModel = ComposeModel
- ComposeModel.UPDATE_COMPOSE_VIEW_RED = "ComposeModel.UPDATE_COMPOSE_VIEW_RED"--更新红点
-
- local table_insert = table.insert
- local Trim = Trim
- local stringtotable = stringtotable
-
- -- 菜单ID
- ComposeModel.ComposePanelID = ComposeModel.ComposePanelID or {
- GOODS_JEWEL = 10000000, --宝石合成
- UPGRADE_ITEM = 20000000, --进阶合成
- EQUIP_CAREER = 30000000, --装备合成
- EQUIP_CAREER1 = 31000000, --职业1魔剑士装备
- EQUIP_CAREER2 = 32000000, --职业2龙骑士装备
- EQUIP_CAREER3 = 33000000, --职业3魔导士装备
- EQUIP_CAREER4 = 34000000, --职业4重炮手装备
- GOODS_SUIT = 40000000, --套装
- GOODS_ITEM = 50000000, --道具合成
- }
-
- --页签
- ComposeModel.MainTab = {
- Guard = 1,--守护
- Ornaments = 2,--饰品
- Draconic = 3,--刻印
- Gemstone = 4,--宝石
- Galaxy = 5,--星辰
- AwardBox = 6,--宝箱合成
- Other = 7,--其他合成
- Equip = 8,--装备合成
- }
-
- function ComposeModel:__init()
- ComposeModel.Instance = self
- self:Reset()
- end
-
- function ComposeModel:Reset()
- self.red_dot_info = {}--页签红点数据
- self.gemstone_login_red = true
- self.galaxy_login_red = true
- self.is_first_open_view = true--第一次打开合成界面不需要选择 默认帮他选择第一个页签
- self.goods_model = GoodsModel:getInstance()
- self.equip_model = EquipModel:getInstance()
- self.orange_jump_id = nil--橙装调整额外参数
- self:InitComposeCfg()
- end
-
- function ComposeModel:getInstance()
- if ComposeModel.Instance == nil then
- ComposeModel.New()
- end
- return ComposeModel.Instance
- end
-
- function ComposeModel:Clear()
-
- end
-
- --初始化合成配置
- function ComposeModel:InitComposeCfg( )
- -- Config.Goodscompose
- -- Config.Composemenu
- -- Config.Goodscomposeindex
-
- --合成类型控制配置
- self.compose_classify_cfg = {}
- local compose_classify_cfg = DeepCopy(Config.Goodscomposeorevolutionclassify)
- for k,v in pairs(compose_classify_cfg) do
- v.condition = stringtotable(v.condition)
- for i,vv in ipairs(v.condition) do
- if vv[1] == "open_lv" then
- v.open_lv = tonumber(vv[2])
- elseif vv[1] == "opday" then
- v.opday = tonumber(vv[2])
- end
- end
- if not self.compose_classify_cfg[v.id] then
- self.compose_classify_cfg[v.id] = {}
- end
- self.compose_classify_cfg[v.id][v.sub_id] = v
- end
- --物品合成升星物品typeid表
- self.goods_compose_info_cfg = {}
- --物品合成升星物品升星表
- self.up_quality_compose_list_cfg = {}
- self.equip_random_compose_list_cfg = {}----装备不指定合成配置表(服务端自己去购买获取装备随机属性的合成配置)
- local goods_compose_info_cfg = DeepCopy(Config.Goodscomposeorevolutioninfo)
- for k,v in pairs(goods_compose_info_cfg) do
- v.cost_goods = stringtotable(v.cost_goods)
- v.cost_money = stringtotable(v.cost_money)
- v.condition = stringtotable(v.condition)
- if v.condition then
- for i,vv in ipairs(v.condition) do
- if vv[1] == "open_lv" then
- v.open_lv = tonumber(vv[2])
- end
- end
- end
- if v.hidden ~= 1 then
- if not self.up_quality_compose_list_cfg[v.classify_id] then
- self.up_quality_compose_list_cfg[v.classify_id] = {}
- end
- if not self.up_quality_compose_list_cfg[v.classify_id][v.subclass] then
- self.up_quality_compose_list_cfg[v.classify_id][v.subclass] = {}
- end
- self.up_quality_compose_list_cfg[v.classify_id][v.subclass][#self.up_quality_compose_list_cfg[v.classify_id][v.subclass] + 1] = v
- end
- if v.classify_id == 1 or v.classify_id == 2 then
- if v.main_goods_id == 0 then
- self.equip_random_compose_list_cfg[v.target_goods_id] = v
- else
- self.goods_compose_info_cfg[v.main_goods_id] = v
- end
- end
- end
- end
-
- --刷新主界面装备图标红点
- function ComposeModel:CheckMainIconRedDot( )
- local show = false
- for k,v in pairs(self.red_dot_info) do
- if v == true then
- show = v
- break
- end
- end
- GlobalEventSystem:Fire(EventName.SHOW_FUNCTION_RED_POINT, 151, show)
- end
-
- --这样写红点 每次调全局的只要调两次
- function ComposeModel:IsNeedRedAll( )
- self.red_dot_info[ComposeModel.MainTab.Guard] = self:CheckGuardRedDot()
- self.red_dot_info[ComposeModel.MainTab.Ornaments] = self:CheckOrnamentsRedDot()
- self.red_dot_info[ComposeModel.MainTab.Gemstone] = self:CheckGemstoneRedDot()
- self.red_dot_info[ComposeModel.MainTab.Galaxy] = self:CheckGalaxyRedDot()
- self.red_dot_info[ComposeModel.MainTab.AwardBox] = self:CheckAwardBoxRedDot()
- self.red_dot_info[ComposeModel.MainTab.Other] = self:CheckOtherRedDot()
- self.red_dot_info[ComposeModel.MainTab.Equip] = self:CheckEquipRedDot()
-
-
-
- self:CheckMainIconRedDot()
- StrengthModel:getInstance():Fire(EventName.UPDATE_STRENGTH_MAIN_VIEW_SPECIAL)
- end
-
- --红点刷新
- function ComposeModel:IsNeedRed( tab_type,is_all,not_refresh_view )
- if not is_all then--全刷新就不判断等级了
- local can_refresh = self:CheckLevel(tab_type)
- if not can_refresh then return end
- end
-
- local bool = false
- if tab_type == ComposeModel.MainTab.Guard then--守护
- bool = self:CheckGuardRedDot()
- elseif tab_type == ComposeModel.MainTab.Ornaments then--饰品
- bool = self:CheckOrnamentsRedDot()
- elseif tab_type == ComposeModel.MainTab.Draconic then--刻印
-
- elseif tab_type == ComposeModel.MainTab.Gemstone then--宝石合成
- bool = self:CheckGemstoneRedDot()
- elseif tab_type == ComposeModel.MainTab.Galaxy then--星辰
- bool = self:CheckGalaxyRedDot()
- elseif tab_type == ComposeModel.MainTab.AwardBox then--宝箱合成
- bool = self:CheckAwardBoxRedDot()
- elseif tab_type == ComposeModel.MainTab.Other then--其他合成
- bool = self:CheckOtherRedDot()
- elseif tab_type == ComposeModel.MainTab.Equip then--装备合成
- bool = self:CheckEquipRedDot()
- end
- self.red_dot_info[tab_type] = bool
- -- print("huangcong:ComposeModel [start:159] :", self.red_dot_info)
- -- PrintTable(self.red_dot_info)
- -- print("huangcong:ComposeModel [end]")
- if not not_refresh_view then
- self:Fire(ComposeModel.UPDATE_COMPOSE_VIEW_RED,tab_type,bool)
- end
- if not is_all then
- self:CheckMainIconRedDot()
- end
- StrengthModel:getInstance():Fire(EventName.UPDATE_STRENGTH_MAIN_VIEW_SPECIAL)
- -- print("huangcong:ComposeModel [222]: ",bool,id)
- -- PrintTable(self.red_dot_info)
- end
-
- --检查等级
- function ComposeModel:CheckLevel( tab_type )
- local level = RoleManager:getInstance():GetMainRoleVo().level
- if tab_type == ComposeModel.MainTab.Guard and level >= Config.Modulesub["151@1"].open_lv then--守护
- return true
- elseif tab_type == ComposeModel.MainTab.Ornaments and level >= Config.Modulesub["151@2"].open_lv then--饰品
- return true
- elseif tab_type == ComposeModel.MainTab.Draconic and level >= Config.Modulesub["151@3"].open_lv then--刻印
- return true
- elseif tab_type == ComposeModel.MainTab.Gemstone and level >= Config.Modulesub["151@4"].open_lv then--宝石
- return true
- elseif tab_type == ComposeModel.MainTab.Galaxy and level >= Config.Modulesub["151@5"].open_lv then--星辰
- return true
- elseif tab_type == ComposeModel.MainTab.AwardBox and level >= Config.Modulesub["151@6"].open_lv then--宝箱合成
- return true
- elseif tab_type == ComposeModel.MainTab.Other and level >= Config.Modulesub["151@7"].open_lv then--其他合成
- return true
- elseif tab_type == ComposeModel.MainTab.Equip and level >= Config.Modulesub["151@8"].open_lv then--装备合成
- return true
- end
- return false
- end
-
- --检查守护的红点
- function ComposeModel:CheckGuardRedDot( )
- local have_red = self.equip_model:CheckGuardRedDot()--放在装备那边可以减少一部分红点刷新次数
- return have_red
- end
-
- --检查饰品红点
- function ComposeModel:CheckOrnamentsRedDot( )
- local have_red = self.equip_model:CheckOrnamentRedDot()--放在装备那边可以减少一部分红点刷新次数
- return have_red
- end
-
- --检查宝石红点
- function ComposeModel:CheckGemstoneRedDot( )
- do return false end
- local have_red = false--放在装备那边可以减少一部分红点刷新次数
- if not self.gemstone_login_red then
- return have_red
- end
- local cfg_list = self:GetEvolutionComposeListCfg(ComposeModel.MainTab.Gemstone) or {}
- local cost_list = nil
- local goods_num = 0
- for k,v in pairs(cfg_list) do
- if not have_red then
- for kk,vv in pairs(v) do
- cost_list = vv.cost_goods
- if cost_list and cost_list[1] then--宝石只需要判断下一级宝石是否满足合成数量接口
- goods_num = self.goods_model:GetTypeGoodsNum(cost_list[1][2])
- if goods_num >= cost_list[1][3] then
- have_red = true
- break
- end
- end
- end
- else
- break
- end
- end
- return have_red
- end
-
- --检查装备红点
- function ComposeModel:CheckEquipRedDot( )
- local cfg_list = self:GetEvolutionComposeListCfg(ComposeModel.MainTab.Equip) or {}
- local cost_list = nil
- local goods_num = 0
- local have_red = false
- for k,v in pairs(cfg_list) do
- if not have_red then
- for kk,vv in pairs(v) do
- if not self:CheckBagAndWearHaveOrangeEquip(vv.target_goods_id) then--如果身上和背包上没有就不用有红点了
- cost_list = vv.cost_goods
- if cost_list and cost_list[1] then--只要判断碎片是否足够就OK
- goods_num = self.goods_model:GetTypeGoodsNum(cost_list[1][2])
- if goods_num >= cost_list[1][3] then
- have_red = true
- break
- end
- end
- end
- end
- else
- break
- end
- end
- return have_red
- end
-
- --检查背包和身上穿戴是否有橙色装备
- function ComposeModel:CheckBagAndWearHaveOrangeEquip( type_id )
- local have_orange_equip = false--默认找不到
- local equip_cfg = self.equip_model:GetEquipmentCfg(type_id)
- if equip_cfg then
- local wear_goods_vo = self.goods_model:GetTargetSeriesTargetPosEquip(equip_cfg.series,equip_cfg.equip_type)
- if wear_goods_vo and wear_goods_vo.color >= 4 then
- return true
- end
- local bag_list = self.goods_model.bag_goods_list
- for i,v in pairs(bag_list) do
- local bag_equip_cfg = self.equip_model:GetEquipmentCfg(v.type_id)
- if bag_equip_cfg and self.equip_model:SelfCareerIsOk(v.type_id) and bag_equip_cfg.series == equip_cfg.series and bag_equip_cfg.equip_type == equip_cfg.equip_type and v.color >= 4 and v.goods_num > 0 then
- return true
- end
- end
- end
- return false
- end
-
- --检查星辰红点
- function ComposeModel:CheckGalaxyRedDot( )
- local have_red = false--放在装备那边可以减少一部分红点刷新次数
- if not self.galaxy_login_red then
- return have_red
- end
- local cfg_list = self:GetEvolutionComposeListCfg(ComposeModel.MainTab.Galaxy) or {}
- local cost_list = nil
- local goods_num = 0
- for k,v in pairs(cfg_list) do
- if not have_red then
- for kk,vv in pairs(v) do
- cost_list = vv.cost_goods
- if cost_list and cost_list[1] then--宝石只需要判断下一级宝石是否满足合成数量接口
- goods_num = self.goods_model:GetTypeGoodsNum(cost_list[1][2])
- if goods_num >= cost_list[1][3] then
- have_red = true
- break
- end
- end
- end
- else
- break
- end
- end
- return have_red
- end
-
-
- --检查宝箱合成红点
- function ComposeModel:CheckAwardBoxRedDot( )
- local have_red = false
- if self.awardBox_login_red then
- return have_red
- end
- local cfg_list = self:GetEvolutionComposeListCfg(ComposeModel.MainTab.AwardBox) or {}
- local cost_list = nil
- local goods_num = 0
- local is_all_have = false
- local openDay = ServerTimeModel:getInstance():GetOpenServerDay()
- local level = RoleManager.Instance.mainRoleInfo.level
- local open_lv = 0
- local open_day = 0
- for k,v in pairs(cfg_list) do
- if not have_red then
- for kk,vv in pairs(v) do
- open_lv = 0
- open_day = 0
- if #vv.condition > 0 then
- for kkk,vvv in ipairs(vv.condition) do
- if vvv[1] == "open_lv" then
- open_lv = tonumber(vvv[2])
- elseif vvv[1] == "opday" then
- open_day = tonumber(vvv[2])
- end
- end
- end
- if open_lv <= level and open_day <= openDay then
- cost_list = vv.cost_goods
- is_all_have = true
- for kkk,vvv in pairs(cost_list) do
- goods_num = self.goods_model:GetTypeGoodsNum(vvv[2])
- if goods_num < vvv[3] then
- is_all_have = false
- break
- end
- end
- if is_all_have then
- have_red = true
- end
- end
- end
- else
- break
- end
- end
- return have_red
- end
-
- --检查其他合成红点
- function ComposeModel:CheckOtherRedDot( )
- local have_red = false
- if self.other_login_red then
- return have_red
- end
- local cfg_list = self:GetEvolutionComposeListCfg(ComposeModel.MainTab.Other) or {}
- local cost_list = nil
- local goods_num = 0
- local is_all_have = false
- local openDay = ServerTimeModel:getInstance():GetOpenServerDay()
- local level = RoleManager.Instance.mainRoleInfo.level
- local open_lv = 0
- local open_day = 0
- for k,v in pairs(cfg_list) do
- if not have_red then
- for kk,vv in pairs(v) do
- open_lv = 0
- open_day = 0
- if #vv.condition > 0 then
- for kkk,vvv in ipairs(vv.condition) do
- if vvv[1] == "open_lv" then
- open_lv = tonumber(vvv[2])
- elseif vvv[1] == "opday" then
- open_day = tonumber(vvv[2])
- end
- end
- end
- if open_lv <= level and open_day <= openDay then
- cost_list = vv.cost_goods
- is_all_have = true
- for kkk,vvv in pairs(cost_list) do
- goods_num = self.goods_model:GetTypeGoodsNum(vvv[2])
- if goods_num < vvv[3] then
- is_all_have = false
- break
- end
- end
- if is_all_have then
- have_red = true
- end
- end
- end
- else
- break
- end
- end
- return have_red
- end
-
- --获得合成类型配置
- function ComposeModel:GetComposeTypeCfg( compose_type,compose_sub_type )
- if compose_type and compose_sub_type then
- if self.compose_classify_cfg[compose_type] then
- return self.compose_classify_cfg[compose_type][compose_sub_type]
- end
- elseif compose_type and not compose_sub_type then
- return self.compose_classify_cfg[compose_type]
- end
- end
-
- --获得道具(首饰)升品配置
- function ComposeModel:GetEvolutionComposeListCfg( classify_id )
- if self.up_quality_compose_list_cfg[classify_id] then
- local new_data = {}
- local up_quality_cfg = self.up_quality_compose_list_cfg[classify_id]
- local openDay = ServerTimeModel:getInstance():GetOpenServerDay()
- local level = RoleManager.Instance.mainRoleInfo.level
- local open_lv = 0
- local open_day = 0
- for i,v in pairs(up_quality_cfg) do
- for k,vv in pairs(v) do
- local type_id = vv.main_goods_id
- if classify_id == ComposeModel.MainTab.Equip then
- type_id = vv.target_goods_id
- end
- if self:IsCanCompose(vv.classify_id,vv.subclass,type_id) then
- if not new_data[vv.subclass] then
- new_data[vv.subclass] = {}
- end
- open_lv = 0
- open_day = 0
- if #vv.condition > 0 then
- for kkk,vvv in ipairs(vv.condition) do
- if vvv[1] == "open_lv" then
- open_lv = tonumber(vvv[2])
- elseif vvv[1] == "opday" then
- open_day = tonumber(vvv[2])
- end
- end
- end
- if open_lv <= level and open_day <= openDay then
- new_data[vv.subclass][#new_data[vv.subclass] + 1] = vv
- end
- end
- end
- end
- return new_data
- end
- end
-
- --获得道具ID合成配置
- function ComposeModel:GetEvolutionComposeCfg( type_id )
- if self.goods_compose_info_cfg[type_id] then
- local compose_type_cfg = self.compose_classify_cfg[self.goods_compose_info_cfg[type_id].classify_id][self.goods_compose_info_cfg[type_id].subclass]
- local openDay = ServerTimeModel:getInstance():GetOpenServerDay()
- local level = RoleManager.Instance.mainRoleInfo.level
- if compose_type_cfg and compose_type_cfg.open_lv <= level and compose_type_cfg.opday <= openDay then
- return self.goods_compose_info_cfg[type_id]
- end
- end
- end
-
- --装备不指定合成配置表
- function ComposeModel:GetEquipRandomComposeCfg( type_id )
- if self.equip_random_compose_list_cfg[type_id] then
- local compose_type_cfg = self.compose_classify_cfg[self.equip_random_compose_list_cfg[type_id].classify_id][self.equip_random_compose_list_cfg[type_id].subclass]
- local openDay = ServerTimeModel:getInstance():GetOpenServerDay()
- local level = RoleManager.Instance.mainRoleInfo.level
- if compose_type_cfg and compose_type_cfg.open_lv <= level and compose_type_cfg.opday <= openDay then
- return self.equip_random_compose_list_cfg[type_id]
- end
- end
- end
-
- --能否合成
- function ComposeModel:IsCanCompose( classify_id,subclass,type_id )
- if classify_id and subclass then
- local compose_type_cfg = self:GetComposeTypeCfg(classify_id,subclass)
- local openDay = ServerTimeModel:getInstance():GetOpenServerDay()
- local level = RoleManager.Instance.mainRoleInfo.level
- if classify_id == ComposeModel.MainTab.Equip and not self.equip_model:SelfCareerIsOk(type_id) then
- return false
- end
- if compose_type_cfg and compose_type_cfg.open_lv <= level and compose_type_cfg.opday <= openDay then--先满足主类型的
- if type_id and type_id ~= 0 then
- local goods_compose_cfg = self:GetEvolutionComposeCfg(type_id)
- if goods_compose_cfg and goods_compose_cfg.open_lv ~= nil then
- return level >= goods_compose_cfg.open_lv
- else
- return true
- end
- end
- return true
- end
- end
- return false
- end
-
- --获得刻印列表通过颜色和装备类型
- function ComposeModel:GetDraconicListByColorAndEquiptype( color,equip_type )
- local draconic_cfg_list = self.equip_model:GetDraconicCfg(equip_type)
- if draconic_cfg_list then
- draconic_cfg_list = DeepCopy(draconic_cfg_list)
- local new_list = {}
- for k,v in pairs(draconic_cfg_list) do
- if v.color == color then
- new_list[#new_list + 1] = v
- end
- end
- if #new_list > 1 then
- local sort_func = function ( a, b )
- return a.goods_id < b.goods_id
- end
- table.sort(new_list, sort_func)
- return new_list
- end
- end
- end
-
- --设置当前选中道具列表
- function ComposeModel:SetDraconicChooseList( list )
- self.draconic_choose_list = {}
- for i,v in pairs(list) do
- if v[4] then
- self.draconic_choose_list[#self.draconic_choose_list + 1] = v[4]
- end
- end
- -- print("huangcong:ComposeModel [start:263] :", self.draconic_choose_list)
- -- PrintTable(self.draconic_choose_list)
- -- print("huangcong:ComposeModel [end]")
- end
-
- function ComposeModel:GetDraconicChooseList( )
- return self.draconic_choose_list
- end
-
- --获得当前选择刻印的剩余数量 可能已经选了一个
- function ComposeModel:GetCurDraconicHaveNum( type_id )
- local goods_num = self.goods_model:GetTypeGoodsNum(type_id)
- local offer_num = 0
- for i,v in ipairs(self.draconic_choose_list) do
- if v.type_id == type_id then
- offer_num = offer_num + 1
- end
- end
- return goods_num - offer_num
- end
-
- --获取合成红点
- function ComposeModel:GetComposeRedDotByType( tab_type )
- if not tab_type then return false end
- return self.red_dot_info[tab_type]
- end
-
- --合成跳转
- function ComposeModel:TryComposeJump( tab_type )
- OpenFun.Open(151,1, type_id)
- end
-
- --请求装备合成
- function ComposeModel:ReqEquipCompose( choose_data,times,shop_item_info,cost_list,is_aotu_buy_cost)
- if not choose_data then return end
- local cur_cfg = choose_data
- if cur_cfg and cur_cfg.cost_goods[1] then
- local can_not_buy_list = {}
- local main_goods_id = cur_cfg.main_goods_id
- local goods_vo = nil
- local equip_cfg = self.equip_model:GetEquipmentCfg(main_goods_id)
- local secend_main_goods = tonumber(cur_cfg.cost_goods[1][2]) or nil
- if equip_cfg then
- secend_main_goods = equip_cfg.equip_type == EquipModel.EquipType.Guard and nil or secend_main_goods
- local series = equip_cfg.series
- local pos = equip_cfg.equip_type
- local wear_equip_suit_list = self.goods_model.wear_equip_suit_list
- if equip_cfg.equip_type == EquipModel.EquipType.Guard then
- for k,v in pairs(wear_equip_suit_list) do
- for kk,vv in pairs(v) do
- if vv.type_id == main_goods_id then
- goods_vo = vv
- elseif vv.type_id == secend_main_goods then
- goods_vo = vv
- cur_cfg = self:GetEvolutionComposeCfg(secend_main_goods)
- break
- end
- end
- end
- else
- if wear_equip_suit_list[series] and wear_equip_suit_list[series][pos] then
- if wear_equip_suit_list[series][pos].type_id == main_goods_id then
- goods_vo = wear_equip_suit_list[series][pos]
- elseif wear_equip_suit_list[series][pos].type_id == secend_main_goods then
- cur_cfg = self:GetEvolutionComposeCfg(secend_main_goods)
- goods_vo = wear_equip_suit_list[series][pos]
- end
- end
- end
- if not goods_vo then--如果是在背包中找到 主次合成物品ID调换
- local bag_list = self.goods_model.bag_goods_list
- for i,v in pairs(bag_list) do
- if (v.type_id == equip_cfg.goods_id or (v.type_id == secend_main_goods and equip_cfg.equip_type ~= EquipModel.EquipType.Guard)) and v.goods_num > 0 then
- goods_vo = v
- cur_cfg = self:GetEvolutionComposeCfg(v.type_id)
- break
- end
- end
- end
- end
- local cfg = cur_cfg
- if goods_vo then--主合成道具
- -- cfg = self:GetEvolutionComposeCfg(goods_vo.type_id)
- else
- cfg = self:GetEquipRandomComposeCfg(choose_data.target_goods_id)
- end
- if cfg then
- local data = {}
- data.rule_id = cfg.rule_id
- data.main_goods_id = goods_vo and goods_vo.goods_id or 0
- data.main_goods_location = goods_vo and goods_vo.pos or 2
- data.times = times or 1
- -- local list = self:GetUpQualityComposeList(cfg.cost_goods)--其实可以不拿 服务端可以自己拿的
- -- data.list = list or {}
- data.list = {}
- local auto_buy_list = {}
- local show_shop_item_num = 0
- if shop_item_info and TableSize(shop_item_info) > 0 then
- for i,v in ipairs(shop_item_info) do
- if v.shop_cfg then
- show_shop_item_num = show_shop_item_num + 1
- local shop_id,shop_num = v.shop_cfg.key_id,v.need_num
- if shop_id then
- auto_buy_list[#auto_buy_list + 1] = {shop_id,shop_num}
- end
- else
- can_not_buy_list[#can_not_buy_list + 1] = {0,v.type_id,v.need_num}
- end
- end
- end
- if #auto_buy_list > 0 and not is_aotu_buy_cost then
- Message.show("材料不足","fault")
- return
- end
- if #auto_buy_list == TableSize(shop_item_info) or TableSize(shop_item_info) == 0 then
- data.auto_buy_list = auto_buy_list
- print("huangcong:ComposeModel [start:131] :", data)
- PrintTable(data)
- print("huangcong:ComposeModel [end]")
- local ok = function ( )
- self:Fire(ComposeEvent.REQUEST_COMPOSE,data)
- end
- local goods_name = self.goods_model:getGoodsName(cfg.target_goods_id, true)
- local view_data = {}
- view_data.ok_callback = ok
- view_data.goods_name = goods_name
- view_data.times = times
- view_data.cost_list = cost_list or {}
- self:Fire(ComposeEvent.OPEN_COMPOSE_COST_AWARD_TIP_VIEW,view_data)
- else
- local view_data = {}
- view_data.cost_list = can_not_buy_list or {}
- local content_desc = string.format("当前缺失<color=%s>无法购买的材料</color>\n\n\n\n\n\n<color=%s>没有办法直接补齐材料合成哦</color>",ColorUtil.RED_DARK,ColorUtil.RED_DARK)
- view_data.content_desc = content_desc
- self:Fire(ComposeEvent.OPEN_COMPOSE_COST_AWARD_TIP_VIEW,view_data)
- end
- else
- Message.show("配置有误","fault")
- end
- end
- end
-
- --请求宝石合成
- function ComposeModel:ReqGemStoneCompose( choose_data,times,shop_item_info,cost_list,is_aotu_buy_cost )
- if not choose_data then return end
- local cfg = choose_data
- if cfg and cfg.cost_goods[1] then
- if cost_list then
- local can_not_buy_list = {}
- local data = {}
- data.rule_id = cfg.rule_id
- data.main_goods_id = 0
- data.main_goods_location = 0
- data.times = times or 1
- -- local list = self:GetUpQualityComposeList(cfg.cost_goods)--其实可以不拿 服务端可以自己拿的
- -- data.list = list or {}
- data.list = {}
- local auto_buy_list = {}
- local show_shop_item_num = 0
- if shop_item_info and TableSize(shop_item_info) > 0 then
- for i,v in ipairs(shop_item_info) do
- if v.shop_cfg then
- show_shop_item_num = show_shop_item_num + 1
- local shop_id,shop_num = v.shop_cfg.key_id,v.need_num
- if shop_id then
- auto_buy_list[#auto_buy_list + 1] = {shop_id,shop_num}
- end
- else
- can_not_buy_list[#can_not_buy_list + 1] = {0,v.type_id,v.need_num}
- end
- end
- end
- if #auto_buy_list > 0 and not is_aotu_buy_cost then
- Message.show("合成材料不足哦!")
- return
- end
- if #auto_buy_list == TableSize(shop_item_info) or TableSize(shop_item_info) == 0 then
- data.auto_buy_list = auto_buy_list
- print("huangcong:ComposeModel [start:715] :", data)
- PrintTable(data)
- print("huangcong:ComposeModel [end]")
- local ok = function ( )
- self:Fire(ComposeEvent.REQUEST_COMPOSE,data)
- end
- local goods_name = self.goods_model:getGoodsName(cfg.target_goods_id, true)
- local view_data = {}
- view_data.ok_callback = ok
- view_data.goods_name = goods_name
- view_data.times = times
- view_data.cost_list = cost_list or {}
- self:Fire(ComposeEvent.OPEN_COMPOSE_COST_AWARD_TIP_VIEW,view_data)
- else
- local view_data = {}
- view_data.cost_list = can_not_buy_list or {}
- local content_desc = string.format("当前缺失<color=%s>无法购买的材料</color>\n\n\n\n\n\n<color=%s>没有办法直接补齐材料合成哦</color>",ColorUtil.RED_DARK,ColorUtil.RED_DARK)
- view_data.content_desc = content_desc
- self:Fire(ComposeEvent.OPEN_COMPOSE_COST_AWARD_TIP_VIEW,view_data)
- end
- end
- end
- end
-
-
- --请求橙装合成
- function ComposeModel:ReqOrangeEquipCompose( choose_data,times,shop_item_info,cost_list,is_aotu_buy_cost )
- if not choose_data then return end
- local cfg = choose_data
- if cfg and cfg.cost_goods[1] then
- if cost_list then
- local can_not_buy_list = {}
- local data = {}
- data.rule_id = cfg.rule_id
- data.main_goods_id = 0
- data.main_goods_location = 0
- data.times = times or 1
- data.list = {}
- local auto_buy_list = {}
- local show_shop_item_num = 0
- if shop_item_info and TableSize(shop_item_info) > 0 then
- for i,v in ipairs(shop_item_info) do
- if v.shop_cfg then
- show_shop_item_num = show_shop_item_num + 1
- local shop_id,shop_num = v.shop_cfg.key_id,v.need_num
- if shop_id then
- auto_buy_list[#auto_buy_list + 1] = {shop_id,shop_num}
- end
- else
- can_not_buy_list[#can_not_buy_list + 1] = {0,v.type_id,v.need_num}
- end
- end
- end
- if #auto_buy_list > 0 and not is_aotu_buy_cost then
- Message.show("合成材料不足哦!")
- return
- end
- if #auto_buy_list == TableSize(shop_item_info) or TableSize(shop_item_info) == 0 then
- data.auto_buy_list = auto_buy_list
- self:Fire(ComposeEvent.REQUEST_COMPOSE,data)
- else
- local view_data = {}
- view_data.cost_list = can_not_buy_list or {}
- local content_desc = string.format("当前缺失<color=%s>无法购买的材料</color>\n\n\n\n\n\n<color=%s>没有办法直接补齐材料合成哦</color>",ColorUtil.RED_DARK,ColorUtil.RED_DARK)
- view_data.content_desc = content_desc
- self:Fire(ComposeEvent.OPEN_COMPOSE_COST_AWARD_TIP_VIEW,view_data)
- end
- end
- end
- end
-
- --请求宝箱或其他合成
- function ComposeModel:ReqAwardBoxOrOTherCompose( choose_data,times,shop_item_info,cost_list,is_aotu_buy_cost)
- if not choose_data then return end
- local cfg = choose_data
- if cfg and cfg.cost_goods[1] then
- if cost_list then
- local can_not_buy_list = {}
- local data = {}
- data.rule_id = cfg.rule_id
- data.main_goods_id = 0
- data.main_goods_location = 0
- data.times = times or 1
- -- local list = self:GetUpQualityComposeList(cfg.cost_goods)--其实可以不拿 服务端可以自己拿的
- -- data.list = list or {}
- data.list = {}
- local auto_buy_list = {}
- local show_shop_item_num = 0
- if shop_item_info and TableSize(shop_item_info) > 0 then
- for i,v in ipairs(shop_item_info) do
- if v.shop_cfg then
- show_shop_item_num = show_shop_item_num + 1
- local shop_id,shop_num = v.shop_cfg.key_id,v.need_num
- if shop_id then
- auto_buy_list[#auto_buy_list + 1] = {shop_id,shop_num}
- end
- else
- can_not_buy_list[#can_not_buy_list + 1] = {0,v.type_id,v.need_num}
- end
- end
- end
- if #auto_buy_list > 0 and not is_aotu_buy_cost then
- Message.show("合成材料不足哦!")
- return
- end
- if #auto_buy_list == TableSize(shop_item_info) or TableSize(shop_item_info) == 0 then
- data.auto_buy_list = auto_buy_list
- print("huangcong:ComposeModel [start:645] :", data)
- PrintTable(data)
- print("huangcong:ComposeModel [end]")
- local ok = function ( )
- self:Fire(ComposeEvent.REQUEST_COMPOSE,data)
- end
- local goods_name = self.goods_model:getGoodsName(cfg.target_goods_id, true)
- local view_data = {}
- view_data.ok_callback = ok
- view_data.goods_name = goods_name
- view_data.times = times
- view_data.cost_list = cost_list or {}
- self:Fire(ComposeEvent.OPEN_COMPOSE_COST_AWARD_TIP_VIEW,view_data)
- else
- local view_data = {}
- view_data.cost_list = can_not_buy_list or {}
- local content_desc = string.format("当前缺失<color=%s>无法购买的材料</color>\n\n\n\n\n\n<color=%s>没有办法直接补齐材料合成哦</color>",ColorUtil.RED_DARK,ColorUtil.RED_DARK)
- view_data.content_desc = content_desc
- self:Fire(ComposeEvent.OPEN_COMPOSE_COST_AWARD_TIP_VIEW,view_data)
- end
- end
- end
- end
-
- --获得守护或者饰品可以购买材料升品
- function ComposeModel:GetGuardOrOrnamentCanEvolution( equip_cfg )
- if not equip_cfg or not equip_cfg.goods_id then return end
- local compose_cfg = self:GetEvolutionComposeCfg(equip_cfg.goods_id)
- local limit_level = compose_cfg and compose_cfg.open_lv or 0
- local cost_list = RoleManager.Instance.mainRoleInfo.level >= limit_level and compose_cfg and compose_cfg.cost_goods or {}
- if cost_list and #cost_list > 0 then
- local shop_list = {}
- for kkk,vvv in ipairs(cost_list) do
- local goods_num = self.goods_model:GetTypeGoodsNum(vvv[2]) or 0
- if goods_num < vvv[3] then
- if self:GetShopCanBuyGoods(vvv) then--获得商城能否买道具
- else
- return false--如果有不能商城购买的消耗自己返回不能升品
- end
- end
- end
- return true
- end
- end
-
- --获得商城能否买道具
- function ComposeModel:GetShopCanBuyGoods( data )
- if not data or not data[2] then return end
- local goods_vo = self.goods_model:GetGoodsBasicByTypeId(data[2])
- if goods_vo then
- local cfg = ShopModel:getInstance():GetShopTypeIdBuyCFG(data[2])
- if cfg then
- cfg = DeepCopy(cfg)
- local new_data = {}
- for k,v in pairs(cfg) do
- new_data[#new_data + 1] = v
- end
- local sort_func = function ( a, b )
- return a.ctype > b.ctype
- end
- table.sort(new_data, sort_func)
-
- local quota_num = 0
- local jin = RoleManager.Instance.mainRoleInfo.jin--彩钻
- local jinLock = RoleManager.Instance.mainRoleInfo.jinLock--红钻
- local tong = RoleManager.Instance.mainRoleInfo.tong--交易券
- local honor = RoleManager.Instance.mainRoleInfo.honor--名望券
- local need_num = (data[3] or 1)--需要数量
- local have_num = self.goods_model:GetTypeGoodsNum(data[2]) or 0--拥有数量
- local need_price = 0
- local jin_enough = false
- for i,v in ipairs(new_data) do
- need_price = v.price * (need_num - have_num)
- --先判断钱够不够
- if v.ctype == 1 then--彩钻
- jin_enough = jin >= need_price
- elseif v.ctype == 2 then--红钻
- jin_enough = jinLock >= need_price
- elseif v.ctype == 3 then--交易券
- jin_enough = tong >= need_price
- elseif v.ctype == 4 then--名望券
- jin_enough = honor >= need_price
- end
- local shop_info = ShopModel:getInstance():GetGoodsShopInfoById(v.shop_type,v.sub_type,v.goods_id)
- if jin_enough then--如果钱够判断购买数量
- if v.quota_type > 0 and shop_info then--限购商品
- local left_num = v.quota_num - shop_info.sold_out
- if left_num >= need_num - have_num then
- return true
- end
- else--不限购
- return true
- end
- end
- end
- end
- end
- return false
- end
-
- --设置橙装合成跳转
- function ComposeModel:SetOrangeEquipComposeJumpInfo( type_id )
- if type_id == 108012 then--1代
- self.orange_jump_id = 801
- elseif type_id == 108022 then--2代
- self.orange_jump_id = 802
- elseif type_id == 108032 then--3代
- self.orange_jump_id = 803
- elseif type_id == 108042 then--4代
- self.orange_jump_id = 804
- elseif type_id == 108052 then--5代
- self.orange_jump_id = 805
- elseif type_id == 108062 then--6代
- self.orange_jump_id = 806
- end
- end
|