寻宝:单排玩家强退

This commit is contained in:
luying
2021-08-17 17:45:52 +08:00
parent e81a9b67db
commit a785644cbb
5 changed files with 22 additions and 3 deletions

View File

@@ -33,6 +33,9 @@ export default function(app: Application) {
}
export class ComBattleHandler {
constructor(private app: Application) {
this.app.set('teamMap', this.teamMap);
this.app.set('teamDisTimer', this.teamDisTimer);
this.app.set('robotHurtTimer', this.robotHurtTimer);
}
private teamMap: Map<string, MemComBtlTeam> = new Map();
private teamDisTimer: Map<string, NodeJS.Timer> = new Map();

View File

@@ -1,6 +1,8 @@
import { Application, ChannelService, FrontendSession, RemoterClass, HandlerService, pinus, } from 'pinus';
import { resResult } from '../../../pubUtils/util';
import { STATUS } from '../../../consts';
import { handleComBtlProgress } from '../../../services/comBattleService';
import { MemComBtlTeam } from '../../../domain/battleField/ComBattleTeamField';
export default function (app: Application) {
new HandlerService(app, {});
@@ -129,6 +131,18 @@ export class ComBattleRemote {
}
public async leaveFromBattle(roleId: string, teamCode: string ) {
// this.app.sysrpc.msgRemote.forwardMessage
let teamMap: Map<string, MemComBtlTeam> = this.app.get('teamMap');
if(teamMap && teamMap.has(teamCode)) {
let myTeam = teamMap.get(teamCode);
for(let roleStatus of myTeam.roleStatus) {
if(roleStatus.roleId == roleId) {
roleStatus.battleStatus = 2; // 自己失败了
}
}
let channelService = this.app.get('channelService');
let channel = channelService.getChannel(teamCode, false);
await handleComBtlProgress(myTeam, this.app.get('robotHurtTimer'), teamMap, channel); // 结算
}
}
}

View File

@@ -19,6 +19,8 @@ Filter.prototype.before = async function (routeRecord: RouteRecord, msg: any, se
const roleId: string = session.get('roleId');
const uid: number = session.get('userid');
session.push('teamCode', () => {});
let connectorServers = pinus.app.getServersByType('connector');
let { id } = connectorServers[0];
let maintenServers = await pinus.app.rpc.connector.connectorRemote.getServerMainten.toServer(id);

View File

@@ -209,7 +209,7 @@ export class EntryHandler {
await leaveGuildChannel(roleId, sid, guildCode);
RoleModel.updateRoleInfo(roleId, { quitTime: nowSeconds() });
if(teamCode) { // 如果有寻宝中的队伍,那么等于战败
await setComBtlOnUserLeave(roleId, teamCode)
setComBtlOnUserLeave(roleId, teamCode)
}
}

View File

@@ -81,7 +81,7 @@ export function checkComBattleResult(teamStatus) {
// 看看是否还有活人
teamStatus.roleStatus.forEach(st => {
// 设置了阵容,且阵容人数和阵亡人数一样,说明玩家战败
if (!st.isRobot && st.heroes && ((st.heroes.length > 0 && st.killed.length < st.heroes.length) || st.heroes.length === 0)) {
if (!st.isRobot && st.battleStatus != 2 && st.heroes && ((st.heroes.length > 0 && st.killed.length < st.heroes.length) || st.heroes.length === 0 )) {
allPlayerKilled = false
}
});