Files

342 lines
12 KiB
JavaScript
Raw Permalink Normal View History

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