248 lines
7.2 KiB
JavaScript
248 lines
7.2 KiB
JavaScript
/*
|
|
這裡填寫簡要說明(必填),
|
|
@author: lwc@syg.com(必填, 創建模塊的人員)
|
|
@editor: xxx@syg.com(必填, 後續維護以及修改的人員)
|
|
@description:
|
|
組隊競技場 後端 鋒林 策劃 康傑
|
|
<br/>Create: 2019-09-28
|
|
*/
|
|
|
|
const BridgeClass = require( "bridge.class" );
|
|
var RoleController = require("role_controller");
|
|
var ArenateamEvent = require("arenateam_event");
|
|
|
|
var ArenateamModel = cc.Class({
|
|
extends: BridgeClass,
|
|
|
|
ctor: function () {
|
|
// this.ctrl = arguments[0]
|
|
|
|
//我的隊伍信息
|
|
this.my_team_info = null
|
|
|
|
//我的詳細隊伍信息
|
|
this.my_team_details_info = null
|
|
},
|
|
|
|
initConfig: function () {
|
|
|
|
},
|
|
|
|
//主界面的紅點
|
|
checkArenateamTotalRedPoint:function (need_check) {
|
|
let redpoint = false
|
|
|
|
if (this.my_team_info) {
|
|
//1:開啟組隊 2:開啟挑戰
|
|
if (this.my_team_info.state == 1 || this.my_team_info.state == 2) {
|
|
for (let 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 (let 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(data) {
|
|
if (!data) { return }
|
|
this.login_data = data
|
|
|
|
for (let k in data.point) {
|
|
let 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 (status) {
|
|
this.is_report_red = status
|
|
this.checkArenateamTotalRedPoint(true)
|
|
},
|
|
|
|
setIsApplayRedpoint: function (status) {
|
|
this.is_apply_red = status
|
|
this.checkArenateamTotalRedPoint(true)
|
|
},
|
|
|
|
setIsInvitationRedpoint: function (status) {
|
|
this.is_invitation_red = status
|
|
this.checkArenateamTotalRedPoint(true)
|
|
},
|
|
|
|
setIsChatRedpoint: function (status) {
|
|
this.is_chat_red = status
|
|
this.checkArenateamTotalRedPoint(true)
|
|
},
|
|
|
|
getMyTeamInfo: function () {
|
|
return this.my_team_info
|
|
},
|
|
|
|
setMyTeamInfo: function (my_team_info) {
|
|
this.my_team_info = my_team_info
|
|
this.checkArenateamTotalRedPoint(true)
|
|
},
|
|
|
|
updateRewardInfo: function (id) {
|
|
if (this.my_team_info && id) {
|
|
for (let k in this.my_team_info.award_list) {
|
|
let 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 (data) {
|
|
if (data.tid == 0)
|
|
this.my_team_details_info = null
|
|
else
|
|
this.my_team_details_info = data
|
|
},
|
|
|
|
getMyTeamDetailsInfo: function () {
|
|
return this.my_team_details_info
|
|
},
|
|
|
|
//是否已有隊伍
|
|
isHaveTeam: function () {
|
|
if (this.my_team_info && this.my_team_info.tid != 0) {
|
|
return true
|
|
}
|
|
return false
|
|
},
|
|
|
|
updateRankInfo: function (data) {
|
|
this.rank_data = data
|
|
},
|
|
|
|
getRankData: function () {
|
|
return this.rank_data
|
|
},
|
|
|
|
checkArenaTeamIsOpen: function (not_tips) {
|
|
let role_lv_cfg = game.configs.arena_team_data.data_const["open_lev"]
|
|
let 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 () {
|
|
if (this.my_team_info) {
|
|
let team_members = this.my_team_info.team_members
|
|
for (let k in team_members) {
|
|
let v = team_members[k]
|
|
for (let i in v.ext) {
|
|
let data = v.ext[i]
|
|
if (data.extra_key == 1 && data.extra_val == 1) {
|
|
let 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 () {
|
|
if (this.time_step) {
|
|
return this.time_step
|
|
}
|
|
return 0
|
|
},
|
|
|
|
startTimeTicket: function () {
|
|
if (this.refresh_cd == null) {
|
|
this.refresh_cd = 10
|
|
let config = game.configs.arena_team_data.data_const.refresh_cd
|
|
if (config) {
|
|
this.refresh_cd = config.val
|
|
}
|
|
}
|
|
this.time_step = this.refresh_cd
|
|
let _callback = function () {
|
|
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 () {
|
|
if (this.time_ticket != null) {
|
|
gcore.Timer.del(this.time_ticket)
|
|
this.time_ticket = null
|
|
}
|
|
}
|
|
|
|
|
|
}); |