Commit 77811ec5 authored by nanahira's avatar nanahira

still broken

parent 4ecf82ee
......@@ -44,7 +44,6 @@
"jest": "^30.2.0",
"prettier": "^3.8.1",
"ts-jest": "^29.4.6",
"ts-node": "^10.9.2",
"typescript": "^5.9.3"
}
},
......@@ -570,6 +569,8 @@
"integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
"dependencies": {
"@jridgewell/trace-mapping": "0.3.9"
},
......@@ -583,6 +584,8 @@
"integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
"dependencies": {
"@jridgewell/resolve-uri": "^3.0.3",
"@jridgewell/sourcemap-codec": "^1.4.10"
......@@ -1477,28 +1480,36 @@
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.12.tgz",
"integrity": "sha512-UCYBaeFvM11aU2y3YPZ//O5Rhj+xKyzy7mvcIoAjASbigy8mHMryP5cK7dgjlz2hWxh1g5pLw084E0a/wlUSFQ==",
"dev": true,
"license": "MIT"
"license": "MIT",
"optional": true,
"peer": true
},
"node_modules/@tsconfig/node12": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz",
"integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==",
"dev": true,
"license": "MIT"
"license": "MIT",
"optional": true,
"peer": true
},
"node_modules/@tsconfig/node14": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz",
"integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==",
"dev": true,
"license": "MIT"
"license": "MIT",
"optional": true,
"peer": true
},
"node_modules/@tsconfig/node16": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz",
"integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==",
"dev": true,
"license": "MIT"
"license": "MIT",
"optional": true,
"peer": true
},
"node_modules/@tybys/wasm-util": {
"version": "0.10.1",
......@@ -2191,6 +2202,8 @@
"integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
"dependencies": {
"acorn": "^8.11.0"
},
......@@ -2329,7 +2342,9 @@
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
"integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==",
"dev": true,
"license": "MIT"
"license": "MIT",
"optional": true,
"peer": true
},
"node_modules/argparse": {
"version": "2.0.1",
......@@ -2921,7 +2936,9 @@
"resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz",
"integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==",
"dev": true,
"license": "MIT"
"license": "MIT",
"optional": true,
"peer": true
},
"node_modules/cross-spawn": {
"version": "7.0.6",
......@@ -3047,6 +3064,8 @@
"integrity": "sha512-X07nttJQkwkfKfvTPG/KSnE2OMdcUCao6+eXF3wmnIQRn2aPAHH3VxDbDOdegkd6JbPsXqShpvEOHfAT+nCNwQ==",
"dev": true,
"license": "BSD-3-Clause",
"optional": true,
"peer": true,
"engines": {
"node": ">=0.3.1"
}
......@@ -6842,6 +6861,8 @@
"integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
"dependencies": {
"@cspotcode/source-map-support": "^0.8.0",
"@tsconfig/node10": "^1.0.7",
......@@ -7091,7 +7112,9 @@
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
"integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==",
"dev": true,
"license": "MIT"
"license": "MIT",
"optional": true,
"peer": true
},
"node_modules/v8-to-istanbul": {
"version": "9.3.0",
......@@ -7451,6 +7474,8 @@
"integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
"engines": {
"node": ">=6"
}
......
......@@ -9,7 +9,7 @@
"build": "tsc",
"gen:config-example": "npm run build && node dist/src/scripts/gen-config-example.js",
"test": "jest --passWithNoTests",
"dev": "ts-node index.ts",
"dev": "npm run build && npm start",
"start": "node dist/index.js"
},
"repository": {
......@@ -52,7 +52,6 @@
"jest": "^30.2.0",
"prettier": "^3.8.1",
"ts-jest": "^29.4.6",
"ts-node": "^10.9.2",
"typescript": "^5.9.3"
},
"dependencies": {
......
......@@ -95,6 +95,9 @@ export abstract class Client {
}
async sendChat(msg: string, type: number = ChatColor.BABYBLUE) {
if (type >= ChatColor.RED) {
msg = `[Server]: ${msg}`;
}
return this.send(
new YGOProStocChat().fromPartial({
msg:
......
......@@ -2,8 +2,10 @@ import { createAppContext } from 'nfkit';
import { ContextState } from '../app';
import { ClientVersionCheck } from './client-version-check';
import { JoinRoom } from './join-room';
import { JoinFallback } from './fallback';
export const JoinHandlerModule = createAppContext<ContextState>()
.provide(ClientVersionCheck)
.provide(JoinRoom)
.provide(JoinFallback)
.define();
......@@ -179,7 +179,10 @@ export class Room {
]);
}
private finalizors: RoomFinalizor[] = [() => this.cleanPlayers()];
private finalizors: RoomFinalizor[] = [
() => this.cleanPlayers(),
() => this.ocgcore?.dispose(),
];
addFinalizor(finalizor: RoomFinalizor, atEnd = false) {
if (atEnd) {
......@@ -375,6 +378,7 @@ export class Room {
}
async win(winMsg: Partial<YGOProMsgWin>, forceWinMatch = false) {
await this.ocgcore?.dispose();
if (this.duelStage === DuelStage.Siding) {
this.playingPlayers
.filter((p) => !p.deck)
......@@ -850,6 +854,10 @@ export class Room {
if (![DuelStage.Begin, DuelStage.Siding].includes(this.duelStage)) {
return false;
}
if (this.playingPlayers.some((p) => !p.deck)) {
return false;
}
if (this.duelRecords.length === 0) {
this.allPlayers.forEach((p) => p.send(new YGOProStocDuelStart()));
const displayCountDecks = [0, 1].map(
......@@ -1202,23 +1210,31 @@ export class Room {
}
return next();
})
.middleware(YGOProMsgBase, async (message, next) => {
//
if (this.pendingResponse && !(message instanceof YGOProMsgRetry)) {
// player made valid response
const resp = this.pendingResponse;
this.pendingResponse = undefined;
this.lastDuelRecord.responses.push(resp);
// TODO: clear timer
}
return next();
})
.middleware(YGOProMsgResponseBase, async (message, next) => {
this.responsePos = message.responsePlayer();
// TODO: set timer
return next();
});
.middleware(
YGOProMsgBase,
async (message, next) => {
//
if (this.pendingResponse && !(message instanceof YGOProMsgRetry)) {
// player made valid response
const resp = this.pendingResponse;
this.pendingResponse = undefined;
this.lastDuelRecord.responses.push(resp);
// TODO: clear timer
}
return next();
},
true,
)
.middleware(
YGOProMsgResponseBase,
async (message, next) => {
this.responsePos = message.responsePlayer();
// TODO: set timer
return next();
},
true,
);
private pendingResponse?: Buffer;
private responsePos?: number;
......
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