Commit 77811ec5 authored by nanahira's avatar nanahira

still broken

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