Files
fc/dev/project/library/imports/a3/a3d5793f-a520-4360-b8b6-0dc2fea6f6b8.js
2026-05-24 10:21:26 +08:00

221 lines
6.6 KiB
JavaScript

"use strict";
cc._RF.push(module, 'a3d57k/pSBDYLi2DcL+pva4', 'arenateam_model');
// Scripts/mod/pvp/arenateam/arenateam_model.js
"use strict";
/*
這裡填寫簡要說明(必填),
@author: lwc@syg.com(必填, 創建模塊的人員)
@editor: xxx@syg.com(必填, 後續維護以及修改的人員)
@description:
組隊競技場 後端 鋒林 策劃 康傑
<br/>Create: 2019-09-28
*/
var BridgeClass = require("bridge.class");
var RoleController = require("role_controller");
var ArenateamEvent = require("arenateam_event");
var ArenateamModel = cc.Class({
"extends": BridgeClass,
ctor: function ctor() {
// this.ctrl = arguments[0]
//我的隊伍信息
this.my_team_info = null;
//我的詳細隊伍信息
this.my_team_details_info = null;
},
initConfig: function initConfig() {},
//主界面的紅點
checkArenateamTotalRedPoint: function checkArenateamTotalRedPoint(need_check) {
var redpoint = false;
if (this.my_team_info) {
//1:開啟組隊 2:開啟挑戰
if (this.my_team_info.state == 1 || this.my_team_info.state == 2) {
for (var k in this.my_team_info.award_list) {
if (this.my_team_info.award_list[k].status == 1) {
redpoint = true;
break;
}
}
// if (this.login_data){
if (!redpoint) {
redpoint = this.is_report_red;
}
if (!redpoint) {
//隊員數量不滿足紅點
if (this.my_team_info && this.my_team_info.team_members.length < 3) {
redpoint = this.is_apply_red;
}
}
if (!redpoint) {
redpoint = this.is_invitation_red;
}
if (!redpoint) {
redpoint = this.is_chat_red;
}
// }
else if (this.my_team_info.state == 4 || this.my_team_info.state == 3) {
//結算期 和 排行展示時期
//結算期只需要判斷 寶箱和戰報紅點
for (var _k in this.my_team_info.award_list) {
if (this.my_team_info.award_list[_k].status == 1) {
redpoint = true;
break;
}
}
if (!redpoint) {
redpoint = this.is_report_red;
}
}
if (need_check) {
gcore.GlobalEvent.fire(ArenateamEvent.ARENATEAM_ALL_RED_POINT_EVENT);
}
if (!redpoint) {
redpoint = false;
}
}
return redpoint;
}
},
updateLoginRedpoint: function updateLoginRedpoint(data) {
if (!data) {
return;
}
this.login_data = data;
for (var k in data.point) {
var v = data.point[k];
if (v.type == 1)
//戰報紅點
this.is_report_red = v.state == 1;else if (v.type == 2)
//申請紅點
this.is_apply_red = v.state == 1;else if (v.type == 3)
//被邀請紅點
this.is_invitation_red = v.state == 1;else if (v.type == 4)
//新的聊天
this.is_chat_red = v.state == 1;
}
this.checkArenateamTotalRedPoint(true);
},
//設置紅點類型
setIsReportRedpoint: function setIsReportRedpoint(status) {
this.is_report_red = status;
this.checkArenateamTotalRedPoint(true);
},
setIsApplayRedpoint: function setIsApplayRedpoint(status) {
this.is_apply_red = status;
this.checkArenateamTotalRedPoint(true);
},
setIsInvitationRedpoint: function setIsInvitationRedpoint(status) {
this.is_invitation_red = status;
this.checkArenateamTotalRedPoint(true);
},
setIsChatRedpoint: function setIsChatRedpoint(status) {
this.is_chat_red = status;
this.checkArenateamTotalRedPoint(true);
},
getMyTeamInfo: function getMyTeamInfo() {
return this.my_team_info;
},
setMyTeamInfo: function setMyTeamInfo(my_team_info) {
this.my_team_info = my_team_info;
this.checkArenateamTotalRedPoint(true);
},
updateRewardInfo: function updateRewardInfo(id) {
if (this.my_team_info && id) {
for (var k in this.my_team_info.award_list) {
var v = this.my_team_info.award_list[k];
// for (i, v in ipairs(this.my_team_info.award_list)) {
if (v.award_id == id) {
v.status = 2;
}
}
this.checkArenateamTotalRedPoint(true);
}
},
setMyTeamDetailsInfo: function setMyTeamDetailsInfo(data) {
if (data.tid == 0) this.my_team_details_info = null;else this.my_team_details_info = data;
},
getMyTeamDetailsInfo: function getMyTeamDetailsInfo() {
return this.my_team_details_info;
},
//是否已有隊伍
isHaveTeam: function isHaveTeam() {
if (this.my_team_info && this.my_team_info.tid != 0) {
return true;
}
return false;
},
updateRankInfo: function updateRankInfo(data) {
this.rank_data = data;
},
getRankData: function getRankData() {
return this.rank_data;
},
checkArenaTeamIsOpen: function checkArenaTeamIsOpen(not_tips) {
var role_lv_cfg = game.configs.arena_team_data.data_const["open_lev"];
var role_vo = RoleController.getInstance().getRoleVo();
if (role_vo && role_lv_cfg && role_vo.lev < role_lv_cfg.val) {
if (!not_tips) {
message(role_lv_cfg.desc);
}
return false, 1, role_lv_cfg.desc;
}
return true;
},
//判斷玩家是否是隊長
isLeader: function isLeader() {
if (this.my_team_info) {
var team_members = this.my_team_info.team_members;
for (var k in team_members) {
var v = team_members[k];
for (var i in v.ext) {
var data = v.ext[i];
if (data.extra_key == 1 && data.extra_val == 1) {
var role_vo = RoleController.getInstance().getRoleVo();
if (role_vo && v.rid == role_vo.rid && v.sid == role_vo.srv_id) {
//是隊長
return true;
}
}
}
}
}
return false;
},
getTimeStep: function getTimeStep() {
if (this.time_step) {
return this.time_step;
}
return 0;
},
startTimeTicket: function startTimeTicket() {
if (this.refresh_cd == null) {
this.refresh_cd = 10;
var config = game.configs.arena_team_data.data_const.refresh_cd;
if (config) {
this.refresh_cd = config.val;
}
}
this.time_step = this.refresh_cd;
var _callback = function _callback() {
this.time_step = this.time_step - 1;
gcore.GlobalEvent.fire(ArenateamEvent.ARENATEAM_TIMER_EVENT, this.time_step);
if (this.time_step <= 0) {
this.clearTimeTicket();
}
};
this.time_ticket = gcore.Timer.set(_callback, 1, -1);
},
clearTimeTicket: function clearTimeTicket() {
if (this.time_ticket != null) {
gcore.Timer.del(this.time_ticket);
this.time_ticket = null;
}
}
});
cc._RF.pop();