ygopro-msg-encode 1.1.26 → 1.1.28
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 +50 -4
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +50 -4
- package/dist/index.mjs.map +2 -2
- package/dist/src/protos/msg/proto/update-data.d.ts +1 -0
- package/package.json +1 -1
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
|
-
|
|
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
|
|
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
|
|
1564
|
+
card.queryLength = inferCardQueryChunkLength(source);
|
|
1544
1565
|
return card;
|
|
1545
1566
|
}
|
|
1546
1567
|
__name(createCodeHiddenCardQuery, "createCodeHiddenCardQuery");
|
|
@@ -6049,6 +6070,15 @@ var YGOProMsgUpdateCard = _YGOProMsgUpdateCard;
|
|
|
6049
6070
|
|
|
6050
6071
|
// src/protos/msg/proto/update-data.ts
|
|
6051
6072
|
var _YGOProMsgUpdateData = class _YGOProMsgUpdateData extends YGOProMsgBase {
|
|
6073
|
+
getFixedSlotCount() {
|
|
6074
|
+
if (this.location === OcgcoreScriptConstants.LOCATION_MZONE) {
|
|
6075
|
+
return 7;
|
|
6076
|
+
}
|
|
6077
|
+
if (this.location === OcgcoreScriptConstants.LOCATION_SZONE) {
|
|
6078
|
+
return 8;
|
|
6079
|
+
}
|
|
6080
|
+
return void 0;
|
|
6081
|
+
}
|
|
6052
6082
|
shouldHideForOpponent(card) {
|
|
6053
6083
|
if (this.location === OcgcoreScriptConstants.LOCATION_GRAVE) {
|
|
6054
6084
|
return false;
|
|
@@ -6123,9 +6153,25 @@ var _YGOProMsgUpdateData = class _YGOProMsgUpdateData extends YGOProMsgBase {
|
|
|
6123
6153
|
return this;
|
|
6124
6154
|
}
|
|
6125
6155
|
toPayload() {
|
|
6156
|
+
const inputCards = this.cards || [];
|
|
6157
|
+
const fixedSlotCount = this.getFixedSlotCount();
|
|
6158
|
+
let cardsToEncode = inputCards;
|
|
6159
|
+
if (fixedSlotCount !== void 0) {
|
|
6160
|
+
if (inputCards.length > fixedSlotCount) {
|
|
6161
|
+
throw new Error(
|
|
6162
|
+
`MSG_UPDATE_DATA location ${this.location} expects at most ${fixedSlotCount} chunks, got ${inputCards.length}`
|
|
6163
|
+
);
|
|
6164
|
+
}
|
|
6165
|
+
if (inputCards.length < fixedSlotCount) {
|
|
6166
|
+
cardsToEncode = inputCards.slice();
|
|
6167
|
+
for (let i = inputCards.length; i < fixedSlotCount; i++) {
|
|
6168
|
+
cardsToEncode.push(createClearedCardQuery());
|
|
6169
|
+
}
|
|
6170
|
+
}
|
|
6171
|
+
}
|
|
6126
6172
|
let totalSize = 3;
|
|
6127
6173
|
const chunks = [];
|
|
6128
|
-
for (const card of
|
|
6174
|
+
for (const card of cardsToEncode) {
|
|
6129
6175
|
const chunk = serializeCardQueryChunk(card);
|
|
6130
6176
|
chunks.push(chunk);
|
|
6131
6177
|
totalSize += chunk.length;
|