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
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
"use strict";
cc._RF.push(module, '2dffcv8hD1O0I8pPJXBDgcT', 'role_controller');
// Scripts/mod/role/role_controller.js
 
"use strict";
 
/*-----------------------------------------------------+
 * 角色控制模块
 * @author whjing2012@163.com
 +-----------------------------------------------------*/
// var MainSceneController = require("mainscene_controller");
var RoleEvent = require("role_event");
 
var RoleController = cc.Class({
  "extends": BaseController,
  ctor: function ctor() {},
  // 初始化配置数据
  initConfig: function initConfig() {
    var RoleModel = require("role_model");
 
    this.model = new RoleModel();
    this.model.initConfig();
    this.is_re_connect = false;
    this.apk_data = null; // SDK_.get_apk_url(function(data){
    //     cc.log(data)
    //     this.apk_data = data;
    // }.bind(this))
  },
  getModel: function getModel() {
    return this.model;
  },
  getRoleVo: function getRoleVo() {
    if (this.model) {
      return this.model.getRoleVo();
    }
  },
  // 注册监听事件
  registerEvents: function registerEvents() {
    this.re_link_game_event = gcore.GlobalEvent.bind(EventId.LOADING_FINISH, function () {
      if (this.need_set_name) this.openRoleSetNameView(true);
    }.bind(this));
  },
  // 注册协议接受事件
  registerProtocals: function registerProtocals() {
    this.RegisterProtocal(10301, this.on10301); // 角色基本信息
 
    this.RegisterProtocal(10302, this.on10302); // 资产信息
 
    this.RegisterProtocal(10315, this.on10315); // 查看角色信息
 
    this.RegisterProtocal(10306, this.on10306); // 战力变更推送
 
    this.RegisterProtocal(10318, this.on10318); // 允许切磋状态
 
    this.RegisterProtocal(10325, this.on10325); // 头像列表信息
 
    this.RegisterProtocal(10327, this.on10327); // 头像变更
 
    this.RegisterProtocal(10345, this.on10345); // 形象信息
 
    this.RegisterProtocal(10346, this.on10346); // 形象使用
 
    this.RegisterProtocal(10347, this.on10347); // 形象激活
 
    this.RegisterProtocal(10342, this.on10342); // 强制改名
 
    this.RegisterProtocal(10343, this.on10343); // 角色改名
 
    this.RegisterProtocal(10317, this.on10317); // 形象激活                
 
    this.RegisterProtocal(10316, this.on10316); // 膜拜角色
    // this.RegisterProtocal(12741, this.on12741); // 能用提示信息
 
    this.RegisterProtocal(12745, this.on12745); // 道具不足通用协议
 
    this.RegisterProtocal(10906, this.on10906); // 开服天数
 
    this.RegisterProtocal(10994, this.on10994); // 服务端通知整点更新
 
    this.RegisterProtocal(10945, this.on10945); // 媒体卡兑换
 
    this.RegisterProtocal(21500, this.on21500); // 头像框获取
 
    this.RegisterProtocal(21501, this.on21501); // 使用头像框 
 
    this.RegisterProtocal(21502, this.on21502); // 更新头像框 
 
    this.RegisterProtocal(21503, this.on21503); // 激活头像框 
 
    this.RegisterProtocal(23300, this.on23300); // 称号信息
 
    this.RegisterProtocal(23301, this.on23301); // 使用称号
 
    this.RegisterProtocal(23302, this.on23302); // 更新称号数据
 
    this.RegisterProtocal(23303, this.on23303); // 激活称号
 
    this.RegisterProtocal(24500, this.on24500); // 当前特权情况
 
    this.RegisterProtocal(10350, this.handle10350); //-- 获取活动资产id
 
    this.RegisterProtocal(10351, this.handle10351); //-- 推送活动资产id 
 
    this.RegisterProtocal(12770, this.handle12770); // -- 发送举报协议
 
    this.RegisterProtocal(12771, this.handle12771); //-- 获取举报协议信息
 
    this.RegisterProtocal(10905, this.handle10905); //-- 世界等级
    //成长之路
    // this.RegisterProtocal(25830, this.handle25830);  //查看成长之路
    // this.RegisterProtocal(25831, this.handle25831);  //成长之路分享
    // this.RegisterProtocal(25832, this.handle25832);  //查看成长之路分享
  },
  setReconnect: function setReconnect(status) {
    this.is_re_connect = status;
  },
  //判断别人srv_id是不是与自己是不是同服
  isTheSameSvr: function isTheSameSvr(srv_id) {
    var is_same = this.model.isTheSame(srv_id);
 
    if (srv_id && is_same) {
      return true;
    } else {
      return false;
    }
  },
  // 角色基本信息
  on10301: function on10301(data) {
    cc.log("角色基本信息");
    cc.log(data);
 
    if (!this.init_role) {
      this.init_role = true; //先实例化
 
      this.model.initRoleBaseData(data); // 这里会有很多信息需要请求
 
      this.requestOpenSrvDay(); // 开服天数
 
      if (PLATFORM_TYPR == "SH_SDK") {
        SDK.roleUpLevel(this.getRoleVo().lev);
      }
 
      if (data.lev <= 5) {
        game.addGuideRes();
 
        if (data.sex == 2) {
          game.addRenameRes();
        }
      }
 
      game.addChapterRes(data.chapter_id);
 
      if (data.lev < 10) {
        window.hide_loading = true;
      }
 
      var SysController = require("sys_controller").getInstance();
 
      game.preloadRes(function () {
        // this.model.initRoleBaseData(data);
        SysController.requestLoginProtocals(function () {
          var MainUiController = require("mainui_controller");
 
          MainUiController.getInstance().openMainUI(true);
 
          var MainSceneController = require("mainscene_controller");
 
          MainSceneController.getInstance().enterMainScene(true);
        }.bind(this));
      }.bind(this));
      gcore.GlobalEvent.fire(EventId.EVT_ROLE_CREATE_SUCCESS); // -- sdk等级计算
 
      if (IS_SUBMIT) {
        SDK.sdkSubmitUserData(3);
      }
 
      game.initMsgView();
    } else {
      this.model.initRoleBaseData(data);
    } // 断线重连抛出事件
 
 
    if (this.is_re_connect) {
      gcore.GlobalEvent.fire(EventId.EVT_RE_LINK_GAME);
      this.is_re_connect = false;
    }
  },
  // 角色资产信息
  on10302: function on10302(data) {
    this.model.initRoleAssetsData(data);
  },
  //查看角色信息
  requestRoleInfo: function requestRoleInfo(rid, srv_id) {
    if (rid == 0 || !srv_id) return;
    var protocal = {};
    protocal.rid = rid;
    protocal.srv_id = srv_id;
    this.SendProtocal(10315, protocal);
  },
  //查看角色信息
  on10315: function on10315(data) {
    gcore.GlobalEvent.fire(RoleEvent.DISPATCH_PLAYER_VO_EVENT, data);
  },
  // 膜拜
  sender10316: function sender10316(rid, srv_id, index, type) {
    if (!rid) return;
    index = index || 0;
    type = type || 0;
    var protocal = {};
    protocal.type = type;
    protocal.rid = rid;
    protocal.srv_id = srv_id;
    protocal.idx = index;
    this.SendProtocal(10316, protocal);
  },
  on10316: function on10316(data) {
    message(data.msg);
 
    if (data.code == 1) {
      gcore.GlobalEvent.fire(RoleEvent.WorshipOtherRole, data);
    }
  },
  // 更新切磋状态
  send10318: function send10318(auto_pk) {
    this.SendProtocal(10318, {
      auto_pk: auto_pk
    });
  },
  // 更新切磋状态结果
  on10318: function on10318(data) {
    message(data.msg);
 
    if (data.code == 1) {
      this.model.setRoleAttribute("auto_pk", data.auto_pk);
    }
  },
  // 请求头像列表信息
  send10325: function send10325() {
    this.SendProtocal(10325, {});
  },
  on10325: function on10325(data) {
    this.model.setRoleAttribute("face_list", data.face_list);
  },
  // 头像变更
  send10327: function send10327(face_id) {
    this.SendProtocal(10327, {
      face_id: face_id
    });
  },
  on10327: function on10327(data) {
    message(data.msg);
 
    if (data.code == 1) {
      this.model.setRoleAttribute("face_id", data.face_id);
    }
  },
  // 通用提示信息
  on12741: function on12741(data) {// message(data.msg);
  },
  // 道具不足通用提示
  on12745: function on12745(data) {
    var item_config = Utils.getItemConfig(data.bid);
 
    if (item_config) {
      if (data.bid == Config.item_data.data_assets_label2id.gold || data.bid == Config.item_data.data_assets_label2id.gold) {
        if (IS_SHOW_CHARGE == false) {
          message(Utils.TI18N("钻石不足"));
        } else {
          var fun = function () {
            require("vip_controller").getInstance().openVipMainWindow(true, VIPTABCONST.CHARGE);
          }.bind(this);
 
          var str = cc.js.formatStr(Utils.TI18N('%s不足,是否前往充值'), item_config.name);
 
          var CommonAlert = require("commonalert");
 
          CommonAlert.show(str, Utils.TI18N('确定'), fun, Utils.TI18N('取消'), null, CommonAlert.type.rich, null, null);
        }
      } else if (data.bid == Config.item_data.data_assets_label2id.energy) {
        message(Utils.TI18N("情报不足"));
      } else {
        var config = Utils.getItemConfig(data.bid);
 
        if (config) {
          var BackpackController = require("backpack_controller");
 
          BackpackController.getInstance().openTipsSource(true, config.id);
        }
      }
    }
  },
  on10994: function on10994(data) {
    if (data.type == 6 || data.type == 18) {
      require("mainscene_controller").getInstance().changeMainCityTimeType(data.type);
    } else if (data.type == 0) {
      this.requestOpenSrvDay(); // require("primus_controller").getInstance().sender20706() //星河神殿请求红点
 
      require("action_controller").getInstance().requestActionRedStatus(); //部分活动请求红点
 
 
      require("startower_controller").getInstance().sender11320();
    }
  },
  // 改名
  changeRoleName: function changeRoleName(name, sex) {
    this.SendProtocal(10343, {
      name: name,
      sex: sex
    });
  },
  // 改名结果
  on10343: function on10343(data) {
    message(data.msg);
 
    if (data.code == 1) {
      this.model.setRoleAttribute("name", data.name);
      this.model.setRoleAttribute("sex", data.sex);
      this.model.setRoleAttribute("is_first_rename", 0);
      this.openRoleSetNameView(false);
    }
  },
  // 形象信息请求
  send10345: function send10345() {
    this.SendProtocal(10345, {});
  },
  on10345: function on10345(data) {
    gcore.GlobalEvent.fire(RoleEvent.GetModelList, data);
  },
  // 形象使用
  send10346: function send10346(id) {
    this.SendProtocal(10346, {
      id: id
    });
  },
  on10346: function on10346(data) {
    message(data.msg);
 
    if (data.code == 1) {
      gcore.GlobalEvent.fire(RoleEvent.UpdateModel, data.id);
    }
  },
  // 形象激活
  send10347: function send10347(id) {
    this.SendProtocal(10347, {
      id: id
    });
  },
  on10347: function on10347(data) {
    message(data.msg);
 
    if (data.code == 1) {
      gcore.GlobalEvent.fire(RoleEvent.ActiveModel, data.id);
    }
  },
  // 媒体卡领取
  sender10945: function sender10945(card_id) {
    this.SendProtocal(10945, {
      card_id: card_id
    });
  },
  on10945: function on10945(data) {
    message(data.msg);
  },
  // 头像框获取
  send21500: function send21500() {
    this.SendProtocal(21500);
  },
  on21500: function on21500(data) {
    gcore.GlobalEvent.fire(RoleEvent.GetFaceList, data);
  },
  // 使用头像框
  send21501: function send21501(base_id) {
    this.SendProtocal(21501, {
      base_id: base_id
    });
  },
  on21501: function on21501(data) {},
  // 更新头像框 
  on21502: function on21502(data) {
    gcore.GlobalEvent.fire(RoleEvent.GetFaceList, data);
  },
  // 激活头像框 
  send21503: function send21503(base_id) {
    this.SendProtocal(21503, {
      base_id: base_id
    });
  },
  on21503: function on21503(data) {
    gcore.GlobalEvent.fire(RoleEvent.GetFaceList, data);
  },
  // 称号列表信息
  send23300: function send23300() {
    this.SendProtocal(23300, {});
  },
  on23300: function on23300(data) {
    this.model.setRoleAttribute("title_id", data.base_id);
    this.model.setRoleAttribute("title_list", data.honor);
    gcore.GlobalEvent.fire(RoleEvent.GetTitleList, data);
  },
  // 使用称号
  send23301: function send23301(base_id) {
    this.SendProtocal(23301, {
      base_id: base_id
    });
  },
  on23301: function on23301(data) {
    this.model.setRoleAttribute("title_id", data.base_id);
    gcore.GlobalEvent.fire(RoleEvent.UseTitle, data.base_id);
  },
  // 更新称号
  on23302: function on23302(data) {
    this.model.setRoleAttribute("title_list", data.honor);
    gcore.GlobalEvent.fire(RoleEvent.UpdateTitleList, data);
  },
  // 激活称号 
  send23303: function send23303(base_id) {
    this.SendProtocal(23303, {
      base_id: base_id
    });
  },
  on23303: function on23303(data) {
    this.model.setRoleAttribute("title_list", data.honor);
    gcore.GlobalEvent.fire(RoleEvent.UpdateTitleList, data);
  },
  // 打开角色设置面板
  openRoleInfoView: function openRoleInfoView(status) {
    if (status == true) {
      if (!this.role_info_view) {
        var RoleSetWindow = require("role_set_window");
 
        this.role_info_view = new RoleSetWindow();
      }
 
      this.role_info_view.open();
    } else {
      if (this.role_info_view) {
        this.role_info_view.close();
        this.role_info_view = null;
      }
    }
  },
  // 打开更改装饰界面
  openRoleDecorateView: function openRoleDecorateView(status, index, setting) {
    if (status) {
      if (!this.role_decorate_view) {
        var RoleDecorateWindow = require("role_decorate_window");
 
        this.role_decorate_view = new RoleDecorateWindow();
      }
 
      this.role_decorate_view.open(index, setting);
    } else {
      if (this.role_decorate_view) {
        this.role_decorate_view.close();
        this.role_decorate_view = null;
      }
    }
  },
  //判断一个人是否是自己
  checkIsSelf: function checkIsSelf(srv_id, rid) {
    var role_vo = this.getRoleVo();
    if (role_vo == null) return false;else return role_vo.srv_id == srv_id && role_vo.rid == rid;
  },
  // 当前特权情况
  on24500: function on24500(data) {
    this.model.setPrivilegeData(data.list);
  },
  // 请求开服天数
  requestOpenSrvDay: function requestOpenSrvDay() {
    this.SendProtocal(10906, {});
  },
  // 开服天数返回
  on10906: function on10906(data) {
    this.model.setOpenSrvDay(data.open_day);
  },
  // 强制改名
  on10342: function on10342() {
    if (game.finish_loading) {
      this.openRoleSetNameView(true);
    } else {
      this.need_set_name = true;
    }
  },
  // 点赞数量
  on10317: function on10317() {},
  // --打开设置名称界面
  openRoleSetNameView: function openRoleSetNameView(status) {
    var self = this;
 
    if (status == true) {
      if (self.role_setname_new == null) {
        var RoleSetNameView = require("role_setname_window");
 
        self.role_setname_new = new RoleSetNameView();
      }
 
      self.role_setname_new.open();
    } else {
      if (self.role_setname_new != null) {
        self.role_setname_new.close();
        self.role_setname_new = null;
      }
    }
  },
  getRandomName: function getRandomName(sex) {
    sex = sex || 1;
    var randomName = "";
 
    for (var i in Config.random_name_data.data_list) {
      var config = Config.random_name_data.data_list[i] || {}; //     -- 取出所有符合性别要求的名称
 
      var temp_data = [];
 
      for (var k = 0; k < config.length; ++k) {
        var v = config[k];
 
        if (v && (v.sex == sex || v.sex == 0)) {
          temp_data.push(v);
        }
      }
 
      var random_data = temp_data[~~(Math.random() * temp_data.length)] || [];
      randomName = randomName + (random_data.name || "");
    }
 
    return randomName;
  },
  // --[[活动资产推送]] --登陆的时候推送
  handle10350: function handle10350(data) {
    this.model.initRoleActionAssetsData(data.holiday_assets, false);
  },
  handle10351: function handle10351(data) {
    this.model.initRoleActionAssetsData(data.holiday_assets, true);
  },
  // --打开举报界面
  openRoleReportedPanel: function openRoleReportedPanel(status, rid, srv_id, play_name) {
    var self = this;
 
    if (status == true) {
      if (self.role_reported_panel == null) {
        var RoleReportedWindow = require("role_reported_window");
 
        self.role_reported_panel = new RoleReportedWindow();
      }
 
      self.role_reported_panel.open({
        rid: rid,
        srv_id: srv_id,
        play_name: play_name
      });
    } else {
      if (self.role_reported_panel != null) {
        self.role_reported_panel.close();
        self.role_reported_panel = null;
      }
    }
  },
  // -----------------------------------------------举报功能协议和打开方法-------------------------
  send12770: function send12770(rid, srv_id, _type, msg, history) {
    var protocal = {};
    protocal.rid = rid;
    protocal.srv_id = srv_id;
    protocal.type = _type || 1;
    protocal.msg = msg || "";
    protocal.history = history || [];
    this.SendProtocal(12770, protocal);
  },
  send12771: function send12771(rid, srv_id) {
    var protocal = {};
    protocal.rid = rid;
    protocal.srv_id = srv_id;
    this.SendProtocal(12771, protocal);
  },
  handle12770: function handle12770(data) {
    message(data.msg);
  },
  handle12771: function handle12771(data) {
    gcore.GlobalEvent.fire(RoleEvent.ROLE_REPORTED_EVENT, data);
  },
  checkRoleSetNameViewIsOpen: function checkRoleSetNameViewIsOpen() {
    if (this.role_setname_new) return true;
    return false;
  },
  on10306: function on10306(data) {
    var role = this.getRoleVo();
    role.setPower(data.power);
    role.setMaxPower(data.max_power);
  },
  getApkData: function getApkData() {
    if (this.apk_data) {
      return this.apk_data;
    }
  },
  handle10905: function handle10905(data) {
    this.model.setWorldLev(data.world_lev);
  },
  //成长之路---------
  send25830: function send25830(start, num) {
    var protocal = {};
    protocal.start = start;
    protocal.num = num;
    this.SendProtocal(25830, protocal);
  },
  handle25830: function handle25830(data) {
    cc.log("25830", data); //num等于1是计算红点用途
 
    if (data.num == 1) {} // data.is_redpoint = this.model.checkGrowthWayRedPoint(data);
    // this.model.setGrowthWayData(data);
 
  },
  //成长之路分享
  send25831: function send25831(channel) {
    var protocal = {};
    protocal.channel = channel;
    this.SendProtocal(25831, protocal);
  },
  handle25831: function handle25831(data) {
    cc.log("25831", data);
  },
  //查看成长之路分享
  send25832: function send25832(rid, srv_id, start, num) {
    var protocal = {};
    protocal.rid = rid;
    protocal.srv_id = srv_id;
    protocal.start = start;
    protocal.num = num;
    this.SendProtocal(25832, protocal);
  },
  handle25832: function handle25832(data) {
    cc.log("25832", data);
  },
  //角色是否第一次创建
  isfirstRole: function isfirstRole() {
    var role_vo = this.getRoleVo();
    if (role_vo && role_vo.sex == 2) return true;
    return false;
  }
});
module.exports = RoleController;
 
cc._RF.pop();