寻宝:机器人分开加入战斗
This commit is contained in:
@@ -11,13 +11,13 @@ import { ComBattleTeamModel, BossHp } from '../../../db/ComBattleTeam';
|
||||
import Role, { RoleModel } from '../../../db/Role';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { resResult, getRandomByLen, calculateNum, getRandValue, ratioReward, reduceCe } from '../../../pubUtils/util';
|
||||
import { resResult, getRandomByLen, calculateNum, getRandValue, ratioReward, reduceCe, getRandValueByMinMax } from '../../../pubUtils/util';
|
||||
import { RoleStatus } from '../../../db/ComBattleTeam';
|
||||
import { ItemModel } from '../../../db/Item';
|
||||
import { handleFixedReward, addItems, handleCost } from '../../../services/rewardService';
|
||||
import { checkRoleInQueue, getTeamSearchByQuality, rmRoleFromQueue, setTeamSearchReq } from '../../../services/redisService';
|
||||
import { transBossHpArr } from '../../../services/battleService';
|
||||
import { getRandBlueprtId, getRandComBtlRobots, checkComBattleResult, clearComBtlTimer, getRealReward, getAssistTimesByQuality, getFrd, updateRobotHurt, updateRobotHurtByTime, comBtlLvInvalid, clearRobotHurtTimer } from '../../../services/comBattleService';
|
||||
import { getRandBlueprtId, getRandComBtlRobots, checkComBattleResult, clearComBtlTimer, getRealReward, getAssistTimesByQuality, getFrd, updateRobotHurt, updateRobotHurtByTime, comBtlLvInvalid, clearRobotHurtTimer, setDismissTimer, dismissTeam } from '../../../services/comBattleService';
|
||||
import { setAp } from '../../../services/actionPointService';
|
||||
import { roleLevelup } from '../../../services/normalBattleService';
|
||||
|
||||
@@ -165,32 +165,26 @@ export class ComBattleHandler {
|
||||
channelService.pushMessageByUids('onTeamJoin', resResult(STATUS.SUCCESS, {teamInfo: comTeam}), uids);
|
||||
}
|
||||
let thiz = this;
|
||||
|
||||
// 倒计时一定时间给队长匹配机器人
|
||||
setTimeout(async () => {
|
||||
let team = thiz.teamMap.get(teamCode);
|
||||
if (team && team.roleIds && team.status === COM_TEAM_STATUS.DEFAULT && team.roleIds.length < 3) {
|
||||
let { robotStArr, robotIdArr } = getRandComBtlRobots(topFiveCe, team.ceLimit, lv, 3 - team.roleIds.length);
|
||||
team.roleIds = team.roleIds.concat(robotIdArr);
|
||||
team.roleStatus = team.roleStatus.concat(robotStArr);
|
||||
for (let st of robotStArr) {
|
||||
await ComBattleTeamModel.addRole(teamCode, st);
|
||||
}
|
||||
channel.pushMessage('onTeamJoin', resResult(STATUS.SUCCESS, {teamInfo: team}));
|
||||
let teamStatus = thiz.teamMap.get(teamCode);
|
||||
if (teamStatus && teamStatus.roleIds && teamStatus.status === COM_TEAM_STATUS.DEFAULT && teamStatus.roleIds.length < 3) {
|
||||
const robotCnt = 3 - teamStatus.roleIds.length;
|
||||
for(let robotIdx = 0; robotIdx < robotCnt; robotIdx++) {
|
||||
const joinTime = getRandValueByMinMax(COM_BTL_CONST.MIN_CAP_TIME, COM_BTL_CONST.MAX_CAP_TIME, 0);
|
||||
setTimeout(async () => {
|
||||
let { robotStArr, robotIdArr } = getRandComBtlRobots(topFiveCe, teamStatus.ceLimit, lv, 1);
|
||||
teamStatus.roleIds = teamStatus.roleIds.concat(robotIdArr);
|
||||
teamStatus.roleStatus = teamStatus.roleStatus.concat(robotStArr);
|
||||
for (let st of robotStArr) {
|
||||
await ComBattleTeamModel.addRole(teamCode, st);
|
||||
}
|
||||
channel.pushMessage('onTeamJoin', resResult(STATUS.SUCCESS, {teamInfo: teamStatus}));
|
||||
setDismissTimer(teamStatus, thiz.teamMap, roleId, thiz.teamDisTimer, thiz.app);
|
||||
}, joinTime);
|
||||
}
|
||||
// TODO: 代码抽象
|
||||
if (team && team.roleIds && team.roleIds.length === 3) {
|
||||
let timer = setTimeout(async () => {
|
||||
thiz.dismiss({teamCode}, session);
|
||||
}, COM_BTL_CONST.CAP_START_TIME);
|
||||
thiz.teamDisTimer.set(teamCode, timer);
|
||||
}
|
||||
}, COM_BTL_CONST.CAP_TIME);
|
||||
if (team.roleIds && team.roleIds.length === 3) {
|
||||
let timer = setTimeout(async () => {
|
||||
thiz.dismiss({teamCode}, session);
|
||||
}, COM_BTL_CONST.CAP_START_TIME);
|
||||
thiz.teamDisTimer.set(teamCode, timer);
|
||||
}
|
||||
setDismissTimer(teamStatus, thiz.teamMap, roleId, thiz.teamDisTimer, thiz.app);
|
||||
return resResult(STATUS.SUCCESS, { teamCode, roleStatus });
|
||||
}
|
||||
|
||||
@@ -329,13 +323,7 @@ export class ComBattleHandler {
|
||||
}
|
||||
channel.pushMessage('onTeamJoin', resResult(STATUS.SUCCESS, {teamInfo: teamStatus}));
|
||||
|
||||
if (teamStatus.roleIds && teamStatus.roleIds.length === 3) {
|
||||
let thiz = this;
|
||||
let timer = setTimeout(async () => {
|
||||
thiz.dismiss({teamCode}, session);
|
||||
}, COM_BTL_CONST.CAP_START_TIME);
|
||||
thiz.teamDisTimer.set(teamCode, timer);
|
||||
}
|
||||
setDismissTimer(teamStatus, this.teamMap, roleId, this.teamDisTimer, this.app);
|
||||
return resResult(STATUS.SUCCESS, { teamInfo: teamStatus});
|
||||
}
|
||||
|
||||
@@ -470,13 +458,7 @@ export class ComBattleHandler {
|
||||
}
|
||||
channel.pushMessage('onTeamJoin', resResult(STATUS.SUCCESS, {teamInfo: team}));
|
||||
}
|
||||
// TODO: 代码抽象
|
||||
if (team && team.roleIds && team.roleIds.length === 3) {
|
||||
let timer = setTimeout(async () => {
|
||||
thiz.dismiss({teamCode}, session);
|
||||
}, COM_BTL_CONST.CAP_START_TIME);
|
||||
thiz.teamDisTimer.set(teamCode, timer);
|
||||
}
|
||||
await setDismissTimer(team, thiz.teamMap, roleId, thiz.teamDisTimer, thiz.app);
|
||||
}, COM_BTL_CONST.ASSIST_TIME);
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
@@ -492,6 +474,9 @@ export class ComBattleHandler {
|
||||
let roleId = session.get('roleId');
|
||||
let { teamCode } = msg;
|
||||
let teamStatus = this.teamMap.get(teamCode);
|
||||
let result = await dismissTeam(teamStatus, this.teamMap, roleId, this.teamDisTimer, this.app);
|
||||
return result;
|
||||
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user