Files
fc/dev/project/library/imports/ce/ce9eaa55-6dd8-4a47-a0a3-43089de76f50.js
2026-05-24 10:21:26 +08:00

165 lines
5.0 KiB
JavaScript

"use strict";
cc._RF.push(module, 'ce9eapVbdhKR6CjQwid529Q', 'battle_data');
// Scripts/mod/battle/act/battle_data.js
"use strict";
// --------------------------------------------------------------------
// @author: shiraho@syg.com(必填, 创建模块的人员)
// @description:
// 当前战斗的详细数据,包含双方数据
// <br/>Create: new Date().toISOString()
// --------------------------------------------------------------------
var BridgeClass = require("bridge.class");
var BattleRoleData = require("battle_role_data");
var BattleBuffData = require("battle_buff_data");
var BattleData = cc.Class({
"extends": BridgeClass,
ctor: function ctor() {
this.fight_object_list = {};
this.buff_play_list = {};
this.halo_list = {};
this.formation = {};
},
properties: {
fight_object_list: null,
// 双方战斗单位数据
buff_play_list: null,
// 拥有buff
halo_list: null,
// 两边阵营光环信息 group, type
formation: null,
// 战法信息,包含 group, formation_type, formation_lev
combat_type: 0,
// 战斗类型
current_wave: 0,
// 当前波数
total_wave: 0,
// 总波数
action_count: 0,
// 当前回合数
target_role_name: "",
// 如果对方是玩家,则是对方的角色名
actor_role_name: "",
// 发起方的玩家名字,用于看录像
flag: 0,
// 标识(0:正常进入 1:断线重连 2:切入观战)
extra_args: [],
// 战斗的额外参数,比如当前副本id,具体值跟战斗类型有关系
is_active: false // 当前战斗是否处于激活状态
},
// 更新详细数据
updateData: function updateData(data) {
this.combat_type = data.combat_type;
this.current_wave = data.current_wave;
this.total_wave = data.total_wave;
// let new_msg = null;
// if(data.target_role_name.indexOf("^")!=-1){
// let arr = data.target_role_name.split("^");
// for(let i=0;i<arr.length;i++){
// let cfg = game.configs.partner_data.data_partner_base[arr[i]];
// if(cfg){
// arr[i] = cfg.name;
// }
// }
// new_msg = arr.join("");
// }else{
// new_msg = data.target_role_name;
// }
this.target_role_name = data.target_role_name;
this.actor_role_name = data.actor_role_name;
this.flag = data.flag ? data.flag : 0;
if (data.extra_args) {
this.extra_args = data.extra_args;
}
if (data.action_count) {
this.action_count = data.action_count;
}
// 单位
this.updateObjectData(data.objects);
// buff
this.updateBuffData(data.buffs);
// 阵营
this.updateHaloData(data.halo_list);
// 阵法
this.updateFormationData(data.formation);
this.is_active = true;
},
// 更新单位数据
updateObjectData: function updateObjectData(array) {
if (array == null) {
return;
}
for (var index = 0; index < array.length; index++) {
var element = array[index];
if (this.fight_object_list[element.pos] == null) {
this.fight_object_list[element.pos] = new BattleRoleData();
}
this.fight_object_list[element.pos].updateData(element);
}
},
// 更新BUFF数据
updateBuffData: function updateBuffData(array) {
if (array == null) {
return;
}
for (var index = 0; index < array.length; index++) {
var element = array[index];
if (this.buff_play_list[element.target] == null) {
this.buff_play_list[element.target] = {};
}
if (this.buff_play_list[element.target][element.id] == null) {
this.buff_play_list[element.target][element.id] = new BattleBuffData();
}
this.buff_play_list[element.target][element.id].updateData(element);
}
},
// 更新阵营数据
updateHaloData: function updateHaloData(array) {
if (array == null) {
return;
}
for (var index = 0; index < array.length; index++) {
var element = array[index];
if (this.halo_list[element.group] == null) {
this.halo_list[element.group] = {
group: 0,
type: 0
};
}
this.halo_list[element.group].group = element.group;
this.halo_list[element.group].type = element.type;
}
},
// 更新阵法数据
updateFormationData: function updateFormationData(array) {
if (array == null) {
return;
}
for (var index = 0; index < array.length; index++) {
var element = array[index];
if (this.formation[element.group] == null) {
this.formation[element.group] = {
formation_type: 0,
formation_lev: 0
};
}
this.formation[element.group].formation_type = element.formation_type;
this.formation[element.group].formation_lev = element.formation_lev;
}
},
// 当前战斗是否是激活,不清除数据是想重复利用
setActive: function setActive(status) {
if (status == false) {
this.buff_play_list = {};
this.is_active = false;
}
}
});
module.exports = BattleData;
cc._RF.pop();