407 lines
13 KiB
JavaScript
407 lines
13 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, 'af0cdKpdsRCIILDfb8oxAqH', 'ladder_controller');
|
|
// Scripts/mod/pvp/ladder/ladder_controller.js
|
|
|
|
"use strict";
|
|
|
|
// --------------------------------------------------------------------
|
|
// @author: xxx@syg.com(必填, 创建模块的人员)
|
|
// @description:
|
|
// 跨服天梯ctrl
|
|
// <br/>Create: 2019-07-24 10:23:54
|
|
// --------------------------------------------------------------------
|
|
var BridgeController = require("bridge.controller");
|
|
var LadderEvent = require("ladder_event");
|
|
var BattleController = require("battle_controller");
|
|
var BattleConst = require("battle_const");
|
|
var RoleController = require("role_controller");
|
|
var LadderConst = require("ladder_const");
|
|
var LadderController = cc.Class({
|
|
"extends": BridgeController,
|
|
ctor: function ctor() {},
|
|
// 初始化配置数据
|
|
initConfig: function initConfig() {
|
|
var LadderModel = require("ladder_model");
|
|
this.model = new LadderModel();
|
|
this.model.initConfig();
|
|
},
|
|
// 返回当前的model
|
|
getModel: function getModel() {
|
|
return this.model;
|
|
},
|
|
// 注册监听事件
|
|
registerEvents: function registerEvents() {},
|
|
// 注册协议接受事件
|
|
registerProtocals: function registerProtocals() {
|
|
this.RegisterProtocal(24300, this.handle24300); // 个人数据
|
|
this.RegisterProtocal(24301, this.handle24301); // 挑战对手列表
|
|
this.RegisterProtocal(24302, this.handle24302); // 对手数据
|
|
this.RegisterProtocal(24303, this.handle24303); // 挑战对手
|
|
this.RegisterProtocal(24304, this.handle24304); // 刷新对手
|
|
this.RegisterProtocal(24305, this.handle24305); // 购买挑战次数
|
|
this.RegisterProtocal(24306, this.handle24306); // 一键挑战
|
|
this.RegisterProtocal(24307, this.handle24307); // 挑战结算
|
|
this.RegisterProtocal(24308, this.handle24308); // 前三名玩家数据
|
|
this.RegisterProtocal(24309, this.handle24309); // 排行榜数据
|
|
this.RegisterProtocal(24310, this.handle24310); // 我的记录
|
|
this.RegisterProtocal(24311, this.handle24311); // 大神风采
|
|
this.RegisterProtocal(24312, this.handle24312); // 天梯是否开启
|
|
this.RegisterProtocal(24313, this.handle24313); // 英雄殿红点
|
|
this.RegisterProtocal(24314, this.handle24314); // 战报红点
|
|
this.RegisterProtocal(24315, this.handle24315); // 清除cd时间
|
|
this.RegisterProtocal(24316, this.handle24316); // 查看英雄信息
|
|
this.RegisterProtocal(24317, this.handle24317); // 挑战次数红点
|
|
this.RegisterProtocal(24318, this.handle24318); // 录像分享
|
|
},
|
|
|
|
// 从服务器初始化数据
|
|
reqBaseFromServer: function reqBaseFromServer(_cb) {
|
|
var _this = this;
|
|
// 配置加载
|
|
var cfgs = ["sky_ladder_data" // 跨服天梯
|
|
];
|
|
|
|
this.loadConfigs(cfgs, function (_ret, _data) {
|
|
_this.reqLadderData(_cb);
|
|
});
|
|
},
|
|
reqLadderData: function reqLadderData(_cb) {
|
|
this.SendProtocal(24300, {}, _cb);
|
|
this.SendProtocal(24301, {});
|
|
this.SendProtocal(24312, {});
|
|
},
|
|
//请求天梯个人信息
|
|
requestLadderMyBaseInfo: function requestLadderMyBaseInfo() {
|
|
this.SendProtocal(24300, {});
|
|
},
|
|
//请求挑战列表
|
|
requestLadderEnemyListData: function requestLadderEnemyListData() {
|
|
this.SendProtocal(24301, {});
|
|
},
|
|
//请求玩家信息
|
|
requestLadderEnemyData: function requestLadderEnemyData(rid, srv_id) {
|
|
var protocal = {};
|
|
protocal.rid = rid;
|
|
protocal.srv_id = srv_id;
|
|
this.SendProtocal(24302, protocal);
|
|
},
|
|
//请求挑战玩家
|
|
requestChallengeEnemy: function requestChallengeEnemy(rid, srv_id) {
|
|
var protocal = {};
|
|
protocal.rid = rid;
|
|
protocal.srv_id = srv_id;
|
|
this.SendProtocal(24303, protocal);
|
|
},
|
|
//请求刷新对手列表
|
|
requestRefreshEnemyList: function requestRefreshEnemyList() {
|
|
this.SendProtocal(24304, {});
|
|
},
|
|
//请求购买挑战次数
|
|
requestBuyChallengeCount: function requestBuyChallengeCount() {
|
|
this.SendProtocal(24305, {});
|
|
},
|
|
//请求一键挑战
|
|
requestQuickChallenge: function requestQuickChallenge() {
|
|
this.SendProtocal(24306, {});
|
|
},
|
|
//请求前三名玩家数据(英雄殿)
|
|
requestTopThreeRoleData: function requestTopThreeRoleData() {
|
|
this.SendProtocal(24308, {});
|
|
},
|
|
//请求排行榜信息
|
|
requestLadderRankData: function requestLadderRankData() {
|
|
this.SendProtocal(24309, {});
|
|
},
|
|
//请求日志记录
|
|
requestMyLogData: function requestMyLogData() {
|
|
this.SendProtocal(24310, {});
|
|
},
|
|
//请求大神风采
|
|
requestGodLogData: function requestGodLogData() {
|
|
this.SendProtocal(24311, {});
|
|
},
|
|
//请求天梯是否开启
|
|
requestLadderIsOpen: function requestLadderIsOpen() {
|
|
this.SendProtocal(24312, {});
|
|
},
|
|
//请求清除冷却时间
|
|
requestCleanCDTime: function requestCleanCDTime() {
|
|
this.SendProtocal(24315, {});
|
|
},
|
|
//请求查看英雄信息
|
|
requestCheckRoleInfo: function requestCheckRoleInfo(rid, srv_id, pos) {
|
|
var protocal = {};
|
|
protocal.rid = rid;
|
|
protocal.srv_id = srv_id;
|
|
protocal.pos = pos;
|
|
this.SendProtocal(24316, protocal);
|
|
},
|
|
//请求天梯录像分享
|
|
requestShareVideo: function requestShareVideo(replay_id, srv_id, channel, target_name) {
|
|
var protocal = {};
|
|
protocal.replay_id = replay_id;
|
|
protocal.srv_id = srv_id;
|
|
protocal.channel = channel;
|
|
protocal.target_name = target_name;
|
|
this.SendProtocal(24316, protocal);
|
|
},
|
|
//-----------------------------------------------
|
|
//个人数据
|
|
handle24300: function handle24300(data) {
|
|
if (data) {
|
|
this.model.setLadderMyBaseInfo(data);
|
|
}
|
|
gcore.GlobalEvent.fire(LadderEvent.UpdateLadderMyBaseInfo, data);
|
|
},
|
|
//挑战对手列表
|
|
handle24301: function handle24301(data) {
|
|
if (data) {
|
|
if (data.type == 0) {
|
|
//全部更新
|
|
this.model.setLadderEnemyListData(data.f_list);
|
|
} else {
|
|
//部分更新
|
|
this.model.updateLadderEnemyListData(data.f_list);
|
|
}
|
|
gcore.GlobalEvent.fire(LadderEvent.UpdateAllLadderEnemyList);
|
|
}
|
|
},
|
|
//对手数据
|
|
handle24302: function handle24302(data) {
|
|
if (data) {
|
|
gcore.GlobalEvent.fire(LadderEvent.GetLadderEnemyData, data);
|
|
}
|
|
},
|
|
//挑战对手
|
|
handle24303: function handle24303(data) {
|
|
nx.tbox(data.msg);
|
|
this.openLadderRoleInfoWindow(false);
|
|
},
|
|
//刷新对手
|
|
handle24304: function handle24304(data) {
|
|
nx.tbox(data.msg);
|
|
},
|
|
//购买挑战次数
|
|
handle24305: function handle24305(data) {
|
|
nx.tbox(data.msg);
|
|
if (data.code == 1 && this._temp_rid != null && this._temp_srv_id != null) {
|
|
this.requestChallengeEnemy(this._temp_rid, this._temp_srv_id);
|
|
this._temp_rid = null;
|
|
this._temp_srv_id = null;
|
|
} else if (data.code == 1 && this._temp_quick_flag) {
|
|
this.requestQuickChallenge();
|
|
this._temp_quick_flag = null;
|
|
}
|
|
},
|
|
//一键挑战
|
|
handle24306: function handle24306(data) {
|
|
nx.tbox(data.msg);
|
|
},
|
|
//挑战结算
|
|
handle24307: function handle24307(data) {
|
|
this.new_result_data = data;
|
|
return;
|
|
BattleController.getInstance().openFinishView(true, BattleConst.Fight_Type.LadderWar, data);
|
|
},
|
|
newResultWin: function newResultWin() {
|
|
if (!this.new_result_data) return;
|
|
BattleController.getInstance().openFinishView(true, BattleConst.Fight_Type.LadderWar, this.new_result_data);
|
|
this.new_result_data = null;
|
|
},
|
|
//前三名数据
|
|
handle24308: function handle24308(data) {
|
|
if (data && data.rank_list) {
|
|
gcore.GlobalEvent.fire(LadderEvent.UpdateLadderTopThreeRoleData, data.rank_list);
|
|
}
|
|
},
|
|
//排行榜数据
|
|
handle24309: function handle24309(data) {
|
|
if (data) {
|
|
gcore.GlobalEvent.fire(LadderEvent.UpdateLadderRankData, data);
|
|
}
|
|
},
|
|
//我的记录
|
|
handle24310: function handle24310(data) {
|
|
if (data) {
|
|
gcore.GlobalEvent.fire(LadderEvent.UpdateLadderMyLogData, data);
|
|
}
|
|
},
|
|
//大神风采
|
|
handle24311: function handle24311(data) {
|
|
if (data) {
|
|
gcore.GlobalEvent.fire(LadderEvent.UpdateLadderGodLogData, data);
|
|
}
|
|
},
|
|
//天梯是否开启
|
|
handle24312: function handle24312(data) {
|
|
if (data) {
|
|
this.model.setLadderOpenStatus(data.code);
|
|
// nx.mTip.openTip( "pvp.ladder", data.code == 1 );
|
|
gcore.GlobalEvent.fire(LadderEvent.UpdateLadderOpenStatus);
|
|
}
|
|
},
|
|
//英雄殿红点
|
|
handle24313: function handle24313(data) {
|
|
if (data.code != null) {
|
|
if (!this._login_flag && data.code == 1) {
|
|
this._login_flag = true;
|
|
this.model.updateLadderRedStatus(LadderConst.RedType.TopThree, true);
|
|
} else {
|
|
this.model.updateLadderRedStatus(LadderConst.RedType.TopThree, false);
|
|
}
|
|
}
|
|
},
|
|
//英雄殿红点
|
|
handle24314: function handle24314(data) {
|
|
if (data.code != null) {
|
|
gcore.GlobalEvent.fire(LadderConst.RedType.BattleLog, data.code == 1);
|
|
}
|
|
},
|
|
//清除cd时间
|
|
handle24315: function handle24315(data) {
|
|
nx.tbox(data.msg);
|
|
},
|
|
//查看英雄
|
|
handle24316: function handle24316(data) {
|
|
nx.tbox(data.msg);
|
|
},
|
|
//挑战次数红点
|
|
handle24317: function handle24317(data) {
|
|
if (data.code != null) {
|
|
gcore.GlobalEvent.fire(LadderConst.RedType.Challenge, data.code == 1);
|
|
}
|
|
},
|
|
//录像分享
|
|
handle24318: function handle24318(data) {
|
|
nx.tbox(data.msg);
|
|
},
|
|
//检测挑战次数并且进入战斗
|
|
checkJoinLadderBattle: function checkJoinLadderBattle(rid, srv_id, is_quick) {
|
|
if (this.model.getLeftChallengeCount() > 0) {
|
|
if (is_quick) {
|
|
this.requestQuickChallenge();
|
|
} else {
|
|
this.requestChallengeEnemy(rid, srv_id);
|
|
}
|
|
} else if (this.model.getTodayLeftBuyCount() > 0) {
|
|
var buy_combat_num = this.model.getTodayBuyCount();
|
|
var cost_config = game.configs.sky_ladder_data.data_buy_num[buy_combat_num + 1];
|
|
if (cost_config) {
|
|
if (is_quick) {
|
|
var res = PathTool.getItemRes(3);
|
|
var str = cc.js.formatStr(nx.text.getKey("lab_ladder_controller_tip1"), 3, cost_config.cost);
|
|
} else {
|
|
var _res = PathTool.getItemRes(3);
|
|
var _str = cc.js.formatStr(nx.text.getKey("lab_ladder_controller_tip2"), 3, cost_config.cost);
|
|
}
|
|
}
|
|
} else {
|
|
nx.tbox(nx.text.getKey("lab_ladder_controller_tip3"));
|
|
this.openLadderRoleInfoWindow(false);
|
|
}
|
|
},
|
|
//-----------------------打开界面------------
|
|
//天梯主界面
|
|
openMainWindow: function openMainWindow(status) {
|
|
if (status) {
|
|
var role_vo = RoleController.getInstance().getRoleVo();
|
|
var config = game.configs.sky_ladder_data.data_const.join_min_lev;
|
|
if (role_vo.lev < config.val) {
|
|
nx.tbox(config.desc);
|
|
return;
|
|
}
|
|
if (this.ladder_main_window == null) {
|
|
this.ladder_main_window = Utils.createClass("ladder_main_window");
|
|
}
|
|
this.ladder_main_window.open();
|
|
} else {
|
|
if (this.ladder_main_window) {
|
|
this.ladder_main_window.close();
|
|
this.ladder_main_window = null;
|
|
}
|
|
}
|
|
},
|
|
//天梯商店
|
|
openLadderShopWindow: function openLadderShopWindow(status) {
|
|
if (status) {
|
|
if (this.ladder_shop_window == null) {
|
|
this.ladder_shop_window = Utils.createClass("ladder_shop_window");
|
|
}
|
|
this.ladder_shop_window.open();
|
|
} else {
|
|
if (this.ladder_shop_window) {
|
|
this.ladder_shop_window.close();
|
|
this.ladder_shop_window = null;
|
|
}
|
|
}
|
|
},
|
|
//天梯对手信息
|
|
openLadderRoleInfoWindow: function openLadderRoleInfoWindow(status, _fightinfo) {
|
|
if (status) {
|
|
nx.bridge.createPanel("WndLadderFightInfo", _fightinfo);
|
|
} else {
|
|
nx.bridge.closePanel("WndLadderFightInfo");
|
|
}
|
|
},
|
|
//天梯战报
|
|
openLadderLogWindow: function openLadderLogWindow(status) {
|
|
if (status) {
|
|
nx.bridge.createPanel("WndLadderWarLog");
|
|
} else {
|
|
nx.bridge.closePanel("WndLadderWarLog");
|
|
}
|
|
},
|
|
//天梯奖励
|
|
openLadderAwardWindow: function openLadderAwardWindow(status) {
|
|
if (status) {
|
|
if (this.ladder_award_window == null) {
|
|
this.ladder_award_window = Utils.createClass("ladder_award_window");
|
|
}
|
|
this.ladder_award_window.open();
|
|
} else {
|
|
if (this.ladder_award_window) {
|
|
this.ladder_award_window.close();
|
|
this.ladder_award_window = null;
|
|
}
|
|
}
|
|
},
|
|
//天梯排行榜
|
|
openLadderRankWindow: function openLadderRankWindow(status) {
|
|
if (status) {
|
|
if (this.ladder_rank_window == null) {
|
|
this.ladder_rank_window = Utils.createClass("ladder_rank_window");
|
|
}
|
|
this.ladder_rank_window.open();
|
|
} else {
|
|
if (this.ladder_rank_window) {
|
|
this.ladder_rank_window.close();
|
|
this.ladder_rank_window = null;
|
|
}
|
|
}
|
|
},
|
|
//天梯英雄殿
|
|
openLadderTopThreeWindow: function openLadderTopThreeWindow(status) {
|
|
if (status) {
|
|
nx.bridge.createPanel("WndLadderWorship");
|
|
} else {
|
|
nx.bridge.closePanel("WndLadderWorship");
|
|
}
|
|
},
|
|
//天梯结算界面
|
|
openLadderBattleResultWindow: function openLadderBattleResultWindow(status, data) {
|
|
if (status) {
|
|
if (this.ladder_result_window == null) {
|
|
this.ladder_result_window = Utils.createClass("ladder_battle_result_window");
|
|
}
|
|
this.ladder_result_window.open(data);
|
|
} else {
|
|
if (this.ladder_result_window) {
|
|
this.ladder_result_window.close();
|
|
this.ladder_result_window = null;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
module.exports = LadderController;
|
|
|
|
cc._RF.pop(); |