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
"use strict";
cc._RF.push(module, '5cfb3xdItxGKKjOd3kfE5/Q', 'chat_item_controller');
// Scripts/mod/chat/chat_item_controller.js
 
"use strict";
 
var ChatConst = require("chat_const");
 
var ChatEvent = require("chat_event");
 
var BackPackConst = require("backpack_const");
 
var GoodsVo = require("goods_vo");
 
var HeroController = require("hero_controller");
 
var TipsController = require("tips_controller");
 
var PartnerConst = require("partner_const");
 
var FriendController = cc.Class({
  "extends": BaseController,
  ctor: function ctor() {},
  registerProtocals: function registerProtocals() {
    this.RegisterProtocal(12418, this.handle12418.bind(this)); // 发送任务到聊天
 
    this.RegisterProtocal(12419, this.handle12419.bind(this)); // 点击任务返回数据
 
    this.RegisterProtocal(11221, this.handle11221.bind(this)); // 发送伙伴到聊天
 
    this.RegisterProtocal(11222, this.handle11222.bind(this)); // 点击伙伴返回数据
 
    this.RegisterProtocal(10535, this.handle10535.bind(this));
    this.RegisterProtocal(10536, this.handle10536.bind(this)); // 点击物品返回数据  
  },
  // 生成item Text
  buildItemMsg: function buildItemMsg(item_bid, srv_id, share_id, count) {
    var config_data = Utils.getItemConfig(item_bid);
    count = count || 0;
    var item_name = config_data.name;
    if (count > 1) item_name = item_name + "x" + count;
 
    if (config_data) {
      // <div fontcolor=%s href=%s|%s|%s>[%s]</div>"
      return cc.js.formatStr("<color=%s><on click='handler' param='%s|%s|%s'>[%s]</on></color>", BackPackConst.quality_color(config_data.quality), ChatConst.Link.Item_Show, srv_id, share_id, item_name);
    }
  },
  relapceFaceIconTag: function relapceFaceIconTag(text) {
    var patt = /(#)\d+/g;
    var result = null;
 
    while ((result = patt.exec(text)) != null) {
      var face_id = result[0].slice(1, result[0].length);
      var face_cfg = Config.face_data.data_biaoqing[face_id];
      var replace_str = "";
      if (face_cfg) replace_str = cc.js.formatStr("<img src='emoji' emoji='%s'/>", face_cfg.name);
      text = text.replace(new RegExp(result[0], 'i'), replace_str);
    }
 
    return text;
  },
  analyzeMessage: function analyzeMessage(message) {
    var patt = /(src=)/g;
    var result = null;
 
    while ((result = patt.exec(message)) != null) {
      message += "**";
    }
 
    return message;
  },
  getImages: function getImages(message) {
    var img_ids = [];
    var emojis = message.match(/src='(\S*)'/g);
 
    for (var emoji_i in emojis) {
      var emoji = emojis[emoji_i];
      var emoji_info = emoji.match(/src='(\S*)'/);
      if (emoji_info[1] !== "emoji") img_ids.push(emoji_info[1]);
    }
 
    return img_ids;
  },
  getEmojis: function getEmojis(message) {
    var emoji_ids = [];
    var emojis = message.match(/emoji='(\S*)'/g);
 
    for (var emoji_i in emojis) {
      var emoji = emojis[emoji_i];
      var emoji_info = emoji.match(/emoji='(\S*)'/);
      emoji_ids.push(emoji_info[1]);
    }
 
    return emoji_ids;
  },
  handle12418: function handle12418(data) {},
  handle12419: function handle12419(data) {},
  handle11221: function handle11221(data) {},
  handle11222: function handle11222(data) {},
  send10535: function send10535(type, id, partner_id, code) {
    var protocal = {};
    protocal.type = type;
    protocal.id = id;
    protocal.partner_id = partner_id;
    protocal.code = code;
    this.SendProtocal(10535, protocal);
  },
  handle10535: function handle10535(data) {
    if (data.flag == 1) {
      gcore.GlobalEvent.fire(ChatEvent.CHAT_SELECT_ITEM, data);
    } else {
      message(data.msg);
    }
  },
  // 获取物品Tips
  sender10536: function sender10536(share_id, srv_id) {
    if (!share_id) return;
    var protocal = {};
    protocal.srv_id = srv_id;
    protocal.id = share_id;
    this.SendProtocal(10536, protocal);
  },
  // 显示物品Tips
  handle10536: function handle10536(data) {
    if (data) {
      var item_vo = new GoodsVo();
      item_vo.setBaseId(data.base_id);
      item_vo.initAttrData(data);
 
      if (!item_vo.config) {
        message(Utils.TI18N("数据异常"));
        return;
      }
 
      if (BackPackConst.checkIsEquip(item_vo.config.type)) {
        HeroController.getInstance().openEquipTips(true, item_vo, PartnerConst.EqmTips.other);
      } else if (BackPackConst.checkIsArtifact(item_vo.config.type)) {
        HeroController.getInstance().openArtifactTipsWindow(true, item_vo, PartnerConst.ArtifactTips.normal);
      } else {
        var TipsController = require("tips_controller");
 
        TipsController.getInstance().showGoodsTips(item_vo.config);
      }
    }
  }
});
 
cc._RF.pop();