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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
"use strict";
cc._RF.push(module, 'c4a6c1KRGZPGoer42/oM1wb', 'adventure_model');
// Scripts/mod/adventure/adventure_model.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-05-09 14:14:52
// --------------------------------------------------------------------
var AdventureEvent = require("adventure_event");
 
var AdventureActivityController = require("adventureactivity_controller");
 
var AdventureActivityConst = require("adventureactivity_const");
 
var MainSceneController = require("mainscene_controller");
 
var SceneConst = require("scene_const");
 
var RoleController = require("role_controller");
 
var AdventureModel = cc.Class({
  "extends": BaseClass,
  ctor: function ctor() {},
  properties: {},
  initConfig: function initConfig() {
    this.room_list = []; // 所有房间的
 
    this.base_data = []; // 当前冒险的基础数据
 
    this.buff_data = []; // buff数据
 
    this.holiday_buff_data = []; // 活动buff数据
 
    this.form_list = []; // 当前上阵伙伴信息
 
    this.select_partner_id = 0; // 当前选中的伙伴id
 
    this.red_status = false;
    this.backpack_list = [];
    this.plist = []; //伙伴死亡情况信息
 
    this.before_room = 0;
    this.plunder_record_list = []; //防御布阵掠夺记录
 
    this.is_first_record_red = true;
  },
  // ==============================--
  // desc:获取当前上阵伙伴信息
  // @data:
  // @return 
  // ==============================-- 
  updateFormPartner: function updateFormPartner(data, partner_id) {
    this.form_list = data;
    this.select_partner_id = partner_id; // 这里判断一下如果列表为空,则显示一个红点
 
    this.updateRedStatus(data.length == 0);
    gcore.GlobalEvent.fire(AdventureEvent.UpdateAdventureForm);
  },
  updateRedStatus: function updateRedStatus(status) {
    this.red_status = status;
    var is_open = AdventureActivityController.getInstance().isOpenActivity(AdventureActivityConst.Ground_Type.adventure);
 
    if (is_open == false) {
      this.red_status = false;
    }
 
    MainSceneController.getInstance().setBuildRedStatus(SceneConst.CenterSceneBuild.adventure, {
      bid: AdventureActivityConst.Red_Type.adventure,
      status: this.red_status
    });
  },
  // 宝箱领取红点
  setAdventureBoxStatus: function setAdventureBoxStatus(data) {
    this.box_status_list = {};
 
    for (var i in data.list) {
      this.box_status_list[data.list[i].id] = data.list[i].status;
    }
 
    var red_point = false;
 
    for (var i in data.list) {
      if (data.list[i].status == 1) {
        red_point = true;
        break;
      }
    }
 
    this.box_redpoint = red_point;
    gcore.GlobalEvent.fire(AdventureEvent.UpdateAdventureForm);
    var scene_adventure_redpiont = this.getAdventureRedPoint();
    MainSceneController.getInstance().setBuildRedStatus(SceneConst.CenterSceneBuild.adventure, {
      bid: AdventureActivityConst.Red_Type.adventure,
      status: scene_adventure_redpiont
    });
  },
  getAdventureBoxStatus: function getAdventureBoxStatus(id) {
    if (this.box_status_list && this.box_status_list[id]) {
      return this.box_status_list[id];
    }
 
    return 0;
  },
  // 冒险红点
  getAdventureRedPoint: function getAdventureRedPoint() {
    var status = this.red_status || false;
    var box_status = this.box_redpoint || false;
    return status || box_status;
  },
  getFormList: function getFormList() {
    return this.form_list;
  },
  // ==============================--
  // desc:全部伙伴是否都已经死亡
  // @return 
  // ==============================--
  allHeroIsDie: function allHeroIsDie() {
    var is_die = true;
 
    for (var i in this.form_list) {
      if (this.form_list[i].now_hp != 0) {
        is_die = false;
        break;
      }
    }
 
    return is_die;
  },
  getSelectPartnerID: function getSelectPartnerID() {
    return this.select_partner_id;
  },
  updateSelectPartnerID: function updateSelectPartnerID(id) {
    this.select_partner_id = id;
    gcore.GlobalEvent.fire(AdventureEvent.UpdateAdventureSelectHero);
  },
  // ==============================--
  // desc:冒险的基础信息,对应协议的20600
  // @data:
  // @return 
  // ==============================--
  setAdventureBaseData: function setAdventureBaseData(data) {
    this.base_data = data;
    gcore.GlobalEvent.fire(AdventureEvent.Update_Room_Base_Info);
  },
  getAdventureBaseData: function getAdventureBaseData() {
    return this.base_data;
  },
  setBuffData: function setBuffData(data) {
    this.buff_data = data.buff_list;
    this.holiday_buff_data = data.holiday_buff_list;
    gcore.GlobalEvent.fire(AdventureEvent.Update_Buff_Info);
  },
  getBuffData: function getBuffData() {
    if (this.buff_data && Utils.next(this.buff_data || {}) != null) {
      return this.buff_data;
    }
  },
  getHolidayBuffData: function getHolidayBuffData() {
    if (this.holiday_buff_data && Utils.next(this.holiday_buff_data || {}) != null) {
      return this.holiday_buff_data;
    }
  },
  setRoomList: function setRoomList(data) {
    if (data == null || data.room_list == null) return;
 
    for (var i in data.room_list) {
      this.room_list[data.room_list[i].id] = data.room_list[i];
    }
 
    gcore.GlobalEvent.fire(AdventureEvent.Update_Room_Info);
  },
  getRoomList: function getRoomList() {
    if (this.room_list && Utils.next(this.room_list || {}) != null) {
      return this.room_list;
    }
  },
  updateRoomList: function updateRoomList(data) {
    for (var i in data.room_list) {
      var room = this.room_list[data.room_list[i].id];
 
      if (room) {
        room.status = data.room_list[i].status;
        room.lock = data.room_list[i].lock;
        room.evt_id = data.room_list[i].evt_id;
      }
    }
 
    gcore.GlobalEvent.fire(AdventureEvent.Update_Single_Room_Info, data);
  },
  getRoomInfoByRoomID: function getRoomInfoByRoomID(id) {
    if (this.room_list && Utils.next(this.room_list || {}) != null) {
      var data = null;
 
      for (var i in this.room_list) {
        if (this.room_list[i].id == id) {
          data = this.room_list[i];
          break;
        }
      }
 
      return data;
    }
  },
  getCurIndex: function getCurIndex(reset_num, config) {
    var idx = reset_num + 1;
    var free_num = 0;
    var cost_num = 0;
    var vip_lev = RoleController.getInstance().getRoleVo().vip_lev;
 
    while (config[idx]) {
      if (config[idx].cost == 0) {
        free_num = free_num + 1;
      } else {
        if (vip_lev >= config[idx].vip) {
          cost_num = cost_num + 1;
        }
      }
 
      idx = idx + 1;
    }
 
    return [free_num, cost_num];
  }
});
 
cc._RF.pop();