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

369 lines
8.8 KiB
JavaScript

/*******************************************************************************
*
* 活动: 月卡
*
*
******************************************************************************/
const ActBase = require( "act.base" );
const ActStartravel = cc.Class( {
extends: ActBase,
// 初始化配置数据
initConfig: function() {
// 视图附着
nx.plugin.add( this, [ "view" ] );
this.vattach( "Acts" );
},
// 注册协议接受事件
registerProtocals: function() {
this.RegisterProtocal(28700, this.handle28700.bind(this) )//戰靈任務信息
this.RegisterProtocal(28701, this.handle28701.bind(this) )//任務信息更新
this.RegisterProtocal(28702, this.handle28702.bind(this) )//提交任務
this.RegisterProtocal(28703, this.handle28703.bind(this) )//等级奖励展示
this.RegisterProtocal(28704, this.handle28704.bind(this) )//领取等级礼包(成功推送28703)
this.RegisterProtocal(28705, this.handle28705.bind(this) )//等级变更(只会主动推)
this.RegisterProtocal(28706, this.handle28706.bind(this) )//进阶卡情况
// this.RegisterProtocal(28707, this.handle28707.bind(this) )//是否要弹窗
this.RegisterProtocal(28708, this.handle28708.bind(this) )//周期重置红点
},
// 从服务器初始化数据
reqBaseFromServer: function( _cb ) {
// nx.dt.fnInvoke( _cb, true );
let cfgs = [
this.data.config,
]
this.loadConfigs( cfgs, ( _ret, _data ) =>{
this.reqBaseData(_cb);
} )
},
// 请求剧情信息
reqBaseData: function( _cb ) {
this.reqOrderData(_cb);
},
reqOrderData( _cb ){
this.send28700(_cb);
},
// ============================================================
// 首充操作
// ============================================================
//任務信息
send28700(_cb){
this.SendProtocal(28700, {},_cb)
},
// 请求戰靈任務信息返回
handle28700: function( _data ) {
if( !this.isGoodData( _data ) ) {
this.vset( "orderTasks", [] );
return;
}
this.setCurPeriod(_data.period) //週期數
this.setCurDay(_data.cur_day) //天數
this.setRMBStatus(_data.rmb_status) //是否激活特權
this.setCurLev(_data.lev) //當前等級
this.setCurExp(_data.exp) //當前經驗
this.setPeriodLev(_data.period_lev) //週期開始等級
this.setDayLev(_data.day_lev) //天開始等級
this.setWeekLev(_data.week_lev) //周開始等級
this.vset( "orderTasks", _data.list);//任務列表
this.vset( "orderLastTime",_data.end_time)
// 提示刷新
this.freshTips();
this.freshAwardTips();
},
//任務更新
handle28701(_data){
if( !this.isGoodData( _data ) ) {
return;
}
let tasks = this.vget("orderTasks");
for(let i in tasks){
let task = tasks[i];
for(let j in _data.list){
if(_data.list[j].id == task.id){
tasks[i] = _data.list[j];
break;
}
}
}
this.vset("orderTasks",tasks);
},
// 提交任務
reqTask: function( _id, _cb ) {
this.SendProtocal( 28702, {
id: _id,
}, _cb );
},
// 提交任務返回
handle28702: function( _data ) {
if( !this.isGoodData( _data ) ) {
return;
}
// 提示刷新
this.freshTips();
this.freshAwardTips();
},
//等級獎勵
send28703(_cb){
this.SendProtocal(28703, {}, _cb)
},
handle28703(data){
if( !this.isGoodData( data ) ) {
this.vset( "orderRewards", [] );
return;
}
this.setCurLev(data.lev) //當前等級
this.vset( "orderRewards", data.reward_list );
// 提示刷新
this.freshAwardTips();
},
// 領取等級禮包
reqGift: function( _id, _cb ) {
this.SendProtocal( 28704, {
id: _id,
}, _cb );
},
handle28704: function( _data ) {
if( !this.isGoodData( _data ) ) {
return;
}
},
// 等級變更(只會主動推)
handle28705(_data){
if( !this.isGoodData( _data ) ) {
return;
}
this.setCurExp(_data.exp)
this.setCurLev(_data.lev)
this.send28700();
},
//進階卡情況
send28706(){
this.SendProtocal(28706, {})
},
handle28706(_data){
if( !this.isGoodData( _data ) ) {
return;
}
this.setRMBStatus(_data.rmb_status);
if(_data.list.length > 0){
this.setOrderCardId(_data.list[0].id);
let reward_list = this.vget("orderRewards");
this.vset( "orderRewards", reward_list );
}
},
//週期重置紅點
send28708(){
this.SendProtocal(28708)
},
handle28708(data){
if( !this.isGoodData( data ) ) {
return;
}
if (data && data.flag && data.flag == 1) {
this.setPeriodRed(true)
}
this.setPeriodRed(false)
},
// ============================================================
// 活动红点提示
// ============================================================
// 活动用到的提示KEY
tipKeys: function() {
return ["orderTask","reward"];
},
// 红点提示更新
freshTips: function() {
let tasks = this.vget("orderTasks");
let is_reward = false;
for(let i in tasks){
if(tasks[i].finish == 1){
is_reward = true;
break;
}
}
this.openTip( "orderTask", is_reward );
},
freshAwardTips(){
let awards = this.vget("orderRewards");
let is_reward = false;
let exp_data = game.configs.holiday_new_war_order_data.data_lev_reward_list[this.getCurPeriod()];
for(let idx in exp_data){
if(this.getCurExp() >= exp_data[idx].exp){
is_reward = true;
for(let i in awards){
if(exp_data[idx].lev == awards[i].id){
if(awards[i].status == 1 && this.getRMBStatus() == 0){//基础奖励
is_reward = false;
break;
}else if(awards[i].status == 1 && awards[i].rmb_status == 1 && this.getRMBStatus() == 1){//氪金奖励
is_reward = false;
break;
}
}
}
}
}
this.openTip( "reward", is_reward );
},
//當前經驗
setCurExp(exp){
this.cur_exp = exp
},
getCurExp(){
if (this.cur_exp) {
return this.cur_exp
}
return 1
},
//當前週期
setCurPeriod(period){
this.cur_period = period
},
//獲取當前週期
getCurPeriod(){
if (this.cur_period) {
return this.cur_period
}
return 1
},
//當前天數
setCurDay(day){
this.cur_day = day
},
getCurDay(){
if (this.cur_day) {
return this.cur_day
}
return 1
},
//當前等級
setCurLev(lev){
this.cur_lev = lev
},
getCurLev(){
if (this.cur_lev ){
return this.cur_lev
}
return 1
},
//是否激活特權
setRMBStatus(status){
this.rmb_status = status
},
getRMBStatus(){
if (this.rmb_status) {
return this.rmb_status
}
return 0
},
// 週期開始等級
setPeriodLev(period_lev){
this.period_lev = period_lev
},
getPeriodLev(){
if( this.period_lev) {
return this.period_lev
}
return 1
},
// 天開始等級
setDayLev(day_lev){
this.day_lev = day_lev
},
getDayLev(){
if (this.day_lev) {
return this.day_lev
}
return 1
},
// 周開始等級
setWeekLev(week_lev){
this.week_lev = week_lev
},
getWeekLev(){
if (this.week_lev) {
return this.week_lev
}
return 1
},
//設置週期重置紅點
setPeriodRed(bool){
this.period_red = bool
},
getPeriodRed(){
if (this.period_red) {
return this.period_red
}
return false
},
setOrderCardId(card_id){
this.card_id = card_id;
},
getOrderCardId(){
if(this.card_id){
return this.card_id;
}
return null;
}
} );
// 模块导出
module.exports = ActStartravel;