diff --git a/game-server/app/servers/battle/handler/comBattleHandler.ts b/game-server/app/servers/battle/handler/comBattleHandler.ts index 2005652bb..57036eff9 100644 --- a/game-server/app/servers/battle/handler/comBattleHandler.ts +++ b/game-server/app/servers/battle/handler/comBattleHandler.ts @@ -448,11 +448,12 @@ export class ComBattleHandler { // 推送移除消息 let channelService = this.app.get('channelService'); let channel = channelService.getChannel(teamCode, false); + // 先推送离队消息,再将玩家从房间中移除 + channel.pushMessage('onLeaveTeam', resResult(STATUS.SUCCESS, {teamCode, roleId: roleIdToRm})); let users = channel.getMembers(); if (users.indexOf(roleIdToRm) !== -1) { channel.removeMember(roleIdToRm); } - channel.pushMessage('onLeaveTeam', resResult(STATUS.SUCCESS, {teamCode, roleId: roleIdToRm})); clearComBtlTimer(teamCode, this.teamDisTimer); // 移除队员停止解散计时 let thiz = this; setTimeout(async () => { diff --git a/game-server/app/services/comBattleService.ts b/game-server/app/services/comBattleService.ts index 33d716143..0a72334b6 100644 --- a/game-server/app/services/comBattleService.ts +++ b/game-server/app/services/comBattleService.ts @@ -24,16 +24,19 @@ export function getRandBlueprtId(qualityArr: Array, cnt = 1) { export function getRandComBtlRobots(topFiveCe: number, lv: number, cnt: number) { let robotHeroes = getRandRobot(cnt); // 随机几个阵容 + let robotInfos = getRandEelm(COM_BATTLE_ROBOT_ID_NAME, cnt); // 随机几个阵容 // 创建并添加机器人 let robotStArr = [], robotIdArr = []; - for (let robot of robotHeroes) { - const robotCe = getRandValue(topFiveCe || 0, COM_BTL_CONST.ROBOT_CE_RATIO, 0); - const robotLv = getRandValue(lv, COM_BTL_CONST.ROBOT_CE_RATIO, 0); - const imgHid = robot[Math.floor(Math.random() * robot.length)]; - const { robotRoleId, robotRoleName } = COM_BATTLE_ROBOT_ID_NAME[Math.floor(Math.random() * COM_BATTLE_ROBOT_ID_NAME.length)]; - let robotStatus = new RoleStatus(robotRoleId, robotRoleName, false, false, imgHid, imgHid, robotCe, robotLv, robot, true); - robotStArr.push(robotStatus); - robotIdArr.push(robotRoleId); + if (robotHeroes && robotInfos && robotHeroes.length && robotInfos.length && robotInfos.length === robotHeroes.length) { + robotHeroes.forEach((robot, idx) => { + const robotCe = getRandValue(topFiveCe || 0, COM_BTL_CONST.ROBOT_CE_RATIO, 0); + const robotLv = getRandValue(lv, COM_BTL_CONST.ROBOT_CE_RATIO, 0); + const imgHid = robot[Math.floor(Math.random() * robot.length)]; + const { robotRoleId, robotRoleName } = robotInfos[idx]; + let robotStatus = new RoleStatus(robotRoleId, robotRoleName, false, false, imgHid, imgHid, robotCe, robotLv, robot, true); + robotStArr.push(robotStatus); + robotIdArr.push(robotRoleId); + }); } return { robotStArr, robotIdArr