"use strict"; cc._RF.push(module, '38414tz0/NM7qQqsbBWz8f0', 'summon.mod'); // Scripts/mod/summon/summon.mod.js "use strict"; // -------------------------------------------------------------------- // @author: xxx@syg.com(必填, 创建模块的人员) // @description: // 这里填写详细说明,主要填写该模块的功能简要 //
Create: {DATE} // -------------------------------------------------------------------- var BridgeController = require("bridge.controller"); var SummonDefine = require("summon.define"); var RoleController = require("role_controller"); var SCST = SummonDefine.Summon_Type; var SCRK = SummonDefine.Recruit_Key; var PartnersummonController = cc.Class({ "extends": BridgeController, properties: { partner_summon_window: null }, ctor: function ctor() {}, // 初始化配置数据 initConfig: function initConfig() { var PartnersummonModel = require("summon.model"); this.model = new PartnersummonModel(); this.model.initConfig(); }, // 返回当前的model getModel: function getModel() { return this.model; }, // 注册协议接受事件 registerProtocals: function registerProtocals() { // 普通召唤 this.RegisterProtocal(23200, this.handle23200.bind(this)); //请求召唤信息 this.RegisterProtocal(23201, this.handle23201.bind(this)); //召唤 this.RegisterProtocal(23202, this.handle23202.bind(this)); //更新召唤通用信息 this.RegisterProtocal(23203, this.handle23203.bind(this)); //领取召唤分享奖励 this.RegisterProtocal(23204, this.handle23204.bind(this)); //跟新单个召唤卡库信息 this.RegisterProtocal(11095, this.handle11095.bind(this)); //其他途径获得伙伴推送 this.RegisterProtocal(23212, this.handle23212.bind(this)); //推送新卡库开启 this.RegisterProtocal(23205, this.handle23205.bind(this)); //必出5星 // 无限十连召唤 this.RegisterProtocal(23250, this.handle23250.bind(this)); // 请求信息 this.RegisterProtocal(23251, this.handle23251.bind(this)); // 召唤返回 this.RegisterProtocal(23252, this.handle23252.bind(this)); // 满意确认 this.RegisterProtocal(23253, this.handle23253.bind(this)); // 方案保存 this.RegisterProtocal(23254, this.handle23254.bind(this)); // 方案获取 // 阵营召唤 this.RegisterProtocal(23261, this.handle23261.bind(this)); // 阵营道具召唤 this.RegisterProtocal(23262, this.handle23262.bind(this)); // 阵营积分召唤 }, // 从服务器初始化数据 reqBaseFromServer: function reqBaseFromServer(_cb) { var _this = this; // 配置加载 var cfgs = ["recruit_data", // 召唤抽卡 "recruit_high_data", // 先知召唤 "recruit_holiday_data", // 限定召唤 "infinite_ten_recruit_data", // 无限十连召唤 'recruit_gather_data' // 阵营召唤 ]; this.loadConfigs(cfgs, function (_ret, _data) { _this.send23200(_cb); _this.reqInfiniteData(); }); }, // 请求召唤信息 send23200: function send23200(_cb) { this.SendProtocal(23200, {}, _cb); }, // 召唤信息回复 handle23200: function handle23200(_data) { // 失败 if (nx.dt.objEmpty(_data)) { return; } this.model.setSummonData(_data); // 提示更新 this.updateTipView(); this.updateScoreTipView(); }, // 召唤 send23201: function send23201(group_id, times, recruit_type, _cb) { // 操作频繁 if (this.LK23201) { nx.dt.fnInvoke(_cb, false, "ErrWaitLater"); return; } this.CB23201 = _cb; this.LK23201 = true; this.SendProtocal(23201, { group_id: group_id, times: times, recruit_type: recruit_type }); }, // 召唤回复 handle23201: function handle23201(_data) { this.LK23201 = false; this.LK23231 = false; // 失败 if (nx.dt.objEmpty(_data) || nx.dt.strNEmpty(_data.msg)) { nx.dt.fnInvoke(this.CB23201, false, _data ? _data.msg : "ErrFailed"); nx.dt.fnInvoke(this.CB23231, false, _data ? _data.msg : "ErrFailed"); this.CB23201 = null; this.CB23231 = null; return; } // 召唤信息 this.model.setRecruitData(_data); // 回调通告 nx.dt.fnInvoke(this.CB23201, true, _data); this.CB23201 = null; // 提示更新 this.updateTipView(); }, // 更新召唤通用信息 handle23202: function handle23202(_data) { if (nx.dt.objEmpty(_data)) { return; } this.model.updateSummonData(_data); // 提示更新 this.updateTipView(); }, handle23203: function handle23203() {}, handle23204: function handle23204() {}, sender23205: function sender23205() { this.SendProtocal(23205, {}); }, handle23205: function handle23205(data) { this.five_star_data = data; }, //获取5星必出数据 getFiveStarData: function getFiveStarData() { return this.five_star_data; }, handle11095: function handle11095(data) { this.openSummonGainShowWindow(true, [data]); this.is_add_partner = true; this.add_partner_data = data; }, handle23212: function handle23212() {}, scoreRecruit: function scoreRecruit(group_id, times, recruit_type) { if (this.partner_summon_window) { this.partner_summon_window.startRecruit(group_id, times, recruit_type); } }, // 再次召唤 againRecruit: function againRecruit() { if (this.partner_summon_window) { this.partner_summon_window.regainRecruit(); } }, recurit: function recurit(group_id, times, recruit_type) { this.partner_summon_window.sendRecruitProtocal(group_id, times, recruit_type); // againRecruit }, // 展示高级英雄 openSummonGainShowWindow: function openSummonGainShowWindow(status, show_bids, finish_cb, bg_type) { if (!status) { nx.bridge.closePanel("WndSummonPartnerShowPanel"); return; } var params = {}; params.bids = show_bids; params.cb = finish_cb; params.bg_type = bg_type; params.status = show_bids[0].status; nx.bridge.createPanel("WndSummonPartnerShowPanel", params); }, // ============================================================ // 方法增加: 提示相关 --- Kevin 2023.04.21 // ============================================================ // 提示视图更新机制 updateTipView: function updateTipView() { // 单次免费判断 var freeS = function freeS(_rdata) { var draws = _rdata ? _rdata.draw_list : []; if (nx.dt.arrEmpty(draws)) { return false; } for (var i in draws) { var dt = draws[i]; if (dt && dt.times == 1 && nx.dt.arrNEmpty(dt.kv_list)) { for (var k in dt.kv_list) { var kt = dt.kv_list[k]; if (kt && kt.key == SCRK.Free_Count) { return kt.val > 0; } } } } return false; }; // 常规召唤更新 var data = this.model.getSummonGroupData(); for (var i = 0; i < data.length; ++i) { var ifo = data[i]; var tip = freeS(ifo.recruit_data); var ret = nx.bridge.checkConditions(ifo.config_data.limit_id); nx.mTip.openTip("summon." + ifo.group_id + ".free", tip && nx.dt.objEmpty(ret)); } }, // 更新积分召唤提示 updateScoreTipView: function updateScoreTipView() { // 监听角色属性 var role = RoleController.getInstance().getRoleVo(); if (!role) { nx.mTip.openTip("summon." + SCST.Score + ".free", false); return; } var self = this; var update = function update() { var cur = role.recruit_hero; var need = self.model.getScoreSummonNeedCount(); nx.mTip.openTip("summon." + SCST.Score + ".free", cur >= need); }; if (!this.scoreBinder) { this.scoreBinder = role.bind(EventId.UPDATE_ROLE_ATTRIBUTE, function (_key) { if (_key == "recruit_hero") { update(); } }); } update(); }, // ============================================================ // 功能增加: 无限十连召唤 --- Kevin 2023.05.06 // ============================================================ // 请求召唤信息 reqInfiniteData: function reqInfiniteData(_cb) { this.SendProtocal(23250, {}, _cb); }, // 请求信息 handle23250: function handle23250(_data) { if (!this.isGoodData(_data)) { return; } nx.bridge.vset("INFTimes", _data.num); nx.bridge.vset("INFRecords", _data.plan_list || []); nx.bridge.vset("INFCurrent", _data.partner_bids || []); }, // 召唤 reqInfiniteSummon: function reqInfiniteSummon(_cb) { this.SendProtocal(23251, {}, _cb); }, // 召唤返回 handle23251: function handle23251(_data) { if (!this.isGoodData(_data)) { return; } nx.bridge.vset("INFTimes", _data.num); nx.bridge.vset("INFCurrent", _data.partner_bids || []); }, // 满意 reqInfiniteConfirm: function reqInfiniteConfirm(_id, _cb) { this.SendProtocal(23252, { id: _id }, _cb); }, // 满意确认 handle23252: function handle23252(_data) {}, // 方案保存 reqInfiniteSave: function reqInfiniteSave(_id, _cb) { this.SendProtocal(23253, { id: _id }, _cb); }, // 方案保存 handle23253: function handle23253(_data) { if (!this.isGoodData(_data)) { return; } }, // 方案获取 reqInfiniteRecords: function reqInfiniteRecords(_cb) { this.SendProtocal(23254, {}, _cb); }, // 方案列表 handle23254: function handle23254(_data) { if (!this.isGoodData(_data)) { return; } nx.bridge.vset("INFRecords", _data.plan_list || []); }, // ============================================================ // 功能增加: 阵营召唤 --- Kevin 2024.03.06 // ============================================================ // 阵营道具召唤 reqSummonTeamItem: function reqSummonTeamItem(_gid, _times, _cb) { this.SendProtocal(23261, { group_id: _gid, recruit_type: 4, times: _times }, _cb); }, // 召唤返回 handle23261: function handle23261(_data) { if (!this.isGoodData(_data, false)) { return; } }, // 阵营积分召唤 reqSummonTeamScore: function reqSummonTeamScore(_cb) { this.SendProtocal(23262, {}, _cb); }, // 阵营积分召唤返回 handle23262: function handle23262(_data) { if (!this.isGoodData(_data)) { return; } } }); module.exports = PartnersummonController; cc._RF.pop();