ygopro-msg-encode 1.1.29 → 1.1.31

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
@@ -236,6 +236,7 @@ __export(index_exports, {
236
236
  createClearedCardQuery: () => createClearedCardQuery,
237
237
  createCodeHiddenCardQuery: () => createCodeHiddenCardQuery,
238
238
  fillBinaryFields: () => fillBinaryFields,
239
+ getCardQueryPosition: () => getCardQueryPosition,
239
240
  isIndexResponse: () => isIndexResponse,
240
241
  parseCardQueryChunk: () => parseCardQueryChunk,
241
242
  serializeCardQuery: () => serializeCardQuery,
@@ -1201,7 +1202,10 @@ var _CardQuery = class _CardQuery {
1201
1202
  offset += 4;
1202
1203
  }
1203
1204
  if (this.flags & OcgcoreCommonConstants.QUERY_POSITION) {
1204
- const pdata = view.getInt32(offset, true);
1205
+ const pdata = view.getUint32(offset, true);
1206
+ this.controller = pdata & 255;
1207
+ this.location = pdata >>> 8 & 255;
1208
+ this.sequence = pdata >>> 16 & 255;
1205
1209
  this.position = (pdata >>> 24 & 255) >>> 0;
1206
1210
  offset += 4;
1207
1211
  }
@@ -1250,13 +1254,20 @@ var _CardQuery = class _CardQuery {
1250
1254
  offset += 4;
1251
1255
  }
1252
1256
  if (this.flags & OcgcoreCommonConstants.QUERY_REASON_CARD) {
1257
+ this.reasonCard = {
1258
+ controller: view.getUint8(offset),
1259
+ location: view.getUint8(offset + 1),
1260
+ sequence: view.getUint8(offset + 2),
1261
+ position: view.getUint8(offset + 3)
1262
+ };
1253
1263
  offset += 4;
1254
1264
  }
1255
1265
  if (this.flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) {
1256
1266
  this.equipCard = {
1257
1267
  controller: view.getUint8(offset),
1258
1268
  location: view.getUint8(offset + 1),
1259
- sequence: view.getUint8(offset + 2)
1269
+ sequence: view.getUint8(offset + 2),
1270
+ position: view.getUint8(offset + 3)
1260
1271
  };
1261
1272
  offset += 4;
1262
1273
  }
@@ -1268,7 +1279,8 @@ var _CardQuery = class _CardQuery {
1268
1279
  this.targetCards.push({
1269
1280
  controller: view.getUint8(offset),
1270
1281
  location: view.getUint8(offset + 1),
1271
- sequence: view.getUint8(offset + 2)
1282
+ sequence: view.getUint8(offset + 2),
1283
+ position: view.getUint8(offset + 3)
1272
1284
  });
1273
1285
  offset += 4;
1274
1286
  }
@@ -1370,8 +1382,8 @@ function serializeCardQuery(card) {
1370
1382
  offset += 4;
1371
1383
  }
1372
1384
  if (flags & OcgcoreCommonConstants.QUERY_POSITION) {
1373
- const pdata = (source.position || 0) << 24 >>> 0;
1374
- view.setInt32(offset, pdata, true);
1385
+ const pdata = (source.controller || 0) & 255 | ((source.location || 0) & 255) << 8 | ((source.sequence || 0) & 255) << 16 | ((source.position || 0) & 255) << 24;
1386
+ view.setUint32(offset, pdata, true);
1375
1387
  offset += 4;
1376
1388
  }
1377
1389
  if (flags & OcgcoreCommonConstants.QUERY_ALIAS) {
@@ -1419,30 +1431,41 @@ function serializeCardQuery(card) {
1419
1431
  offset += 4;
1420
1432
  }
1421
1433
  if (flags & OcgcoreCommonConstants.QUERY_REASON_CARD) {
1422
- view.setInt32(offset, 0, true);
1434
+ const reasonCard = source.reasonCard || {
1435
+ controller: 0,
1436
+ location: 0,
1437
+ sequence: 0,
1438
+ position: 0
1439
+ };
1440
+ view.setUint8(offset, reasonCard.controller);
1441
+ view.setUint8(offset + 1, reasonCard.location);
1442
+ view.setUint8(offset + 2, reasonCard.sequence);
1443
+ view.setUint8(offset + 3, reasonCard.position || 0);
1423
1444
  offset += 4;
1424
1445
  }
1425
1446
  if (flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) {
1426
1447
  const equipCard = source.equipCard || {
1427
1448
  controller: 0,
1428
1449
  location: 0,
1429
- sequence: 0
1450
+ sequence: 0,
1451
+ position: 0
1430
1452
  };
1431
1453
  view.setUint8(offset, equipCard.controller);
1432
1454
  view.setUint8(offset + 1, equipCard.location);
1433
1455
  view.setUint8(offset + 2, equipCard.sequence);
1434
- view.setUint8(offset + 3, 0);
1456
+ view.setUint8(offset + 3, equipCard.position || 0);
1435
1457
  offset += 4;
1436
1458
  }
1437
1459
  if (flags & OcgcoreCommonConstants.QUERY_TARGET_CARD) {
1438
1460
  const targets = source.targetCards || [];
1439
1461
  view.setInt32(offset, targets.length, true);
1440
1462
  offset += 4;
1441
- for (const target of targets) {
1463
+ for (let i = 0; i < targets.length; i++) {
1464
+ const target = targets[i];
1442
1465
  view.setUint8(offset, target.controller);
1443
1466
  view.setUint8(offset + 1, target.location);
1444
1467
  view.setUint8(offset + 2, target.sequence);
1445
- view.setUint8(offset + 3, 0);
1468
+ view.setUint8(offset + 3, target.position || 0);
1446
1469
  offset += 4;
1447
1470
  }
1448
1471
  }
@@ -1565,6 +1588,13 @@ function createCodeHiddenCardQuery(source) {
1565
1588
  return card;
1566
1589
  }
1567
1590
  __name(createCodeHiddenCardQuery, "createCodeHiddenCardQuery");
1591
+ function getCardQueryPosition(card) {
1592
+ if (!card) {
1593
+ return void 0;
1594
+ }
1595
+ return typeof card.position === "number" ? card.position : void 0;
1596
+ }
1597
+ __name(getCardQueryPosition, "getCardQueryPosition");
1568
1598
 
1569
1599
  // src/proto-base/ygopro-proto-base.ts
1570
1600
  var _YGOProProtoBase = class _YGOProProtoBase extends PayloadBase {
@@ -5989,7 +6019,8 @@ var YGOProMsgUnequip = _YGOProMsgUnequip;
5989
6019
  var _YGOProMsgUpdateCard = class _YGOProMsgUpdateCard extends YGOProMsgBase {
5990
6020
  opponentView() {
5991
6021
  const copy = this.copy();
5992
- if (copy.card?.position && copy.card.position & OcgcoreCommonConstants.POS_FACEDOWN) {
6022
+ const position = getCardQueryPosition(copy.card);
6023
+ if (position && position & OcgcoreCommonConstants.POS_FACEDOWN) {
5993
6024
  copy.card = createCodeHiddenCardQuery(copy.card);
5994
6025
  }
5995
6026
  return copy;
@@ -6071,23 +6102,25 @@ var _YGOProMsgUpdateData = class _YGOProMsgUpdateData extends YGOProMsgBase {
6071
6102
  return void 0;
6072
6103
  }
6073
6104
  shouldHideForOpponent(card) {
6105
+ const position = getCardQueryPosition(card);
6074
6106
  if (this.location === OcgcoreScriptConstants.LOCATION_GRAVE) {
6075
6107
  return false;
6076
6108
  }
6077
6109
  if (this.location === OcgcoreScriptConstants.LOCATION_HAND) {
6078
- return !card.position || !(card.position & OcgcoreCommonConstants.POS_FACEUP);
6110
+ return !position || !(position & OcgcoreCommonConstants.POS_FACEUP);
6079
6111
  }
6080
- return !!(card.position && card.position & OcgcoreCommonConstants.POS_FACEDOWN);
6112
+ return !!(position && position & OcgcoreCommonConstants.POS_FACEDOWN);
6081
6113
  }
6082
6114
  shouldHideForTeammate(card) {
6115
+ const position = getCardQueryPosition(card);
6083
6116
  if (this.location === OcgcoreScriptConstants.LOCATION_MZONE || this.location === OcgcoreScriptConstants.LOCATION_SZONE || this.location === OcgcoreScriptConstants.LOCATION_REMOVED || this.location === OcgcoreScriptConstants.LOCATION_GRAVE) {
6084
6117
  return false;
6085
6118
  }
6086
6119
  if (this.location === OcgcoreScriptConstants.LOCATION_HAND) {
6087
- return !card.position || !(card.position & OcgcoreCommonConstants.POS_FACEUP);
6120
+ return !position || !(position & OcgcoreCommonConstants.POS_FACEUP);
6088
6121
  }
6089
6122
  if (this.location === OcgcoreScriptConstants.LOCATION_EXTRA) {
6090
- return !!(card.position && card.position & OcgcoreCommonConstants.POS_FACEDOWN);
6123
+ return !!(position && position & OcgcoreCommonConstants.POS_FACEDOWN);
6091
6124
  }
6092
6125
  return false;
6093
6126
  }
@@ -6919,6 +6952,7 @@ YGOProStoc.register(YGOProStocSrvproRoomlist);
6919
6952
  createClearedCardQuery,
6920
6953
  createCodeHiddenCardQuery,
6921
6954
  fillBinaryFields,
6955
+ getCardQueryPosition,
6922
6956
  isIndexResponse,
6923
6957
  parseCardQueryChunk,
6924
6958
  serializeCardQuery,