409 lines
13 KiB
JavaScript
409 lines
13 KiB
JavaScript
// 这里填写简要说明(必填),
|
|
//
|
|
// @author: jyd
|
|
// @editor: jyd
|
|
// @description:
|
|
// 神裝 (遺跡探索)
|
|
// <br/>
|
|
// ////////////////////////////////////////////////////////////////////
|
|
|
|
const BridgeController = require( "bridge.controller" );
|
|
const BattleConst = require( "battle_const" );
|
|
const HeroController = require( "hero_controller" )
|
|
const BattleController = require( "battle_controller" );
|
|
const HeavenModel = require( 'heaven_model' )
|
|
const HeavenEvent = require( 'heaven_event' )
|
|
|
|
const HeavenController = cc.Class( {
|
|
extends: BridgeController,
|
|
ctor: function() { },
|
|
|
|
// 初始化配置数据
|
|
initConfig: function() {
|
|
this.model = new HeavenModel();
|
|
this.model.initConfig();
|
|
},
|
|
|
|
// 返回当前的model
|
|
getModel: function() {
|
|
return this.model
|
|
},
|
|
|
|
registerEvents: function() {
|
|
|
|
},
|
|
|
|
// 从服务器初始化数据
|
|
reqBaseFromServer: function( _cb ) {
|
|
|
|
// 配置加载
|
|
let cfgs = [
|
|
"dungeon_heaven_data", // 神装副本
|
|
];
|
|
this.loadConfigs( cfgs, ( _ret, _data ) => {
|
|
nx.dt.fnInvoke( _cb, true );
|
|
this.reqHeavenData();
|
|
} );
|
|
|
|
},
|
|
|
|
reqHeavenData( _cb ) {
|
|
this.SendProtocal( 25200, {}, _cb );
|
|
},
|
|
|
|
checkIsOpen: function() {
|
|
var open_config1 = game.configs.dungeon_heaven_data.data_const.open_lev;
|
|
if( open_config1 == null ) return null;
|
|
let ret = nx.bridge.checkConditions( open_config1.val );
|
|
|
|
var open_config2 = game.configs.dungeon_heaven_data.data_const.open_world_lev;
|
|
if( open_config2 == null ) return null;
|
|
let ret2 = nx.bridge.checkConditions( open_config2.val );
|
|
|
|
if( ret && ret2 ) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
},
|
|
|
|
|
|
//////////////////-@ c2s
|
|
// 请求天界基础数据
|
|
sender25200: function( _cb ) {
|
|
this.SendProtocal( 25200, {}, _cb );
|
|
},
|
|
|
|
// 请求天界某一章节数据
|
|
sender25201: function( id ) {
|
|
let protocal = {}
|
|
protocal.id = id
|
|
this.SendProtocal( 25201, protocal )
|
|
},
|
|
|
|
// 请求挑战副本
|
|
sender25205: function( id, order_id ) {
|
|
let protocal = {}
|
|
protocal.id = id
|
|
protocal.order_id = order_id
|
|
this.SendProtocal( 25205, protocal )
|
|
},
|
|
|
|
// 请求购买次数
|
|
sender25207: function() {
|
|
this.SendProtocal( 25207, {} )
|
|
},
|
|
|
|
// 请求扫荡
|
|
sender25208: function( id, order_id ) {
|
|
let protocal = {}
|
|
protocal.id = id
|
|
protocal.order_id = order_id
|
|
this.SendProtocal( 25208, protocal )
|
|
},
|
|
|
|
// 请求天界副本阵法数据
|
|
sender25210: function( type ) {
|
|
let protocal = {}
|
|
protocal.type = type
|
|
this.SendProtocal( 25210, protocal )
|
|
},
|
|
|
|
// 设置天界副本阵法数据
|
|
sender25211: function( type, formations ) {
|
|
let protocal = {}
|
|
protocal.type = type
|
|
protocal.formations = formations
|
|
this.SendProtocal( 25211, protocal )
|
|
},
|
|
|
|
// 请求领取章节星级奖励
|
|
sender25215: function( id, award_id ) {
|
|
let protocal = {}
|
|
protocal.id = id
|
|
protocal.award_id = award_id
|
|
this.SendProtocal( 25215, protocal )
|
|
},
|
|
|
|
// 请求神装抽奖
|
|
sender25217: function( group_id, times, recruit_type ) {
|
|
let protocal = {}
|
|
protocal.group_id = group_id
|
|
protocal.times = times
|
|
protocal.recruit_type = recruit_type
|
|
this.SendProtocal( 25217, protocal )
|
|
},
|
|
|
|
// 请求抽奖日志
|
|
sender25218: function( type, group_id ) {
|
|
let protocal = {}
|
|
protocal.type = type
|
|
protocal.group_id = group_id
|
|
this.SendProtocal( 25218, protocal )
|
|
},
|
|
|
|
//////////////////@ s2c
|
|
registerProtocals: function() {
|
|
this.RegisterProtocal( 25200, this.handle25200.bind( this ) ) // 天界基础数据
|
|
this.RegisterProtocal( 25201, this.handle25201.bind( this ) ) // 天界某一章节数据
|
|
this.RegisterProtocal( 25203, this.handle25203.bind( this ) ) // 天界基础数据更新
|
|
this.RegisterProtocal( 25204, this.handle25204.bind( this ) ) // 天界某一章数据更新
|
|
this.RegisterProtocal( 25205, this.handle25205.bind( this ) ) // 天界挑战关卡
|
|
this.RegisterProtocal( 25206, this.handle25206.bind( this ) ) // 天界挑战结算
|
|
this.RegisterProtocal( 25207, this.handle25207.bind( this ) ) // 购买次数
|
|
this.RegisterProtocal( 25208, this.handle25208.bind( this ) ) // 扫荡返回
|
|
this.RegisterProtocal( 25210, this.handle25210.bind( this ) ) // 天界副本阵法数据
|
|
this.RegisterProtocal( 25211, this.handle25211.bind( this ) ) // 设置阵法数据返回
|
|
this.RegisterProtocal( 25215, this.handle25215.bind( this ) ) // 领取章节奖励返回
|
|
|
|
this.RegisterProtocal( 25216, this.handle25216.bind( this ) ) // 当前是否还有未完成的战斗
|
|
|
|
|
|
},
|
|
|
|
// 天界基础数据
|
|
handle25200: function( data ) {
|
|
if( data ) {
|
|
if( data.count != null ) {
|
|
this.model.setLeftChallengeCount( data.count )
|
|
}
|
|
if( data.buy_count ) {
|
|
this.model.setTodayBuyCount( data.buy_count )
|
|
}
|
|
if( data.max_dun_id ) {
|
|
this.model.setMaxDunId( data.max_dun_id )
|
|
}
|
|
if( data.chapter_info ) {
|
|
this.model.setChapterData( data.chapter_info )
|
|
}
|
|
gcore.GlobalEvent.fire( HeavenEvent.Get_Chapter_Data_Event )
|
|
}
|
|
},
|
|
|
|
// 天界某一章节数据
|
|
handle25201: function( data ) {
|
|
if( data ) {
|
|
if( data.dun_info ) {
|
|
this.model.setCustomsData( data.dun_info, data.id )
|
|
}
|
|
gcore.GlobalEvent.fire( HeavenEvent.Update_Chapter_Basedata_Event )
|
|
}
|
|
},
|
|
|
|
// 天界基础数据更新
|
|
handle25203: function( data ) {
|
|
if( data ) {
|
|
if( data.count != null ) {
|
|
this.model.setLeftChallengeCount( data.count )
|
|
}
|
|
if( data.buy_count != null ) {
|
|
this.model.setTodayBuyCount( data.buy_count )
|
|
}
|
|
if( data.max_dun_id != null ) {
|
|
this.model.setMaxDunId( data.max_dun_id )
|
|
}
|
|
if( data.chapter_info != null ) {
|
|
this.model.updateChapterData( data.chapter_info )
|
|
}
|
|
gcore.GlobalEvent.fire( HeavenEvent.Update_Chapter_Count_Event )
|
|
}
|
|
},
|
|
|
|
// 天界某一章数据更新
|
|
handle25204: function( data ) {
|
|
if( data ) {
|
|
if( data.dun_info ) {
|
|
this.model.updateCustomsData( data.dun_info, data.id )
|
|
gcore.GlobalEvent.fire( HeavenEvent.Update_Chapter_Basedata_Event )
|
|
}
|
|
}
|
|
},
|
|
|
|
// 挑战关卡
|
|
handle25205: function( data ) {
|
|
if( data ) {
|
|
// message(data.msg)
|
|
}
|
|
},
|
|
|
|
// 挑战结算
|
|
handle25206: function( data ) {
|
|
nx.bridge.vset("ResultInfo",data);
|
|
},
|
|
|
|
// 购买次数
|
|
handle25207: function( data ) {
|
|
if( data ) {
|
|
// message(data.msg)
|
|
if( data.count != null ) {
|
|
this.model.setLeftChallengeCount( data.count )
|
|
}
|
|
if( data.buy_count ) {
|
|
this.model.setTodayBuyCount( data.buy_count )
|
|
}
|
|
if( data.code == 1 && this._temp_type && this._temp_formations ) {
|
|
this.sender25211( this._temp_type, this._temp_formations )
|
|
this._temp_type = null
|
|
this._temp_formations = null
|
|
} else if( data.code == 1 && this._temp_id && this._temp_order_id ) {
|
|
this.sender25208( this._temp_id, this._temp_order_id )
|
|
this._temp_id = null
|
|
this._temp_order_id = null
|
|
}
|
|
gcore.GlobalEvent.fire( HeavenEvent.Update_Chapter_Count_Event )
|
|
}
|
|
},
|
|
|
|
// 扫荡返回
|
|
handle25208: function( data ) {
|
|
if( data ) {
|
|
// message(data.msg)
|
|
if( data.count != null ) {
|
|
this.model.setLeftChallengeCount( data.count )
|
|
}
|
|
gcore.GlobalEvent.fire( HeavenEvent.Update_Chapter_Count_Event )
|
|
}
|
|
},
|
|
|
|
// 天界副本阵法数据
|
|
handle25210: function( data ) {
|
|
gcore.GlobalEvent.fire( HeavenEvent.Update_Heaven_Fun_Form, data )
|
|
},
|
|
|
|
// 设置阵法数据返回
|
|
handle25211: function( data ) {
|
|
if( data ) {
|
|
// message(data.msg)
|
|
gcore.GlobalEvent.fire( HeavenEvent.Save_Heaven_Fun_Form, data )
|
|
}
|
|
},
|
|
|
|
// 领取章节奖励返回
|
|
handle25215: function( data ) {
|
|
if( data ) {
|
|
// message(data.msg)
|
|
let temp_data = {}
|
|
temp_data.award_info = data.award_info
|
|
this.model.updateOneChapterDataById( data.id, temp_data )
|
|
gcore.GlobalEvent.fire( HeavenEvent.Get_Chapter_Award_Event,data.id )
|
|
gcore.GlobalEvent.fire( HeavenEvent.Refresh_Chapter_Award_Event );
|
|
}
|
|
},
|
|
|
|
// 是否还有未完成的战斗
|
|
handle25216: function( data ) {
|
|
if( data ) {
|
|
BattleController.getInstance().getModel().setUnfinishedWarStatus( data.combat_type, data.flag )
|
|
if( data.flag == 0 ) {
|
|
// 服务端可能会先告知客户端有战斗,再结算,再告知无战斗
|
|
BattleController.getInstance().openRelevanceWindowAtOnce(
|
|
data.combat_type
|
|
)
|
|
}
|
|
}
|
|
},
|
|
|
|
// 检测挑战次数并且进入战斗
|
|
checkJoinHeavenBattle: function( _type, formations ) {
|
|
if( this.model.getLeftChallengeCount() > 0 ) {
|
|
this.sender25211( _type, formations )
|
|
} else if( this.model.getTodayLeftBuyCount() > 0 ) {
|
|
let buy_num = this.model.getTodayBuyCount()
|
|
let buy_cfg = game.configs.dungeon_heaven_data.data_count_buy[ buy_num + 1 ]
|
|
if( buy_cfg ) {
|
|
let str = cc.js.formatStr(
|
|
nx.text.getKey('lab_star_tower_main_window_tip7')
|
|
,
|
|
3,
|
|
buy_cfg.cost
|
|
)
|
|
let fun = () => {
|
|
this._temp_type = _type
|
|
this._temp_formations = formations
|
|
this.sender25207()
|
|
}
|
|
nx.mbox(str,["cancel","confirm"],(_key,_box)=>{
|
|
_box.close();
|
|
if(_key == "confirm"){
|
|
fun();
|
|
}
|
|
});
|
|
}
|
|
} else {
|
|
nx.tbox( 'lab_ladder_controller_tip3' )
|
|
}
|
|
},
|
|
|
|
// 检测挑战次数并且进行扫荡
|
|
checkHeavenSweep: function( id, order_id ) {
|
|
if( this.model.getLeftChallengeCount() > 0 ) {
|
|
this.sender25208( id, order_id )
|
|
} else if( this.model.getTodayLeftBuyCount() > 0 ) {
|
|
let buy_num = this.model.getTodayBuyCount()
|
|
let buy_cfg = game.configs.dungeon_heaven_data.data_count_buy[ buy_num + 1 ]
|
|
if( buy_cfg ) {
|
|
let str = cc.js.formatStr(
|
|
nx.text.getKey('lab_element_controller_tip1')
|
|
,
|
|
3,
|
|
buy_cfg.cost
|
|
)
|
|
nx.mbox(str,["cancel","confirm"],(_key,_box)=>{
|
|
_box.close();
|
|
if(_key == "confirm"){
|
|
this._temp_order_id = order_id
|
|
this.sender25207()
|
|
}
|
|
});
|
|
} else {
|
|
nx.tbox( 'lab_ladder_controller_tip3' )
|
|
}
|
|
}else{
|
|
nx.tbox( 'lab_ladder_controller_tip3' )
|
|
}
|
|
},
|
|
|
|
//////////////////////-@ 界面相关
|
|
// 打开天界副本主界面 chapter_id.强制打开某一章节
|
|
openHeavenMainWindow: function( status, chapter_id, index, group_id, is_open_chapter ) {
|
|
|
|
},
|
|
|
|
// 打开天界章节界面
|
|
openHeavenChapterWindow: function( status, chapter_id ) {
|
|
|
|
},
|
|
|
|
// 打开天界排行榜
|
|
openHeavenRankWindow: function( status ) {
|
|
|
|
},
|
|
|
|
// 星数奖励界面
|
|
openHeavenStarAwardWindow: function( status, chapter_id ) {
|
|
|
|
},
|
|
|
|
// 战斗胜利结算界面
|
|
openHeavenBattleWinView: function( status, data ) {
|
|
|
|
},
|
|
|
|
// 打开神装转盘界面
|
|
openHeavenDialWindow( status, group_id ) {
|
|
|
|
},
|
|
|
|
// 打开抽奖记录界面
|
|
openHeavenDialRecordWindow( status, group_id ) {
|
|
|
|
},
|
|
|
|
//打开心愿界面
|
|
openHeavenDialWishWindow( status, pos, data ) {
|
|
|
|
},
|
|
} )
|
|
|
|
module.exports = HeavenController
|