Files
fc/dev/project/library/imports/ca/cab3eaaa-2866-4b50-9801-bd72945f2ffb.js
T
2026-05-24 10:21:26 +08:00

2367 lines
80 KiB
JavaScript

"use strict";
cc._RF.push(module, 'cab3eqqKGZLUJgBvXKUXy/7', 'hero_model');
// Scripts/mod/partner/hero_model.js
"use strict";
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
// 这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: {DATE}
// --------------------------------------------------------------------
var BridgeClass = require("bridge.class");
var HeroConst = require("hero_const");
var PartnerConst = require("partner_const");
var HeroEvent = require("hero_event");
var PartnerCalculate = require("partner_calculate");
var HeroCalculate = require("hero_calculate");
var HeroController = require("hero_controller");
var BackpackController = require("backpack_controller");
var PathTool = require("pathtool");
var BackPackConst = require("backpack_const");
var RoleController = require("role_controller");
var FID = require("bridge.function.ids");
// const { util } = require("config");
// const { config } = require("process");
var HeroModel = cc.Class({
"extends": BridgeClass,
ctor: function ctor() {
this.ctrl = arguments[0];
},
properties: {},
initConfig: function initConfig() {
// 伙伴数据列表 (id :英雄唯一标识)
// 结构 this.hero_list[id] = hero_vo
this.hero_list = {};
// 伙伴bid列表的
// 结构 this.hero_bid_list[bid] = {hero_vo1,hero_vo2}
this.hero_bid_list = {};
// 伙伴数据数组形式存储,便于排序
this.hero_array = [];
// 标志第一次初始
this.is_init = true;
// 英雄上限
this.hero_max_count = 0;
// 英雄已激活上限次数
this.buy_num = 0;
//皮肤数据 结构: self.hero_skin_list[皮肤id] = 皮肤结束时间 (如果时间 == 0 表永久)
this.hero_skin_list = null;
// 英雄图书馆信息
this.dic_pokedex_info = null;
// 英雄图书馆信息 [bid] = 数据
this.dic_pokedex_bid = {};
// 熔炼祭坛的列表
this.dic_fuse_info = null;
// 已拥过有英雄id [bid] = 1
this.dic_had_hero_info = {};
// 布阵站位信息 this.pos_list[布阵类型][pos] = id
this.pos_list = {};
this.expedit_list = null;
// 阵法类型
this.use_formation_type = 1;
// 使用的圣器id
this.use_hallows_id = 0;
// 装备红点背包已更新 记录
this.is_equip_redpoint_bag_update = true;
// 装备红点英雄已更新 记录
this.is_equip_redpoint_hero_update = true;
// 是否延迟红点更新中 例子:this.is_delay_redpoint_update[HeroConst.RedPointType.eRPLevelUp] = true
// 目前只有升级红点用
this.is_delay_redpoint_update = {};
// 进阶和升星材料消耗 只能写死 如果策划改了.跟着改吧
this.upgrade_star_cost_id = 10001;
this.dic_star_count = {};
// 升星红点背包已更新 记录
this.is_upgradestar_redpoint_bag_update = true;
// 升星红点英雄已更新 记录
this.is_upgradestar_redpoint_hero_update = true;
// 阵法 红点 (一次性的)
this.is_redpoint_form = false;
// 圣器 红点 (一次性的)
this.is_redpoint_hallows = false;
// 记录登陆时候角色的等级 判断阵法是否新解锁用
this.record_login_lev = 0;
this.holy_equip_plans = {};
// 符文解锁条件信息
// var artifact_one = game.configs.partner_data.data_partner_const["artifact_one"].val;
// var artifact_two = game.configs.partner_data.data_partner_const["artifact_two"].val;
// this.artifact_lock_list = {"1":artifact_one, "2":artifact_two};
this.artifact_lucky = 0; // 符文祝福值
this.artifact_lucky_red = false; // 祝福值红点
// 英雄信息界面 升星页签的参数 6星才限时页签(后面策划要求熔炼祭坛的也加入)
this.hero_info_upgrade_star_param = 6;
this.hero_info_upgrade_star_param2 = 10;
this.hero_info_upgrade_star_param3 = 11;
this.hero_info_upgrade_star_param4 = 12;
// --天赋技能升星的材料
this.talent_skill_cost_id = 10450;
// --天赋技能可学习的列表 用于红点 结构 self.dic_hero_talent_skill_learn_redpoint[skill_id] = 1
this.dic_hero_talent_skill_learn_redpoint = {};
this.is_need_update_talent_redpoint = true;
// --共鸣水晶等级
this.resonate_cystal_lev = 0;
// --英雄共鸣锁定信息
this.dic_resonate_lock_info = {};
// --共鸣石碑等级
this.resonate_stone_level = 0;
// --共鸣历史星级
this.resonate_max_partner_lev = null; //--一定要nil 有地方判断nil来决定有木有数据
// --共鸣精炼红点
this.is_resonate_extract_redpoint = false;
this.dic_itemid_to_partner_id = {};
this.data_level_up_length = 200;
this.data_level_up_cache = {};
//穿戴在英雄身上的神裝信息結構 self.hero_holy_list[id] = good_vo
this.hero_holy_list = {};
},
setHeroMaxCount: function setHeroMaxCount(max_count) {
if (typeof max_count == "number") {
this.hero_max_count = max_count;
}
},
//--批量请求英雄的属性 装备等数据 11026
batchSendHeroInfo: function batchSendHeroInfo() {
if (this.hero_list) {
var list = [];
for (var k in this.hero_list) {
var v = this.hero_list[k];
list.push([partner_id = v.id]);
if (list.length > 150) {
HeroController.getInstance().sender11026(list);
list = [];
}
}
if (list.length > 0) {
//--请求英雄详细信息
HeroController.getInstance().sender11026(list);
}
}
},
// 获取英雄上上限
getHeroMaxCount: function getHeroMaxCount() {
var max_count = this.hero_max_count || 0;
var have_coutn = this.hero_array.length;
return {
max_count: max_count,
have_coutn: have_coutn
};
},
setHeroBuyNum: function setHeroBuyNum(buy_num) {
this.buy_num = Number(buy_num);
},
getHeroBuyNum: function getHeroBuyNum() {
return this.buy_num || 0;
},
// --根据bid 和star 获取对应的英雄信息
// --@return 英雄信息列表
getHeroInfoByBidStar: function getHeroInfoByBidStar(bid, star) {
if (!bid || !star) return;
var list = this.hero_bid_list[bid];
if (list) {
list.forEach(function (_item) {
if (_item.face_id == 0) {
_item.face_id = "null";
}
});
var return_list = [];
for (var i in list) {
var hero_vo = list[i];
if (hero_vo.star == star) {
return_list.push(hero_vo);
// table_insert(return_list, hero_vo)
}
}
return return_list;
}
return null;
},
/**
* 更新英雄列表
* @author zhanghuxing 2019-01-24
* @param {[type]} not_show_power 不显示战力变化提示
*/
updateHeroList: function updateHeroList(hero_list, is_add, not_show_power, is_detail_info) {
if (!hero_list) return;
for (var hero_i in hero_list) {
this.updateHeroVo(hero_list[hero_i], not_show_power, is_detail_info);
}
// console.log( "紅點相關" + count + JSON.stringify( lists ) );
// 熔炼祭坛的红点 新增需要重新算红点
if (is_add) {
HeroCalculate.getInstance().clearAllStarFuseRedpointRecord();
gcore.GlobalEvent.fire(HeroEvent.Hero_Data_Add, hero_list);
var lists = this.getHeroReformListByCamp(0);
var count = 0;
lists.forEach(function (_item) {
if (_item.result.is_redpoint) {
count++;
}
});
// console.log( "紅點相關" + count + JSON.stringify( lists ) );
nx.mTip.openTip("tipReform.show", count > 0);
}
// let reds = HeroCalculate.getInstance().checkAllHeroRedPoint();
// // console.log( "所有夥伴紅點相關" + JSON.stringify( reds ) );
this.is_init = false;
},
/**
* 更新单个英雄信息,如果没有则是新增;
*/
updateHeroVo: function updateHeroVo(info, not_show_power, is_detail_info) {
if (!info) return;
info.id = info.partner_id;
var bid = info.partner_bid || info.bid;
if (!bid && this.hero_list[info.id]) bid = this.hero_list[info.id].bid;
var par_cfg = game.configs.partner_data.data_partner_base[bid];
if (!par_cfg) return;
var is_add = false;
var true_star = info.star;
// if (!this.hero_list[hero_id] ){
// if (is_detail_info){
// return
// }
// this.hero_list[hero_id] = new HeroVo()
// is_add = true
// }
var hero_vo = this.hero_list[info.id];
if (!hero_vo) {
if (!is_detail_info) {
is_add = true;
var HeroVo = require("hero_vo");
hero_vo = this.hero_list[info.id] = new HeroVo();
for (var config_k in par_cfg) {
if (config_k !== "skills") info[config_k] = par_cfg[config_k];
if (config_k == "star") {
info[config_k] = true_star;
}
}
// let star = info.star || config.init_star
// if( this.dic_had_hero_info[ bid ] ) {
// if( this.dic_had_hero_info[ bid ] < star ) {
// this.dic_had_hero_info[ bid ] = star
// }
// } else {
// this.dic_had_hero_info[ bid ] = star
// }
}
// 设置角色id
// var RoleController = require( "role_controller" );
var role_vo = RoleController.getInstance().getRoleVo();
if (role_vo) {
info.rid = role_vo.rid;
info.srv_id = role_vo.srv_id;
}
}
// 旧数据
var old_vo = null;
var open_type = 0;
if (!is_add) {
if (!is_detail_info) {
// 处理升星、进阶
if (info.star && hero_vo.star < info.star) {
// 升星
open_type = 1;
old_vo = nx.dt.objClone(hero_vo);
var data = game.configs.partner_skill_data.data_partner_skill_const["skill_slot"].val;
if (hero_vo.star == data[1] - 1) {
hero_vo.is_open_talent = true;
}
if (info.star >= 10) {
// --清除 星級數量記錄
this.dic_star_count = {};
}
} else if (info.break_lev && hero_vo.break_lev < info.break_lev) {
// 进阶
open_type = 2;
old_vo = nx.dt.objClone(hero_vo);
}
}
} else {}
// 更新最大星级
// var cur_star = info.star || par_cfg.init_star;
// if( this.dic_had_hero_info[ bid ] ) {
// if( this.dic_had_hero_info[ bid ] < cur_star )
// this.dic_had_hero_info[ bid ] = cur_star;
// } else {
// this.dic_had_hero_info[ bid ] = cur_star;
// }
hero_vo.updateHeroVo(info);
if (is_add) {
this.hero_array.push(hero_vo);
if (!this.hero_bid_list[hero_vo.bid]) {
this.hero_bid_list[hero_vo.bid] = [];
}
this.hero_bid_list[hero_vo.bid].push(hero_vo);
} else {
if (open_type == 1 && old_vo) {
// 打开升星成功界面
this.ctrl.openHeroUpgradeStarExhibitionPanel(true, old_vo, hero_vo);
HeroCalculate.getInstance().clearAllHeroRecordByRedPointType(HeroConst.RedPointType.eRPStar);
} else if (open_type == 2 && old_vo) {
// 打开进阶成功界面
this.ctrl.openBreakExhibitionWindow(true, old_vo, hero_vo);
}
if (is_detail_info) {
hero_vo.setInitAttr();
gcore.GlobalEvent.fire(HeroEvent.Hero_Detail_Data_Update, hero_vo);
} else {
if (!not_show_power) {
if (hero_vo.partner_id == info.partner_id) {
// nx.bridge.vset( "ShowPartner", hero_vo );
gcore.GlobalEvent.fire(HeroEvent.Hero_Data_Update, hero_vo);
}
}
}
// gcore.GlobalEvent.fire(HeroEvent.Hero_Data_Update, hero_vo);
}
HeroCalculate.getInstance().checkHeroRedPointByRedPointType(HeroConst.RedPointType.eRPLevelUp);
},
updateSingle: function updateSingle(info, not_show_power, is_detail_info) {
if (!info) return;
info.id = info.partner_id;
var bid = info.partner_bid || info.bid;
if (!bid && this.hero_list[info.id]) bid = this.hero_list[info.id].bid;
var par_cfg = game.configs.partner_data.data_partner_base[bid];
if (!par_cfg) return;
var is_add = false;
var true_star = info.star;
// if (!this.hero_list[hero_id] ){
// if (is_detail_info){
// return
// }
// this.hero_list[hero_id] = new HeroVo()
// is_add = true
// }
var hero_vo = this.hero_list[info.id];
if (!hero_vo) {
if (!is_detail_info) {
is_add = true;
var HeroVo = require("hero_vo");
hero_vo = this.hero_list[info.id] = new HeroVo();
for (var config_k in par_cfg) {
if (config_k !== "skills") info[config_k] = par_cfg[config_k];
if (config_k == "star") {
info[config_k] = true_star;
}
}
}
// 设置角色id
// var RoleController = require( "role_controller" );
var role_vo = RoleController.getInstance().getRoleVo();
if (role_vo) {
info.rid = role_vo.rid;
info.srv_id = role_vo.srv_id;
}
}
// 旧数据
var old_vo = null;
var open_type = 0;
if (!is_add) {
if (!is_detail_info) {
// 处理升星、进阶
if (info.star && hero_vo.star < info.star) {
// 升星
open_type = 1;
old_vo = nx.dt.objClone(hero_vo);
var data = game.configs.partner_skill_data.data_partner_skill_const["skill_slot"].val;
if (hero_vo.star == data[1] - 1) {
hero_vo.is_open_talent = true;
}
if (info.star >= 10) {
// --清除 星級數量記錄
this.dic_star_count = {};
}
} else if (info.break_lev && hero_vo.break_lev < info.break_lev) {
// 进阶
open_type = 2;
old_vo = nx.dt.objClone(hero_vo);
}
}
} else {}
hero_vo.updateHeroVo(info);
if (is_add) {
this.hero_array.push(hero_vo);
if (!this.hero_bid_list[hero_vo.bid]) {
this.hero_bid_list[hero_vo.bid] = [];
}
this.hero_bid_list[hero_vo.bid].push(hero_vo);
} else {
if (open_type == 1 && old_vo) {
// 打开升星成功界面
this.ctrl.openHeroUpgradeStarExhibitionPanel(true, old_vo, hero_vo);
HeroCalculate.getInstance().clearAllHeroRecordByRedPointType(HeroConst.RedPointType.eRPStar);
} else if (open_type == 2 && old_vo && old_vo.resonate_lev == 0) {
// 打开进阶成功界面
this.ctrl.openBreakExhibitionWindow(true, old_vo, hero_vo);
}
if (is_detail_info) {
hero_vo.setInitAttr();
gcore.GlobalEvent.fire(HeroEvent.Hero_Detail_Data_Update, hero_vo);
} else {
// if( !not_show_power ) {
// if( hero_vo.partner_id == info.partner_id ) {
// nx.bridge.vset( "ShowPartner", hero_vo );
// // gcore.GlobalEvent.fire( HeroEvent.Hero_Data_Update, hero_vo )
// }
// }
}
if (hero_vo.resonate_lev == 0) {
nx.bridge.vset("ShowPartner", hero_vo);
}
gcore.GlobalEvent.fire(HeroEvent.Hero_Data_Update, hero_vo);
}
HeroCalculate.getInstance().checkHeroRedPointByRedPointType(HeroConst.RedPointType.eRPLevelUp);
HeroCalculate.getInstance().checkHeroRedPointByRedPointType(HeroConst.RedPointType.eRPStar);
},
getHeroNumByBid: function getHeroNumByBid(bid) {
if (!bid) {
return 0;
}
;
var list = this.hero_bid_list[bid] || {};
return list.length;
},
// 获取单个伙伴数据,id
// @id 是英雄唯一标识id
getHeroById: function getHeroById(partner_id) {
if (!this.hero_list) return;
if (!partner_id || typeof partner_id != "number") return;
return this.hero_list[partner_id] || {};
},
// 删除英雄
delHeroDataList: function delHeroDataList(list) {
if (!list) return;
var delParts = [];
// cc.log( "delHeroDataList" )
for (var hero_i in list) {
var v = list[hero_i];
var temp_bid = this.hero_list[v.partner_id].bid;
delParts.push(this.hero_list[list[hero_i].partner_id]);
delete this.hero_list[list[hero_i].partner_id];
// --同时从bid英雄列表删除该英雄记录
var bidlist = this.hero_bid_list[temp_bid];
if (bidlist) {
for (var i = 0; i < bidlist.length; ++i) {
var hero_vo = bidlist[i];
if (hero_vo.partner_id == v.partner_id) {
bidlist.splice(i, 1);
}
}
}
}
this.hero_array = [];
for (var hero_i in this.hero_list) {
this.hero_array.push(this.hero_list[hero_i]);
}
// 消除熔炼祭坛的红点 删除也要重新算
HeroCalculate.getInstance().clearAllStarFuseRedpointRecord();
// 升星红点
this.is_upgradestar_redpoint_hero_update = true;
this.checkUpgradeStarRedPointUpdate();
gcore.GlobalEvent.fire(HeroEvent.Del_Hero_Event, delParts);
},
// --更新天赋信息
updateHeroVoTalent: function updateHeroVoTalent(data_list, is_not_check) {
var is_team = false;
var self = this;
for (var i = 0; i < data_list.length; ++i) {
var v = data_list[i];
if (self.hero_list[v.partner_id]) {
self.hero_list[v.partner_id].updateSkill(v.dower_skill);
if (!is_team) {
if (self.hero_list[v.partner_id].isFormDrama()) {
is_team = true;
}
}
}
}
if (is_team && !is_not_check) {
// --如果有剧情阵容的英雄..需要检查红点
// --检测红点
// HeroCalculate.getInstance().checkAllHeroRedPoint()
}
},
getHeroList: function getHeroList() {
return this.hero_list || {};
},
getAllHeroArray: function getAllHeroArray() {
this.hero_array.forEach(function (_item) {
if (_item.face_id == 0) {
_item.face_id = "null";
}
});
return this.hero_array;
},
// 根据阵容获取英雄列表
getHeroListByCamp: function getHeroListByCamp(camp) {
if (typeof camp !== "number") return;
var hero_list = [];
for (var hero_i in this.hero_array) {
if (camp === HeroConst.CampType.eNone || camp === this.hero_array[hero_i].camp_type) {
// if( this.hero_array[ hero_i ]. )
if (this.hero_array[hero_i].is_in_form > 0) {
this.hero_array[hero_i].sortidd = this.hero_array[hero_i].quality;
} else {
this.hero_array[hero_i].sortidd = this.hero_array[hero_i].quality - 3;
}
if (this.hero_array[hero_i].face_id == 0) {
this.hero_array[hero_i].face_id = "null";
}
hero_list.push(this.hero_array[hero_i]);
}
}
// hero_list.forEach( _item => {
// if( _item.face_id == 0 ) {
// _item.face_id = "null";
// }
// } )
var hero_sort = this.getHeroSortFunc();
return hero_list.sort(hero_sort);
},
getHeroListByStar: function getHeroListByStar(_star) {
var hero_list = [];
for (var hero_i in this.hero_array) {
if (_star == this.hero_array[hero_i].star) {
hero_list.push(this.hero_array[hero_i]);
}
}
return hero_list;
},
// 获取指定BID的所有伙伴
getHeroListByBid: function getHeroListByBid(_bid) {
var hero_list = [];
for (var hero_i in this.hero_array) {
if (_bid == this.hero_array[hero_i].bid) {
hero_list.push(this.hero_array[hero_i]);
}
}
return hero_list;
},
// 改造 根据阵容获取4星以上英雄列表
getHeroReformListByCamp: function getHeroReformListByCamp(camp) {
var camp_type = camp || 0;
var camp_fuse_list = [];
var fuse_cfg = game.configs.partner_data.data_partner_fuse_star;
if (!fuse_cfg) return;
for (var cfg_i in fuse_cfg) {
var fuse_cfg_item = fuse_cfg[cfg_i];
var base_config = game.configs.partner_data.data_partner_base[cfg_i];
for (var item_i in fuse_cfg_item) {
var star = fuse_cfg_item[item_i].star;
var key = cfg_i + "_" + star;
var star_config = gdata("partner_data", "data_partner_star", key);
// game.configs.partner_data.data_partner_star[key];
if (base_config && (base_config.camp_type == camp_type || camp_type === 0)) {
if (base_config && star_config && star_config.expend1.length > 0) {
var fuse_data = {};
// fuse_data.base_config = base_config;
// fuse_data.star_config = star_config;
fuse_data.result = HeroCalculate.getInstance().checkSingleStarFuseRedPointByStarConfig(star_config, false, cfg_i);
fuse_data.red = fuse_data.result.is_redpoint ? 1 : 0;
fuse_data._flag = "partner", fuse_data.camp_type = base_config.camp_type;
fuse_data.bid = cfg_i;
fuse_data.icon = base_config.item_id;
fuse_data.res_id = star_config.res_id;
fuse_data.item_id = base_config.item_id;
fuse_data.quality = base_config.quality;
fuse_data.type = base_config.type;
fuse_data.stars = star;
camp_fuse_list.push(fuse_data);
}
}
}
}
return camp_fuse_list;
},
// 根据阵容获取英雄列表
getDeepHeroListByCamp: function getDeepHeroListByCamp(camp) {
if (typeof camp !== "number") return;
var hero_list = [];
for (var hero_i in this.hero_array) {
if (camp === HeroConst.CampType.eNone || camp === this.hero_array[hero_i].camp_type) {
hero_list.push(this.hero_array[hero_i]);
}
}
var hero_sort = this.getHeroSortFunc();
return hero_list.sort(hero_sort);
},
getRestHeroListByCamp: function getRestHeroListByCamp(camp, type) {
if (typeof camp !== "number") return;
var hero_list = [];
for (var hero_i in this.hero_array) {
if (camp === HeroConst.CampType.eNone || camp === this.hero_array[hero_i].camp_type) {
if (type) {
if (this.hero_array[hero_i].is_lock == 0) {
hero_list.push(this.hero_array[hero_i]);
}
} else {
hero_list.push(this.hero_array[hero_i]);
}
}
}
var rest_hero_list = hero_list;
for (var hero_i in rest_hero_list) {
var hero_vo = rest_hero_list[hero_i];
if (hero_vo.is_in_form > 0 || hero_vo.is_lock) {
hero_vo.is_ui_lock = true;
}
}
rest_hero_list.forEach(function (_item) {
if (_item.face_id == 0) {
_item.face_id = "null";
}
});
var hero_sort = function hero_sort(role_vo1, role_vo2) {
if (!role_vo1.is_ui_lock && !role_vo2.is_ui_lock || role_vo1.is_ui_lock && role_vo2.is_ui_lock) {
if (role_vo1.star === role_vo2.star) {
if (role_vo1.power == role_vo2.power) {
if (role_vo1.lev == role_vo2.lev) {
return role_vo2.sort_order - role_vo1.sort_order;
} else {
return role_vo1.lev - role_vo2.lev;
}
} else {
return role_vo1.power - role_vo2.power;
}
} else {
return role_vo1.star - role_vo2.star;
}
} else {
if (role_vo1.is_ui_lock) return 1;
return -1;
}
};
return rest_hero_list.sort(hero_sort);
},
setHadHeroInfo: function setHadHeroInfo(list) {
if (!list) return;
for (var hero_i in list) {
this.dic_had_hero_info[list[hero_i].partner_id] = list[hero_i].max_star;
}
var sfg = game.configs.source_data.data_source_data[FID.Equips];
var eqm = nx.bridge.checkConditions(sfg.lev_limit);
if (nx.dt.objEmpty(eqm)) {
this.dealReformEqm();
}
// this.dealPartnerSplinterRed();
// console.log( JSON.stringify( cfg ) + "裝備相關處理紅點起始" + JSON.stringify( eqms ) );
},
// 背包中 夥伴碎片合成紅點處理
dealPartnerSplinterRed: function dealPartnerSplinterRed() {
var can_merge = BackpackController.getInstance().getModel().getHeroChipRedPoint();
nx.mTip.openTip("bag.partnermerge", can_merge);
},
// 處理 改造 義肢合成--- 芯片合成紅點
dealReformEqm: function dealReformEqm() {
nx.mTip.openTip("tipReform.equip.arm", false);
nx.mTip.openTip("tipReform.equip.foot", false);
nx.mTip.openTip("tipReform.equip.clothes", false);
nx.mTip.openTip("tipReform.equip.head", false);
var cfg = game.configs.partner_eqm_data.data_eqm_compose_id;
var artifacts = BackpackController.getInstance().getModel().getAllBackPackArray(BackPackConst.item_sub_type.SPECIAL);
var eqms = BackpackController.getInstance().getModel().getBagItemList(BackPackConst.Bag_Code.EQUIPS);
var count = 0;
var type = [];
var have = BackpackController.getInstance().getModel().getItemNumByBid(1);
;
for (var i in cfg) {
var eqm = cfg[i];
var need = eqm.expend[0][0];
for (var e in eqms) {
var eqmBag = eqms[e];
if (eqmBag.base_id == need) {
if (eqmBag.quantity >= eqm.expend[0][1] && have >= eqm.expend[1][1]) {
count++;
if (!nx.dt.arrMember(type, eqm.type)) {
type.push(eqm.type);
}
// break;
}
}
}
}
if (nx.dt.arrNEmpty(type)) {
for (var _i = 0; _i < type.length; _i++) {
var item = type[_i];
if (item == 1) {
nx.mTip.openTip("tipReform.equip.arm", true);
} else if (item == 2) {
nx.mTip.openTip("tipReform.equip.foot", true);
} else if (item == 3) {
nx.mTip.openTip("tipReform.equip.clothes", true);
} else if (item == 4) {
nx.mTip.openTip("tipReform.equip.head", true);
}
}
}
nx.mTip.openTip("tipReform.equip", count > 0);
var acfg = game.configs.partner_artifact_data.data_artifact_data;
var samef = [];
var target_lev = 0;
for (var arttt in acfg) {
var artcfg = nx.dt.objClone(acfg[arttt]);
artcfg.quantity = 0;
artcfg.needCoins = 0;
artcfg.targetid = 0;
artcfg.target_lev = 0;
for (var art = 0; art < artifacts.length; art++) {
var bag = artifacts[art];
if (bag.base_id == artcfg.id) {
artcfg.quantity++;
artcfg.targetid = artcfg.com_artifact;
// artcfg.needCoins +=
}
if (artcfg.quantity >= 5 && acfg[artcfg.targetid]) {
artcfg.target_lev = acfg[artcfg.targetid].limit_lv;
}
}
samef.push(artcfg);
}
var arthave = 0;
var lev = 0;
var needCoins = 0;
samef.forEach(function (_art) {
if (_art.quantity >= 5) {
arthave = _art.quantity;
lev = _art.target_lev;
needCoins = _art.ref_expend[1][1];
}
});
nx.mTip.openTip("tipReform.artifact", arthave >= 5 && RoleController.getInstance().getRoleVo().lev >= lev && have >= needCoins);
},
// 初始化图鉴数据
getHeroPokedexList: function getHeroPokedexList(camp) {
if (!this.dic_pokedex_info) {
this.dic_pokedex_info = {};
for (var camp_i in HeroConst.CampType) {
if (camp_i !== "eNone") this.dic_pokedex_info[HeroConst.CampType[camp_i]] = [];
}
var pokedex_cfg = game.configs.partner_data.data_partner_pokedex;
if (pokedex_cfg) {
for (var bid in pokedex_cfg) {
var par_cfg = game.configs.partner_data.data_partner_base[bid];
for (var star_i in pokedex_cfg[bid]) {
var star = pokedex_cfg[bid][star_i].star;
var key = bid + "_" + star;
var info = this.getHeroPokedexByBid(key);
if (info) {
this.dic_pokedex_info[info.camp_type].push(info);
}
}
}
}
var sort_function = function sort_function(dic_pokedex_1, dic_pokedex_2) {
if (dic_pokedex_1.star === dic_pokedex_2.star) {
return dic_pokedex_1.bid - dic_pokedex_2.bid;
} else {
return dic_pokedex_1.star - dic_pokedex_2.star;
}
};
// 排序
for (var dic_pokedex_i in this.dic_pokedex_info) {
this.dic_pokedex_info[dic_pokedex_i].sort(sort_function);
}
}
return this.dic_pokedex_info[camp];
},
getHeroPokedexByBid: function getHeroPokedexByBid(key) {
if (this.dic_pokedex_bid[key]) return this.dic_pokedex_bid[key];
var par_show_cfg = gdata("partner_data", "data_partner_show", key);
if (!par_show_cfg) {
return null;
}
var par_base_cfg = game.configs.partner_data.data_partner_base[par_show_cfg.bid];
if (par_base_cfg) {
var break_lev = this.getHeroMaxBreakCountByInitStar(par_show_cfg.star);
par_show_cfg.hp_max = par_show_cfg.hp; // 为了计算战力用的
par_show_cfg.power = PartnerCalculate.calculatePower(par_show_cfg);
par_show_cfg.camp_type = par_base_cfg.camp_type;
par_show_cfg.name = par_base_cfg.name;
par_show_cfg.init_star = par_base_cfg.init_star;
par_show_cfg.type = par_base_cfg.type;
par_show_cfg.break_id = par_base_cfg.break_id;
par_show_cfg.break_lev = break_lev;
par_show_cfg.partner_id = par_show_cfg.bid * 10 + par_show_cfg.star; // 定义一个唯一id
par_show_cfg.is_pokedex = true; // 是不是图鉴
this.dic_pokedex_bid[key] = par_show_cfg;
return this.dic_pokedex_bid[key];
}
return null;
},
// 根据初始星级 或者对应英雄最大进阶次数
getHeroMaxBreakCountByInitStar: function getHeroMaxBreakCountByInitStar(init_star) {
if (!this.dic_max_break) {
var val = game.configs.partner_data.data_partner_const.advanced_limit.val;
this.dic_max_break = {};
for (var val_i in val) {
this.dic_max_break[val[val_i][0]] = val[val_i][1];
}
}
return this.dic_max_break[init_star] || 0;
},
// 根据品质获取默认头像
getRandomHeroHeadByQuality: function getRandomHeroHeadByQuality(quality) {
if (!this.dic_random_hero_head) {
var val = game.configs.partner_data.data_partner_const.random_hero_icon.val;
this.dic_random_hero_head = {};
for (var val_i in val) {
var item_config = gitemdata(val[val_i][1]);
if (item_config) this.dic_random_hero_head[val[val_i][0]] = item_config.icon;
}
}
var quality = quality || 0;
if (quality > 5) quality = 5;
return this.dic_random_hero_head[quality];
},
// --根据阵营和星级.得到对应来源的道具id
// --self.dic_source_item_ids[camp][star] = item_id
getSourceHeroCombinationByCampStar: function getSourceHeroCombinationByCampStar(camp, star) {
if (!this.dic_source_item_ids) {
this.dic_source_item_ids = [];
var val = game.configs.partner_data.data_partner_const.source_hero_combination.val;
for (var i in val) {
var val_i = val[i];
if (this.dic_source_item_ids[val_i[0]] == null) {
this.dic_source_item_ids[val_i[0]] = [];
}
this.dic_source_item_ids[val_i[0]][val_i[1]] = [val_i[3]];
}
}
if (this.dic_source_item_ids[camp]) {
var _star2 = _star2 || 0;
if (_star2 == 0) {
_star2 = 3; //--最低星就三
}
return this.dic_source_item_ids[camp][_star2];
}
},
getHadHeroInfo: function getHadHeroInfo() {
return this.dic_had_hero_info || {};
},
getHadHeroStarBybid: function getHadHeroStarBybid(bid) {
if (this.dic_had_hero_info && this.dic_had_hero_info[bid]) {
return this.dic_had_hero_info[bid];
}
return null;
},
isOpenTanlentByHerovo: function isOpenTanlentByHerovo(hero_vo) {
var data = game.configs.partner_skill_data.data_partner_skill_const["skill_slot"].val;
if (hero_vo[data[0]]) {
if (hero_vo[data[0]] >= data[1]) {
return true;
}
}
return false;
},
/************阵法相关************/
//order 参数用于同一类型玩法的多个组别
setFormList: function setFormList(data, order) {
var form_type = data.type >= 0 ? data.type : PartnerConst.Fun_Form.Drama;
if (this.pos_list[form_type]) {
if (order) {
for (var form_i in this.pos_list[form_type][order]) {
var vo = this.getHeroById(this.pos_list[form_type][order][form_i].id);
if (vo && vo.updateFormPos) {
vo.updateFormPos(0, form_type);
}
}
} else {
for (var form_i in this.pos_list[form_type]) {
var vo = this.getHeroById(this.pos_list[form_type][form_i].id);
if (vo && vo.updateFormPos) {
vo.updateFormPos(0, form_type);
}
}
}
}
this.pos_list[form_type] = {};
if (order) {
this.pos_list[form_type][order] = {};
for (var pos_i in data.pos_info) {
this.pos_list[form_type][order][data.pos_info[pos_i].pos] = data.pos_info[pos_i];
var vo = this.getHeroById(data.pos_info[pos_i].id);
// 容错处理 bugly出现说 updateFormPos 这个是 (a null value)
if (vo && vo.updateFormPos) vo.updateFormPos(data.pos_info[pos_i].pos, form_type);
}
} else {
for (var pos_i in data.pos_info) {
this.pos_list[form_type][data.pos_info[pos_i].pos] = data.pos_info[pos_i];
var vo = this.getHeroById(data.pos_info[pos_i].id);
// 容错处理 bugly出现说 updateFormPos 这个是 (a null value)
if (vo && vo.updateFormPos) vo.updateFormPos(data.pos_info[pos_i].pos, form_type);
}
}
// 剧情阵法逻辑
if (form_type == PartnerConst.Fun_Form.Drama) {
this.form_power = data.power || 0;
// 阵法类型
this.use_formation_type = data.formation_type;
// 使用的圣器id
this.use_hallows_id = data.hallows_id;
// gcore.GlobalEvent.fire(HeroEvent.Form_Drama_Event,data)
// var calculate = HeroCalculate.getInstance();
// RedMgr.getInstance().addCalHandler( calculate.checkAllHeroRedPoint.bind( calculate ), RedIds.HeroAll );
// 检测红点
// HeroCalculate.getInstance().checkAllHeroRedPoint();
var list = [];
if (order) {
for (var k in this.pos_list[form_type][order]) {
var v = this.pos_list[form_type][order][k];
list.push({
partner_id: v.id
});
}
} else {
for (var _k in this.pos_list[form_type]) {
var _v = this.pos_list[form_type][_k];
list.push({
partner_id: _v.id
});
}
}
// --请求天赋的
HeroController.getInstance().sender11099(list);
}
},
// 获取最高战力的英雄战力
getMaxFight: function getMaxFight() {
if (this.hero_array) {
this.hero_array.sort(Utils.tableUpperSorter(["power"]));
var hero_vo = this.hero_array[0];
if (hero_vo) {
return hero_vo.power;
}
}
return 0;
},
//通过bid获取等级最高的英雄信息
getTopLevHeroInfoByBid: function getTopLevHeroInfoByBid(bid) {
if (!bid) return;
var list = this.hero_bid_list[bid];
if (list) {
list.sort(Utils.tableUpperSorter(["lev", "power"]));
return list[0];
}
return null;
},
//雇佣的
getExpeditHeroData: function getExpeditHeroData() {
var hero_list = this.getAllHeroArray();
var list = [];
for (var i = 0; i < hero_list.length; i++) {
var tab = {};
tab.power = hero_list[i].power;
tab.name = hero_list[i].name;
tab.bid = hero_list[i].bid;
tab.index = i;
tab.rid = hero_list[i].rid;
tab.srv_id = hero_list[i].srv_id;
tab.id = hero_list[i].id;
tab.star = hero_list[i].star;
tab.lev = hero_list[i].lev;
tab.use_skin = hero_list[i].use_skin;
list.push(tab);
}
list.sort(function (a, b) {
return b.power < a.power;
});
return list;
},
getTeamOrderPosList: function getTeamOrderPosList(type) {
return this.pos_list[type];
},
// 获取自己的队伍阵法站位
getMyPosList: function getMyPosList() {
return this.pos_list[PartnerConst.Fun_Form.Drama] || {};
},
getHeroSortFunc: function getHeroSortFunc() {
var hero_sort = function hero_sort(role_vo1, role_vo2) {
if (role_vo1.star === role_vo2.star) {
if (role_vo1.power == role_vo2.power) {
if (role_vo1.lev == role_vo2.lev) {
return role_vo1.sort_order - role_vo2.sort_order;
} else {
return role_vo2.lev - role_vo1.lev;
}
} else {
return role_vo2.power - role_vo1.power;
}
} else {
return role_vo2.star - role_vo1.star;
}
};
return hero_sort;
},
isMaxStarHero: function isMaxStarHero(bid, star) {
if (!bid || !star) return false;
var max_star = game.configs.partner_data.data_partner_max_star[bid];
if (max_star && star >= max_star) {
return true;
}
if (star >= this.hero_info_upgrade_star_param) {
if (star == this.hero_info_upgrade_star_param2) {
// --10级升11有世界等级要求
return !this.checkOpenStar11();
} else if (star == this.hero_info_upgrade_star_param3) {
return !this.checkOpenStar12();
} else if (star == this.hero_info_upgrade_star_param4) {
return !this.checkOpenStar13();
}
}
return false;
},
// checkSingleStarFuseRedPointByStarConfig
getStarFuseList: function getStarFuseList(camp_type) {
camp_type = camp_type || 0;
var camp_fuse_list = [];
var fuse_cfg = game.configs.partner_data.data_partner_fuse_star;
if (!fuse_cfg) return;
for (var cfg_i in fuse_cfg) {
var fuse_cfg_item = fuse_cfg[cfg_i];
var base_config = game.configs.partner_data.data_partner_base[cfg_i];
for (var item_i in fuse_cfg_item) {
var star = fuse_cfg_item[item_i].star;
var key = cfg_i + "_" + star;
var star_config = gdata("partner_data", "data_partner_star", key);
// game.configs.partner_data.data_partner_star[key];
if (base_config && (base_config.camp_type == camp_type || camp_type === 0)) {
if (base_config && star_config && star_config.expend1.length > 0) {
var fuse_data = {};
fuse_data.base_config = base_config;
fuse_data.star_config = star_config;
fuse_data.camp_type = base_config.camp_type;
fuse_data.bid = cfg_i;
fuse_data.star = star;
camp_fuse_list.push(fuse_data);
}
}
}
}
return camp_fuse_list;
},
// --根据bid 获取一个模拟herovo对象..属性都是1级的
getMockHeroVoByBid: function getMockHeroVoByBid(bid) {
var base_config = game.configs.partner_data.data_partner_base[bid];
var attr_config = game.configs.partner_data.data_partner_attr[bid];
if (!base_config || !attr_config) {
return;
}
var hero_vo = nx.dt.objClone(base_config);
hero_vo.star = base_config.init_star; //--默认星数
hero_vo.break_lev = 0; //--默认进阶
for (var k in attr_config) {
// k,v in pairs(attr_config) do
var v = attr_config[k];
if (!hero_vo[k]) {
hero_vo[k] = v;
}
}
hero_vo.hp = attr_config.hp_max; //--血量等于最大血量
hero_vo.power = PartnerCalculate.calculatePower(hero_vo);
return hero_vo;
},
/****************装备相关******************/
updateHeroEquipList: function updateHeroEquipList(data) {
var partner_id = data.partner_id;
if (partner_id && this.hero_list[partner_id]) {
var hero_vo = this.hero_list[partner_id];
// 判断战力变化
this.hero_list[partner_id].updateHeroVo(data);
}
},
getHeroEquipList: function getHeroEquipList(parener_id) {
if (this.hero_list[parener_id]) {
return this.hero_list[parener_id].eqm_list;
}
},
//----------------------------符文锻造相关------------------------
//获取符文祝福红点状态
getArtifactLuckyRedStatus: function getArtifactLuckyRedStatus() {
return this.artifact_lucky_red;
},
//符文祝福值
setArtifactLucky: function setArtifactLucky(value) {
this.artifact_lucky = value;
this.updateArtifactLuckyRed();
// RedMgr.getInstance().addCalHandler( this.updateArtifactLuckyRed.bind( this ) )
},
getArtifactLucky: function getArtifactLucky() {
return this.artifact_lucky || 0;
},
//祝福值红点
updateArtifactLuckyRed: function updateArtifactLuckyRed() {
var max_lucky = 0;
var lucky_cfg = game.configs.partner_artifact_data.data_artifact_const["change_condition"];
if (lucky_cfg && lucky_cfg.val != null) {
max_lucky = lucky_cfg.val;
}
if (this.artifact_lucky >= max_lucky) {
this.artifact_lucky_red = true;
} else {
this.artifact_lucky_red = false;
}
gcore.GlobalEvent.fire(HeroEvent.Artifact_Lucky_Red_Event);
},
updatePartnerArtifactList: function updatePartnerArtifactList(data) {
var id = data.partner_id || 0;
if (this.hero_list[id]) {
var hero_vo = this.hero_list[id];
if (hero_vo) {
this.hero_list[id].updateHeroVo(data);
gcore.GlobalEvent.fire(HeroEvent.Artifact_Update_Event, hero_vo);
// let is_artifact = PartnerCalculate.getIsCanClothArtifact(hero_vo.bid);
// hero_vo.updateRedPoint(PartnerConst.Vo_Red_Type.Artifact,false)
}
}
},
getPartnerArtifactList: function getPartnerArtifactList(id) {
if (this.hero_list[id]) {
return this.hero_list[id].artifact_list || [];
}
return [];
},
// -- 符文重鑄次數相關數據
updateArtifactRecastCount: function updateArtifactRecastCount(data_list) {
this.artifact_recast_data = data_list;
},
// -- 根據符文品質獲取對應品質的重鑄次數
getArtifactRecastCountByQuality: function getArtifactRecastCountByQuality(quality) {
var count = 0;
var max_count = 0;
var _type = 0;
if (quality == BackPackConst.quality.orange) {
// 彩虹符文
_type = 1;
} else if (quality == BackPackConst.quality.red) {
// 閃爍符文
_type = 2;
}
if (this.artifact_recast_data && _type > 0) {
for (var k in this.artifact_recast_data) {
var v = this.artifact_recast_data[k];
if (v.type == _type) {
count = v.current;
max_count = v.limit;
break;
}
}
}
return {
count: count,
max_count: max_count
};
},
//---------------------------符文锻造相关end-------------------------
setLockByPartnerid: function setLockByPartnerid(partner_id, is_lock) {
if (this.hero_list[partner_id]) {
this.hero_list[partner_id].is_lock = is_lock || 0;
}
},
// 活动英雄列表 根据匹配信息 熔炼祭坛用
// @dic_the_conditions 指定匹配 dic_the_conditions[bid][star] = 数量
// @dic_random_conditions 随机阵容匹配 dic_the_conditions[camp][star] = 数量
// @dic_hero_id 标志已用
// return
// @ count 拥有不重复英雄总数量
getHeroListByMatchInfo: function getHeroListByMatchInfo(dic_the_conditions, dic_random_conditions, dic_hero_id) {
// 找不重复的数量
var count = 0;
var dic_hero_id = dic_hero_id || {};
var dic_count = {};
var _setDicCount = function _setDicCount(partner_id, str, max) {
// 判断是否重复
if (!dic_hero_id[partner_id]) {
if (!dic_count[str]) dic_count[str] = 0;
if (dic_count[str] < max) {
dic_count[str] = dic_count[str] + 1;
count = count + 1;
dic_hero_id[partner_id] = 1;
}
}
};
for (var hero_i in this.hero_list) {
var hero = this.hero_list[hero_i];
if (dic_the_conditions && dic_the_conditions[hero.bid] && dic_the_conditions[hero.bid][hero.star] && hero.is_in_form == 0 && hero.is_lock == 0 && nx.dt.objEmpty(hero.dic_locks)) {
var str = cc.js.formatStr("%s%s", hero.bid, hero.star);
_setDicCount(hero.partner_id, str, dic_the_conditions[hero.bid][hero.star]);
}
if (dic_random_conditions) {
// 0表示所有阵营的合适
if (dic_random_conditions[0] && dic_random_conditions[0][hero.star] && hero.is_in_form == 0 && hero.is_lock == 0) {
// if (dic_random_conditions[0][hero.star]) {
var str = cc.js.formatStr("_%s%s", 0, hero.star);
_setDicCount(hero.partner_id, str, dic_random_conditions[0][hero.star]);
// }
} else {
if (dic_random_conditions[hero.camp_type] && dic_random_conditions[hero.camp_type][hero.star] && hero.is_in_form == 0 && hero.is_lock == 0) {
var str = cc.js.formatStr("_%s%s", hero.camp_type, hero.star);
_setDicCount(hero.partner_id, str, dic_random_conditions[hero.camp_type][hero.star]);
}
}
}
}
return count;
},
/***********************************红点检查********************************/
// 检测升级红点更新
checkLevelRedPointUpdate: function checkLevelRedPointUpdate() {
// gcore.GlobalEvent.fire(HeroEvent.Level_RedPoint_Event)
// if (this.is_delay_redpoint_update[HeroConst.RedPointType.eRPLevelUp])
// return
// this.is_delay_redpoint_update[HeroConst.RedPointType.eRPLevelUp] = true;
// 清除升级红点记录
HeroCalculate.getInstance().clearAllHeroRecordByRedPointType(HeroConst.RedPointType.eRPLevelUp, true);
},
// 检查阵法解锁
checkUnlockFormRedPoint: function checkUnlockFormRedPoint() {},
// 设置更新equip红点的记录
setEquipUpdateRecord: function setEquipUpdateRecord(bool) {
this.is_equip_redpoint_bag_update = bool;
this.is_equip_redpoint_hero_update = bool;
},
// 检查装备红点
checkEquipRedPointUpdate: function checkEquipRedPointUpdate() {
// 需要 背包 返回 和 英雄更新返回 才处理红点计算
if (this.is_equip_redpoint_bag_update && this.is_equip_redpoint_hero_update) {
//清除装备红点记录
HeroCalculate.getInstance().clearAllHeroRecordByRedPointType(HeroConst.RedPointType.eRPEquip);
gcore.GlobalEvent.fire(HeroEvent.Equip_RedPoint_Event);
}
},
// 设置更新升星红点的记录
setUpgradeStarUpdateRecord: function setUpgradeStarUpdateRecord(bool) {
this.is_upgradestar_redpoint_bag_update = bool;
this.is_upgradestar_redpoint_hero_update = bool;
},
// 升星红点检查
checkUpgradeStarRedPointUpdate: function checkUpgradeStarRedPointUpdate() {
// 需要 背包 返回 和 英雄更新返回 才处理红点计算
if (this.is_upgradestar_redpoint_bag_update && this.is_upgradestar_redpoint_hero_update) {
HeroCalculate.getInstance().clearAllHeroRecordByRedPointType(HeroConst.RedPointType.eRPStar);
}
},
// 检查圣器解锁
checkUnlockHallowsRedPoint: function checkUnlockHallowsRedPoint() {},
checkHighStarCondition: function checkHighStarCondition(_star) {
var can = [];
var star = _star + 1;
// let role_vo = RoleController.getInstance();
var cfg = game.configs.partner_data.data_get_star_cond[star];
switch (_star) {
case 10:
{
can = this.dealStar11(cfg);
}
;
break;
case 11:
{
can = this.dealStar11(cfg);
}
;
break;
case 12:
{
can = this.dealStar13(cfg);
}
;
break;
}
return can;
},
// 升星 11、12 条件是否达成判断
dealStar11: function dealStar11(_cfg) {
this.desc = [];
var role_vo = RoleController.getInstance();
var levEnough = false;
var slevEnough = true;
var worldlevEnough = true;
var results = [];
var conds = [];
for (var i = 0; i < _cfg.cond1.length; i++) {
var cond = _cfg.cond1[i];
if (cond[0] == "lev") {
if (role_vo.getRoleVo().lev >= cond[1]) {
levEnough = true;
} else {
this.desc.push(_cfg.desc1 + nx.text.getKey("UpStarsNeedTip"));
conds.push(role_vo.getRoleVo().lev >= cond[1]);
break;
}
}
if (cond[0] == "hero_star") {
var have = 0;
have = this.getHeroListByStar(cond[1]).length;
if (have < cond[2] && !levEnough) {
this.desc.push(_cfg.desc1 + nx.text.getKey("UpStarsNeedTip"));
conds.push(have < cond[2]);
}
}
}
results.push(conds.length == 0);
if (role_vo.getRoleVo().lev < _cfg.cond3[1]) {
slevEnough = false;
}
results.push(slevEnough);
this.desc.push(_cfg.desc3 + nx.text.getKey("UpStarsNeedTip"));
return results;
},
// 升星 11、12 条件是否达成判断
dealStar13: function dealStar13(_cfg) {
this.desc = [];
var role_vo = RoleController.getInstance();
var levEnough = false;
var slevEnough = true;
var worldlevEnough = true;
var results = [];
var conds = [];
var cond2s = [];
var cond3s = [];
for (var i = 0; i < _cfg.cond1.length; i++) {
var cond = _cfg.cond1[i];
if (cond[0] == "lev") {
if (role_vo.getRoleVo().lev >= cond[1]) {
levEnough = true;
} else {
this.desc.push(_cfg.desc1 + nx.text.getKey("UpStarsNeedTip"));
conds.push(role_vo.getRoleVo().lev >= cond[1]);
break;
}
}
if (cond[0] == "hero_star") {
var have = 0;
have = this.getHeroListByStar(cond[1]).length;
if (have < cond[2] && !levEnough) {
this.desc.push(_cfg.desc1 + nx.text.getKey("UpStarsNeedTip"));
conds.push(have < cond[2]);
}
}
}
results.push(conds.length == 0);
for (var t = 0; t < _cfg.cond3.length; t++) {
var _cond = _cfg.cond3[t];
if (role_vo.getRoleVo().lev < _cond[1]) {
slevEnough = false;
this.desc.push(_cfg.desc3 + nx.text.getKey("UpStarsNeedTip"));
cond3s.push(role_vo.getRoleVo().lev >= _cond[1]);
break;
}
if (_cond[0] == "hero_star") {
var _have = 0;
_have = this.getHeroListByStar(_cond[1]).length;
if (_have < _cond[2] && !slevEnough) {
this.desc.push(_cfg.desc3 + nx.text.getKey("UpStarsNeedTip"));
cond3s.push(_have < _cond[2]);
}
}
}
results.push(cond3s.length == 0);
return results;
},
getDescs: function getDescs() {
return this.desc;
},
checkOpenStar11: function checkOpenStar11() {
this.desc = [];
var is_open = true;
var all = [];
var role_vo = RoleController.getInstance().getRoleVo();
// var RoleController = require( "role_controller" );
var config = game.configs.partner_data.data_partner_const.staropen11_world_lev;
if (config) {
if (config.val[0] == "world_lev") {
var world_lev = RoleController.getInstance().getModel().getWorldLev() || 0;
if (world_lev < config.val[1]) {
is_open = false;
all.push(world_lev < config.val[1]);
}
}
this.desc.push(config.desc + config.val[1]);
}
// --要麼滿足 個人等級條件
// if( !is_open ) {
var config_lev = game.configs.partner_data.data_partner_const.staropen11_player_lev;
if (config_lev && config_lev.val[0] == "lev") {
if (role_vo && role_vo.lev < config_lev.val[1]) {
is_open = false;
all.push(role_vo.lev < config_lev.val[1]);
}
this.desc.push(config_lev.desc + config_lev.val[1]);
}
// }
// --策劃加的額外條件
var config2 = game.configs.partner_data.data_partner_const.staropen11_3rd_open_limit;
var conditions = config2.val;
var enough = false;
for (var c = 0; c < conditions.length; c++) {
var item = conditions[c];
if (item[0] = "lev") {
if (role_vo.lev < item[1]) {
all.push(role_vo.lev < item[1]);
}
}
if (item[0] = "hero_star") {
var have = 0;
have = this.getHeroListByStar(item[1]).length;
if (have < item[2]) {
all.push(have < item[2]);
}
// have = this.gethero
}
}
this.desc.push(config2.desc);
// let is_condition_3 = this.checkExtOpenInfo( config2 );
// if( !is_condition_3 ){
// all.push( is_condition_3 );
// }
// // if( !is_open ) {
// is_open = is_condition_3 || false
// // }
return all.length == 0;
},
checkOpenStar12: function checkOpenStar12() {
var is_open = true;
// var RoleController = require( "role_controller" );
var config = game.configs.partner_data.data_partner_const.staropen12_world_lev;
if (config) {
if (config.val[0] == "world_lev") {
var world_lev = RoleController.getInstance().getModel().getWorldLev() || 0;
if (world_lev < config.val[1]) {
is_open = false;
}
}
}
// --要麼滿足 個人等級條件
if (!is_open) {
is_open = true;
var config_lev = game.configs.partner_data.data_partner_const.staropen12_player_lev;
if (config_lev && config_lev.val[0] == "lev") {
var role_vo = RoleController.getInstance().getRoleVo();
if (role_vo && role_vo.lev < config_lev.val[1]) {
is_open = false;
}
}
}
// --策劃加的額外條件
var config2 = game.configs.partner_data.data_partner_const.staropen12_3rd_open_limit;
var is_condition_3 = this.checkExtOpenInfo(config2);
if (!is_open) {
is_open = is_condition_3 || false;
}
return is_open;
},
checkOpenStar13: function checkOpenStar13() {
var self = this;
if (self.is_star13_open) {
//如果已經計算開啟過了.就不計算了
return true;
}
// --優先判斷 等級 第一條件不滿足再判斷第二條件
var config = game.configs.partner_data.data_partner_const.staropen13_limit_lev2;
var is_open = true;
if (config) {
if (self.checkOpenByKeyValue(config.val[0], config.val[1])) {
is_open = false;
}
}
// --如果上面不滿足 再判斷第二個條件
if (!is_open) {
is_open = true;
var _config = game.configs.partner_data.data_partner_const.staropen13_limit_lev1;
if (_config) {
for (var i in _config.val) {
var v = _config.val[i];
if (self.checkOpenByKeyValue(v[0], v[1])) {
is_open = false;
break;
}
}
}
}
// --條件1 個人和世界等級達到170級 或 個人等級到達180級 開啟升星
var is_condition_1 = is_open;
// --條件2 擁有2個12星英雄開啟升星
var is_condition_2 = false;
// --條件3 個人等級達到150,且擁有5個及以上的12星,13星
var is_condition_3 = false;
// --第二個硬性條件
// --13星特殊要 曾經有2個12星英雄
var config2 = game.configs.partner_data.data_partner_const.staropen13_limit_partner;
if (config2 && config2.val) {
var count = 0;
for (var k in self.dic_had_hero_info) {
var star = self.dic_had_hero_info[k];
if (star >= config2.val[0]) {
count = count + 1;
if (count >= config2.val[1]) {
break;
}
}
}
if (count < config2.val[1]) {
is_open = false;
is_condition_2 = false;
} else {
is_condition_2 = true;
}
}
is_condition_2 = is_open;
// --策劃加的額外條件
var config3 = game.configs.partner_data.data_partner_const.staropen13_3rd_open_limit;
is_condition_3 = self.checkExtOpenInfo(config3);
if (!is_open) {
is_open = is_condition_3;
}
// local tips_str = nil
// if is_show_tips and not is_open then
// -- if not is_condition_1 and not is_condition_2 and not is_condition_3 then
// -- --三個條件都不滿足
// -- tips_str = TI18N("滿足以下任意條件開啟:1.擁有2個12星英雄 並且個人和世界等級達到170級 \n2. 擁有2個12星英雄 並且個人等級到達180級 \n3.擁有5個12星英雄 並且個人等級達到150級")
// -- end
// -- if not is_condition_1 and not is_condition_2 then
// -- --兩個都不滿足
// -- tips_str = TI18N("滿足以下條件開啟:1.擁有2個12星英雄\n2.個人和世界等級達到170級 或 個人等級到達180級")
// -- elseif not is_condition_1 and is_condition_2 then
// -- tips_str = TI18N("個人和世界等級達到170級 或 個人等級到達180級 開啟升星")
// -- else
// -- tips_str = TI18N("擁有2個12星英雄開啟升星")
// -- end
// tips_str = self:getTipsStr(13)
// end
if (is_open) {
// --如果已經開啟 那麼記錄
self.is_star13_open = true;
}
return is_open;
},
checkExtOpenInfo: function checkExtOpenInfo(config) {
// -- 策劃要求:原來的條件沒變。只是新增一個或條件,
// -- 個人等級達到100/120/150,且擁有5個及以上的10/11/12星,開啟11/12/13星
var val = config.val;
if (val == null) return false;
if (this.checkOpenByKeyValue(val[0][0], val[0][1])) {
return false;
}
if (val[1] == null) return false;
// -- local hero_star = val[2][1] or "hero_star" --這個前端不需要..因為需要寫死的
var star = val[1][1] || 10;
var count = val[1][2] || 5;
if (this.dic_star_count[star] == null) {
this.dic_star_count[star] = 0;
for (var k in this.dic_had_hero_info) {
var _star = this.dic_had_hero_info[k];
if (_star >= star) {
this.dic_star_count[star] = this.dic_star_count[star] + 1;
if (this.dic_star_count[star] >= count) {
break;
}
}
}
if (this.dic_star_count[star] >= count) {
return true;
}
} else {
if (this.dic_star_count[star] >= count) {
return true;
}
}
return false;
},
// --return true 表示不滿足 false 表示滿足
checkOpenByKeyValue: function checkOpenByKeyValue(key, value) {
if (!value) return false;
// var RoleController = require( "role_controller" );
if (key == "world_lev") {
var world_lev = RoleController.getInstance().getModel().getWorldLev() || 0;
return world_lev < value;
} else if (key == "lev") {
var role_vo = RoleController.getInstance().getRoleVo();
if (role_vo && role_vo.lev < value) {
return true;
}
}
return false;
},
//---------------------天赋技能---------------------------
// --设置更新天赋红点
setUpdateTalentRedpoint: function setUpdateTalentRedpoint() {
this.is_need_update_talent_redpoint = true;
},
getTalentRedpointRecord: function getTalentRedpointRecord() {
var self = this;
if (self.is_need_update_talent_redpoint) {
var dic_config = game.configs.partner_skill_data.data_partner_skill_learn;
if (dic_config) {
var is_enough;
for (var k in dic_config) {
var config = dic_config[k];
self.dic_hero_talent_skill_learn_redpoint[config.id] = null;
is_enough = true;
for (var i = 0; i < config.expend.length; ++i) {
var v = config.expend[i];
var count = BackpackController.getInstance().getModel().getItemNumByBid(v[0]);
if (count < v[1]) {
is_enough = false;
break;
}
}
if (is_enough) {
self.dic_hero_talent_skill_learn_redpoint[config.id] = config.id;
}
}
}
}
self.is_need_update_talent_redpoint = false;
if (!Utils.next(self.dic_hero_talent_skill_learn_redpoint)) {
self.dic_hero_talent_skill_learn_redpoint = {};
}
return self.dic_hero_talent_skill_learn_redpoint;
},
// --检测天赋红点更新
checkTalentRedPointUpdate: function checkTalentRedPointUpdate() {
if (this.is_delay_redpoint_update[HeroConst.RedPointType.eRPTalent]) {
return;
}
this.is_delay_redpoint_update[HeroConst.RedPointType.eRPTalent] = true;
// --清除天赋红点记录
HeroCalculate.getInstance().clearAllHeroRecordByRedPointType(HeroConst.RedPointType.eRPTalent, true);
},
// --增加详细信息
updateHeroVoDetailedInfo: function updateHeroVoDetailedInfo(info) {
if (!info) return;
if (this.hero_list[info.partner_id]) {
cc.log(this.hero_list[info.partner_id], info);
for (var k in info) {
var v = info[k];
this.hero_list[info.partner_id][k] = v;
}
this.hero_list[info.partner_id].is_had_detailed = true;
gcore.GlobalEvent.fire(HeroEvent.Hero_Vo_Detailed_info, this.hero_list[info.partner_id]);
}
},
//初始化皮肤 信息英雄皮肤
initHeroSkin: function initHeroSkin(data) {
var lists = this.getHeroReformListByCamp(0);
var count = 0;
lists.forEach(function (_item) {
if (_item.result.is_redpoint) {
count++;
}
});
nx.mTip.openTip("tipReform.show", count > 0);
if (!data) return;
//判定是否要显示卡片展示界面
if (this.hero_skin_list) {
var show_skin_id = null;
for (var i in data.partner_skins) {
var v = data.partner_skins[i];
if (this.hero_skin_list[v.id] == null) {
show_skin_id = v.id;
break;
}
}
if (show_skin_id) {
nx.bridge.createPanel("WndPartnerSkinReward", {
skin_id: show_skin_id
});
}
}
this.hero_skin_list = {};
for (var _i2 in data.partner_skins) {
var _v2 = data.partner_skins[_i2];
this.hero_skin_list[_v2.id] = _v2.end_time;
}
gcore.GlobalEvent.fire(HeroEvent.Hero_Skin_Info_Event, data);
},
//根据皮肤id 返回皮肤数据
//@return 皮肤有效时间点.. 如果永久返回 0 如果返回nil 表示 没有解锁该皮肤
getHeroSkinInfoBySkinID: function getHeroSkinInfoBySkinID(skin_id) {
if (this.hero_skin_list && this.hero_skin_list[skin_id] != null) {
return this.hero_skin_list[skin_id];
}
},
//--是否解锁该皮肤
//is_check_time:判断是否过期
isUnlockHeroSkin: function isUnlockHeroSkin(skin_id, is_check_time) {
if (this.hero_skin_list && this.hero_skin_list[skin_id] != null) {
if (is_check_time) {
if (this.hero_skin_list[skin_id] > 0) {
return false;
}
}
return true;
}
return false;
},
//共鸣水晶
getCystalPreLevLimit: function getCystalPreLevLimit() {
if (this.cystal_pre_lev_limit == null) {
this.cystal_pre_lev_limit = 340;
var config = game.configs.resonate_data.data_const.cystal_pre_lev_limit;
if (config) {
this.cystal_pre_lev_limit = config.val;
}
}
return this.cystal_pre_lev_limit || 340;
},
// --是否共鸣水晶最大等级 注意: 还有一个突破上限等级 后端传过来的
isResonateCystalMaxLev: function isResonateCystalMaxLev() {
// --340 英雄 13星升级的最大等级
if (this.resonate_cystal_lev && this.resonate_cystal_lev >= this.getCystalPreLevLimit()) {
return true;
}
return false;
},
isCanShowLabelMaxLev: function isCanShowLabelMaxLev(lev) {
if (lev && lev < this.getCystalPreLevLimit()) {
return false;
}
return true;
},
getDicResonateFiveHeroVo: function getDicResonateFiveHeroVo() {
return this.dic_resonate_five_hero_vo || {};
},
// --是否共鸣水晶上阵的英雄 如果 hero_vo 不确定是 hero_vo 类的 用此方法判断
isResonateCystalHero: function isResonateCystalHero(hero_vo) {
if (hero_vo.isResonateCrystalHero) {
if (hero_vo.isResonateCrystalHero()) {
return true;
}
} else if (hero_vo.resonate_lev && hero_vo.resonate_lev > 0) {
return true;
}
return false;
},
// 更新共鸣锁定信息
updateResonateCystalInfo: function updateResonateCystalInfo(data) {
if (!data) {
return;
}
this.resonate_cystal_lev = data.lev;
this.dic_resonate_five_hero_vo = {};
var star = 0;
for (var i in data.con_list) {
var v = data.con_list[i];
if (v.id != 0) {
var hero_vo = this.getHeroById(v.id);
if (hero_vo && Utils.next(hero_vo) != null) {
this.dic_resonate_five_hero_vo[hero_vo.id] = hero_vo;
}
if (hero_vo.star) {
star = star + hero_vo.star;
}
}
}
for (var i in this.dic_resonate_lock_info) {
var hero_vo = this.dic_resonate_lock_info[i];
if (hero_vo.updateLock) {
var _data = [{
lock_type: HeroConst.LockType.eHeroResonateLock,
is_lock: 0
}];
hero_vo.updateLock(_data);
}
}
this.dic_resonate_lock_info = {};
for (var i in data.res_list) {
var v = data.res_list[i];
if (v.id != 0) {
var hero_vo = this.getHeroById(v.id);
if (hero_vo && hero_vo.updateLock) {
this.dic_resonate_lock_info[v.id] = hero_vo;
var _data2 = [{
lock_type: HeroConst.LockType.eHeroResonateLock,
is_lock: 1
}];
hero_vo.updateLock(_data2);
}
}
}
if (this.resonate_max_partner_lev == null) {
// -- 说明26400没有返回了
this.resonate_max_partner_lev = star;
}
},
updateResonateLockInfo: function updateResonateLockInfo(data) {
this.resonate_stone_level = data.lev || 0;
this.resonate_max_partner_lev = data.max_partner_lev || 0;
// --判断是有红点
this.checkResonateRedPoint();
},
checkResonateRedPoint: function checkResonateRedPoint() {
if (!this.resonate_stone_level) {
return;
}
if (!this.resonate_max_partner_lev) {
return;
}
var resonate_stone_condition = 50;
var config = game.configs.resonate_data.data_const.amp_all_start_limit;
if (config) {
resonate_stone_condition = config.val;
}
// --不满足开启不计算显示了
if (this.resonate_max_partner_lev < resonate_stone_condition) {
return;
}
var config2 = gdata("resonate_data", "data_level_up", this.resonate_stone_level);
var is_redpoint = false;
if (config2) {
if (config2.expend && Utils.next(config2.expend) != null) {
is_redpoint = true;
for (var i in config2.expend) {
var v = config2.expend[i];
var bid = v[0];
var num = v[1];
var have_num = BackpackController.getInstance().getModel().getItemNumByBid(bid);
if (num && num > have_num) {
is_redpoint = false;
}
}
}
}
this.is_resonate_stone_redpoint = is_redpoint;
},
// 是否最高等级
isResonateMaxLevel: function isResonateMaxLevel(lev) {
if (lev) {
var config = gdata("resonate_data", "data_level_up", lev + 1);
if (config == null) {
return true;
}
}
return false;
},
// 共鸣是否开启
checkResonateIsOpen: function checkResonateIsOpen(not_tips) {
// var RoleController = require( "role_controller" );
var role_vo = RoleController.getInstance().getRoleVo();
var limit_lv_cfg = game.configs.resonate_data.data_const["open_lev"];
if (limit_lv_cfg && role_vo && limit_lv_cfg.val <= role_vo.lev) {
return true;
}
if (!not_tips && limit_lv_cfg) {
message(limit_lv_cfg.desc);
}
return false;
},
createStar: function createStar(num2, star_con, setting, star_width) {
var num = num2 || 0;
var star_setting = setting || {};
if (star_setting.star_list == null) {
star_setting.star_list = {};
}
if (star_setting.star_list2 == null) {
star_setting.star_list2 = {};
}
for (var i in star_setting.star_list) {
var v = star_setting.star_list[i];
v.node.active = false;
}
for (var _i3 in star_setting.star_list2) {
var _v3 = star_setting.star_list2[_i3];
_v3.node.active = false;
}
if (star_setting.star10) {
star_setting.star10.node.active = false;
}
var _cStar = function _cStar(star_count, res, star_list) {
var width = star_width || 29 + 3;
var x = -star_count * width * 0.5 + width * 0.5;
for (var _i4 = 0; _i4 < star_count; _i4++) {
if (!star_list[_i4]) {
var star = Utils.createImage(star_con, res, 0, 0, cc.v2(0.5, 0.5), false, 0, false);
star.node.scale = 1;
star_list[_i4] = star;
}
star_list[_i4].node.active = true;
star_list[_i4].node.x = x + (_i4 - 1) * width;
}
};
if (num > 0 && num <= 5) {
var res = PathTool.getIconPath("common", "ico_star_3");
_cStar(num, res, star_setting.star_list);
} else if (num >= 6 && num <= 9) {
var _res = PathTool.getIconPath("common", "ico_star_2");
var count = num - 5;
_cStar(count, _res, star_setting.star_list2);
} else if (num >= 10) {
var new_num = num - 10;
var _res2 = PathTool.getIconPath("common", "ico_star_1");
if (star_setting.star10 == null) {
var star = Utils.createImage(star_con, _res2, 0, 0, cc.v2(0.5, 0.5), false, 0, false);
star.node.scale = 1.2;
star_setting.star10 = star;
} else {
star_setting.star10.node.active = true;
}
if (new_num > 0) {
if (star_setting.star_label == null) {
var size = star_setting.star10.node.getContentSize();
star_setting.star_label = Utils.createLabel(12, game.configs.color_data.data_color16[1], game.configs.color_data.data_color16[9], size.width * 0.5 - 2, size.height * 0.5, "10", star_setting.star10.node, 1, cc.v2(0.5, 0.5));
} else {
star_setting.star_label.node.active = true;
}
star_setting.star_label.string = new_num;
} else {
if (star_setting.star_label) {
star_setting.star_label.node.active = false;
}
}
}
return star_setting;
},
//获取所有英雄的神装信息
sendAllHeroHolyEquipInfo: function sendAllHeroHolyEquipInfo() {
if (this.hero_list) {
var list = [];
for (var k in this.hero_list) {
var v = this.hero_list[k];
if (!v.ishaveHolyEquipmentData()) {
list.push({
partner_id: v.id
});
}
}
if (list.length > 0) {
//所有英雄的神装信息
HeroController.getInstance().sender11092(list);
}
}
},
//是否神装开启
//@is_show_tips 是否显示提示 --暂时没用
isOpenHolyEquipMentByHerovo: function isOpenHolyEquipMentByHerovo(hero_vo, is_show_tips) {
if (!hero_vo) return false;
//神装开启所需英雄星级
var config = game.configs.partner_holy_eqm_data.data_const.open_star_condition;
var star = hero_vo.star || 1;
if (config && hero_vo.star < config.val) {
return false;
}
// var RoleController = require( "role_controller" );
var role_vo = RoleController.getInstance().getRoleVo();
var lev = 0;
if (role_vo) {
lev = role_vo.lev || 0;
}
//策划要求两个情况 : 1世界等级110且个人等级105开启 2个人等级120开启
// 个人等级限制 --先判断2
var role_second_lv_cfg = game.configs.partner_holy_eqm_data.data_const.open_lev_second_condition;
if (role_second_lv_cfg && lev < role_second_lv_cfg.val) {
//不满足2 再判断1
// 个人等级条件
var role_lv_cfg = game.configs.partner_holy_eqm_data.data_const.open_lev_condition;
if (lev < role_lv_cfg.val) {
return false;
}
// 世界等级限制
var world_lv_cfg = game.configs.partner_holy_eqm_data.data_const.open_worldlev_condition;
var world_lev = RoleController.getInstance().getModel().getWorldLev();
if (world_lev && world_lv_cfg && world_lev < world_lv_cfg.val) {
return false;
}
}
return true;
},
getHeroHolyEquipList: function getHeroHolyEquipList(id) {
if (this.hero_list[id]) {
return this.hero_list[id].holy_eqm_list || [];
}
return {};
},
updateHolyEquipmentInfo: function updateHolyEquipmentInfo(data) {
var self = this;
var id = data.partner_id || 0;
if (self.hero_list[id]) {
var hero_vo = self.hero_list[id];
//先清空神装记录
if (hero_vo.holy_eqm_list) {
for (var i in hero_vo.holy_eqm_list) {
var equip_vo = hero_vo.holy_eqm_list[i];
self.hero_holy_list[equip_vo.id] = null;
self.dic_itemid_to_partner_id[equip_vo.id] = null;
}
}
this.updateHeroVo(data);
//在重新记录新的记录
if (hero_vo.holy_eqm_list) {
for (var _i5 in hero_vo.holy_eqm_list) {
var _equip_vo = hero_vo.holy_eqm_list[_i5];
for (var k in data.holy_eqm) {
var element = data.holy_eqm[k];
if (_equip_vo.type == element.type) {
self.hero_holy_list[_equip_vo.id] = _equip_vo;
self.dic_itemid_to_partner_id[_equip_vo.id] = hero_vo.partner_id;
break;
}
}
}
}
gcore.GlobalEvent.fire(HeroEvent.Holy_Equipment_Update_Event, hero_vo);
}
},
//更新神装信息
updateHeroVoHolyEquipment: function updateHeroVoHolyEquipment(data_list, is_not_check) {
var self = this;
var is_team = false;
for (var i in data_list) {
var v = data_list[i];
if (self.hero_list[v.partner_id]) {
self.hero_list[v.partner_id].updateHolyEqmList(v.holy_eqm);
if (!is_team) {
if (self.hero_list[v.partner_id].isFormDrama()) {
is_team = true;
}
}
}
}
self.hero_holy_list = {};
for (var k in self.hero_list) {
var _v4 = this.hero_list[k];
if (_v4.holy_eqm_list) {
for (var _i6 in _v4.holy_eqm_list) {
var equip_vo = _v4.holy_eqm_list[_i6];
self.hero_holy_list[equip_vo.id] = equip_vo;
self.dic_itemid_to_partner_id[equip_vo.id] = _v4.partner_id;
}
}
}
// -- 检查红点是要的暂时不考虑.留著
// -- if is_team && not is_not_check then
// -- --如果有剧情阵容的英雄..需要检查红点
// -- --检测红点
// -- HeroCalculate.checkAllHeroRedPoint()
// -- end
},
updateHolyEquipmentPlan: function updateHolyEquipmentPlan(data, _false) {
var self = this;
if (data.num && _false == true) {
// console.log( JSON.stringify( this.holy_equip_plans ) + "当前的神装" );
this.holy_equip_plans.num = data.num;
}
if (data.holy_eqm_set_cell) {
this.holy_equip_plans.holy_eqm_set_cell = data.holy_eqm_set_cell;
}
if (data.num) {
//格子上限
self.holy_equip_plan_count = data.num;
}
if (!self.holy_equip_plan) {
self.holy_equip_plan = {};
}
if (data.holy_eqm_set_cell) {
for (var i in data.holy_eqm_set_cell) {
var cell = data.holy_eqm_set_cell[i];
if (self.holy_equip_plan[cell.id]) {
for (var k in cell) {
var v = cell[k];
self.holy_equip_plan[cell.id][k] = v;
}
} else {
self.holy_equip_plan[cell.id] = cell;
}
}
}
},
getHolyEquipmentPlanDatad: function getHolyEquipmentPlanDatad() {
if (this.holy_equip_plans && this.holy_equip_plans.holy_eqm_set_cell) {
this.holy_equip_plans.holy_eqm_set_cell.sort(Utils.tableLowerSorter(["id"]));
}
return this.holy_equip_plans;
},
getHolyPlanCount: function getHolyPlanCount() {
return this.holy_equip_plan_count;
},
getHolyEquipmentPlanData: function getHolyEquipmentPlanData() {
return this.holy_equip_plan;
},
// --重生次数
setResetCount: function setResetCount(data) {
if (!data) return;
this.reset_count = data.day_num;
var hero_vo = this.getHeroById(data.partner_id);
if (hero_vo) {
hero_vo.initResetTime(data.end_time);
}
},
//获取神装套装描述
//@equip_vo_list 装备列表 结构{goods_vo,goods_vo,...}
//return 描述list
// 返回结构 {}
getHolyEquipSuitDes: function getHolyEquipSuitDes(equip_vo_list) {
if (!equip_vo_list) {
return {};
}
var dic_suit_set = [];
var dic_eqm_set_list = [];
for (var k in equip_vo_list) {
//遍历当前装备列表
var euip_vo = equip_vo_list[k];
if (euip_vo.config) {
var eqm_key = Math.floor(euip_vo.config.eqm_set / 100); //判断当前是那一套套装
if (dic_suit_set[eqm_key] == null) {
dic_eqm_set_list[eqm_key] = [];
dic_suit_set[eqm_key] = 1;
dic_eqm_set_list[eqm_key].push(euip_vo.config.eqm_set);
} else {
dic_suit_set[eqm_key] = dic_suit_set[eqm_key] + 1; //列表中有几件装备
dic_eqm_set_list[eqm_key].push(euip_vo.config.eqm_set);
}
}
}
var suit_config = [];
for (var _eqm_key in dic_suit_set) {
var count = dic_suit_set[_eqm_key];
var eqm_set_list = dic_eqm_set_list[_eqm_key];
if (count > 1) {
//2件以上说明有套装
eqm_set_list.sort(function (a, b) {
//按照星级排序
return b - a;
});
var cur_eqm_set = null;
var cur_config = null;
for (var i in eqm_set_list) {
var eqm_set = eqm_set_list[i];
var num = Number(i) + 1;
if (cur_eqm_set == null) {
cur_eqm_set = eqm_set;
cur_config = game.configs.partner_holy_eqm_data.data_suit_info[eqm_set];
cur_config.sort(function (a, b) {
return a.num < b.num;
});
} else {
if (cur_eqm_set != eqm_set) {
cur_config = game.configs.partner_holy_eqm_data.data_suit_info[eqm_set];
cur_config.sort(function (a, b) {
return a.num < b.num;
});
}
for (var _ in cur_config) {
var suit_info = cur_config[_];
if (suit_info.num == num) {
suit_config.push(suit_info);
break;
}
}
}
}
}
}
var list = [];
for (var _i7 in suit_config) {
var v = suit_config[_i7];
//说明是激活的
var _eqm_set = v.id;
var id = Math.floor(_eqm_set / 100);
var config = game.configs.partner_holy_eqm_data.data_suit_res_prefix[id];
if (config) {
var data = {};
data.num = v.num;
data.icon_res = config.prefix; // PathTool.getSuitRes(config.prefix)
data.name = cc.js.formatStr("%s(%s)", v.name, v.num);
data.id = _eqm_set;
list.push(data);
}
}
list.sort(Utils.tableLowerSorter(["id", "num"]));
return list;
},
//檢查道具是否在神裝管理裡面
//@item_id 物品唯一id
checkHolyEquipmentPalnByItemID: function checkHolyEquipmentPalnByItemID(item_id) {
if (!item_id) {
return false;
}
if (!this.holy_equip_plan) {
return false;
}
for (var i in this.holy_equip_plan) {
var cell = this.holy_equip_plan[i];
for (var j in cell.list) {
var v = cell.list[j];
if (item_id == v.item_id) {
return {
bool: true,
cell: cell
};
}
}
}
return {
bool: false
};
},
//獲取所有英雄穿戴的裝備信息
//@ return
getAllHeroHolyEquipList: function getAllHeroHolyEquipList() {
return this.hero_holy_list || {};
},
getHolyEquipById: function getHolyEquipById(id) {
if (this.hero_holy_list) {
return this.hero_holy_list[id];
}
},
getHolyPreviewInfo: function getHolyPreviewInfo(_index) {
var ct = parseInt(_index) * 100 + 5;
var lst = [];
var cfgs = game.configs.item_data.data_holy_eqm_list;
for (var i in cfgs) {
if (ct >= i && i >= ct - 4) {
var cfg = cfgs[i];
for (var j in cfg) {
lst.push(cfg[j]);
}
}
}
lst.sort(function (a, b) {
return b.id - a.id;
});
return lst;
},
getResetCount: function getResetCount() {
return this.reset_count;
},
//獲取品質
//@item_id 道具id
//@ attr_key 屬性名字
//@ value 屬性值
getHolyEquipmentQualityByItemIdAttrKey: function getHolyEquipmentQualityByItemIdAttrKey(item_id, attr_key, value) {
var quality = 0;
var holy_equip_config = game.configs.partner_holy_eqm_data.data_base_info[item_id];
if (holy_equip_config) {
var key = Utils.getNorKey(holy_equip_config[2], attr_key);
var config = game.configs.partner_holy_eqm_data.data_attr_color_rule[key];
if (value > 0 && config && config.color_list[0]) {
var list = config.color_list[0]; // {0-12}
for (var i = 0; i < list.length; i++) {
if (list[i + 1]) {
if (value >= list[i] && value < list[i + 1]) {
quality = i;
}
} else {
if (value >= list[i]) {
quality = i;
}
}
}
}
}
return quality;
},
//獲取某個屬性最大值
getHolyEquipmentMaxAttrByItemIdAttrKey: function getHolyEquipmentMaxAttrByItemIdAttrKey(item_id, attr_key) {
var max_count = 1;
var holy_equip_config = game.configs.partner_holy_eqm_data.data_base_info[item_id];
if (holy_equip_config) {
var config = game.configs.partner_holy_eqm_data.data_attr_max_info[holy_equip_config[3]];
if (config) {
for (var i = 0; i < config.max_attr.length; i++) {
var v = config.max_attr[i];
if (v[0] && v[0] == attr_key) {
max_count = v[1] || 1;
break;
}
}
}
}
return max_count;
},
// --是否是公會pvp 陣法類型
isGuildPvpFrom: function isGuildPvpFrom(form_type) {
var self = this;
if (self.dic_guild_from_type == null) {
self.dic_guild_from_type = {};
var config_list = game.configs.combat_type_data.data_fight_list;
if (config_list) {
for (var k in config_list) {
var config = config_list[k];
if (config.is_guild_pvp == 1) {
if (config.from != null) {
for (var i in config.from[0]) {
var form = config.from[0][i];
self.dic_guild_from_type[form] = true;
}
}
}
}
}
}
return self.dic_guild_from_type[form_type];
}
});
cc._RF.pop();