寻宝:机器人分开加入战斗
This commit is contained in:
@@ -295,3 +295,31 @@ export function comBtlLvInvalid(lv: number, lvRange: number) {
|
||||
const minLv = lvs[0];
|
||||
return lv < minLv;
|
||||
}
|
||||
|
||||
export async function dismissTeam(teamStatus, teamMap: Map<string, any>, roleId: string, teamDisTimer: Map<string, NodeJS.Timer>, app) {
|
||||
const { teamCode } = teamStatus;
|
||||
if (!teamStatus || !teamStatus.roleIds || teamStatus.roleIds.indexOf(roleId) === -1) return resResult(STATUS.COM_BATTLE_TEAM_INVALID);
|
||||
if (roleId !== teamStatus.capId) return resResult(STATUS.COM_BATTLE_CAP_ONLY);
|
||||
|
||||
let team = await ComBattleTeamModel.removeTeam(teamCode);
|
||||
if (!team) return resResult(STATUS.COM_BATTLE_DISSMISS_ERR);
|
||||
|
||||
let rmSt = teamMap.delete(teamCode);
|
||||
if (!rmSt) return resResult(STATUS.COM_BATTLE_DISSMISS_ERR);
|
||||
|
||||
let channelService = app.get('channelService');
|
||||
let channel = channelService.getChannel(teamCode, false);
|
||||
channel.pushMessage('onTeamDismiss', resResult(STATUS.SUCCESS, {teamCode}));
|
||||
channel.destroy();
|
||||
clearComBtlTimer(teamCode, teamDisTimer); // 队伍解散停止解散计时
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
export function setDismissTimer(teamStatus, teamMap: Map<string, any>, roleId: string, teamDisTimer: Map<string, NodeJS.Timer>, app) {
|
||||
if (teamStatus && teamStatus.roleIds && teamStatus.roleIds.length === 3) {
|
||||
let timer = setTimeout(async () => {
|
||||
await dismissTeam(teamStatus, teamMap, roleId, teamDisTimer, app);
|
||||
}, COM_BTL_CONST.CAP_START_TIME);
|
||||
teamDisTimer.set(teamStatus.teamCode, timer);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user