Commit b3e5f074 authored by nanahira's avatar nanahira

migrate to ygopro-cdb-encode

parent 0fa86c77
......@@ -10,7 +10,9 @@
"license": "MIT",
"dependencies": {
"js-yaml": "^4.1.1",
"koishipro-core.js": "^1.2.12",
"sql.js": "^1.13.0",
"ygopro-cdb-encode": "^1.0.1",
"ygopro-jstest": "^1.0.10",
"ygopro-msg-encode": "^1.1.7"
},
......@@ -4489,9 +4491,9 @@
}
},
"node_modules/koishipro-core.js": {
"version": "1.2.10",
"resolved": "https://registry.npmjs.org/koishipro-core.js/-/koishipro-core.js-1.2.10.tgz",
"integrity": "sha512-lrsPwrE0hAOjBtKc2Ixan3/vrcddbgMIoPsaxz/fDhGeaAh465ph60IOuhvbyWNNodJS5xh0n5JGwYhnNSV7UQ==",
"version": "1.2.12",
"resolved": "https://registry.npmjs.org/koishipro-core.js/-/koishipro-core.js-1.2.12.tgz",
"integrity": "sha512-WPu7qdz+zv3rQc2+LiGKtqAqQjGOZ2Mov/UYfIQws7Dh1lLQBwrVfSvHyAYA3wpRaeVDp2LtWhn+O82Ga1vu2Q==",
"license": "MIT",
"dependencies": {
"@types/emscripten": "^1.41.5",
......@@ -4500,7 +4502,8 @@
"jszip": "^3.10.1",
"nfkit": "^1.0.14",
"sql.js": "^1.13.0",
"ygopro-msg-encode": "^1.1.5",
"ygopro-cdb-encode": "^1.0.1",
"ygopro-msg-encode": "^1.1.7",
"ygopro-yrp-encode": "^1.0.1"
}
},
......@@ -4722,9 +4725,9 @@
"license": "MIT"
},
"node_modules/nfkit": {
"version": "1.0.14",
"resolved": "https://registry.npmjs.org/nfkit/-/nfkit-1.0.14.tgz",
"integrity": "sha512-jou0ZvwZXvUlp9T0Rerv19BIqn5m2VgFyy76u5CLSYyKIjEmwKCPWytZyBSTOcPv41OaNBC48uzQO9QtNgDH1A==",
"version": "1.0.21",
"resolved": "https://registry.npmjs.org/nfkit/-/nfkit-1.0.21.tgz",
"integrity": "sha512-YLs7zUoq9Lz3r91xM4UkHddKWhvaBvdTz+45E/k0xOqKrWiXj0iXMLwSwK9+q1rS39PoV+mD2+vJ8ox/M53HuQ==",
"license": "MIT"
},
"node_modules/node-int64": {
......@@ -6378,6 +6381,18 @@
"node": ">=8"
}
},
"node_modules/ygopro-cdb-encode": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/ygopro-cdb-encode/-/ygopro-cdb-encode-1.0.1.tgz",
"integrity": "sha512-MfNcrM9w/r9Pp7yFAnZyIkmYwEkoDJlyeddo7xviGgKf2E4dnlK06TGBPO2dk6JpdxB8Ij6jpmFw0B/qd0c7LA==",
"license": "MIT",
"dependencies": {
"@types/sql.js": "^1.4.9",
"nfkit": "^1.0.21",
"sql.js": "^1.13.0",
"ygopro-msg-encode": "^1.1.7"
}
},
"node_modules/ygopro-deck-encode": {
"version": "1.0.15",
"resolved": "https://registry.npmjs.org/ygopro-deck-encode/-/ygopro-deck-encode-1.0.15.tgz",
......
......@@ -54,7 +54,9 @@
},
"dependencies": {
"js-yaml": "^4.1.1",
"koishipro-core.js": "^1.2.12",
"sql.js": "^1.13.0",
"ygopro-cdb-encode": "^1.0.1",
"ygopro-jstest": "^1.0.10",
"ygopro-msg-encode": "^1.1.7"
}
......
......@@ -4,6 +4,7 @@ import path from "node:path";
import { createTest } from "./utility/create-test";
import { OcgcoreScriptConstants } from "ygopro-msg-encode";
import { SlientAdvancor } from "ygopro-jstest";
import { YGOProCdb } from "ygopro-cdb-encode";
describe("No Red Text", () => {
it("should not get redtext Lua errors", async () => {
......@@ -14,25 +15,21 @@ describe("No Red Text", () => {
if (!file.endsWith(".cdb")) continue;
const buf = await fs.promises.readFile(path.resolve(process.cwd(), file));
const db = new SQL.Database(buf);
const res = db.exec(
`SELECT id FROM datas where type != ${OcgcoreScriptConstants.TYPE_MONSTER | OcgcoreScriptConstants.TYPE_NORMAL} and type & ${OcgcoreScriptConstants.TYPE_TOKEN} = 0 and not (alias > 0 and alias - id < 20)`,
);
for (const data of res) {
for (const row of data.values) {
const id = row[0] as number;
expect(id).toBeGreaterThan(0); // dummy assertion to use id variable
console.log(
`Testing redtext of card ID: ${id} from database: ${file}`,
);
await createTest({}, (ygo) =>
ygo
.addCard({
code: id,
location: OcgcoreScriptConstants.LOCATION_DECK,
})
.advance(SlientAdvancor()),
);
}
const cdb = new YGOProCdb(db);
for (const data of cdb.find(
`datas.type != ${OcgcoreScriptConstants.TYPE_MONSTER | OcgcoreScriptConstants.TYPE_NORMAL} and datas.type & ${OcgcoreScriptConstants.TYPE_TOKEN} = 0 and not (datas.alias > 0 and datas.alias - datas.id < 20)`,
)) {
const id = data.code;
expect(id).toBeGreaterThan(0); // dummy assertion to use id variable
console.log(`Testing redtext of card ID: ${id} from database: ${file}`);
await createTest({}, (ygo) =>
ygo
.addCard({
code: id,
location: OcgcoreScriptConstants.LOCATION_DECK,
})
.advance(SlientAdvancor()),
);
}
db.close();
}
......
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