koishipro-core.js 1.0.7 → 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.cjs CHANGED
@@ -54,7 +54,8 @@ __export(index_exports, {
54
54
  parseFieldInfo: () => parseFieldInfo,
55
55
  parseRegistryDump: () => parseRegistryDump,
56
56
  parseRegistryKeys: () => parseRegistryKeys,
57
- playYrp: () => playYrp
57
+ playYrp: () => playYrp,
58
+ testCard: () => testCard
58
59
  });
59
60
  module.exports = __toCommonJS(index_exports);
60
61
  var import_buffer = require("buffer");
@@ -1093,7 +1094,7 @@ var OcgcoreWrapper = class {
1093
1094
  }
1094
1095
  this.ocgcoreModule._get_log_message(duelPtr, this.logBufferPtr);
1095
1096
  const message = this.getUTF8String(this.logBufferPtr);
1096
- const type = messageType === 1 ? "ScriptError" /* ScriptError */ : messageType === 2 ? "DebugMessage" /* DebugMessage */ : messageType;
1097
+ const type = messageType === 2 ? "DebugMessage" /* DebugMessage */ : "ScriptError" /* ScriptError */;
1097
1098
  const duel = this.getOrCreateDuel(duelPtr);
1098
1099
  for (const handler of this.messageHandlers) {
1099
1100
  try {
@@ -2534,6 +2535,49 @@ var playYrp = (ocgcoreWrapper, yrpInput) => {
2534
2535
  return messages;
2535
2536
  };
2536
2537
 
2538
+ // src/test-card.ts
2539
+ var { LOCATION_DECK: LOCATION_DECK2, POS_FACEUP_ATTACK } = OcgcoreScriptConstants;
2540
+ function testCard(ocgcoreWrapper, ...ids) {
2541
+ const logs = [];
2542
+ const duel = ocgcoreWrapper.createDuelV2(
2543
+ Array.from(
2544
+ { length: 8 },
2545
+ () => Math.floor(Math.random() * 4294967295) >>> 0
2546
+ )
2547
+ );
2548
+ ocgcoreWrapper.setMessageHandler((_duel, message, type) => {
2549
+ if (duel.duelPtr !== _duel.duelPtr) return;
2550
+ logs.push({ type, message });
2551
+ });
2552
+ duel.preloadScript("./script/special.lua");
2553
+ duel.preloadScript("./script/init.lua");
2554
+ duel.setPlayerInfo({ playerId: 0, lp: 8e3, startCount: 5, drawCount: 1 });
2555
+ duel.setPlayerInfo({ playerId: 1, lp: 8e3, startCount: 5, drawCount: 1 });
2556
+ for (const code of ids) {
2557
+ duel.newCard({
2558
+ code,
2559
+ owner: 0,
2560
+ playerId: 0,
2561
+ location: LOCATION_DECK2,
2562
+ sequence: 0,
2563
+ position: POS_FACEUP_ATTACK
2564
+ });
2565
+ }
2566
+ duel.startDuel(0);
2567
+ while (true) {
2568
+ const { status, raw } = duel.process();
2569
+ if (raw.length > 0 && raw[0] === OcgcoreCommonConstants.MSG_RETRY) {
2570
+ break;
2571
+ }
2572
+ if (status === 0) {
2573
+ continue;
2574
+ }
2575
+ break;
2576
+ }
2577
+ duel.endDuel();
2578
+ return logs;
2579
+ }
2580
+
2537
2581
  // index.ts
2538
2582
  if (typeof globalThis !== "undefined" && !globalThis.Buffer) {
2539
2583
  globalThis.Buffer = import_buffer.Buffer;
@@ -2565,6 +2609,7 @@ if (typeof globalThis !== "undefined" && !globalThis.Buffer) {
2565
2609
  parseFieldInfo,
2566
2610
  parseRegistryDump,
2567
2611
  parseRegistryKeys,
2568
- playYrp
2612
+ playYrp,
2613
+ testCard
2569
2614
  });
2570
2615
  //# sourceMappingURL=index.cjs.map