ygopro-msg-encode 1.1.12 → 1.1.14
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 +169 -159
- package/dist/index.cjs.map +3 -3
- package/dist/index.mjs +166 -157
- package/dist/index.mjs.map +3 -3
- package/dist/src/protos/common/card-query.d.ts +1 -0
- package/dist/src/protos/msg/with-response-base.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -231,6 +231,7 @@ __export(index_exports, {
|
|
|
231
231
|
YGOProStocWaitingSide: () => YGOProStocWaitingSide,
|
|
232
232
|
fillBinaryFields: () => fillBinaryFields,
|
|
233
233
|
isIndexResponse: () => isIndexResponse,
|
|
234
|
+
serializeCardQuery: () => serializeCardQuery,
|
|
234
235
|
toBinaryFields: () => toBinaryFields
|
|
235
236
|
});
|
|
236
237
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -1308,172 +1309,177 @@ var _CardQuery = class _CardQuery {
|
|
|
1308
1309
|
return this;
|
|
1309
1310
|
}
|
|
1310
1311
|
toPayload() {
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1312
|
+
return serializeCardQuery(this);
|
|
1313
|
+
}
|
|
1314
|
+
};
|
|
1315
|
+
__name(_CardQuery, "CardQuery");
|
|
1316
|
+
var CardQuery = _CardQuery;
|
|
1317
|
+
function serializeCardQuery(card) {
|
|
1318
|
+
const source = card || {};
|
|
1319
|
+
const flags = source.flags || 0;
|
|
1320
|
+
let size = 4;
|
|
1321
|
+
if (flags & OcgcoreCommonConstants.QUERY_CODE) size += 4;
|
|
1322
|
+
if (flags & OcgcoreCommonConstants.QUERY_POSITION) size += 4;
|
|
1323
|
+
if (flags & OcgcoreCommonConstants.QUERY_ALIAS) size += 4;
|
|
1324
|
+
if (flags & OcgcoreCommonConstants.QUERY_TYPE) size += 4;
|
|
1325
|
+
if (flags & OcgcoreCommonConstants.QUERY_LEVEL) size += 4;
|
|
1326
|
+
if (flags & OcgcoreCommonConstants.QUERY_RANK) size += 4;
|
|
1327
|
+
if (flags & OcgcoreCommonConstants.QUERY_ATTRIBUTE) size += 4;
|
|
1328
|
+
if (flags & OcgcoreCommonConstants.QUERY_RACE) size += 4;
|
|
1329
|
+
if (flags & OcgcoreCommonConstants.QUERY_ATTACK) size += 4;
|
|
1330
|
+
if (flags & OcgcoreCommonConstants.QUERY_DEFENSE) size += 4;
|
|
1331
|
+
if (flags & OcgcoreCommonConstants.QUERY_BASE_ATTACK) size += 4;
|
|
1332
|
+
if (flags & OcgcoreCommonConstants.QUERY_BASE_DEFENSE) size += 4;
|
|
1333
|
+
if (flags & OcgcoreCommonConstants.QUERY_REASON) size += 4;
|
|
1334
|
+
if (flags & OcgcoreCommonConstants.QUERY_REASON_CARD) size += 4;
|
|
1335
|
+
if (flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) size += 4;
|
|
1336
|
+
if (flags & OcgcoreCommonConstants.QUERY_TARGET_CARD) {
|
|
1337
|
+
size += 4 + (source.targetCards?.length || 0) * 4;
|
|
1338
|
+
}
|
|
1339
|
+
if (flags & OcgcoreCommonConstants.QUERY_OVERLAY_CARD) {
|
|
1340
|
+
size += 4 + (source.overlayCards?.length || 0) * 4;
|
|
1341
|
+
}
|
|
1342
|
+
if (flags & OcgcoreCommonConstants.QUERY_COUNTERS) {
|
|
1343
|
+
size += 4 + (source.counters?.length || 0) * 4;
|
|
1344
|
+
}
|
|
1345
|
+
if (flags & OcgcoreCommonConstants.QUERY_OWNER) size += 4;
|
|
1346
|
+
if (flags & OcgcoreCommonConstants.QUERY_STATUS) size += 4;
|
|
1347
|
+
if (flags & OcgcoreCommonConstants.QUERY_LSCALE) size += 4;
|
|
1348
|
+
if (flags & OcgcoreCommonConstants.QUERY_RSCALE) size += 4;
|
|
1349
|
+
if (flags & OcgcoreCommonConstants.QUERY_LINK) size += 8;
|
|
1350
|
+
const result = new Uint8Array(size);
|
|
1351
|
+
const view = new DataView(result.buffer);
|
|
1352
|
+
let offset = 0;
|
|
1353
|
+
view.setInt32(offset, flags, true);
|
|
1354
|
+
offset += 4;
|
|
1355
|
+
if (source.empty || flags === 0) {
|
|
1356
|
+
return result;
|
|
1357
|
+
}
|
|
1358
|
+
if (flags & OcgcoreCommonConstants.QUERY_CODE) {
|
|
1359
|
+
view.setInt32(offset, source.code || 0, true);
|
|
1346
1360
|
offset += 4;
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
}
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1361
|
+
}
|
|
1362
|
+
if (flags & OcgcoreCommonConstants.QUERY_POSITION) {
|
|
1363
|
+
const pdata = (source.position || 0) << 24 >>> 0;
|
|
1364
|
+
view.setInt32(offset, pdata, true);
|
|
1365
|
+
offset += 4;
|
|
1366
|
+
}
|
|
1367
|
+
if (flags & OcgcoreCommonConstants.QUERY_ALIAS) {
|
|
1368
|
+
view.setInt32(offset, source.alias || 0, true);
|
|
1369
|
+
offset += 4;
|
|
1370
|
+
}
|
|
1371
|
+
if (flags & OcgcoreCommonConstants.QUERY_TYPE) {
|
|
1372
|
+
view.setInt32(offset, source.type || 0, true);
|
|
1373
|
+
offset += 4;
|
|
1374
|
+
}
|
|
1375
|
+
if (flags & OcgcoreCommonConstants.QUERY_LEVEL) {
|
|
1376
|
+
view.setInt32(offset, source.level || 0, true);
|
|
1377
|
+
offset += 4;
|
|
1378
|
+
}
|
|
1379
|
+
if (flags & OcgcoreCommonConstants.QUERY_RANK) {
|
|
1380
|
+
view.setInt32(offset, source.rank || 0, true);
|
|
1381
|
+
offset += 4;
|
|
1382
|
+
}
|
|
1383
|
+
if (flags & OcgcoreCommonConstants.QUERY_ATTRIBUTE) {
|
|
1384
|
+
view.setInt32(offset, source.attribute || 0, true);
|
|
1385
|
+
offset += 4;
|
|
1386
|
+
}
|
|
1387
|
+
if (flags & OcgcoreCommonConstants.QUERY_RACE) {
|
|
1388
|
+
view.setInt32(offset, source.race || 0, true);
|
|
1389
|
+
offset += 4;
|
|
1390
|
+
}
|
|
1391
|
+
if (flags & OcgcoreCommonConstants.QUERY_ATTACK) {
|
|
1392
|
+
view.setInt32(offset, source.attack || 0, true);
|
|
1393
|
+
offset += 4;
|
|
1394
|
+
}
|
|
1395
|
+
if (flags & OcgcoreCommonConstants.QUERY_DEFENSE) {
|
|
1396
|
+
view.setInt32(offset, source.defense || 0, true);
|
|
1397
|
+
offset += 4;
|
|
1398
|
+
}
|
|
1399
|
+
if (flags & OcgcoreCommonConstants.QUERY_BASE_ATTACK) {
|
|
1400
|
+
view.setInt32(offset, source.baseAttack || 0, true);
|
|
1401
|
+
offset += 4;
|
|
1402
|
+
}
|
|
1403
|
+
if (flags & OcgcoreCommonConstants.QUERY_BASE_DEFENSE) {
|
|
1404
|
+
view.setInt32(offset, source.baseDefense || 0, true);
|
|
1405
|
+
offset += 4;
|
|
1406
|
+
}
|
|
1407
|
+
if (flags & OcgcoreCommonConstants.QUERY_REASON) {
|
|
1408
|
+
view.setInt32(offset, source.reason || 0, true);
|
|
1409
|
+
offset += 4;
|
|
1410
|
+
}
|
|
1411
|
+
if (flags & OcgcoreCommonConstants.QUERY_REASON_CARD) {
|
|
1412
|
+
view.setInt32(offset, 0, true);
|
|
1413
|
+
offset += 4;
|
|
1414
|
+
}
|
|
1415
|
+
if (flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) {
|
|
1416
|
+
const equipCard = source.equipCard || {
|
|
1417
|
+
controller: 0,
|
|
1418
|
+
location: 0,
|
|
1419
|
+
sequence: 0
|
|
1420
|
+
};
|
|
1421
|
+
view.setUint8(offset, equipCard.controller);
|
|
1422
|
+
view.setUint8(offset + 1, equipCard.location);
|
|
1423
|
+
view.setUint8(offset + 2, equipCard.sequence);
|
|
1424
|
+
view.setUint8(offset + 3, 0);
|
|
1425
|
+
offset += 4;
|
|
1426
|
+
}
|
|
1427
|
+
if (flags & OcgcoreCommonConstants.QUERY_TARGET_CARD) {
|
|
1428
|
+
const targets = source.targetCards || [];
|
|
1429
|
+
view.setInt32(offset, targets.length, true);
|
|
1430
|
+
offset += 4;
|
|
1431
|
+
for (const target of targets) {
|
|
1432
|
+
view.setUint8(offset, target.controller);
|
|
1433
|
+
view.setUint8(offset + 1, target.location);
|
|
1434
|
+
view.setUint8(offset + 2, target.sequence);
|
|
1416
1435
|
view.setUint8(offset + 3, 0);
|
|
1417
1436
|
offset += 4;
|
|
1418
1437
|
}
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
view.setUint8(offset + 2, target.sequence);
|
|
1427
|
-
view.setUint8(offset + 3, 0);
|
|
1428
|
-
offset += 4;
|
|
1429
|
-
}
|
|
1430
|
-
}
|
|
1431
|
-
if (flags & OcgcoreCommonConstants.QUERY_OVERLAY_CARD) {
|
|
1432
|
-
const overlays = this.overlayCards || [];
|
|
1433
|
-
view.setInt32(offset, overlays.length, true);
|
|
1434
|
-
offset += 4;
|
|
1435
|
-
for (const card of overlays) {
|
|
1436
|
-
view.setInt32(offset, card, true);
|
|
1437
|
-
offset += 4;
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
if (flags & OcgcoreCommonConstants.QUERY_COUNTERS) {
|
|
1441
|
-
const counters = this.counters || [];
|
|
1442
|
-
view.setInt32(offset, counters.length, true);
|
|
1443
|
-
offset += 4;
|
|
1444
|
-
for (const counter of counters) {
|
|
1445
|
-
view.setUint16(offset, counter.type, true);
|
|
1446
|
-
view.setUint16(offset + 2, counter.count, true);
|
|
1447
|
-
offset += 4;
|
|
1448
|
-
}
|
|
1449
|
-
}
|
|
1450
|
-
if (flags & OcgcoreCommonConstants.QUERY_OWNER) {
|
|
1451
|
-
view.setInt32(offset, this.owner || 0, true);
|
|
1452
|
-
offset += 4;
|
|
1453
|
-
}
|
|
1454
|
-
if (flags & OcgcoreCommonConstants.QUERY_STATUS) {
|
|
1455
|
-
view.setInt32(offset, this.status || 0, true);
|
|
1456
|
-
offset += 4;
|
|
1457
|
-
}
|
|
1458
|
-
if (flags & OcgcoreCommonConstants.QUERY_LSCALE) {
|
|
1459
|
-
view.setInt32(offset, this.lscale || 0, true);
|
|
1460
|
-
offset += 4;
|
|
1461
|
-
}
|
|
1462
|
-
if (flags & OcgcoreCommonConstants.QUERY_RSCALE) {
|
|
1463
|
-
view.setInt32(offset, this.rscale || 0, true);
|
|
1438
|
+
}
|
|
1439
|
+
if (flags & OcgcoreCommonConstants.QUERY_OVERLAY_CARD) {
|
|
1440
|
+
const overlays = source.overlayCards || [];
|
|
1441
|
+
view.setInt32(offset, overlays.length, true);
|
|
1442
|
+
offset += 4;
|
|
1443
|
+
for (const card2 of overlays) {
|
|
1444
|
+
view.setInt32(offset, card2, true);
|
|
1464
1445
|
offset += 4;
|
|
1465
1446
|
}
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1447
|
+
}
|
|
1448
|
+
if (flags & OcgcoreCommonConstants.QUERY_COUNTERS) {
|
|
1449
|
+
const counters = source.counters || [];
|
|
1450
|
+
view.setInt32(offset, counters.length, true);
|
|
1451
|
+
offset += 4;
|
|
1452
|
+
for (const counter of counters) {
|
|
1453
|
+
view.setUint16(offset, counter.type, true);
|
|
1454
|
+
view.setUint16(offset + 2, counter.count, true);
|
|
1470
1455
|
offset += 4;
|
|
1471
1456
|
}
|
|
1472
|
-
return new Uint8Array(view.buffer, view.byteOffset, offset);
|
|
1473
1457
|
}
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1458
|
+
if (flags & OcgcoreCommonConstants.QUERY_OWNER) {
|
|
1459
|
+
view.setInt32(offset, source.owner || 0, true);
|
|
1460
|
+
offset += 4;
|
|
1461
|
+
}
|
|
1462
|
+
if (flags & OcgcoreCommonConstants.QUERY_STATUS) {
|
|
1463
|
+
view.setInt32(offset, source.status || 0, true);
|
|
1464
|
+
offset += 4;
|
|
1465
|
+
}
|
|
1466
|
+
if (flags & OcgcoreCommonConstants.QUERY_LSCALE) {
|
|
1467
|
+
view.setInt32(offset, source.lscale || 0, true);
|
|
1468
|
+
offset += 4;
|
|
1469
|
+
}
|
|
1470
|
+
if (flags & OcgcoreCommonConstants.QUERY_RSCALE) {
|
|
1471
|
+
view.setInt32(offset, source.rscale || 0, true);
|
|
1472
|
+
offset += 4;
|
|
1473
|
+
}
|
|
1474
|
+
if (flags & OcgcoreCommonConstants.QUERY_LINK) {
|
|
1475
|
+
view.setInt32(offset, source.link || 0, true);
|
|
1476
|
+
offset += 4;
|
|
1477
|
+
view.setInt32(offset, source.linkMarker || 0, true);
|
|
1478
|
+
offset += 4;
|
|
1479
|
+
}
|
|
1480
|
+
return new Uint8Array(view.buffer, view.byteOffset, offset);
|
|
1481
|
+
}
|
|
1482
|
+
__name(serializeCardQuery, "serializeCardQuery");
|
|
1477
1483
|
|
|
1478
1484
|
// src/proto-base/ygopro-proto-base.ts
|
|
1479
1485
|
var _YGOProProtoBase = class _YGOProProtoBase extends PayloadBase {
|
|
@@ -2046,6 +2052,9 @@ var _YGOProMsgResponseBase = class _YGOProMsgResponseBase extends YGOProMsgBase
|
|
|
2046
2052
|
defaultResponse() {
|
|
2047
2053
|
return void 0;
|
|
2048
2054
|
}
|
|
2055
|
+
responsePlayer() {
|
|
2056
|
+
return 0;
|
|
2057
|
+
}
|
|
2049
2058
|
getSendTargets() {
|
|
2050
2059
|
return [this.responsePlayer()];
|
|
2051
2060
|
}
|
|
@@ -5817,7 +5826,7 @@ var _YGOProMsgUpdateCard = class _YGOProMsgUpdateCard extends YGOProMsgBase {
|
|
|
5817
5826
|
return this;
|
|
5818
5827
|
}
|
|
5819
5828
|
toPayload() {
|
|
5820
|
-
const cardPayload = this.card
|
|
5829
|
+
const cardPayload = serializeCardQuery(this.card);
|
|
5821
5830
|
const length = 4 + cardPayload.length;
|
|
5822
5831
|
const result = new Uint8Array(4 + length);
|
|
5823
5832
|
const view = new DataView(result.buffer);
|
|
@@ -5927,7 +5936,7 @@ var _YGOProMsgUpdateData = class _YGOProMsgUpdateData extends YGOProMsgBase {
|
|
|
5927
5936
|
let totalSize = 3;
|
|
5928
5937
|
const cardPayloads = [];
|
|
5929
5938
|
for (const card of this.cards || []) {
|
|
5930
|
-
const payload = card
|
|
5939
|
+
const payload = serializeCardQuery(card);
|
|
5931
5940
|
cardPayloads.push(payload);
|
|
5932
5941
|
totalSize += 4 + payload.length;
|
|
5933
5942
|
}
|
|
@@ -6682,6 +6691,7 @@ YGOProStoc.register(YGOProStocSrvproRoomlist);
|
|
|
6682
6691
|
YGOProStocWaitingSide,
|
|
6683
6692
|
fillBinaryFields,
|
|
6684
6693
|
isIndexResponse,
|
|
6694
|
+
serializeCardQuery,
|
|
6685
6695
|
toBinaryFields
|
|
6686
6696
|
});
|
|
6687
6697
|
//# sourceMappingURL=index.cjs.map
|