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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
"use strict";
cc._RF.push(module, 'af0cdKpdsRCIILDfb8oxAqH', 'ladder_controller');
// Scripts/mod/ladder/ladder_controller.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      跨服天梯ctrl
// <br/>Create: 2019-07-24 10:23:54
// --------------------------------------------------------------------
var LadderEvent = require("ladder_event");
 
var BattleController = require("battle_controller");
 
var BattleConst = require("battle_const");
 
var CommonAlert = require("commonalert");
 
var RoleController = require("role_controller");
 
var LadderController = cc.Class({
  "extends": BaseController,
  ctor: function ctor() {},
  // 初始化配置数据
  initConfig: function initConfig() {
    var LadderModel = require("ladder_model");
 
    this.model = new LadderModel();
    this.model.initConfig();
  },
  // 返回当前的model
  getModel: function getModel() {
    return this.model;
  },
  // 注册监听事件
  registerEvents: function registerEvents() {},
  // 注册协议接受事件
  registerProtocals: function registerProtocals() {
    // this.RegisterProtocal(1110, this.on1110);
    this.RegisterProtocal(24300, this.handle24300); // 个人数据
 
    this.RegisterProtocal(24301, this.handle24301); // 挑战对手列表
 
    this.RegisterProtocal(24302, this.handle24302); // 对手数据
 
    this.RegisterProtocal(24303, this.handle24303); // 挑战对手
 
    this.RegisterProtocal(24304, this.handle24304); // 刷新对手
 
    this.RegisterProtocal(24305, this.handle24305); // 购买挑战次数
 
    this.RegisterProtocal(24306, this.handle24306); // 一键挑战
 
    this.RegisterProtocal(24307, this.handle24307); // 挑战结算
 
    this.RegisterProtocal(24308, this.handle24308); // 前三名玩家数据
 
    this.RegisterProtocal(24309, this.handle24309); // 排行榜数据
 
    this.RegisterProtocal(24310, this.handle24310); // 我的记录
 
    this.RegisterProtocal(24311, this.handle24311); // 大神风采
 
    this.RegisterProtocal(24312, this.handle24312); // 天梯是否开启
 
    this.RegisterProtocal(24313, this.handle24313); // 英雄殿红点
 
    this.RegisterProtocal(24314, this.handle24314); // 战报红点
 
    this.RegisterProtocal(24315, this.handle24315); // 清除cd时间
 
    this.RegisterProtocal(24316, this.handle24316); // 查看英雄信息
 
    this.RegisterProtocal(24317, this.handle24317); // 挑战次数红点
 
    this.RegisterProtocal(24318, this.handle24318); // 录像分享
  },
  //请求天梯个人信息
  requestLadderMyBaseInfo: function requestLadderMyBaseInfo() {
    this.SendProtocal(24300, {});
  },
  //请求挑战列表
  requestLadderEnemyListData: function requestLadderEnemyListData() {
    this.SendProtocal(24301, {});
  },
  //请求玩家信息
  requestLadderEnemyData: function requestLadderEnemyData(rid, srv_id) {
    var protocal = {};
    protocal.rid = rid;
    protocal.srv_id = srv_id;
    this.SendProtocal(24302, protocal);
  },
  //请求挑战玩家
  requestChallengeEnemy: function requestChallengeEnemy(rid, srv_id) {
    var protocal = {};
    protocal.rid = rid;
    protocal.srv_id = srv_id;
    this.SendProtocal(24303, protocal);
  },
  //请求刷新对手列表
  requestRefreshEnemyList: function requestRefreshEnemyList() {
    this.SendProtocal(24304, {});
  },
  //请求购买挑战次数
  requestBuyChallengeCount: function requestBuyChallengeCount() {
    this.SendProtocal(24305, {});
  },
  //请求一键挑战
  requestQuickChallenge: function requestQuickChallenge() {
    this.SendProtocal(24306, {});
  },
  //请求前三名玩家数据(英雄殿)
  requestTopThreeRoleData: function requestTopThreeRoleData() {
    this.SendProtocal(24308, {});
  },
  //请求排行榜信息
  requestLadderRankData: function requestLadderRankData() {
    this.SendProtocal(24309, {});
  },
  //请求日志记录
  requestMyLogData: function requestMyLogData() {
    this.SendProtocal(24310, {});
  },
  //请求大神风采
  requestGodLogData: function requestGodLogData() {
    this.SendProtocal(24311, {});
  },
  //请求天梯是否开启
  requestLadderIsOpen: function requestLadderIsOpen() {
    this.SendProtocal(24312, {});
  },
  //请求清除冷却时间
  requestCleanCDTime: function requestCleanCDTime() {
    this.SendProtocal(24315, {});
  },
  //请求查看英雄信息
  requestCheckRoleInfo: function requestCheckRoleInfo(rid, srv_id, pos) {
    var protocal = {};
    protocal.rid = rid;
    protocal.srv_id = srv_id;
    protocal.pos = pos;
    this.SendProtocal(24316, protocal);
  },
  //请求天梯录像分享
  requestShareVideo: function requestShareVideo(replay_id, srv_id, channel, target_name) {
    var protocal = {};
    protocal.replay_id = replay_id;
    protocal.srv_id = srv_id;
    protocal.channel = channel;
    protocal.target_name = target_name;
    this.SendProtocal(24316, protocal);
  },
  //-----------------------------------------------
  //个人数据
  handle24300: function handle24300(data) {
    if (data) {
      this.model.setLadderMyBaseInfo(data);
    }
 
    gcore.GlobalEvent.fire(LadderEvent.UpdateLadderMyBaseInfo);
  },
  //挑战对手列表
  handle24301: function handle24301(data) {
    if (data) {
      if (data.type == 0) {
        //全部更新
        this.model.setLadderEnemyListData(data.f_list);
      } else {
        //部分更新
        this.model.updateLadderEnemyListData(data.f_list);
      }
 
      gcore.GlobalEvent.fire(LadderEvent.UpdateAllLadderEnemyList);
    }
  },
  //对手数据
  handle24302: function handle24302(data) {
    if (data) {
      gcore.GlobalEvent.fire(LadderEvent.GetLadderEnemyData, data);
    }
  },
  //挑战对手
  handle24303: function handle24303(data) {
    message(data.msg);
    this.openLadderRoleInfoWindow(false);
  },
  //刷新对手
  handle24304: function handle24304(data) {
    message(data.msg);
  },
  //购买挑战次数
  handle24305: function handle24305(data) {
    message(data.msg);
 
    if (data.code == 1 && this._temp_rid != null && this._temp_srv_id != null) {
      this.requestChallengeEnemy(this._temp_rid, this._temp_srv_id);
      this._temp_rid = null;
      this._temp_srv_id = null;
    } else if (data.code == 1 && this._temp_quick_flag) {
      this.requestQuickChallenge();
      this._temp_quick_flag = null;
    }
  },
  //一键挑战
  handle24306: function handle24306(data) {
    message(data.msg);
  },
  //挑战结算
  handle24307: function handle24307(data) {
    BattleController.getInstance().openFinishView(true, BattleConst.Fight_Type.LadderWar, data);
  },
  //前三名数据
  handle24308: function handle24308(data) {
    if (data && data.rank_list) {
      gcore.GlobalEvent.fire(LadderEvent.UpdateLadderTopThreeRoleData, data.rank_list);
    }
  },
  //排行榜数据
  handle24309: function handle24309(data) {
    if (data) {
      gcore.GlobalEvent.fire(LadderEvent.UpdateLadderRankData, data);
    }
  },
  //我的记录
  handle24310: function handle24310(data) {
    if (data) {
      gcore.GlobalEvent.fire(LadderEvent.UpdateLadderMyLogData, data);
    }
  },
  //大神风采
  handle24311: function handle24311(data) {
    if (data) {
      gcore.GlobalEvent.fire(LadderEvent.UpdateLadderGodLogData, data);
    }
  },
  //天梯是否开启
  handle24312: function handle24312(data) {
    if (data) {
      this.model.setLadderOpenStatus(data.code);
      gcore.GlobalEvent.fire(LadderEvent.UpdateLadderOpenStatus);
    }
  },
  //英雄殿红点
  handle24313: function handle24313(data) {
    if (data.code != null) {
      if (!this._login_flag && data.code == 1) {
        this._login_flag = true;
        this.model.updateLadderRedStatus(LadderConst.RedType.TopThree, true);
      } else {
        this.model.updateLadderRedStatus(LadderConst.RedType.TopThree, false);
      }
    }
  },
  //英雄殿红点
  handle24314: function handle24314(data) {
    if (data.code != null) {
      gcore.GlobalEvent.fire(LadderConst.RedType.BattleLog, data.code == 1);
    }
  },
  //清除cd时间
  handle24315: function handle24315(data) {
    message(data.msg);
  },
  //查看英雄
  handle24316: function handle24316(data) {
    message(data.msg);
  },
  //挑战次数红点
  handle24317: function handle24317(data) {
    if (data.code != null) {
      gcore.GlobalEvent.fire(LadderConst.RedType.Challenge, data.code == 1);
    }
  },
  //录像分享
  handle24318: function handle24318(data) {
    message(data.msg);
  },
  //检测挑战次数并且进入战斗
  checkJoinLadderBattle: function checkJoinLadderBattle(rid, srv_id, is_quick) {
    if (this.model.getLeftChallengeCount() > 0) {
      if (is_quick) {
        this.requestQuickChallenge();
      } else {
        this.requestChallengeEnemy(rid, srv_id);
      }
    } else if (this.model.getTodayLeftBuyCount() > 0) {
      var buy_combat_num = this.model.getTodayBuyCount();
      var cost_config = Config.sky_ladder_data.data_buy_num[buy_combat_num + 1];
 
      if (cost_config) {
        if (is_quick) {
          var res = PathTool.getItemRes(3);
          var str = cc.js.formatStr(Utils.TI18N("挑战次数不足,是否消耗<img src='%s'/>%d购买一次挑战次数并且进行一键挑战?"), 3, cost_config.cost);
          CommonAlert.show(str, Utils.TI18N("确定"), function () {
            this._temp_quick_flag = true;
            this.requestBuyChallengeCount();
          }.bind(this), Utils.TI18N("取消"), null, 2, null, {
            resArr: [res]
          });
        } else {
          var _res = PathTool.getItemRes(3);
 
          var _str = string.format(TI18N("挑战次数不足,是否消耗<img src='%s'/>%d购买一次挑战次数并且进入战斗?"), 3, cost_config.cost);
 
          CommonAlert.show(_str, Utils.TI18N("确定"), function () {
            //缓存布阵数据,购买次数成功返回后直接进入战斗
            this._temp_rid = rid;
            this._temp_srv_id = srv_id;
            this.requestBuyChallengeCount();
            this.openLadderRoleInfoWindow(false);
          }.bind(this), Utils.TI18N("取消"), null, 2, null, {
            resArr: [_res]
          });
        }
      }
    } else {
      message(Utils.TI18N("挑战次数不足"));
      this.openLadderRoleInfoWindow(false);
    }
  },
  //-----------------------打开界面------------
  //天梯主界面
  openMainWindow: function openMainWindow(status) {
    if (status) {
      var role_vo = RoleController.getInstance().getRoleVo();
      var config = Config.sky_ladder_data.data["const"].join_min_lev;
 
      if (role_vo.lev < config.val) {
        message(config.desc);
        return;
      }
 
      if (this.ladder_main_window == null) {
        this.ladder_main_window = Utils.createClass("ladder_main_window");
      }
 
      this.ladder_main_window.open();
    } else {
      if (this.ladder_main_window) {
        this.ladder_main_window.close();
        this.ladder_main_window = null;
      }
    }
  },
  //天梯商店
  openLadderShopWindow: function openLadderShopWindow(status) {
    if (status) {
      if (this.ladder_shop_window == null) {
        this.ladder_shop_window = Utils.createClass("ladder_shop_window");
      }
 
      this.ladder_shop_window.open();
    } else {
      if (this.ladder_shop_window) {
        this.ladder_shop_window.close();
        this.ladder_shop_window = null;
      }
    }
  },
  //天梯对手信息
  openLadderRoleInfoWindow: function openLadderRoleInfoWindow(status, data) {
    if (status) {
      if (this.ladder_role_info_window == null) {
        this.ladder_role_info_window = Utils.createClass("ladder_role_info_window");
      }
 
      this.ladder_role_info_window.open(data);
    } else {
      if (this.ladder_role_info_window) {
        this.ladder_role_info_window.close();
        this.ladder_role_info_window = null;
      }
    }
  },
  //天梯战报
  openLadderLogWindow: function openLadderLogWindow(status) {
    if (status) {
      if (this.ladder_log_window == null) {
        this.ladder_log_window = Utils.createClass("ladder_log_window");
      }
 
      this.ladder_log_window.open();
    } else {
      if (this.ladder_log_window) {
        this.ladder_log_window.close();
        this.ladder_log_window = null;
      }
    }
  },
  //天梯奖励
  openLadderAwardWindow: function openLadderAwardWindow(status) {
    if (status) {
      if (this.ladder_award_window == null) {
        this.ladder_award_window = Utils.createClass("ladder_award_window");
      }
 
      this.ladder_award_window.open();
    } else {
      if (this.ladder_award_window) {
        this.ladder_award_window.close();
        this.ladder_award_window = null;
      }
    }
  },
  //天梯排行榜
  openLadderRankWindow: function openLadderRankWindow(status) {
    if (status) {
      if (this.ladder_rank_window == null) {
        this.ladder_rank_window = Utils.createClass("ladder_rank_window");
      }
 
      this.ladder_rank_window.open();
    } else {
      if (this.ladder_rank_window) {
        this.ladder_rank_window.close();
        this.ladder_rank_window = null;
      }
    }
  },
  //天梯英雄殿
  openLadderTopThreeWindow: function openLadderTopThreeWindow(status) {
    if (status) {
      if (this.ladder_top_three_window == null) {
        this.ladder_top_three_window = Utils.createClass("ladder_top_three_window");
      }
 
      this.ladder_top_three_window.open();
    } else {
      if (this.ladder_top_three_window) {
        this.ladder_top_three_window.close();
        this.ladder_top_three_window = null;
      }
    }
  },
  //天梯结算界面
  openLadderBattleResultWindow: function openLadderBattleResultWindow(status, data) {
    if (status) {
      if (this.ladder_result_window == null) {
        this.ladder_result_window = Utils.createClass("ladder_battle_result_window");
      }
 
      this.ladder_result_window.open(data);
    } else {
      if (this.ladder_result_window) {
        this.ladder_result_window.close();
        this.ladder_result_window = null;
      }
    }
  }
});
module.exports = LadderController;
 
cc._RF.pop();