0.0.34 • Published 6 months ago
ocgcore-wasm v0.0.34
ocgcore-wasm
ProjectIgnis' EDOPro Core built for WebAssembly using emscripten.
The async version requires JS Promise Integration (JSPI) and Type reflection. Use
the flag --experimental-wasm-stack-switching
with node.
Example
Initialize sync version
const scriptPath = "...";
const cards = loadCardDatabase();
const lib = await createCore({ sync: true });
const handle = lib.createDuel({
flags: OcgDuelMode.MODE_MR5,
seed: [1n, 1n, 1n, 1n],
team1: {
drawCountPerTurn: 1,
startingDrawCount: 5,
startingLP: 8000,
},
team2: {
drawCountPerTurn: 1,
startingDrawCount: 5,
startingLP: 8000,
},
cardReader: (code) => {
const card = cards.get(code);
if (!card) {
console.warn("missing card: ", code);
}
return card ?? null;
},
scriptReader: (script) => {
const filePath = script.match(/c\d+\.lua/)
? path.join(scriptPath, "official", script)
: path.join(scriptPath, script);
try {
return readFileSync(filePath, "utf-8");
} catch (e) {
console.log(`error reading script "${script}", ${e}`);
throw e;
}
},
errorHandler: (type, text) => {
console.warn(type, text);
},
});
if (!handle) {
throw new Error("failed to create");
}
Processing
await lib.startDuel(handle);
while (true) {
const status = await lib.duelProcess(handle);
const data = lib.duelGetMessage(handle);
data.forEach((d) => console.log(d));
if (status === OcgProcessResult.END) {
break;
}
if (status === OcgProcessResult.CONTINUE) {
continue;
}
// send response
lib.duelSetResponse(handle, getNextResponse());
}
0.0.30
6 months ago
0.0.31
6 months ago
0.0.32
6 months ago
0.0.33
6 months ago
0.0.34
6 months ago
0.0.29
1 year ago
0.0.25
1 year ago
0.0.26
1 year ago
0.0.27
1 year ago
0.0.28
1 year ago
0.0.23
1 year ago
0.0.24
1 year ago
0.0.22
1 year ago
0.0.20
2 years ago
0.0.21
2 years ago
0.0.17
2 years ago
0.0.19
2 years ago
0.0.13
2 years ago
0.0.14
2 years ago
0.0.15
2 years ago
0.0.16
2 years ago
0.0.10
2 years ago
0.0.11
2 years ago
0.0.12
2 years ago
0.0.9
2 years ago
0.0.8
2 years ago
0.0.7
2 years ago
0.0.5
2 years ago
0.0.4
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago