// -------------------------------------------------------------------- // @author: xxx@syg.com(必填, 创建模块的人员) // @description: // 这里填写详细说明,主要填写该模块的功能简要 //
Create: {DATE} // -------------------------------------------------------------------- const BridgeController = require( "bridge.controller" ); const SummonDefine = require( "summon.define" ); const RoleController = require( "role_controller" ); const SCST = SummonDefine.Summon_Type; const SCRK = SummonDefine.Recruit_Key; const PartnersummonController = cc.Class( { extends: BridgeController, properties: { partner_summon_window: null, }, ctor: function() { }, // 初始化配置数据 initConfig: function() { var PartnersummonModel = require( "summon.model" ); this.model = new PartnersummonModel(); this.model.initConfig(); }, // 返回当前的model getModel: function() { return this.model; }, // 注册协议接受事件 registerProtocals: function() { // 普通召唤 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( _cb ) { // 配置加载 let cfgs = [ "recruit_data", // 召唤抽卡 "recruit_high_data", // 先知召唤 "recruit_holiday_data", // 限定召唤 "infinite_ten_recruit_data", // 无限十连召唤 'recruit_gather_data', // 阵营召唤 ]; this.loadConfigs( cfgs, ( _ret, _data ) => { this.send23200( _cb ); this.reqInfiniteData(); } ); }, // 请求召唤信息 send23200: function( _cb ) { this.SendProtocal( 23200, {}, _cb ); }, // 召唤信息回复 handle23200: function( _data ) { // 失败 if( nx.dt.objEmpty( _data ) ) { return; } this.model.setSummonData( _data ); // 提示更新 this.updateTipView(); this.updateScoreTipView(); }, // 召唤 send23201: function( 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( _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( _data ) { if( nx.dt.objEmpty( _data ) ) { return; } this.model.updateSummonData( _data ); // 提示更新 this.updateTipView(); }, handle23203: function() { }, handle23204: function() { }, sender23205: function() { this.SendProtocal( 23205, {} ); }, handle23205: function( data ) { this.five_star_data = data; }, //获取5星必出数据 getFiveStarData: function() { return this.five_star_data; }, handle11095: function( data ) { this.openSummonGainShowWindow( true, [data] ) this.is_add_partner = true this.add_partner_data = data; }, handle23212: function() { }, scoreRecruit: function( group_id, times, recruit_type ) { if( this.partner_summon_window ) { this.partner_summon_window.startRecruit( group_id, times, recruit_type ); } }, // 再次召唤 againRecruit: function() { if( this.partner_summon_window ) { this.partner_summon_window.regainRecruit(); } }, recurit: function( group_id, times, recruit_type ) { this.partner_summon_window.sendRecruitProtocal( group_id, times, recruit_type ); // againRecruit }, // 展示高级英雄 openSummonGainShowWindow: function( status, show_bids, finish_cb, bg_type ) { if( !status ) { nx.bridge.closePanel( "WndSummonPartnerShowPanel" ); return; } let 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() { // 单次免费判断 let freeS = function( _rdata ) { let draws = _rdata ? _rdata.draw_list : []; if( nx.dt.arrEmpty( draws ) ) { return false; } for( let i in draws ) { let dt = draws[i]; if( dt && dt.times == 1 && nx.dt.arrNEmpty( dt.kv_list ) ) { for( let k in dt.kv_list ) { let kt = dt.kv_list[k]; if( kt && kt.key == SCRK.Free_Count ) { return kt.val > 0; } } } } return false; }; // 常规召唤更新 const data = this.model.getSummonGroupData(); for( let i = 0; i < data.length; ++i ) { let ifo = data[i]; let tip = freeS( ifo.recruit_data ); let ret = nx.bridge.checkConditions( ifo.config_data.limit_id ); nx.mTip.openTip( `summon.${ifo.group_id}.free`, tip && nx.dt.objEmpty( ret ) ); } }, // 更新积分召唤提示 updateScoreTipView: function() { // 监听角色属性 let role = RoleController.getInstance().getRoleVo(); if( !role ) { nx.mTip.openTip( `summon.${SCST.Score}.free`, false ); return; } let self = this; let update = function() { let cur = role.recruit_hero; let need = self.model.getScoreSummonNeedCount(); nx.mTip.openTip( `summon.${SCST.Score}.free`, cur >= need ); }; if( !this.scoreBinder ) { this.scoreBinder = role.bind( EventId.UPDATE_ROLE_ATTRIBUTE, ( _key ) => { if( _key == "recruit_hero" ) { update(); } } ); } update(); }, // ============================================================ // 功能增加: 无限十连召唤 --- Kevin 2023.05.06 // ============================================================ // 请求召唤信息 reqInfiniteData: function( _cb ) { this.SendProtocal( 23250, {}, _cb ); }, // 请求信息 handle23250: function( _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( _cb ) { this.SendProtocal( 23251, {}, _cb ); }, // 召唤返回 handle23251: function( _data ) { if( !this.isGoodData( _data ) ) { return; } nx.bridge.vset( "INFTimes", _data.num ); nx.bridge.vset( "INFCurrent", _data.partner_bids || [] ); }, // 满意 reqInfiniteConfirm: function( _id, _cb ) { this.SendProtocal( 23252, { id: _id, }, _cb ); }, // 满意确认 handle23252: function( _data ) { }, // 方案保存 reqInfiniteSave: function( _id, _cb ) { this.SendProtocal( 23253, { id: _id }, _cb ); }, // 方案保存 handle23253: function( _data ) { if( !this.isGoodData( _data ) ) { return; } }, // 方案获取 reqInfiniteRecords: function( _cb ) { this.SendProtocal( 23254, {}, _cb ); }, // 方案列表 handle23254: function( _data ) { if( !this.isGoodData( _data ) ) { return; } nx.bridge.vset( "INFRecords", _data.plan_list || [] ); }, // ============================================================ // 功能增加: 阵营召唤 --- Kevin 2024.03.06 // ============================================================ // 阵营道具召唤 reqSummonTeamItem: function( _gid, _times, _cb ) { this.SendProtocal( 23261, { group_id: _gid, recruit_type: 4, times: _times, }, _cb ); }, // 召唤返回 handle23261: function( _data ) { if( !this.isGoodData( _data, false ) ) { return; } }, // 阵营积分召唤 reqSummonTeamScore: function( _cb ) { this.SendProtocal( 23262, {}, _cb ); }, // 阵营积分召唤返回 handle23262: function( _data ) { if( !this.isGoodData( _data ) ) { return; } }, } ); module.exports = PartnersummonController;