difenduandada
2024-12-31 34abe6963b344c882358274957f4b992456fee40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
"use strict";
cc._RF.push(module, 'ce9eapVbdhKR6CjQwid529Q', 'battle_data');
// Scripts/mod/battle/battle_data.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: shiraho@syg.com(必填, 创建模块的人员)
// @description:
//      当前战斗的详细数据,包含双方数据
// <br/>Create: new Date().toISOString()
// --------------------------------------------------------------------
var BattleRoleData = require("battle_role_data");
 
var BattleBuffData = require("battle_buff_data");
 
var BattleData = cc.Class({
  "extends": BaseClass,
  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;
    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();