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
"use strict";
cc._RF.push(module, 'f8a8cOctShCb5V2PuPgXYZN', 'limitexercise_controller');
// Scripts/mod/limitexercise/limitexercise_controller.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      试炼之境
// <br/>Create: 2019-09-09 19:11:57
// --------------------------------------------------------------------
var LimitExerciseEvent = require("limitexercise_event");
 
var LimitexerciseController = cc.Class({
  "extends": BaseController,
  ctor: function ctor() {},
  // 初始化配置数据
  initConfig: function initConfig() {
    var LimitexerciseModel = require("limitexercise_model");
 
    this.model = new LimitexerciseModel();
    this.model.initConfig();
  },
  // 返回当前的model
  getModel: function getModel() {
    return this.model;
  },
  // 注册监听事件
  registerEvents: function registerEvents() {},
  // 注册协议接受事件
  registerProtocals: function registerProtocals() {
    // this.RegisterProtocal(1110, this.on1110);
    this.RegisterProtocal(25410, this.handle25410);
    this.RegisterProtocal(25411, this.handle25411);
    this.RegisterProtocal(25412, this.handle25412);
    this.RegisterProtocal(25413, this.handle25413);
    this.RegisterProtocal(25414, this.handle25414);
  },
  // --活动boss信息
  send25410: function send25410() {
    this.SendProtocal(25410, {});
  },
  handle25410: function handle25410(data) {
    this.model.setLimitExerciseData(data);
    gcore.GlobalEvent.fire(LimitExerciseEvent.LimitExercise_Message_Event, data);
  },
  //购买挑战次数
  send25411: function send25411() {
    this.SendProtocal(25411, {});
  },
  handle25411: function handle25411(data) {
    message(data.msg);
 
    if (data.code == 1) {
      this.model.setChangeCount(data.count, data.buy_count);
 
      if (this.touch_buy_change && data.count == 1) {
        this.send25413();
      }
 
      this.touch_buy_change = null;
      gcore.GlobalEvent.fire(LimitExerciseEvent.LimitExercise_BuyCount_Event, data);
    }
  },
  //当挑战次数为0的时候,可以根据购买次数是否为0来判断出战
  checkJoinFight: function checkJoinFight() {
    var const_data = Config.holiday_boss_new_data.data_const;
    if (!const_data) return;
    var max_count = const_data.fight_buy_max_count.val;
    var cur_count = this.model.getDayBuyCount();
    var remain_count = this.model.getReaminCount(); // cc.log("max_count,cur_count,remain_count",max_count,cur_count,remain_count)
 
    if (cur_count >= max_count && remain_count == 0) {
      message(Utils.TI18N("今日次数已用完~~"));
    } else {
      if (remain_count <= 0) {
        var CommonAlert = require("commonalert");
 
        var str = cc.js.formatStr("是否花费<img src='%s' scale=0.3 />%s购买一次挑战次数?", Config.item_data.data_assets_label2id.gold, const_data.action_num_espensive.val);
        var res = PathTool.getItemRes(Config.item_data.data_assets_label2id.gold);
 
        var call_back = function () {
          this.touch_buy_change = true;
          this.send25411();
        }.bind(this);
 
        CommonAlert.show(str, Utils.TI18N("确认"), call_back, Utils.TI18N("取消"), null, 2, null, {
          resArr: [res]
        });
      } else {
        this.send25413();
      }
    }
  },
  send25412: function send25412() {
    this.SendProtocal(25412, {});
  },
  handle25412: function handle25412(data) {
    message(data.msg);
    gcore.GlobalEvent.fire(LimitExerciseEvent.LimitExercise_GetBox_Event, data);
  },
  // 挑战活动boss
  send25413: function send25413() {
    this.SendProtocal(25413, {});
  },
  handle25413: function handle25413(data) {
    message(data.msg);
 
    if (data.code == 1) {
      var HeroController = require("hero_controller");
 
      HeroController.getInstance().openFormGoFightPanel(false);
    }
  },
  //当前伙伴已使用次数
  send25414: function send25414() {
    this.SendProtocal(25414, {});
  },
  handle25414: function handle25414(data) {
    this.model.setHeroUseId(data.p_list);
  },
  openLimitExerciseChangeView: function openLimitExerciseChangeView(status) {
    if (status == true) {
      if (!this.limit_exercise_view) {
        var LimitExerciseChangeWindow = require("limitexercise_change_window");
 
        this.limit_exercise_view = new LimitExerciseChangeWindow(this);
      }
 
      this.limit_exercise_view.open();
    } else {
      if (this.limit_exercise_view) {
        this.limit_exercise_view.close();
        this.limit_exercise_view = null;
      }
    }
  },
  //打开查看奖励界面
  openLimitExerciseRewardView: function openLimitExerciseRewardView(status) {
    if (status == true) {
      if (!this.open_reward_view) {
        var LimitExerciseRewardWindow = require("limitexercise_reward_window");
 
        this.open_reward_view = new LimitExerciseRewardWindow(this);
      }
 
      this.open_reward_view.open();
    } else {
      if (this.open_reward_view) {
        this.open_reward_view.close();
        this.open_reward_view = null;
      }
    }
  }
});
module.exports = LimitexerciseController;
 
cc._RF.pop();