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
"use strict";
cc._RF.push(module, '96a6c/OkeZJu4NhjPlRHfom', 'arena_model');
// Scripts/mod/arena/arena_model.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-03-06 11:18:06
// --------------------------------------------------------------------
var ArenaEvent = require("arena_event");
 
var ArenaLoopChallengeVo = require("arena_loop_challenge_vo");
 
var ArenaConst = require("arena_const");
 
var ArenaModel = cc.Class({
  "extends": BaseClass,
  ctor: function ctor() {},
  properties: {},
  initConfig: function initConfig() {
    this.my_loop_data = null;
    this.times_awards = null;
    this.loop_challenge_list = null;
    this.arena_loop_red_list = {};
    this.had_combat_num = 0;
  },
  updateMyLoopData: function updateMyLoopData(data) {
    this.my_loop_data = data;
    gcore.GlobalEvent.fire(ArenaEvent.UpdateMyLoopData); // 更新挑战次数红点
 
    this.updateArenaRedStatus(ArenaConst.red_type.loop_challenge, data.can_combat_num > 0);
  },
  // 循环赛信息
  getMyLoopData: function getMyLoopData() {
    return this.my_loop_data;
  },
  // 更新挑战次数奖励信息
  updateChallengeTimesAwards: function updateChallengeTimesAwards(data) {
    this.times_awards = data; // 更新奖励红点
 
    var bool_status = {};
    this.had_combat_num = data.had_combat_num || 0;
 
    for (var reward_i in Config.arena_data.data_season_num_reward) {
      var reward_info = Config.arena_data.data_season_num_reward[reward_i];
      bool_status[reward_i] = 0;
 
      if (data.had_combat_num) {
        if (reward_info.num <= data.had_combat_num) {
          bool_status[reward_i] = 1;
 
          for (var num_i in data.num_list) {
            var num_info = data.num_list[num_i];
 
            if (num_info.num == reward_info.num) {
              bool_status[reward_i] = 2;
            }
          }
        }
      }
    }
 
    var need_red = false;
 
    for (var status_i in bool_status) {
      if (bool_status[status_i] === 1) {
        need_red = true;
        break;
      }
    }
 
    this.updateArenaRedStatus(ArenaConst.red_type.loop_reward, need_red);
    gcore.GlobalEvent.fire(ArenaEvent.UpdateLoopChallengeTimesList, data);
  },
  getChallengeTimesAwards: function getChallengeTimesAwards() {
    return this.times_awards;
  },
  updateLoopChallengeList: function updateLoopChallengeList(data) {
    if (!this.loop_challenge_list && data.type === 1) return;
    if (!this.loop_challenge_list) this.loop_challenge_list = {};
 
    for (var list_i in data.f_list) {
      if (!this.loop_challenge_list[data.f_list[list_i].idx]) this.loop_challenge_list[data.f_list[list_i].idx] = new ArenaLoopChallengeVo();
      this.loop_challenge_list[data.f_list[list_i].idx].updatetAttributeData(data.f_list[list_i]);
    }
 
    if (data.type === 0) gcore.GlobalEvent.fire(ArenaEvent.UpdateLoopChallengeList);
  },
  getLoopChallengeList: function getLoopChallengeList() {
    var challente_list = [];
 
    for (var cha_i in this.loop_challenge_list) {
      challente_list.push(this.loop_challenge_list[cha_i]);
    }
 
    return challente_list;
  },
  cleanChallengeList: function cleanChallengeList() {
    this.loop_challenge_list = null;
  },
  // 根据积分获取奖杯配置数据,统一一个接口,如果不传入,就默认用自己的
  getZoneConfigBySoure: function getZoneConfigBySoure(score) {
    score = score || this.my_loop_data.score;
    var cur_config = null;
    var first_config = Config.arena_data.data_cup[0];
 
    if (!score || score < first_config.min_score) {
      cur_config = first_config;
    } else {
      for (var cfg_i in Config.arena_data.data_cup) {
        if (Config.arena_data.data_cup[cfg_i].min_score <= score && score <= Config.arena_data.data_cup[cfg_i].max_score) {
          cur_config = Config.arena_data.data_cup[cfg_i];
          break;
        }
      }
    } // var next_config = null;
    // if (cur_config) {
    //     var next_config_index = cur_config.index + 1;
    //     for (var cfg_i in Config.arena_data.data_cup) {
    //         if (Config.arena_data.data_cup[cfg_i].index === next_config_index) {
    //             next_config = Config.arena_data.data_cup[cfg_i];
    //             break;
    //         }
    //     }
    // }
 
 
    return cur_config; // {cur_config: cur_config, next_config: next_config}         
  },
  // 红点相关
  updateArenaRedStatus: function updateArenaRedStatus(type, status) {
    var cur_status = this.arena_loop_red_list[type];
    if (cur_status === status) return;
    this.arena_loop_red_list[type] = status;
 
    var SceneConst = require("scene_const");
 
    var MainSceneController = require("mainscene_controller");
 
    MainSceneController.getInstance().setBuildRedStatus(SceneConst.CenterSceneBuild.arena, {
      bid: type,
      status: status
    });
    gcore.GlobalEvent.fire(ArenaEvent.UpdateArenaRedStatus, type);
  },
  // 挑战记录红点更新
  updateArenaLoopLogStatus: function updateArenaLoopLogStatus(flag) {
    this.updateArenaRedStatus(ArenaConst.red_type.loop_log, !!flag);
  },
  getHadCombatNum: function getHadCombatNum() {
    return this.had_combat_num || 0;
  },
  getArenaLoopLogStatus: function getArenaLoopLogStatus() {
    return this.arena_loop_red_list[ArenaConst.red_type.loop_log];
  }
});
 
cc._RF.pop();