ygopro-msg-encode 1.1.27 → 1.1.29

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
@@ -1524,14 +1524,35 @@ function serializeCardQueryChunk(card) {
1524
1524
  return { length: queryLength, payload: new Uint8Array(queryLength - 4) };
1525
1525
  }
1526
1526
  const payload = serializeCardQuery(card);
1527
- return { length: 4 + payload.length, payload };
1527
+ const minimalLength = 4 + payload.length;
1528
+ if (queryLength && queryLength > minimalLength) {
1529
+ const padded = new Uint8Array(queryLength - 4);
1530
+ padded.set(payload, 0);
1531
+ return { length: queryLength, payload: padded };
1532
+ }
1533
+ return { length: minimalLength, payload };
1528
1534
  }
1529
1535
  __name(serializeCardQueryChunk, "serializeCardQueryChunk");
1536
+ function inferCardQueryChunkLength(source) {
1537
+ if (!source) {
1538
+ return void 0;
1539
+ }
1540
+ if (typeof source.queryLength === "number" && source.queryLength >= 4) {
1541
+ return source.queryLength;
1542
+ }
1543
+ const flags = source.flags ?? 0;
1544
+ if (flags === 0 && source.empty) {
1545
+ return 4;
1546
+ }
1547
+ const payload = serializeCardQuery(source);
1548
+ return 4 + payload.length;
1549
+ }
1550
+ __name(inferCardQueryChunkLength, "inferCardQueryChunkLength");
1530
1551
  function createClearedCardQuery(source) {
1531
1552
  const card = new CardQuery();
1532
1553
  card.flags = 0;
1533
1554
  card.empty = true;
1534
- card.queryLength = source?.queryLength;
1555
+ card.queryLength = inferCardQueryChunkLength(source);
1535
1556
  return card;
1536
1557
  }
1537
1558
  __name(createClearedCardQuery, "createClearedCardQuery");
@@ -1540,7 +1561,7 @@ function createCodeHiddenCardQuery(source) {
1540
1561
  card.flags = OcgcoreCommonConstants.QUERY_CODE;
1541
1562
  card.code = 0;
1542
1563
  card.empty = false;
1543
- card.queryLength = source?.queryLength;
1564
+ card.queryLength = inferCardQueryChunkLength(source);
1544
1565
  return card;
1545
1566
  }
1546
1567
  __name(createCodeHiddenCardQuery, "createCodeHiddenCardQuery");
@@ -3851,16 +3872,7 @@ var _YGOProMsgMove = class _YGOProMsgMove extends YGOProMsgBase {
3851
3872
  return view;
3852
3873
  }
3853
3874
  teammateView() {
3854
- const view = this.copy();
3855
- const cl = view.current.location;
3856
- const cp = view.current.position;
3857
- if (cl & (OcgcoreScriptConstants.LOCATION_GRAVE | OcgcoreScriptConstants.LOCATION_OVERLAY)) {
3858
- return view;
3859
- }
3860
- if (cl & (OcgcoreScriptConstants.LOCATION_DECK | OcgcoreScriptConstants.LOCATION_HAND)) {
3861
- view.code = 0;
3862
- }
3863
- return view;
3875
+ return this.opponentView();
3864
3876
  }
3865
3877
  playerView(playerId) {
3866
3878
  if (playerId === 7 /* OBSERVER */) {