Files
fc/dev/project/assets/Scripts/mod/acts/elite/act.elite.mod.js
T
2026-05-23 22:10:14 +08:00

178 lines
4.4 KiB
JavaScript

/******************************************************************
*
* 活动: 精英召唤
*
******************************************************************/
const ActBase = require( "act.base" );
const ActEliteSummon = cc.Class( {
extends: ActBase,
// 初始化配置数据
initConfig: function() {
// 视图附着
nx.plugin.add( this, [ "view" ] );
this.vattach( "Acts" );
},
// 注册协议接受事件
registerProtocals: function() {
this.RegisterProtocal( 23230, this.handle23230.bind( this ) );
this.RegisterProtocal( 23232, this.handle23232.bind( this ) );
this.RegisterProtocal( 23231, this.handle23231.bind( this ) );
this.RegisterProtocal( 23233, this.handle23233.bind( this ) );
this.RegisterProtocal( 23244, this.handle23244.bind( this ) );
},
// 从服务器初始化数据
reqBaseFromServer: function( _cb ) {
// 配置加载
let cfgs = [
"recruit_holiday_lucky_data", // 5选一精英召唤
];
this.loadConfigs( cfgs, ( _ret, _data ) => {
this.fetchData( _cb );
} );
},
// ============================================================
// 基本信息
// ============================================================
// 信息请求
fetchData: function( _cb ) {
this.SendProtocal( 23230, {}, _cb );
},
// 数据整理
updateData: function( _data, _reset = false ) {
if( nx.dt.objEmpty( _data ) ) {
return;
}
// 基础数据更新
let old = this.vget( "eliteBase" );
if( _reset || old.lucky_bid != _data.lucky_bid ) {
this.vset( "eliteBase", {
camp_id: _data.camp_id,
end_time: _data.end_time,
item_id: _data.item_id,
item_num: _data.item_num,
lucky_bid: _data.lucky_bid,
reward_list: _data.reward_list || [],
start_time: _data.start_time,
} );
}
// 次数数据更新
this.vset( "eliteTimes", {
free_time: _data.free_time,
gold_time: _data.gold_time,
must_count: _data.must_count,
times: _data.times
} );
this.freshTips();
},
// 信息请求返回
handle23230: function( _data ) {
if( !this.isGoodData( _data ) ) {
return;
}
this.updateData( _data, true );
},
// 更新推送
handle23232: function( _data ) {
this.updateData( _data, false );
},
// 请求更换许愿目标
reqTarget: function( _bid, _cb ) {
this.SendProtocal( 23233, {
lucky_bid: _bid,
}, _cb );
},
// 更换许愿目标回复
handle23233: function( _data ) {
if( !this.isGoodData( _data ) ) {
return;
}
},
// ============================================================
// 召唤操作
// ============================================================
// 召唤请求
reqSummon: function( _times, _type, _cb ) {
this.SendProtocal( 23231, {
times: _times,
recruit_type: _type,
}, _cb );
},
// 精英召唤返回
handle23231: function( _data ) {
if( !this.isGoodData( _data ) ) {
return;
}
},
// ============================================================
// 排行榜
// ============================================================
// 排行榜请求
reqRankList: function( _today, _cb ) {
this.SendProtocal( 23244, {
type: _today ? 57 : 58
}, _cb );
},
// 排行榜
handle23244: function( _data ) {
if( !this.isGoodData( _data ) ) {
return;
}
},
// ============================================================
// 活动红点提示
// ============================================================
// 活动用到的提示KEY
tipKeys: function() {
return [ "free" ];
},
// 红点提示更新
freshTips: function() {
let base = this.vget( "eliteBase" );
let times = this.vget( "eliteTimes" );
// 奖励关闭
this.openTip( "reward", false );
// 免费
let tip = ( base.camp_id != 0 ) && ( times.free_time == 0 );
this.openTip( "free", tip );
},
} );
module.exports = ActEliteSummon;