koishipro-core.js 1.0.9 → 1.0.10

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
@@ -55,6 +55,7 @@ __export(index_exports, {
55
55
  parseRegistryDump: () => parseRegistryDump,
56
56
  parseRegistryKeys: () => parseRegistryKeys,
57
57
  playYrp: () => playYrp,
58
+ playYrpStep: () => playYrpStep,
58
59
  testCard: () => testCard
59
60
  });
60
61
  module.exports = __toCommonJS(index_exports);
@@ -1258,9 +1259,7 @@ function normalizeOcgcoreFactory(mod) {
1258
1259
 
1259
1260
  // src/utility/load-node-module.ts
1260
1261
  function loadNodeModule(id, altId) {
1261
- const req = new Function(
1262
- 'return typeof require !== "undefined" ? require : undefined'
1263
- )();
1262
+ const req = typeof module.require !== "undefined" ? module.require : void 0;
1264
1263
  if (!req) {
1265
1264
  return null;
1266
1265
  }
@@ -2443,9 +2442,8 @@ function loadTagDeck(duel, deck, owner) {
2443
2442
  function setRegistryValue(duel, key, value) {
2444
2443
  duel.setRegistryValue(key, value);
2445
2444
  }
2446
- var playYrp = (ocgcoreWrapper, yrpInput) => {
2445
+ function* playYrpStep(ocgcoreWrapper, yrpInput) {
2447
2446
  const yrp = normalizeYrp(yrpInput);
2448
- const messages = [];
2449
2447
  const responses = yrp.responses.slice();
2450
2448
  const duel = createReplayDuel(ocgcoreWrapper, yrp);
2451
2449
  let ended = false;
@@ -2498,16 +2496,19 @@ var playYrp = (ocgcoreWrapper, yrpInput) => {
2498
2496
  }
2499
2497
  duel.startDuel(yrp.opt >>> 0);
2500
2498
  while (true) {
2501
- const { raw, status } = duel.process();
2502
- messages.push(raw);
2503
- if (raw.length > 0 && raw[0] === OcgcoreCommonConstants.MSG_RETRY) {
2499
+ const result = duel.process();
2500
+ yield {
2501
+ duel,
2502
+ result
2503
+ };
2504
+ if (result.raw.length > 0 && result.raw[0] === OcgcoreCommonConstants.MSG_RETRY) {
2504
2505
  throw new Error("Got MSG_RETRY");
2505
2506
  }
2506
- if (status === 0) {
2507
+ if (result.status === 0) {
2507
2508
  continue;
2508
2509
  }
2509
- if (status === 1) {
2510
- if (raw.length === 0) {
2510
+ if (result.status === 1) {
2511
+ if (result.raw.length === 0) {
2511
2512
  continue;
2512
2513
  }
2513
2514
  const response = responses.shift();
@@ -2522,7 +2523,13 @@ var playYrp = (ocgcoreWrapper, yrpInput) => {
2522
2523
  } finally {
2523
2524
  endDuel();
2524
2525
  }
2525
- return messages;
2526
+ }
2527
+ var playYrp = (ocgcoreWrapper, yrpInput) => {
2528
+ const results = [];
2529
+ for (const result of playYrpStep(ocgcoreWrapper, yrpInput)) {
2530
+ results.push(result.result.raw);
2531
+ }
2532
+ return results;
2526
2533
  };
2527
2534
 
2528
2535
  // src/test-card.ts
@@ -2600,6 +2607,7 @@ if (typeof globalThis !== "undefined" && !globalThis.Buffer) {
2600
2607
  parseRegistryDump,
2601
2608
  parseRegistryKeys,
2602
2609
  playYrp,
2610
+ playYrpStep,
2603
2611
  testCard
2604
2612
  });
2605
2613
  //# sourceMappingURL=index.cjs.map