From 666c79a84ff3ba7527aba3d86906f7efef381f95 Mon Sep 17 00:00:00 2001 From: liangtongchuan Date: Wed, 30 Dec 2020 12:11:49 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=AF=BB=E5=AE=9D=EF=BC=9A=E6=9C=BA?= =?UTF-8?q?=E5=99=A8=E4=BA=BA=E9=87=8D=E5=A4=8D=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E8=A2=AB=E8=B8=A2=E4=BA=BA=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../battle/handler/comBattleHandler.ts | 3 ++- game-server/app/services/comBattleService.ts | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) 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