寻宝:加入超时标识

This commit is contained in:
liangtongchuan
2021-01-27 16:00:49 +08:00
parent 11c5705a5f
commit 1df01334c9
2 changed files with 15 additions and 8 deletions
@@ -56,6 +56,8 @@ class ComTeam {
roleCnt: number; roleCnt: number;
// 藏宝图等级所处范围,用来匹配 // 藏宝图等级所处范围,用来匹配
lvRange: number; lvRange: number;
// 队伍是否开放加入
timeout: boolean;
constructor(teamCode: string, pub: boolean, blueprtId: number, status: number, capId: string, ceLimit: number, bossHp: number, quality: number, bossHpArr:Array<BossHp> ) { constructor(teamCode: string, pub: boolean, blueprtId: number, status: number, capId: string, ceLimit: number, bossHp: number, quality: number, bossHpArr:Array<BossHp> ) {
this.teamCode = teamCode; this.teamCode = teamCode;
this.pub = pub; this.pub = pub;
@@ -69,6 +71,7 @@ class ComTeam {
this.bossHpArr = bossHpArr; this.bossHpArr = bossHpArr;
this.curRnd = 0; this.curRnd = 0;
this.roleCnt = 1; this.roleCnt = 1;
this.timeout = false;
let { lvLimited } = getGoodById(blueprtId); let { lvLimited } = getGoodById(blueprtId);
this.lvRange = comBtlRangeByLv(lvLimited); this.lvRange = comBtlRangeByLv(lvLimited);
} }
@@ -542,9 +545,9 @@ export class ComBattleHandler {
clearRobotHurtTimer(teamStatus, this.robotHurtTimer); clearRobotHurtTimer(teamStatus, this.robotHurtTimer);
let channelService = thiz.app.get('channelService'); let channelService = thiz.app.get('channelService');
let channel = channelService.getChannel(teamCode, false); let channel = channelService.getChannel(teamCode, false);
let team = await ComBattleTeamModel.syncTeamData({teamCode, status: COM_TEAM_STATUS.LOOSE, roleStatus: teamStatus.roleStatus, bossHpArr: teamStatus.bossHpArr}); let team = await ComBattleTeamModel.syncTeamData({teamCode, status: COM_TEAM_STATUS.LOOSE, roleStatus: teamStatus.roleStatus, bossHpArr: teamStatus.bossHpArr}, true);
if (!team) return resResult(STATUS.COM_BATTLE_RESULT_ERR); if (!team) return resResult(STATUS.COM_BATTLE_RESULT_ERR);
channel.pushMessage('onTeamComplete', resResult(STATUS.SUCCESS, {teamCode, result: false})); channel.pushMessage('onTeamComplete', resResult(STATUS.SUCCESS, {teamCode, result: false, timeout: true}));
thiz.teamMap.delete(teamCode); thiz.teamMap.delete(teamCode);
} }
}, COM_BTL_CONST.BTL_TIME_LMT); }, COM_BTL_CONST.BTL_TIME_LMT);
@@ -702,16 +705,16 @@ export class ComBattleHandler {
async getComBtlStatus(msg: {teamCode: string}, session: BackendSession) { async getComBtlStatus(msg: {teamCode: string}, session: BackendSession) {
let { teamCode } = msg; let { teamCode } = msg;
let roleStatus, status, bossHpArr; let roleStatus, status, bossHpArr, timeout;
let memTeam = this.teamMap.get(teamCode); let memTeam = this.teamMap.get(teamCode);
if (memTeam) { if (memTeam) {
({ roleStatus, status, bossHpArr } = memTeam); ({ roleStatus, status, bossHpArr, timeout } = memTeam);
} else { } else {
let dbTeam = await ComBattleTeamModel.getTeamByCode(teamCode); let dbTeam = await ComBattleTeamModel.getTeamByCode(teamCode);
if (!dbTeam) return resResult(STATUS.COM_BATTLE_TEAM_INVALID); if (!dbTeam) return resResult(STATUS.COM_BATTLE_TEAM_INVALID);
({ roleStatus, status, bossHpArr } = dbTeam); ({ roleStatus, status, bossHpArr, timeout } = dbTeam);
} }
return resResult(STATUS.SUCCESS, { teamInfo: {status, teamCode, roleStatus, bossHpArr} }); return resResult(STATUS.SUCCESS, { teamInfo: {status, teamCode, roleStatus, bossHpArr, timeout} });
} }
/** /**
+6 -2
View File
@@ -129,6 +129,10 @@ export default class ComBattleTeam extends BaseModel {
@prop({ required: false, type: BossHp, default: [] }) @prop({ required: false, type: BossHp, default: [] })
bossHpArr: Array<BossHp>; bossHpArr: Array<BossHp>;
// 队伍是否开放加入
@prop({ required: true, default: false })
timeout: boolean;
public static async createTeam(teamData: {teamCode: string, roleIds: Array<string>, pub: boolean, blueprtId: number, quality: number, status: number, roleStatus: Array<RoleStatus>, capId: string, ceLimit: number}, lean = true) { public static async createTeam(teamData: {teamCode: string, roleIds: Array<string>, pub: boolean, blueprtId: number, quality: number, status: number, roleStatus: Array<RoleStatus>, capId: string, ceLimit: number}, lean = true) {
const team: ComBattleTeamType = await ComBattleTeamModel.findOneAndUpdate({ teamCode: teamData.teamCode }, {$set :{...teamData, roleCnt: teamData.roleIds.length}}, {upsert: true, new: true}).lean(lean); const team: ComBattleTeamType = await ComBattleTeamModel.findOneAndUpdate({ teamCode: teamData.teamCode }, {$set :{...teamData, roleCnt: teamData.roleIds.length}}, {upsert: true, new: true}).lean(lean);
return team; return team;
@@ -169,9 +173,9 @@ export default class ComBattleTeam extends BaseModel {
return team; return team;
} }
public static async syncTeamData(teamData: {teamCode: string, status: number, roleStatus: Array<RoleStatus>, bossHpArr: Array<BossHp>}, lean = true) { public static async syncTeamData(teamData: {teamCode: string, status: number, roleStatus: Array<RoleStatus>, bossHpArr: Array<BossHp>}, timeout = false, lean = true) {
console.log('syncTeamData bossHpArr: ', teamData.bossHpArr); console.log('syncTeamData bossHpArr: ', teamData.bossHpArr);
const team: ComBattleTeamType = await ComBattleTeamModel.findOneAndUpdate({ teamCode: teamData.teamCode }, {$set :{...teamData, roleCnt: teamData.roleStatus.length}}, {new: true}).lean(lean); const team: ComBattleTeamType = await ComBattleTeamModel.findOneAndUpdate({ teamCode: teamData.teamCode }, {$set :{...teamData, roleCnt: teamData.roleStatus.length, timeout}}, {new: true}).lean(lean);
return team; return team;
} }