Commit 25cd9a64 authored by nanahira's avatar nanahira

still broken

parent 77811ec5
...@@ -47,6 +47,7 @@ import { ...@@ -47,6 +47,7 @@ import {
YGOProMsgUpdateCard, YGOProMsgUpdateCard,
CardQuery, CardQuery,
YGOProCtosResponse, YGOProCtosResponse,
YGOProCtosSurrender,
} from 'ygopro-msg-encode'; } from 'ygopro-msg-encode';
import { DefaultHostInfoProvider } from './default-hostinfo-provder'; import { DefaultHostInfoProvider } from './default-hostinfo-provder';
import { import {
...@@ -379,6 +380,7 @@ export class Room { ...@@ -379,6 +380,7 @@ export class Room {
async win(winMsg: Partial<YGOProMsgWin>, forceWinMatch = false) { async win(winMsg: Partial<YGOProMsgWin>, forceWinMatch = false) {
await this.ocgcore?.dispose(); await this.ocgcore?.dispose();
this.ocgcore = undefined;
if (this.duelStage === DuelStage.Siding) { if (this.duelStage === DuelStage.Siding) {
this.playingPlayers this.playingPlayers
.filter((p) => !p.deck) .filter((p) => !p.deck)
...@@ -455,7 +457,7 @@ export class Room { ...@@ -455,7 +457,7 @@ export class Room {
} else { } else {
this.score[this.getDuelPos(client)] = -9; this.score[this.getDuelPos(client)] = -9;
await this.win( await this.win(
{ player: this.getIngameDuelPos(client), type: 0x4 }, { player: 1 - this.getIngameDuelPos(client), type: 0x4 },
true, true,
); );
} }
...@@ -1190,6 +1192,13 @@ export class Room { ...@@ -1190,6 +1192,13 @@ export class Room {
} }
localGameMsgDispatcher = new ProtoMiddlewareDispatcher() localGameMsgDispatcher = new ProtoMiddlewareDispatcher()
.middleware(YGOProMsgBase, async (message, next) => {
this.logger.debug(
{ msgName: message.constructor.name },
'Received game message',
);
return next();
})
.middleware(YGOProMsgNewTurn, async (message, next) => { .middleware(YGOProMsgNewTurn, async (message, next) => {
// check new turn // check new turn
const player = message.player; const player = message.player;
...@@ -1255,6 +1264,7 @@ export class Room { ...@@ -1255,6 +1264,7 @@ export class Room {
); );
} }
} }
await this.handleGameMsg(message); await this.handleGameMsg(message);
if (message instanceof YGOProMsgWin) { if (message instanceof YGOProMsgWin) {
return this.win(message); return this.win(message);
...@@ -1283,4 +1293,18 @@ export class Room { ...@@ -1283,4 +1293,18 @@ export class Room {
await this.ocgcore.setResponse(msg.response); await this.ocgcore.setResponse(msg.response);
return this.advance(); return this.advance();
} }
@RoomMethod({
allowInDuelStages: DuelStage.Dueling,
})
private async onSurrender(client: Client, _msg: YGOProCtosSurrender) {
if (client.pos === NetPlayerType.OBSERVER) {
return;
}
// TODO: teammate surrender in tag duel
return this.win(
{ player: 1 - this.getIngameDuelPos(client), type: 0x0 },
true,
);
}
} }
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