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
"use strict";
cc._RF.push(module, '0bcfflnB4FJFKqb5h4viHFs', 'pokedex_controller');
// Scripts/mod/pokedex/pokedex_controller.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-04-08 10:31:20
// --------------------------------------------------------------------
var RoleController = require("role_controller");
 
var PokedexEvent = require("pokedex_event");
 
var PokedexController = cc.Class({
  "extends": BaseController,
  ctor: function ctor() {},
  // 初始化配置数据
  initConfig: function initConfig() {
    var PokedexModel = require("pokedex_model");
 
    this.model = new PokedexModel();
    this.model.initConfig();
  },
  // 返回当前的model
  getModel: function getModel() {
    return this.model;
  },
  // 注册监听事件
  registerEvents: function registerEvents() {// var self = this
    // if (!self.init_role_event){
    //     self.init_role_event = gcore.GlobalEvent.bind(EventId.ROLE_CREATE_SUCCESS, function(){
    //         gcore.GlobalEvent.unBind(self.init_role_event)
    //         self.role_vo = RoleController.getInstance().getRoleVo()
    //         // self.sender11040() 登录先请求一下当前的图书馆信息
    //     })
    // }
    // if not self.add_goods_event then
    //     self.add_goods_event = GlobalEvent:getInstance():Bind(BackpackEvent.ADD_GOODS, function(bag_code,temp_add)
    //         if bag_code == BackPackConst.Bag_Code.BACKPACK then 
    //             self:checkRedPoint(temp_add)
    //         end
    //     end)
    // end
    // if not self.del_goods_event then
    //     self.del_goods_event = GlobalEvent:getInstance():Bind(BackpackEvent.DELETE_GOODS, function(bag_code,temp_del)
    //         if bag_code == BackPackConst.Bag_Code.BACKPACK then 
    //             self:checkRedPoint(temp_del)
    //         end
    //     end)
    // end
    // if not self.modify_goods_event then
    //     self.modify_goods_event = GlobalEvent:getInstance():Bind(BackpackEvent.MODIFY_GOODS_NUM, function(bag_code,temp_list)
    //         if bag_code == BackPackConst.Bag_Code.BACKPACK then 
    //             self:checkRedPoint(temp_list)
    //         end
    //     end)
    // end
    // if not self.add_partner_event then
    //     self.add_partner_event = GlobalEvent:getInstance():Bind(PartnerEvent.Partner_Data_Update, function(_partner_vo, is_add)
    //         if is_add then 
    //             -- self:checkIsCanCall()
    //         end
    //     end)
    // end
    // if not self.get_all_data then 
    //     self.get_all_data =  GlobalEvent:getInstance():Bind(BackpackEvent.GET_ALL_DATA, function(bag_code)
    //         if bag_code == BackPackConst.Bag_Code.BACKPACK then 
    //             -- self:checkIsCanCall()
    //         end
    //     end)
    // end
  },
  // 注册协议接受事件
  registerProtocals: function registerProtocals() {
    var self = this; // this.RegisterProtocal(1110, this.on1110);
 
    self.RegisterProtocal(11041, this.handle11041.bind(this)); //--请求指定英雄评论信息
 
    self.RegisterProtocal(11042, this.handle11042.bind(this)); //--设置伙伴为喜欢
 
    self.RegisterProtocal(11043, this.handle11043.bind(this)); //--伙伴评论
 
    self.RegisterProtocal(11044, this.handle11044.bind(this)); //--评论点赞    
 
    self.RegisterProtocal(11046, this.handle11046.bind(this)); //--推送伙伴总星数改变    
 
    self.RegisterProtocal(11047, this.handle11047.bind(this)); //--图书馆加成等级升级
  },
  handle11041: function handle11041(data) {
    gcore.GlobalEvent.fire(PokedexEvent.Comment_List_Event, data);
  },
  handle11042: function handle11042(data) {
    message(data.msg);
 
    if (data.result == 1) {
      gcore.GlobalEvent.fire(PokedexEvent.Comment_Like_Event, data);
    }
  },
  handle11043: function handle11043(data) {
    message(data.msg);
 
    if (data.result == 1) {
      gcore.GlobalEvent.fire(PokedexEvent.Comment_Say_Event, data);
    }
  },
  handle11044: function handle11044(data) {
    message(data.msg);
 
    if (data.result == 1) {
      gcore.GlobalEvent.fire(PokedexEvent.Comment_Zan_Event, data);
    }
  },
  // --推送伙伴总星数改变
  handle11046: function handle11046(data) {
    message(data.msg);
 
    if (data) {
      var all_data = this.model.getAllData();
      all_data.all_star = data.new_star; // this.checkIsCanCall()
    }
  },
  handle11047: function handle11047(data) {
    message(data.msg);
    var self = this;
 
    if (data.result == 1) {
      var config = Config.partner_data.data_pokedex_attr;
      var all_data = self.model.getAllData();
      var cur_lev = all_data.lev;
      if (!cur_lev) return;
      all_data.lev = data.lev;
      var next_lev = Math.min(data.lev + 1, tableLen(config));
      var next_config = Config.partner_data.data_pokedex_attr[next_lev];
      self.star_data = {
        old_star: all_data.all_star,
        new_star: next_config.star,
        old_lev: cur_lev,
        cur_lev: data.lev
      };
 
      if (self.star_data) {
        self.openStarUpWindow(true, self.star_data);
      }
 
      gcore.GlobalEvent.fire(PokedexEvent.Up_End_Event, self.star_data);
    }
  },
  // --评论
  openCommentWindow: function openCommentWindow(bool, data, callFunc) {
    var self = this;
 
    if (bool == false) {
      if (self.commentWindow) {
        self.commentWindow.close();
        self.commentWindow = null;
      }
    } else {
      if (!self.commentWindow) {
        var PartnerCommentWindow = require("partner_comment_window");
 
        self.commentWindow = new PartnerCommentWindow();
      }
 
      if (self.commentWindow.isOpen() == false) {
        self.commentWindow.open(data);
 
        if (callFunc) {
          self.commentWindow.addCallBack(callFunc);
        }
      }
    }
  },
  // --总星数提升一级
  openStarUpWindow: function openStarUpWindow(bool, data) {// if bool == false then
    //     if self.star_window ~= nil then
    //         self.star_window:close()
    //         self.star_window = nil
    //         self:checkIsCanCall()
    //     end
    // else
    //     if self.star_window == nil then
    //         self.star_window = PokedexStarWindow.New(data)
    //     end
    //     if self.star_window:isOpen() == false then
    //         self.star_window:open()
    //     end
    // end  
  },
  // --请求指定英雄评论信息
  sender11041: function sender11041(partner_id, start, num) {
    var protocal = {};
    protocal.partner_id = partner_id;
    protocal.start = start;
    protocal.num = num;
    this.SendProtocal(11041, protocal);
  },
  // --伙伴评论
  sender11043: function sender11043(partner_id, msg) {
    var protocal = {};
    protocal.partner_id = partner_id;
    protocal.msg = msg;
    this.SendProtocal(11043, protocal);
  },
  // --设置伙伴为喜欢
  sender11042: function sender11042(partner_id) {
    var protocal = {};
    protocal.partner_id = partner_id;
    this.SendProtocal(11042, protocal);
  },
  // --评论点赞
  sender11044: function sender11044(partner_id, comment_id, type) {
    var protocal = {};
    protocal.partner_id = partner_id;
    protocal.comment_id = comment_id;
    protocal.type = type;
    this.SendProtocal(11044, protocal);
  }
});
module.exports = PokedexController;
 
cc._RF.pop();