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
"use strict";
cc._RF.push(module, 'cdb68e9gRBEjpBsriuHdUhX', 'primus_model');
// Scripts/mod/primus/primus_model.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-03-16 10:23:00
// --------------------------------------------------------------------
var MainuiController = require("mainui_controller");
 
var MainUiConst = require("mainui_const");
 
var EsecsiceConst = require("esecsice_const");
 
var RoleController = require("role_controller");
 
var PrimusModel = cc.Class({
  "extends": BaseClass,
  ctor: function ctor() {},
  properties: {},
  initConfig: function initConfig() {
    // 是否显示红点  策划要求.点一次界面就消除
    this.is_show_redpoint = true; //  挑战次数
 
    this.challenge_count = 0; //  挑战冷却时间
 
    this.challenge_time = 0;
  },
  recordChallengeCount: function recordChallengeCount(data) {
    this.challenge_count = data.num || 0;
    this.challenge_time = data.time || 0;
    this.updateRedPoint();
  },
  updateRedPoint: function updateRedPoint() {
    RedMgr.getInstance().addCalHandler(this.checkRed.bind(this), RedIds.Primus);
  },
  checkRed: function checkRed() {
    var is_show = this.checkRedStatus();
 
    var SceneConst = require("scene_const");
 
    MainuiController.getInstance().setBtnRedPoint(MainUiConst.btn_index.esecsice, {
      bid: SceneConst.RedPointType.primus,
      status: is_show
    });
  },
  checkRedStatus: function checkRedStatus() {
    var open_data = Config.dailyplay_data.data_exerciseactivity;
    var bool = MainuiController.getInstance().checkIsOpenByActivate(open_data[EsecsiceConst.execsice_index.honourfane].activate);
    if (bool == false) return false;
    var status = this.is_show_redpoint; // 等级
 
    if (status) {
      var role_vo = RoleController.getInstance().getRoleVo();
      var lev = role_vo && role_vo.lev || 0;
      var limit_lev = Config.primus_data.data_const.open_lev.val;
 
      if (lev < limit_lev) {
        status = false;
      }
    } // 挑战次数
 
 
    if (status) {
      var max = Config.primus_data.data_const.daily_challenge_limit.val;
 
      if (this.challenge_count >= max) {
        status = false;
      }
    } // 冷却cd
 
 
    if (status) {
      var time = gcore.SmartSocket.getTime();
 
      if (this.challenge_time != 0 && this.challenge_time > time) {
        status = false;
      }
    }
 
    return status;
  }
});
 
cc._RF.pop();