Files
fc/dev/project/assets/Scripts/mod/guild/boss/guildboss_controller.js
T
2026-05-23 22:10:14 +08:00

371 lines
12 KiB
JavaScript

// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
// 这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-01-24 17:44:54
// --------------------------------------------------------------------
const BridgeController = require( "bridge.controller" );
var RoleController = require("role_controller");
var GuildbossEvent = require("guildboss_event");
var BattleController = require("battle_controller");
var BattleConst = require("battle_const");
var GuildbossConst = require("guildboss_const");
var GuildbossController = cc.Class({
extends: BridgeController,
ctor: function () {
},
// 初始化配置数据
initConfig: function () {
var GuildbossModel = require("guildboss_model");
this.model = new GuildbossModel();
this.model.initConfig();
},
// 返回当前的model
getModel: function () {
return this.model;
},
// 注册监听事件
registerEvents: function () {
},
//请求或者清除一些基础信息的东西
// requestInitProtocal: function (force) {
// if (this.role_vo == null)
// return
// var config = gdata("guild_dun_data", "data_const", "guild_lev");
// if (config == null)
// return
// if (this.role_vo.gid == 0 || this.role_vo.guild_lev < config.val) {
// this.model.clearGuildBossInfo({});
// } else {
// if (force == true) {
// this.requestGuildDunBaseInfo();
// } else {
// var base_info = this.model.getBaseInfo();
// if (base_info == null || Utils.next(base_info) == null) {
// this.requestGuildDunBaseInfo();
// }
// }
// }
// },
reqBaseFromServer: function( _cb ){
let cfgs = [
"guild_dun_data",
];
this.loadConfigs( cfgs, ( _ret, _data ) =>{
nx.dt.fnInvoke( _cb, true );
// this.requestBaseData( _cb );
} )
},
requestBaseData: function( _cb ){
this.requestGuildDunBaseInfo( _cb );
},
// 注册协议接受事件
registerProtocals: function () {
this.RegisterProtocal(21300, this.handle21300) // 公会副本的基础信息
this.RegisterProtocal(21307, this.handle21307) // 重置返回
this.RegisterProtocal(21308, this.handle21308) // 请求挑战返回
this.RegisterProtocal(21312, this.handle21312) // 购买挑战次数返回
this.RegisterProtocal(21318, this.handle21318) // 公会排行榜
this.RegisterProtocal(21319, this.handle21319) // 个人排行榜
this.RegisterProtocal(21303, this.handle21303) // 公会宝箱情况
this.RegisterProtocal(21304, this.handle21304) // 领取公会宝箱
this.RegisterProtocal(21309, this.handle21309) // 战斗结果,用于显示战斗结算
this.RegisterProtocal(21317, this.handle21317) // 扫荡结果,用于显示战斗结算
this.RegisterProtocal(21305, this.handle21305) // 加buff
this.RegisterProtocal(21323, this.handle21323) //集结
},
//开关主窗体
openMainWindow: function (status) {
if (!status) {
nx.bridge.closePanel("WndGuildChallenge");
} else {
if (this.role_vo == null || this.role_vo.gid == 0) {
nx.tbox("lab_guild_boss_controller_tip_1");
return
}
var config = gdata("guild_dun_data", "data_const", "guild_lev");
if (config == null) {
nx.tbox("lab_guild_boss_controller_tip_2");
return
}
if (this.role_vo.guild_lev < config.val) {
nx.tbox(config.desc);
return
}
var open_data = gdata("function_data", "data_base", [6]);
var bool = nx.bridge.checkConditions(open_data.activate);
if (bool == false) {
nx.tbox(open_data.desc);
return
}
nx.bridge.createPanel("WndGuildChallenge",{});
}
},
//开关boss总览窗体
openGuildBossPreviewWindow: function (status) {
if (!status) {
if (this.boss_preview_window) {
this.boss_preview_window.close();
this.boss_preview_window = null;
}
} else {
if (this.boss_preview_window == null) {
this.boss_preview_window = Utils.createClass("guildboss_preview_window");
}
this.boss_preview_window.open();
}
},
//挑战或者扫荡结算面板
openGuildbossResultWindow: function (status, data) {
if (!status) {
if (this.result_window) {
this.result_window.close();
this.result_window = null;
}
} else {
if (this.result_window == null) {
this.result_window = Utils.createClass("guildboss_result_window");
}
this.result_window.open(data);
}
},
//伤害排行榜
openGuildBossRankWindow: function (status, data) {
if (!status) {
if (this.rank_window) {
this.rank_window.close();
this.rank_window = null;
}
} else {
if (this.rank_window == null) {
this.rank_window = Utils.createClass("guildboss_rank_window");
}
this.rank_window.open(data);
}
},
//打开总览奖励界面
oepnGuildRewardShowView: function (status) {
if (!status) {
if (this.reward_view) {
this.reward_view.close();
this.reward_view = null;
}
} else {
if (this.reward_view == null) {
this.reward_view = Utils.createClass("guildboss_reward_view");
}
this.reward_view.open();
}
},
//请求公会副本的基础信息,这个在每次打开面板的时候都请求一下吧
requestGuildDunBaseInfo: function ( _cb ) {
this.SendProtocal(21300, {}, _cb );
},
//公会副本的基础信息返回
handle21300: function (data) {
gcore.GlobalEvent.fire(GuildbossEvent.MusterCoolTime, data.coldtime || 0);
this.model.updateGuildDunBaseInfo(data);
},
//购买次数提示,FALSE为普通购买次数 TRUE是挑战购买次数
requestBuyChallengeTimes: function (buy_type) {
var base_info = this.model.getBaseInfo();
if (base_info == null || base_info.buy_count == null) return
var role_vo = RoleController.getInstance().getRoleVo();
if (role_vo == null) return
if (base_info.count != 0) {
nx.tbox("lab_guild_boss_controller_tip_3");
return
}
let buy_callback = function (type) {
var protocal = {};
protocal.type = type;
this.SendProtocal(21312, protocal);
}.bind(this)
var buy_next_num = base_info.buy_count + 1;
var buy_config = gdata("guild_dun_data", "data_buy_count", [buy_next_num]);
let buy_configdiff = game.configs.guild_dun_data.data_buy_count[buy_next_num];
if (buy_configdiff == null) {
nx.tbox("lab_guild_boss_controller_tip_4");
} else {
if (role_vo.vip_lev < buy_config.vip_lev) {
var msg = cc.js.formatStr(nx.text.getKey("lab_guild_boss_controller_tip_5"), buy_config.vip_lev);
nx.mbox(msg,["cancel","confirm"],(_key,_box)=>{
_box.close();
if(_key == "confirm"){
nx.bridge.createPanel( "WndPayment", { key: "recharge" } );
}
});
} else {
var cost = buy_config.expend;
if (cost == null || Utils.getArrLen(cost) < 2) return
var item_config = Utils.getItemConfig(cost[0]);
if (item_config) {
var msg = cc.js.formatStr(nx.text.getKey("lab_guild_boss_controller_tip_7"), item_config.icon, cost[1])
nx.mbox(msg,["cancel","confirm"],(_key,_box)=>{
_box.close();
if(_key == "confirm"){
buy_callback(buy_type)
}
});
}
}
}
},
//购买次数返回
handle21312: function (data) {
nx.tbox(data.msg);
if (data.code == 1)
this.model.updateBaseWithTimes(data.count, data.buy_count, data.type);
},
//请求重置公会章节信息
requestResetGuildDun: function (type) {
var protocal = {};
protocal.type = type;
this.SendProtocal(21307, protocal);
},
//重置返回
handle21307: function (data) {
nx.tbox(data.msg);
},
//请求挑战指定的boss
send21308: function (boss_id, formation_type, pos_info, hallows_id) {
var protocal = {};
protocal.boss_id = boss_id;
protocal.formation_type = formation_type;
protocal.pos_info = pos_info;
protocal.hallows_id = hallows_id;
this.SendProtocal(21308, protocal);
},
//请求挑战返回
handle21308: function (data) {
},
//更新每日宝箱
handle21303: function (data) {
this.model.initDayBoxRewardsStatus(data.bos_list);
},
//领取宝箱返回
handle21304: function (data) {
nx.tbox(data.msg)
if (data.code == 1)
this.model.updateBoxRewards(data.fid, data.num);
},
handle21321: function (data) {
nx.tbox(data.msg);
},
//集结
send21323: function () {
this.SendProtocal(21323, {});
},
handle21323: function (data) {
if (data.code == 0) {
nx.tbox(data.msg);
} else if (data.code == 1) {
// var less_time = data.coldtime - client.socket.getTime();
// gcore.GlobalEvent.fire(GuildbossEvent.MusterCoolTime, less_time || 0);
}
},
//加buff数据
send21305: function () {
this.SendProtocal(21305, {});
},
handle21305: function (data) {
nx.tbox(data.msg);
},
//请求排行榜数据
requestGuildDunRank: function (index, protocal) {
if (index == GuildbossConst.rank.guild) {
this.SendProtocal(21327, {});
} else if (index == GuildbossConst.rank.role) {
if (protocal)
this.SendProtocal(21319, protocal);
}
},
//公会排行榜
handle21318: function (data) {
gcore.GlobalEvent.fire(GuildbossEvent.UpdateGuildDunRank, data, GuildbossConst.rank.guild)
},
//个人排行榜
handle21319: function (data) {
this.model.setRaknRoleList(data);
gcore.GlobalEvent.fire(GuildbossEvent.UpdateGuildDunRank, data, GuildbossConst.rank.role);
},
//挑战结果,用于显示结算面板的
handle21309: function (data) {
this.new_result_data = data;
return;
BattleController.getInstance().openFinishView(true, BattleConst.Fight_Type.GuildDun, data);
},
newResultWin: function(){
if(!this.new_result_data)return;
BattleController.getInstance().openFinishView(true, BattleConst.Fight_Type.GuildDun, this.new_result_data);
this.new_result_data = null;
},
//扫荡结算
handle21317: function (data) {
nx.tbox(data.msg);
if (data.code == 1)
BattleController.getInstance().openFinishView(true, BattleConst.Fight_Type.GuildDun, data)
},
//请求扫荡指定boss
requestMopupMonster: function (boss_id) {
var protocal = {};
protocal.boss_id = boss_id;
this.SendProtocal(21317, protocal);
},
});
module.exports = GuildbossController;