ygopro-msg-encode 1.1.30 → 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,
@@ -1202,7 +1203,9 @@ var _CardQuery = class _CardQuery {
1202
1203
  }
1203
1204
  if (this.flags & OcgcoreCommonConstants.QUERY_POSITION) {
1204
1205
  const pdata = view.getUint32(offset, true);
1205
- this.positionData = pdata;
1206
+ this.controller = pdata & 255;
1207
+ this.location = pdata >>> 8 & 255;
1208
+ this.sequence = pdata >>> 16 & 255;
1206
1209
  this.position = (pdata >>> 24 & 255) >>> 0;
1207
1210
  offset += 4;
1208
1211
  }
@@ -1251,16 +1254,20 @@ var _CardQuery = class _CardQuery {
1251
1254
  offset += 4;
1252
1255
  }
1253
1256
  if (this.flags & OcgcoreCommonConstants.QUERY_REASON_CARD) {
1254
- this.reasonCardData = view.getUint32(offset, true);
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
+ };
1255
1263
  offset += 4;
1256
1264
  }
1257
1265
  if (this.flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) {
1258
- const pdata = view.getUint32(offset, true);
1259
- this.equipCardData = pdata;
1260
1266
  this.equipCard = {
1261
1267
  controller: view.getUint8(offset),
1262
1268
  location: view.getUint8(offset + 1),
1263
- sequence: view.getUint8(offset + 2)
1269
+ sequence: view.getUint8(offset + 2),
1270
+ position: view.getUint8(offset + 3)
1264
1271
  };
1265
1272
  offset += 4;
1266
1273
  }
