Files
fc/dev/project/library/imports/4e/4e441e9e-d8c7-4faf-bb7e-54a496248d94.js
2026-05-24 10:21:26 +08:00

145 lines
4.7 KiB
JavaScript

"use strict";
cc._RF.push(module, '4e4416e2MdPr7t+VKSWJI2U', 'halidom_vo');
// Scripts/mod/home/base_kernel/halidom_vo.js
"use strict";
var HeroController = require("hero_controller");
var BackpackController = require("backpack_controller");
var HalidomConst = require("halidom_const");
var HalidomVo = cc.Class({
"extends": gcore.BaseEvent,
ctor: function ctor() {
this.id = 0; // 圣物id
this.lev = 0; // 圣物等级
this.exp = 0; // 圣物经验值
this.step = 0; // 圣物阶数
this.all_attr = []; // 圣物属性值
this.red_status_list = []; // 圣物红点
},
////////////////
updateData: function updateData(data) {
for (var key in data) {
var value = data[key];
this[key] = value;
}
this.dispatchUpdateAttrByKey();
// this.checkHalidomRedStatus()
},
dispatchUpdateAttrByKey: function dispatchUpdateAttrByKey() {},
// 检测红点数据
checkHalidomRedStatus: function checkHalidomRedStatus() {
// 升级
var self = this;
var is_can_lvup = false;
var max_lv = game.configs.halidom_data.data_max_lev[this.id];
var all_lv_cfg = game.configs.halidom_data.data_lvup[this.id];
if (this.lev < max_lv && all_lv_cfg) {
var lv_cfg = all_lv_cfg[this.lev];
if (lv_cfg) {
is_can_lvup = true;
for (var k in lv_cfg.loss) {
var v = lv_cfg.loss[k];
var bid = v[0];
var num = v[1];
var have_num = BackpackController.getInstance().getModel().getItemNumByBid(bid);
if (have_num < num) {
is_can_lvup = false;
break;
}
}
}
}
this.red_status_list[HalidomConst.Red_Type.Lvup] = is_can_lvup;
// 进阶
var is_can_step = false;
var max_step = game.configs.halidom_data.data_max_step[this.id];
var all_step_cfg = game.configs.halidom_data.data_step[this.id];
if (this.step < max_step && all_step_cfg) {
var step_cfg = all_step_cfg[this.step + 1];
if (step_cfg) {
// 是否满足进阶条件
is_can_step = true;
for (var i in step_cfg.conds) {
var _v = step_cfg.conds[i];
if (_v[0] == "lev" && _v[1] && self.lev < _v[1]) {
is_can_step = false;
}
}
// 道具消耗是否满足
if (is_can_step) {
for (var a in step_cfg.loss_items) {
var _v2 = step_cfg.loss_items[a];
var _bid = _v2[0];
var _num = _v2[1];
var _have_num = BackpackController.getInstance().getModel().getItemNumByBid(_bid);
if (_have_num < _num) {
is_can_step = false;
break;
}
}
}
var hero_array = HeroController.getInstance().getModel().getAllHeroArray();
var hero_size = hero_array.length;
// 指定英雄消耗
if (is_can_step) {
for (var _k in step_cfg.loss_fixed) {
var _v3 = step_cfg.loss_fixed[_k];
var _bid2 = _v3[0];
var star = _v3[1];
var _num2 = _v3[2];
var _have_num2 = 0;
for (var _i = 1; _i <= hero_size; _i++) {
var hero_vo = hero_array[_i - 1];
if (hero_vo.is_lock == 0 && hero_vo.is_in_form == 0 && hero_vo.bid == _bid2 && hero_vo.star == star) {
_have_num2 = _have_num2 + 1;
}
if (_have_num2 >= _num2) {
break;
}
}
if (_have_num2 < _num2) {
is_can_step = false;
break;
}
}
}
// 随机英雄消耗
if (is_can_step) {
for (var _k2 in step_cfg.loss_rand) {
var _v4 = step_cfg.loss_rand[_k2];
var camp = _v4[0];
var _star = _v4[1];
var _num3 = _v4[2];
var _have_num3 = 0;
for (var _i2 = 1; _i2 <= hero_size; _i2++) {
var _hero_vo = hero_array[_i2 - 1];
if (_hero_vo.is_lock == 0 && _hero_vo.is_in_form == 0 && _hero_vo.camp_type == camp && _hero_vo.star == _star) {
_have_num3 = _have_num3 + 1;
}
if (_have_num3 >= _num3) {
break;
}
}
if (_have_num3 < _num3) {
is_can_step = false;
break;
}
}
}
}
}
this.red_status_list[HalidomConst.Red_Type.Step] = is_can_step;
},
// 获取根据类型圣物红点状态
getRedStatusByType: function getRedStatusByType(red_type) {
return this.red_status_list[red_type] || false;
}
});
HalidomVo.prototype.UPDATE_HALIDOM_ATTR = "UPDATE_HALIDOM_ATTR";
module.exports = HalidomVo;
cc._RF.pop();