Commit eb342374 authored by nanahira's avatar nanahira

use ygopro-deck-encode to parse ydk

parent f7f23e84
Pipeline #20488 passed with stages
in 4 minutes and 36 seconds
......@@ -33,7 +33,8 @@
"react-scripts": "^2.1.3",
"socket.io-client": "^4.5.1",
"sql.js": "^1.8.0",
"web-vitals": "^2.1.4"
"web-vitals": "^2.1.4",
"ygopro-deck-encode": "^1.0.3"
},
"devDependencies": {
"@babylonjs/core": "^5.29.0",
......@@ -14013,6 +14014,11 @@
"node": ">=4.0.0"
}
},
"node_modules/js-base64": {
"version": "3.7.5",
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-3.7.5.tgz",
"integrity": "sha512-3MEt5DTINKqfScXKfJFrRbxkrnk2AxPWGBL/ycjz4dK8iqiSJ06UxD8jh8xuh6p10TX4t2+7FsBYVxxQbMg+qA=="
},
"node_modules/js-levenshtein": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/js-levenshtein/-/js-levenshtein-1.1.6.tgz",
......@@ -26817,6 +26823,14 @@
"resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.2.tgz",
"integrity": "sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ=="
},
"node_modules/ygopro-deck-encode": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/ygopro-deck-encode/-/ygopro-deck-encode-1.0.3.tgz",
"integrity": "sha512-5JpaAdrIO4d2VnQRm+6T9S3JEp8ByXrFmXumAtCScvGYSc/31ianjafe76XVIFA8nSDJJCO8bzJF+C6CBwUONg==",
"dependencies": {
"js-base64": "^3.7.5"
}
},
"node_modules/yocto-queue": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
......@@ -37574,6 +37588,11 @@
"topo": "2.x.x"
}
},
"js-base64": {
"version": "3.7.5",
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-3.7.5.tgz",
"integrity": "sha512-3MEt5DTINKqfScXKfJFrRbxkrnk2AxPWGBL/ycjz4dK8iqiSJ06UxD8jh8xuh6p10TX4t2+7FsBYVxxQbMg+qA=="
},
"js-levenshtein": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/js-levenshtein/-/js-levenshtein-1.1.6.tgz",
......@@ -47493,6 +47512,14 @@
}
}
},
"ygopro-deck-encode": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/ygopro-deck-encode/-/ygopro-deck-encode-1.0.3.tgz",
"integrity": "sha512-5JpaAdrIO4d2VnQRm+6T9S3JEp8ByXrFmXumAtCScvGYSc/31ianjafe76XVIFA8nSDJJCO8bzJF+C6CBwUONg==",
"requires": {
"js-base64": "^3.7.5"
}
},
"yocto-queue": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
......@@ -28,7 +28,8 @@
"react-scripts": "^2.1.3",
"socket.io-client": "^4.5.1",
"sql.js": "^1.8.0",
"web-vitals": "^2.1.4"
"web-vitals": "^2.1.4",
"ygopro-deck-encode": "^1.0.3"
},
"scripts": {
"dev": "vite",
......
// import axios from "axios";
import YGOProDeck from "ygopro-deck-encode";
import DECKS from "./deck.json";
const DeckManager = _objToMap(DECKS);
......@@ -32,56 +33,6 @@ function _objToMap(object: any): Map<string, IDeck> {
}
export function parseYdk(text: string): IDeck | undefined {
const lineIter = text.split("\n");
const deck: { main: number[]; extra: number[]; side: number[] } = {
main: [],
extra: [],
side: [],
};
let flag = -1;
for (const line of lineIter) {
switch (line) {
case "#main\r": {
flag = 1;
break;
}
case "#extra\r": {
flag = 2;
break;
}
case "!side\r": {
flag = 3;
break;
}
default: {
let code = Number(line);
if (!isNaN(code)) {
if (code > 100) {
switch (flag) {
case 1: {
deck.main.push(code);
break;
}
case 2: {
deck.extra.push(code);
break;
}
case 3: {
deck.side.push(code);
break;
}
default: {
break;
}
}
}
}
break;
}
}
}
const deck = YGOProDeck.fromYdkString(text);
return deck.main.length == 0 ? undefined : deck;
}
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