koishipro-core.js 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -8,3 +8,4 @@ export * from './src/constants';
8
8
  export * from './src/vendor';
9
9
  export * from './src/sqljs-card-reader';
10
10
  export * from './src/play-yrp';
11
+ export * from './src/test-card';
package/dist/index.mjs CHANGED
@@ -1042,7 +1042,7 @@ var OcgcoreWrapper = class {
1042
1042
  }
1043
1043
  this.ocgcoreModule._get_log_message(duelPtr, this.logBufferPtr);
1044
1044
  const message = this.getUTF8String(this.logBufferPtr);
1045
- const type = messageType === 1 ? "ScriptError" /* ScriptError */ : messageType === 2 ? "DebugMessage" /* DebugMessage */ : messageType;
1045
+ const type = messageType === 2 ? "DebugMessage" /* DebugMessage */ : "ScriptError" /* ScriptError */;
1046
1046
  const duel = this.getOrCreateDuel(duelPtr);
1047
1047
  for (const handler of this.messageHandlers) {
1048
1048
  try {
@@ -2457,6 +2457,49 @@ var playYrp = (ocgcoreWrapper, yrpInput) => {
2457
2457
  return messages;
2458
2458
  };
2459
2459
 
2460
+ // src/test-card.ts
2461
+ var { LOCATION_DECK: LOCATION_DECK2, POS_FACEUP_ATTACK } = OcgcoreScriptConstants;
2462
+ function testCard(ocgcoreWrapper, ...ids) {
2463
+ const logs = [];
2464
+ const duel = ocgcoreWrapper.createDuelV2(
2465
+ Array.from(
2466
+ { length: 8 },
2467
+ () => Math.floor(Math.random() * 4294967295) >>> 0
2468
+ )
2469
+ );
2470
+ ocgcoreWrapper.setMessageHandler((_duel, message, type) => {
2471
+ if (duel.duelPtr !== _duel.duelPtr) return;
2472
+ logs.push({ type, message });
2473
+ });
2474
+ duel.preloadScript("./script/special.lua");
2475
+ duel.preloadScript("./script/init.lua");
2476
+ duel.setPlayerInfo({ playerId: 0, lp: 8e3, startCount: 5, drawCount: 1 });
2477
+ duel.setPlayerInfo({ playerId: 1, lp: 8e3, startCount: 5, drawCount: 1 });
2478
+ for (const code of ids) {
2479
+ duel.newCard({
2480
+ code,
2481
+ owner: 0,
2482
+ playerId: 0,
2483
+ location: LOCATION_DECK2,
2484
+ sequence: 0,
2485
+ position: POS_FACEUP_ATTACK
2486
+ });
2487
+ }
2488
+ duel.startDuel(0);
2489
+ while (true) {
2490
+ const { status, raw } = duel.process();
2491
+ if (raw.length > 0 && raw[0] === OcgcoreCommonConstants.MSG_RETRY) {
2492
+ break;
2493
+ }
2494
+ if (status === 0) {
2495
+ continue;
2496
+ }
2497
+ break;
2498
+ }
2499
+ duel.endDuel();
2500
+ return logs;
2501
+ }
2502
+
2460
2503
  // index.ts
2461
2504
  if (typeof globalThis !== "undefined" && !globalThis.Buffer) {
2462
2505
  globalThis.Buffer = Buffer2;
@@ -2487,6 +2530,7 @@ export {
2487
2530
  parseFieldInfo,
2488
2531
  parseRegistryDump,
2489
2532
  parseRegistryKeys,
2490
- playYrp
2533
+ playYrp,
2534
+ testCard
2491
2535
  };
2492
2536
  //# sourceMappingURL=index.mjs.map