Files
fc/dev/project/library/imports/dc/dc621612-3ae7-46a3-b469-8ed10ac89c35.js
T

711 lines
25 KiB
JavaScript
Raw Normal View History

2026-05-24 10:21:26 +08:00
"use strict";
cc._RF.push(module, 'dc621YSOudGo7RpjtEKyJw1', 'arena_controller');
// Scripts/mod/pvp/arena/arena_controller.js
"use strict";
// //-----------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
// 这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-03-06 11:18:06
// --------------------------------------------------------------------
var BridgeController = require("bridge.controller");
var ArenaConst = require("arena_const");
var ArenaEvent = require("arena_event");
var MainuiEvent = require("mainui_event");
var BattleController = require("battle_controller");
var ArenaController = cc.Class({
"extends": BridgeController,
ctor: function ctor() {},
// 初始化配置数据
initConfig: function initConfig() {
var ArenaModel = require("arena_model");
var ChampionModel = require("arena_champion_model");
this.model = new ArenaModel();
this.model.initConfig();
this.champion_model = new ChampionModel();
this.champion_model.initConfig();
this.cache_list = []; //缓存登录前打开的界面
},
// 返回当前的model
getModel: function getModel() {
return this.model;
},
getChamPionModel: function getChamPionModel() {
return this.champion_model;
},
// 注册监听事件
registerEvents: function registerEvents() {
if (!this.login_event_success) {
this.login_event_success = gcore.GlobalEvent.bind(EventId.EVT_ROLE_CREATE_SUCCESS, function () {
gcore.GlobalEvent.unbind(this.login_event_success);
// this.role_vo = RoleController.getInstance().getRoleVo();
// if (this.role_vo) {
// if (!this.update_self_event) {
// this.update_self_event = this.role_vo.bind(EventId.UPDATE_ROLE_ATTRIBUTE, function (key, value) {
// if (key == "lev")
// this.requestInitProtocal();
// }.bind(this))
// }
// }
}.bind(this));
}
// if (!this.battle_drama_event) {
// this.battle_drama_event = gcore.GlobalEvent.bind(DramaEvent.BattleDrama_Update_Max_Id, function(max_id){
// this.requestInitProtocal();
// }.bind(this));
// }
if (!this.re_link_game_event) {
this.re_link_game_event = gcore.GlobalEvent.bind(EventId.EVT_RE_LINK_GAME, function () {
this.openArenaLoopMathWindow(false);
}.bind(this));
}
if (this.loading_enter_scene == null) {
this.loading_enter_scene = gcore.GlobalEvent.bind(MainuiEvent.LOADING_ENTER_SCENE, function () {
this.showCachePanel();
}.bind(this));
}
},
requestBaseQuestData: function requestBaseQuestData(_cb) {
this.sender20208(); // 挑战次数奖励信息
this.SendProtocal(20200, {}); // 竞技场个人信息
this.SendProtocal(20250, {}); // 冠军赛状态信息
this.SendProtocal(20223, {}, _cb); // 防守信息
},
reqBaseFromServer: function reqBaseFromServer(_cb) {
var _this = this;
var cfgs = ["arena_data", "arena_cluster_champion_data"];
this.loadConfigs(cfgs, function (_ret, _data) {
_this.requestBaseQuestData(_cb);
});
},
// 注册协议接受事件
registerProtocals: function registerProtocals() {
this.RegisterProtocal(20200, this.handle20200.bind(this));
this.RegisterProtocal(20201, this.handle20201.bind(this));
this.RegisterProtocal(20202, this.handle20202.bind(this));
this.RegisterProtocal(20203, this.handle20203.bind(this));
this.RegisterProtocal(20206, this.handle20206.bind(this));
this.RegisterProtocal(20207, this.handle20207.bind(this));
this.RegisterProtocal(20208, this.handle20208.bind(this)); // 宝箱模式
this.RegisterProtocal(20209, this.handle20209.bind(this)); // 竞技场领取挑战次数奖励
this.RegisterProtocal(20210, this.handle20210.bind(this));
this.RegisterProtocal(20220, this.handle20220.bind(this));
this.RegisterProtocal(20221, this.handle20221.bind(this));
this.RegisterProtocal(20222, this.handle20222.bind(this));
this.RegisterProtocal(20223, this.handle20223.bind(this));
// 冠军赛
this.RegisterProtocal(20250, this.handle20250.bind(this)); // 冠军赛赛程状态数据
this.RegisterProtocal(20251, this.handle20251.bind(this)); // 个人排名以及可下注信息
this.RegisterProtocal(20252, this.handle20252.bind(this)); // 我的比赛信息
this.RegisterProtocal(20253, this.handle20253.bind(this)); // 竞猜比赛信息
this.RegisterProtocal(20254, this.handle20254.bind(this)); // 押注返货
this.RegisterProtocal(20255, this.handle20255.bind(this)); // 我的竞猜列表
this.RegisterProtocal(20256, this.handle20256.bind(this)); // 结算展示
this.RegisterProtocal(20257, this.handle20257.bind(this)); // 竞猜实时更新
this.RegisterProtocal(20258, this.handle20258.bind(this)); // 我的战斗日志
this.RegisterProtocal(20260, this.handle20260.bind(this)); // 32强数据
this.RegisterProtocal(20261, this.handle20261.bind(this)); // 4强数据
this.RegisterProtocal(20262, this.handle20262.bind(this)); // 32强或者4强赛竞猜位置信息
this.RegisterProtocal(20263, this.handle20263.bind(this)); // 32强或者4强赛指定位置的信息
this.RegisterProtocal(20280, this.handle20280.bind(this)); // 冠军赛前3名信息
this.RegisterProtocal(20281, this.handle20281.bind(this)); // 冠军赛排行榜信息
this.RegisterProtocal(20282, this.handle20282.bind(this)); // 赛季结算前3
this.RegisterProtocal(20204, this.handle20204.bind(this)); // 查看剧情人数据
},
handle20200: function handle20200(data) {
this.model.updateMyLoopData(data);
},
sender20201: function sender20201() {
// 请求挑战队列
this.SendProtocal(20201, {});
},
handle20201: function handle20201(data) {
// 挑战队列更新
this.model.updateLoopChallengeList(data);
},
handle20202: function handle20202(data) {
if (this.loop_challenge_role_rid != data.rid && this.loop_challenge_role_srv_id != data.srv_id) return;
this.openCheckLoopChallengeRole(true, data);
},
openCheckLoopChallengeRole: function openCheckLoopChallengeRole(status, data) {
var self = this;
if (status == false) {
if (self.loop_challenge_check_window != null) {
self.loop_challenge_check_window.close();
self.loop_challenge_check_window = null;
}
} else {
if (data == null) return;
if (self.loop_challenge_check_window == null) {
var ArenaLoopChallengeCheckWindow = require("arena_loop_challenge_check_window");
self.loop_challenge_check_window = new ArenaLoopChallengeCheckWindow();
}
self.loop_challenge_check_window.open(data);
}
},
sender20203: function sender20203(rid, srv_id) {
// if (!rid || !srv_id) return;
var skip = this.model.getSkip();
var protocal = {};
protocal.rid = rid;
protocal.srv_id = srv_id;
protocal.is_auto = skip;
this.SendProtocal(20203, protocal);
},
handle20203: function handle20203(data) {
if (nx.dt.strNEmpty(data.msg)) {
nx.tbox(data.msg);
}
},
sender20206: function sender20206() {
// 请求刷新挑战队列
this.SendProtocal(20206, {});
},
handle20206: function handle20206(data) {
// 请求刷新结果
nx.tbox(data.msg);
},
sender20207: function sender20207(num) {
// 购买挑战券
var proto = {};
proto.num = num;
this.SendProtocal(20207, proto);
},
handle20207: function handle20207(data) {
// nx.tbox(data.msg)
if (data.code == 1) {
gcore.GlobalEvent.fire(ArenaEvent.UpdateArena_Number);
}
this.openArenaLoopChallengeBuy(false);
},
sender20208: function sender20208(_cb) {
this.SendProtocal(20208, {}, _cb);
},
handle20208: function handle20208(data) {
if (data) this.model.updateChallengeTimesAwards(data);
},
sender20209: function sender20209(num) {
var protocal = {};
protocal.num = num;
this.SendProtocal(20209, protocal);
},
handle20209: function handle20209(data) {},
// 战斗计算,收到结算的,就同时请求一下个人信息吧,服务器要求
handle20210: function handle20210(data) {
nx.bridge.vset("ResultInfo", data);
},
newResultWin: function newResultWin() {
// if(!this.new_result_data)return;
// var BattleConst = require("battle_const");
// var BattleController = require("battle_controller");
// BattleController.getInstance().openFinishView(true, BattleConst.Fight_Type.Arena, this.new_result_data);
// this.SendProtocal(20200, {});
// this.new_result_data = null;
},
sender20220: function sender20220() {
this.SendProtocal(20220, {});
},
handle20220: function handle20220(data) {
// 循环赛前三
if (data && data.rank_list) {
gcore.GlobalEvent.fire(ArenaEvent.UpdateLoopChallengeStatueList, data.rank_list);
}
},
sender20221: function sender20221() {
this.SendProtocal(20221, {});
},
handle20221: function handle20221(data) {
if (data) {
gcore.GlobalEvent.fire(ArenaEvent.UpdateLoopChallengeRank, data);
}
},
sender20222: function sender20222(data) {
this.SendProtocal(20222, {});
},
handle20222: function handle20222(data) {
if (data) gcore.GlobalEvent.fire(ArenaEvent.UpdateMylogListEvent, data.log_list);
},
handle20223: function handle20223(data) {
this.model.updateArenaLoopLogStatus(data.flag);
},
/********************冠军赛相关********************/
// --==============================--
// --desc:打開冠軍賽的主界面
// --time:2018-07-31 07:20:58
// --@status:
// --@index:
// --@return
// --==============================--
openArenaChampionMatchWindow: function openArenaChampionMatchWindow(status, index, view_type) {
var self = this;
if (!status) {
if (self.champion_window != null) {
self.champion_window.close();
self.champion_window = null;
}
} else {
if (self.champion_window == null) {
var ArenaChampionMatchWindow = require("arena_champion_match_window");
self.champion_window = new ArenaChampionMatchWindow(view_type);
}
self.champion_window.open(index);
}
},
checkChampionWndIsOpen: function checkChampionWndIsOpen() {
if (this.champion_window) {
return true;
}
return false;
},
handle20250: function handle20250(data) {
// 冠军赛赛程状态
this.champion_model.updateChampionBaseInfo(data);
this.sender20251();
if (data.step_status === ArenaConst.champion_step_status.opened) {
// var ActivityController = require( "activity_controller" ).getInstance();
// var ActivityConst = require( "activity_const" );
if (!this.champion_window) {
// if (data.round_status == ArenaConst.champion_round_status.guess) {
// ActivityController.openSignView(true, ActivityConst.ActivitySignType.arena_champion_guess, {timer: true});
// } else {
// if (!this.had_show_notice) {
// ActivityController.openSignView(true, ActivityConst.ActivitySignType.arena_champion, {timer: true})
// this.had_show_notice = true;
// }
// }
}
} else {}
},
sender20251: function sender20251(data) {
this.SendProtocal(20251, {});
},
handle20251: function handle20251(data) {
// 个人排名以及可
this.champion_model.setRoleInfo(data);
},
sender20252: function sender20252() {
this.SendProtocal(20252, {});
},
handle20252: function handle20252(data) {
// 我的比赛信息
gcore.GlobalEvent.fire(ArenaEvent.UpdateMyMatchInfoEvent, data);
},
sender20253: function sender20253() {
this.SendProtocal(20253, {});
},
sender20258: function sender20258() {
this.SendProtocal(20258, {});
},
handle20253: function handle20253(data) {
// 竞猜比赛信息
gcore.GlobalEvent.fire(ArenaEvent.UpdateGuessMatchInfoEvent, data);
},
// 请求押注某一方
sender20254: function sender20254(bet_type, bet_val) {
var proto = {};
proto.bet_type = bet_type;
proto.bet_val = bet_val;
this.SendProtocal(20254, proto);
},
handle20254: function handle20254(data) {
// 押注返货
nx.tbox(data.msg);
if (data.code == 1) {
var role_info = this.champion_model.getRoleInfo();
role_info.can_bet = data.can_bet;
gcore.GlobalEvent.fire(ArenaEvent.UpdateRoleInfoBetEvent, data.can_bet, data.bet_type);
this.openArenaChampionGuessWindow(false);
}
},
sender20255: function sender20255() {
this.SendProtocal(20255, {});
},
handle20255: function handle20255(data) {
// 我的竞猜列表
gcore.GlobalEvent.fire(ArenaEvent.UpdateMylogListEvent, data.list);
},
sender20256: function sender20256() {
this.SendProtocal(20256, {});
},
handle20256: function handle20256(data) {
// 结算展示
this.openArenaChampionBestInfoWindow(true, data);
},
handle20257: function handle20257(data) {
// 竞猜实时更新
gcore.GlobalEvent.fire(ArenaEvent.UpdateBetMatchValueEvent, data);
},
handle20258: function handle20258(data) {
// 我的战斗日志
gcore.GlobalEvent.fire(ArenaEvent.UpdateMylogListEvent, data);
},
sender20260: function sender20260() {
this.SendProtocal(20260, {});
},
handle20260: function handle20260(data) {
// 32强数据
gcore.GlobalEvent.fire(ArenaEvent.UpdateTop32InfoEvent, data.list);
},
sender20261: function sender20261() {
this.SendProtocal(20261, {});
},
handle20261: function handle20261(data) {
// 4强数据
gcore.GlobalEvent.fire(ArenaEvent.UpdateTop4InfoEvent, data.pos_list);
},
sender20262: function sender20262() {
this.SendProtocal(20262, {});
},
handle20262: function handle20262(data) {
// 32强或者4强赛竞猜位置信息
if (data) gcore.GlobalEvent.fire(ArenaEvent.UpdateTop324GuessGroupEvent, data.group, data.pos);
},
sender20263: function sender20263(group, pos) {
var protocal = {};
protocal.group = group;
protocal.pos = pos;
this.SendProtocal(20263, protocal);
},
handle20263: function handle20263(data) {
// 32强或者4强赛
if (data) gcore.GlobalEvent.fire(ArenaEvent.UpdateTop324GroupPosEvent, data);
},
sender20280: function sender20280() {
this.SendProtocal(20280, {});
},
handle20280: function handle20280(data) {
// 冠军赛前3名信
if (data && data.rank_list) gcore.GlobalEvent.fire(ArenaEvent.UpdateChampionTop3Event, data.rank_list, 1);
},
sender20281: function sender20281() {
this.SendProtocal(20281, {});
},
handle20281: function handle20281(data) {
// 冠军赛排行榜信
gcore.GlobalEvent.fire(ArenaEvent.UpdateChampionRankEvent, data);
},
handle20282: function handle20282(data) {// 赛季结算前3
// this.openArenaChampionTop3Window( true, data )
},
//进入主场景后显示缓存的界面
showCachePanel: function showCachePanel() {
if (this.cache_list == null || this.cache_list.length <= 0) return;
for (var i in this.cache_list) {
if (this.cache_list[i]["function"]) {
this.cache_list[i]["function"]();
}
}
this.cache_list = [];
},
// ==============================--
// desc:请求打开竞技场面板,这个时候要判断一下,如果是冠军赛开始阶段,就不要直接进竞技场了,
// 否则直接进竞技场吧,这个才是对外打开竞技场的请求,因为这里要判断是否在冠军赛七剑
// time:2018-08-01 08:10:21
// extend:扩展参数,如果是冠军赛,则需要判断具体的
// @return
// ==============================--
requestOpenArenWindow: function requestOpenArenWindow(status, extend) {
if (extend == ArenaConst.arena_type.rank) {
this.openArenaChampionMatchWindow(true);
} else {
var base_info = this.champion_model.getBaseInfo();
if (!base_info || base_info.step_status != ArenaConst.champion_step_status.opened) {
// this.requestOpenArenaLoopMathWindow(true);
} else {
this.openArenaEnterWindow(true, ArenaConst.arena_type.rank);
}
}
},
// ==============================--
// desc:请求打开竞技场界面
// time:2018-08-01 08:19:25
// @status:
// @index:
// @return
// ==============================--
// requestOpenArenaLoopMathWindow: function(status, index) {
// if (status) {
// MainuiController.getInstance().requestOpenBattleRelevanceWindow(BattleConst.Fight_Type.Arena)
// }
// },
// ==============================--
// desc:打开循环赛界面(这个接口外部只有一个,那就是真正的战斗请求回来之后打开的,也就是mainuicontroller里面打开的)
// time:2018-07-31 09:52:23
// @status:
// @index:
// @return
// ==============================--
openArenaLoopMathWindow: function openArenaLoopMathWindow(status, index) {
if (status) {
index = index || ArenaConst.loop_index.challenge;
} else {}
},
// ==============================--
// desc:打开循环赛或者冠军赛入口界面
// time:2018-07-31 09:52:04
// @status:
// @index:
// @return
// ==============================--
openArenaEnterWindow: function openArenaEnterWindow(status, index) {
if (status) {
if (!this.enter_window) {
var ArenaEnterWindow = require("arena_enter_window");
this.enter_window = new ArenaEnterWindow(this);
}
index = index || ArenaConst.arena_type.loop;
this.enter_window.open(index);
} else {
if (this.enter_window) {
this.enter_window.close();
this.enter_window = null;
}
}
},
// 打开冠军赛主界面
// openArenaChampionMatchWindow: function(status, index) {
// if (status) {
// if (!this.champion_window) {
// var ArenaChampionMatchWindow = require("arena_champion_match_window");
// this.champion_window = new ArenaChampionMatchWindow(this);
// }
// this.champion_window.open(index);
// } else {
// if (this.champion_window) {
// this.champion_window.close();
// this.champion_window = null;
// }
// }
// },
openArenaChampionGuessWindow: function openArenaChampionGuessWindow(status, data, view_type) {
if (status) {
if (!this.guess_window) {
var ArenaChampionGuessWindow = require("arena_champion_guess_window");
this.guess_window = new ArenaChampionGuessWindow(view_type);
}
this.guess_window.open(data);
} else {
if (this.guess_window) {
this.guess_window.close();
this.guess_window = null;
}
}
},
// 打开循环赛结算界面
openLoopResultWindow: function openLoopResultWindow(status, data) {
if (status) {
if (!this.loop_result_window) {
var LoopResultWindow = require("arena_loop_result_window");
this.loop_result_window = new LoopResultWindow(this);
}
this.loop_result_window.open(data);
} else {
if (this.loop_result_window) {
this.loop_result_window.close();
this.loop_result_window = null;
}
}
},
openArenaLoopMyLogWindow: function openArenaLoopMyLogWindow(status) {
if (status) {
if (!this.loop_log_window) {
var ArenaLoopMyLogWindow = require("arena_loop_my_log_window");
this.loop_log_window = new ArenaLoopMyLogWindow(this);
}
this.loop_log_window.open();
} else {
if (this.loop_log_window) {
this.loop_log_window.close();
this.loop_log_window = null;
}
}
},
openArenaLoopChallengeBuy: function openArenaLoopChallengeBuy(status) {
if (status) {
if (!this.arena_champion_buy) {
var ArenaChampionBuy = require("arena_loop_challenge_buy_window");
this.arena_champion_buy = new ArenaChampionBuy(this);
}
this.arena_champion_buy.open();
} else {
if (this.arena_champion_buy) {
this.arena_champion_buy.close();
this.arena_champion_buy = null;
}
}
},
openArenaChampionMyGuessWindow: function openArenaChampionMyGuessWindow(status, view_type) {
if (status) {
if (!this.my_guess_window) {
var ArenaChampionMyGuessWindow = require("arena_champion_my_guess_window");
this.my_guess_window = new ArenaChampionMyGuessWindow(view_type);
}
this.my_guess_window.open();
} else {
if (this.my_guess_window) {
this.my_guess_window.close();
this.my_guess_window = null;
}
}
},
openArenaChampionMyLogWindow: function openArenaChampionMyLogWindow(status, view_type) {
var self = this;
if (status == false) {
if (self.my_log_window != null) {
self.my_log_window.close();
self.my_log_window = null;
}
} else {
if (self.my_log_window == null) {
var ArenaChampionMyLogWindow = require("arena_champion_my_log_window");
self.my_log_window = new ArenaChampionMyLogWindow(view_type);
}
self.my_log_window.open();
}
},
openArenaChampionBestInfoWindow: function openArenaChampionBestInfoWindow(status, data, view_type) {
var self = this;
if (status == false) {
if (self.best_info_window != null) {
self.best_info_window.close();
self.best_info_window = null;
}
} else {
if (self.best_info_window == null) {
var ArenaChampionBestInfoWindow = require("arena_champion_best_info_window");
self.best_info_window = new ArenaChampionBestInfoWindow(view_type);
}
self.best_info_window.open(data);
}
},
//==============================
//desc:打开冠军赛排名奖励面板
//time:2018-08-01 02:04:06
//@status:
//@return
//==============================
openArenaChampionRankAwardsWindow: function openArenaChampionRankAwardsWindow(status, view_type) {
if (status) {
if (!this.champion_rank_awards) {
var ArenaChampionRankAwardsWindow = require("arena_champion_rank_awards_window");
this.champion_rank_awards = new ArenaChampionRankAwardsWindow(view_type);
}
this.champion_rank_awards.open();
} else {
if (this.champion_rank_awards) {
this.champion_rank_awards.close();
this.champion_rank_awards = null;
}
}
},
//==============================
//desc:打开
//time:2018-07-31 05:23:58
//@status:
//@data:
//@return
//==============================
openArenaChampionRankWindow: function openArenaChampionRankWindow(status, view_type) {
if (status) {
if (!this.champion_rank) {
var ArenaChampionRankWindow = require("arena_champion_rank_window");
this.champion_rank = new ArenaChampionRankWindow(view_type);
}
this.champion_rank.open();
} else {
if (this.champion_rank) {
this.champion_rank.close();
this.champion_rank = null;
}
}
},
getArenaRoot: function getArenaRoot() {
if (this.loop_match_window) return this.loop_match_window.root_wnd;
},
//==============================
//desc:冠军赛战况的窗体
//time:2018-08-03 08:40:54
//@status:
//@data:
//@return
//==============================--
openArenaChampionReportWindow: function openArenaChampionReportWindow(status, data, view_type) {
if (status) {
if (!this.report_window) {
var ArenaChampionReportWindow = require("arena_champion_report_window");
this.report_window = new ArenaChampionReportWindow(view_type);
}
this.report_window.open(data);
} else {
if (this.report_window) {
this.report_window.close();
this.report_window = null;
}
}
},
// --==============================--
// --desc:冠軍賽前3結算
// --time:2018-08-03 08:40:54
// --@status:
// --@data:
// --@return
// --==============================--
openArenaChampionTop3Window: function openArenaChampionTop3Window(status, data, view_type) {
var self = this;
if (!status) {
if (self.champion_top3_window != null) {
self.champion_top3_window.close();
self.champion_top3_window = null;
}
} else {
if (self.champion_top3_window == null) {
var ArenaChampionTop3Window = require("arena_champion_top_3_window");
self.champion_top3_window = new ArenaChampionTop3Window(view_type);
}
self.champion_top3_window.open(data);
}
},
updateChampionTab: function updateChampionTab(tab_index) {
if (this.champion_window) this.champion_window.updateTab(tab_index);
},
requestLoopChallengeRoleInfo: function requestLoopChallengeRoleInfo(rid, srv_id) {
if (rid == null || srv_id == null) return;
this.loop_challenge_role_rid = rid; //-- 记录一下当前请求查看的角色rid和srv_id
this.loop_challenge_role_srv_id = srv_id;
var protocal = {};
protocal.rid = rid;
protocal.srv_id = srv_id;
this.SendProtocal(20202, protocal);
},
requestRabotInfo: function requestRabotInfo(rid, srv_id, pos) {
var protocal = {};
protocal.rid = rid;
protocal.srv_id = srv_id;
protocal.pos = pos;
this.SendProtocal(20204, protocal);
},
handle20204: function handle20204(data) {
if (data.code == 0) {
nx.tbox(data.msg);
}
var HeroController = require("hero_controller");
HeroController.getInstance().openHeroTipsPanel(true, data);
}
});
module.exports = ArenaController;
cc._RF.pop();