fix 寻宝:机器人重复问题,被踢人推送

This commit is contained in:
liangtongchuan
2020-12-30 12:11:49 +08:00
parent 0693c896c6
commit 666c79a84f
2 changed files with 13 additions and 9 deletions

View File

@@ -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 () => {

View File

@@ -24,16 +24,19 @@ export function getRandBlueprtId(qualityArr: Array<number>, 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