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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
"use strict";
cc._RF.push(module, '0943dp4vehAXarkETkg9uwC', 'endless_trail_model');
// Scripts/mod/endless_trail/endless_trail_model.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-03-04 21:12:18
// --------------------------------------------------------------------
var Endless_trailEvent = require("endless_trail_event");
 
var MainuiController = require("mainui_controller");
 
var MainuiConst = require("mainui_const");
 
var Endless_trailModel = cc.Class({
  "extends": BaseClass,
  ctor: function ctor() {},
  properties: {},
  initConfig: function initConfig() {
    this.role_rank_list = {};
    this.first_item_list = [];
    this.five_item_list = [];
    this.rank_item_list = [];
    this.endless_data = {};
    this.first_data = {};
    this.send_partner = {};
    this.hire_partner_list = {};
    this.has_hire_partner_list = {}; //已雇佣的
 
    this.is_first_get = false;
    this.is_award_get = false;
    this.is_send_partner = false;
    this.endless_battle_data = null; // this.getFirstKindList()
    // this.getFiveKindList()
    // this.getRankKindList()
  },
  // 设置无尽试炼基础信息
  setEndlessData: function setEndlessData(data) {
    if (data) {
      this.endless_data = data;
      this.updateRedPoint();
      gcore.GlobalEvent.fire(Endless_trailEvent.UPDATA_BASE_DATA, data);
    }
  },
  // 获取无尽试炼基础信息
  getEndlessData: function getEndlessData() {
    if (this.endless_data && Utils.next(this.endless_data || {}) != null) {
      return this.endless_data;
    }
  },
  // 设置首通奖励展示
  setFirstData: function setFirstData(data) {
    if (data) {
      this.first_data = data;
      this.updateRedPoint();
      gcore.GlobalEvent.fire(Endless_trailEvent.UPDATA_FIRST_DATA, data);
    }
  },
  // 获取首通奖励
  getFirstData: function getFirstData() {
    if (this.first_data && Utils.next(this.first_data || {}) != null) {
      return this.first_data;
    }
  },
  // 已派遣的伙伴信息
  setSendPartnerData: function setSendPartnerData(data) {
    this.send_partner = data;
    gcore.GlobalEvent.fire(Endless_trailEvent.UPDATA_SENDPARTNER_DATA, data);
    this.updateRedPoint();
  },
  getSendPartnerData: function getSendPartnerData() {
    if (this.send_partner && Utils.next(this.send_partner || {}) != null) {
      return this.send_partner;
    }
  },
  // 可雇佣伙伴的信息
  setHirePartnerData: function setHirePartnerData(data) {
    this.hire_partner_list = data;
    gcore.GlobalEvent.fire(Endless_trailEvent.UPDATA_HIREPARNER_DATA, data);
  },
  getHirePartnerData: function getHirePartnerData() {
    if (this.hire_partner_list && Utils.next(this.hire_partner_list || {}) != null) {
      return this.hire_partner_list;
    }
  },
  // 已雇佣的伙伴列表
  setHasHirePartnerData: function setHasHirePartnerData(data) {
    this.has_hire_partner_list = data;
    gcore.GlobalEvent.fire(Endless_trailEvent.UPDATA_HASHIREPARNER_DATA, data);
  },
  getHasHirePartnerData: function getHasHirePartnerData() {
    if (this.has_hire_partner_list && Utils.next(this.has_hire_partner_list || {}) != null) {
      return this.has_hire_partner_list;
    }
  },
  setEndlessBattleData: function setEndlessBattleData(data) {
    this.endless_battle_data = data;
    gcore.GlobalEvent.fire(Endless_trailEvent.UPDATA_ENDLESSBATTLE_DATA, data);
  },
  getEndlessBattleData: function getEndlessBattleData() {
    if (this.endless_battle_data) {
      return this.endless_battle_data;
    }
  },
  // 获取前三个
  getRaknRoleTopThreeList: function getRaknRoleTopThreeList() {
    var list = [{
      rank: 1,
      name: Utils.TI18N("虚位以待")
    }, {
      rank: 2,
      name: Utils.TI18N("虚位以待")
    }, {
      rank: 3,
      name: Utils.TI18N("虚位以待")
    }];
 
    if (this.endless_data.rank_list && Utils.next(this.endless_data.rank_list || {}) != null) {
      var rank_list = this.endless_data.rank_list;
 
      for (var i in rank_list) {
        for (var j in list) {
          if (rank_list[i].idx == list[j].rank) {
            list[j] = rank_list[i];
          }
        }
      }
    }
 
    return list;
  },
  // 获取首通奖励种类
  getFirstKindList: function getFirstKindList() {
    if (Utils.next(this.first_item_list || []) == null) {
      if (Config.endless_data.data_first_data) {
        var temp_id = 0;
 
        for (var i in Config.endless_data.data_first_data) {
          var items = Config.endless_data.data_first_data[i].items;
 
          for (var j in items) {
            var bid = items[j][0];
 
            if (!this.is_include(bid, this.first_item_list)) {
              this.first_item_list.push({
                bid: bid,
                num: 1
              });
            }
          }
        }
      }
    }
  },
  getFirstList: function getFirstList() {
    if (this.first_item_list) {
      return this.first_item_list;
    }
  },
  // 获取5次的奖励
  getFiveKindList: function getFiveKindList() {
    if (Utils.next(this.five_item_list || []) == null) {
      if (Config.endless_data.data_floor_data) {
        var temp_id = 0;
 
        for (var i in Config.endless_data.data_floor_data) {
          var items = Config.endless_data.data_floor_data[i].items;
 
          for (var j in items) {
            var bid = items[j][0];
 
            if (!this.is_include(bid, this.five_item_list)) {
              this.five_item_list.push({
                bid: bid,
                num: 1
              });
            }
          }
        }
      }
    }
  },
  getFiveList: function getFiveList() {
    if (this.five_item_list) {
      return this.five_item_list;
    }
  },
  // 排行种类获取
  getRankKindList: function getRankKindList() {
    if (Utils.next(this.rank_item_list || []) == null) {
      if (Config.endless_data.data_rank_reward_data) {
        var temp_id = 0;
 
        for (var i in Config.endless_data.data_rank_reward_data) {
          var items = Config.endless_data.data_rank_reward_data[i].items;
 
          for (var j in items) {
            var bid = items[j][0];
 
            if (!this.is_include(bid, this.rank_item_list)) {
              this.rank_item_list.push({
                bid: bid,
                num: 1
              });
            }
          }
        }
      }
    }
  },
  updateRedPoint: function updateRedPoint() {
    RedMgr.getInstance().addCalHandler(this.checkRedPoint.bind(this), RedIds.Endless);
  },
  // 红点判断
  checkRedPoint: function checkRedPoint() {
    var is_open = MainuiController.getInstance().checkMainFunctionOpenStatus(MainuiConst.btn_index.esecsice, MainuiConst.function_type.main, true);
    if (is_open == null) return; // 先判断首通奖励是否领取
 
    if (this.first_data) {
      if (this.first_data.status == 1) {
        this.is_first_get = true;
      } else {
        this.is_first_get = false;
      }
 
      gcore.GlobalEvent.fire(Endless_trailEvent.UPDATA_REDPOINT_FIRST_DATA, this.is_first_get);
    } // 再判断是否已获所有日常奖励结算
 
 
    if (this.endless_data) {
      if (this.endless_data.is_reward != 1) {
        this.is_award_get = true;
      } else {
        this.is_award_get = false;
      }
 
      gcore.GlobalEvent.fire(Endless_trailEvent.UPDATA_REDPOINT_REWARD_DATA, this.is_award_get);
    } // 再判断是否已上阵
 
 
    if (this.endless_data) {
      if (this.endless_data.is_appoint == 0 && this.send_partner && Utils.next(this.send_partner.list || {}) == null) {
        //没派出
        this.is_send_partner = true;
      } else {
        this.is_send_partner = false;
      }
    }
 
    var is_show_red = this.is_first_get || this.is_award_get || this.is_send_partner; // 设置入口红点
 
    gcore.GlobalEvent.fire(Endless_trailEvent.UPDATA_REDPOINT_SENDPARTNER_DATA, this.is_send_partner);
    gcore.GlobalEvent.fire(Endless_trailEvent.UPDATA_ESECSICE_ENDLESS_REDPOINT);
 
    var SceneConst = require("scene_const");
 
    MainuiController.getInstance().setBtnRedPoint(MainuiConst.btn_index.esecsice, {
      bid: SceneConst.RedPointType.endless,
      status: is_show_red
    });
  },
  // 获取首通红点状态
  getFirstGet: function getFirstGet() {
    return this.is_first_get;
  },
  // 获取是否已经派遣伙伴
  getIsSendPartner: function getIsSendPartner() {
    return this.is_send_partner;
  },
  // 获取是否已获所有日常奖励结算
  getIsGetAllReward: function getIsGetAllReward() {
    return this.is_award_get;
  },
  checkRedStatus: function checkRedStatus() {
    return this.is_first_get || this.is_send_partner || this.is_award_get;
  },
  // -- --根据当前通关获取临近的可以领取奖励
  // -- function Endless_trailModel:getNearFirstRewardByID(id)
  // --     if Config.EndlessData.data_first_data then
  // --         for i, v in ipairs(Config.EndlessData.data_first_data) do
  // --             if id == v.id then
  // --                 return v
  // --             end 
  // --         end
  // --     end
  // -- end
  getRankList: function getRankList() {
    if (this.rank_item_list) {
      return this.rank_item_list;
    }
  },
  is_include: function is_include(value, list) {
    for (var i in list) {
      if (list[i].bid == value) {
        return true;
      }
    }
 
    return false;
  }
});
 
cc._RF.pop();