@@ -1268,13 +1275,12 @@ var _CardQuery = class _CardQuery {
1268
1275
  const count = view.getInt32(offset, true);
1269
1276
  offset += 4;
1270
1277
  this.targetCards = [];
1271
- this.targetCardData = [];
1272
1278
  for (let i = 0; i < count; i++) {
1273
- this.targetCardData.push(view.getUint32(offset, true));
1274
1279
  this.targetCards.push({
1275
1280
  controller: view.getUint8(offset),
1276
1281
  location: view.getUint8(offset + 1),
1277
- sequence: view.getUint8(offset + 2)
1282
+ sequence: view.getUint8(offset + 2),
1283
+ position: view.getUint8(offset + 3)
1278
1284
  });
1279
1285
  offset += 4;
1280
1286
  }
@@ -1376,7 +1382,7 @@ function serializeCardQuery(card) {
1376
1382
  offset += 4;
1377
1383
  }
1378
1384
  if (flags & OcgcoreCommonConstants.QUERY_POSITION) {
1379
- const pdata = source.positionData !== void 0 ? source.positionData >>> 0 : (source.position || 0) << 24 >>> 0;
1385
+ const pdata = (source.controller || 0) & 255 | ((source.location || 0) & 255) << 8 | ((source.sequence || 0) & 255) << 16 | ((source.position || 0) & 255) << 24;
1380
1386
  view.setUint32(offset, pdata, true);
1381
1387
  offset += 4;
1382
1388
  }
@@ -1425,25 +1431,30 @@ function serializeCardQuery(card) {
1425
1431
  offset += 4;
1426
1432
  }
1427
1433
  if (flags & OcgcoreCommonConstants.QUERY_REASON_CARD) {
1428
- view.setUint32(offset, (source.reasonCardData || 0) >>> 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);
1429
1444
  offset += 4;
1430
1445
  }
1431
1446
  if (flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) {
1432
- if (source.equipCardData !== void 0) {
1433
- view.setUint32(offset, source.equipCardData >>> 0, true);
1434
- offset += 4;
1435
- } else {
1436
- const equipCard = source.equipCard || {
1437
- controller: 0,
1438
- location: 0,
1439
- sequence: 0
1440
- };
1441
- view.setUint8(offset, equipCard.controller);
1442
- view.setUint8(offset + 1, equipCard.location);
1443
- view.setUint8(offset + 2, equipCard.sequence);
1444
- view.setUint8(offset + 3, 0);
1445
- offset += 4;
1446
- }
1447
+ const equipCard = source.equipCard || {
1448
+ controller: 0,
1449
+ location: 0,
1450
+ sequence: 0,
1451
+ position: 0
1452
+ };
1453
+ view.setUint8(offset, equipCard.controller);
1454
+ view.setUint8(offset + 1, equipCard.location);
1455
+ view.setUint8(offset + 2, equipCard.sequence);
1456
+ view.setUint8(offset + 3, equipCard.position || 0);
1457
+ offset += 4;
1447
1458
  }
1448
1459
  if (flags & OcgcoreCommonConstants.QUERY_TARGET_CARD) {
1449
1460
  const targets = source.targetCards || [];
@@ -1451,15 +1462,10 @@ function serializeCardQuery(card) {
1451
1462
  offset += 4;
1452
1463
  for (let i = 0; i < targets.length; i++) {
1453
1464
  const target = targets[i];
1454
- const rawTarget = source.targetCardData?.[i];
1455
- if (rawTarget !== void 0) {
1456
- view.setUint32(offset, rawTarget >>> 0, true);
1457
- } else {
1458
- view.setUint8(offset, target.controller);
1459
- view.setUint8(offset + 1, target.location);
1460
- view.setUint8(offset + 2, target.sequence);
1461
- view.setUint8(offset + 3, 0);
1462
- }
1465
+ view.setUint8(offset, target.controller);
1466
+ view.setUint8(offset + 1, target.location);
1467
+ view.setUint8(offset + 2, target.sequence);
1468
+ view.setUint8(offset + 3, target.position || 0);
1463
1469
  offset += 4;
1464
1470
  }
1465
1471
  }
@@ -1582,6 +1588,13 @@ function createCodeHiddenCardQuery(source) {
1582
1588
  return card;
1583
1589
  }
1584
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");
1585
1598
 
1586
1599
  // src/proto-base/ygopro-proto-base.ts
1587
1600
  var _YGOProProtoBase = class _YGOProProtoBase extends PayloadBase {
@@ -6006,7 +6019,8 @@ var YGOProMsgUnequip = _YGOProMsgUnequip;
6006
6019
  var _YGOProMsgUpdateCard = class _YGOProMsgUpdateCard extends YGOProMsgBase {
6007
6020
  opponentView() {
6008
6021
  const copy = this.copy();
6009
- if (copy.card?.position && copy.card.position & OcgcoreCommonConstants.POS_FACEDOWN) {
6022
+ const position = getCardQueryPosition(copy.card);
6023
+ if (position && position & OcgcoreCommonConstants.POS_FACEDOWN) {
6010
6024
  copy.card = createCodeHiddenCardQuery(copy.card);
6011
6025
  }
6012
6026
  return copy;
@@ -6088,23 +6102,25 @@ var _YGOProMsgUpdateData = class _YGOProMsgUpdateData extends YGOProMsgBase {
6088
6102
  return void 0;
6089
6103
  }
6090
6104
  shouldHideForOpponent(card) {
6105
+ const position = getCardQueryPosition(card);
6091
6106
  if (this.location === OcgcoreScriptConstants.LOCATION_GRAVE) {
6092
6107
  return false;
6093
6108
  }
6094
6109
  if (this.location === OcgcoreScriptConstants.LOCATION_HAND) {
6095
- return !card.position || !(card.position & OcgcoreCommonConstants.POS_FACEUP);
6110
+ return !position || !(position & OcgcoreCommonConstants.POS_FACEUP);
6096
6111
  }
6097
- return !!(card.position && card.position & OcgcoreCommonConstants.POS_FACEDOWN);
6112
+ return !!(position && position & OcgcoreCommonConstants.POS_FACEDOWN);
6098
6113
  }
6099
6114
  shouldHideForTeammate(card) {
6115
+ const position = getCardQueryPosition(card);
6100
6116
  if (this.location === OcgcoreScriptConstants.LOCATION_MZONE || this.location === OcgcoreScriptConstants.LOCATION_SZONE || this.location === OcgcoreScriptConstants.LOCATION_REMOVED || this.location === OcgcoreScriptConstants.LOCATION_GRAVE) {
6101
6117
  return false;
6102
6118
  }
6103
6119
  if (this.location === OcgcoreScriptConstants.LOCATION_HAND) {
6104
- return !card.position || !(card.position & OcgcoreCommonConstants.POS_FACEUP);
6120
+ return !position || !(position & OcgcoreCommonConstants.POS_FACEUP);
6105
6121
  }
6106
6122
  if (this.location === OcgcoreScriptConstants.LOCATION_EXTRA) {
6107
- return !!(card.position && card.position & OcgcoreCommonConstants.POS_FACEDOWN);
6123
+ return !!(position && position & OcgcoreCommonConstants.POS_FACEDOWN);
6108
6124
  }
6109
6125
  return false;
6110
6126
  }
@@ -6936,6 +6952,7 @@ YGOProStoc.register(YGOProStocSrvproRoomlist);
6936
6952
  createClearedCardQuery,
6937
6953
  createCodeHiddenCardQuery,
6938
6954
  fillBinaryFields,
6955
+ getCardQueryPosition,
6939
6956
  isIndexResponse,
6940
6957
  parseCardQueryChunk,
6941
6958
  serializeCardQuery,