Commit 3ae9ffa2 authored by nanahira's avatar nanahira

fix resp player

parent e84fae99
Pipeline #43329 passed with stages
in 3 minutes and 12 seconds
......@@ -7,6 +7,7 @@ import {
YGOProCtosTpResult,
YGOProCtosUpdateDeck,
YGOProMsgResponseBase,
YGOProMsgRetry,
} from 'ygopro-msg-encode';
import { Context } from '../app';
import { Client } from '../client';
......@@ -57,7 +58,27 @@ export class WaitForPlayerProvider {
constructor(private ctx: Context) {
this.ctx.middleware(
YGOProMsgResponseBase,
async (_msg, client, next) => {
async (msg, client, next) => {
const room = this.getRoom(client);
if (!room || !this.hasTickForRoom(room)) {
return next();
}
try {
return await next();
} finally {
const operatePlayer = room.getIngameOperatingPlayer(
msg.responsePlayer(),
);
this.setWaitForPlayer(room, operatePlayer);
this.refreshLastActiveTime(room);
}
},
true,
);
this.ctx.middleware(
YGOProMsgRetry,
async (msg, client, next) => {
const room = this.getRoom(client);
if (!room || !this.hasTickForRoom(room)) {
return next();
......@@ -65,7 +86,8 @@ export class WaitForPlayerProvider {
try {
return await next();
} finally {
this.setWaitForPlayer(room, client);
const operatePlayer = room.responsePlayer;
if (operatePlayer) this.setWaitForPlayer(room, operatePlayer);
this.refreshLastActiveTime(room);
}
},
......
......@@ -1752,6 +1752,15 @@ export class Room {
private matchKilled = false;
private responsePos?: number;
get responsePlayer() {
if (this.responsePos == null) {
return undefined;
}
return this.getIngameOperatingPlayer(
this.getIngameDuelPosByDuelPos(this.responsePos),
);
}
private canAdvance() {
return this.duelStage === DuelStage.Dueling && !!this.ocgcore;
}
......@@ -1827,12 +1836,7 @@ export class Room {
if (this.timerState.runningPos !== this.responsePos) {
return;
}
if (
client !==
this.getIngameOperatingPlayer(
this.getIngameDuelPosByDuelPos(this.responsePos),
)
) {
if (client !== this.responsePlayer) {
return;
}
......@@ -1863,10 +1867,7 @@ export class Room {
private async onResponse(client: Client, msg: YGOProCtosResponse) {
if (
this.responsePos == null ||
client !==
this.getIngameOperatingPlayer(
this.getIngameDuelPosByDuelPos(this.responsePos),
) ||
client !== this.responsePlayer ||
!this.ocgcore // || this.timerState.awaitingConfirm
) {
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment