ygopro-msg-encode 1.1.30 → 1.2.0-0
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 +84 -58
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +83 -58
- package/dist/index.mjs.map +2 -2
- package/dist/src/protos/common/card-data.d.ts +2 -4
- package/dist/src/protos/common/card-query.d.ts +6 -4
- package/package.json +1 -1
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,
|
|
@@ -974,23 +975,24 @@ var OcgcoreCommonConstants = {
|
|
|
974
975
|
};
|
|
975
976
|
|
|
976
977
|
// src/protos/common/card-data.ts
|
|
977
|
-
var
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
978
|
+
var SECOND_CODE_CARDS = /* @__PURE__ */ new Set([
|
|
979
|
+
78734254,
|
|
980
|
+
// CARD_MARINE_DOLPHIN
|
|
981
|
+
13857930,
|
|
982
|
+
// CARD_TWINKLE_MOSS
|
|
983
|
+
1784686,
|
|
984
|
+
// CARD_TIMAEUS
|
|
985
|
+
11082056,
|
|
986
|
+
// CARD_CRITIAS
|
|
987
|
+
46232525
|
|
988
|
+
// CARD_HERMOS
|
|
989
|
+
]);
|
|
981
990
|
function checkSetcode(setcode, value) {
|
|
982
991
|
const settype = value & 4095;
|
|
983
992
|
const setsubtype = value & 61440;
|
|
984
|
-
return setcode && (setcode & 4095) === settype && (setcode & setsubtype) === setsubtype;
|
|
993
|
+
return !!setcode && (setcode & 4095) === settype && (setcode & setsubtype) === setsubtype;
|
|
985
994
|
}
|
|
986
995
|
__name(checkSetcode, "checkSetcode");
|
|
987
|
-
function isAlternative(code, alias) {
|
|
988
|
-
if (code === CARD_BLACK_LUSTER_SOLDIER2) {
|
|
989
|
-
return false;
|
|
990
|
-
}
|
|
991
|
-
return alias && alias < code + CARD_ARTWORK_VERSIONS_OFFSET && code < alias + CARD_ARTWORK_VERSIONS_OFFSET;
|
|
992
|
-
}
|
|
993
|
-
__name(isAlternative, "isAlternative");
|
|
994
996
|
var _CardData = class _CardData extends PayloadBase {
|
|
995
997
|
/**
|
|
996
998
|
* Check if this card belongs to a specific setcode
|
|
@@ -1008,12 +1010,11 @@ var _CardData = class _CardData extends PayloadBase {
|
|
|
1008
1010
|
}
|
|
1009
1011
|
return false;
|
|
1010
1012
|
}
|
|
1011
|
-
/**
|
|
1012
|
-
* Get the original code of this card (handles alternate artworks)
|
|
1013
|
-
* @returns The original card code
|
|
1014
|
-
*/
|
|
1015
1013
|
getOriginalCode() {
|
|
1016
|
-
return
|
|
1014
|
+
return this.alias ? this.alias : this.code;
|
|
1015
|
+
}
|
|
1016
|
+
getDuelCode() {
|
|
1017
|
+
return this.ruleCode ? this.ruleCode : this.getOriginalCode();
|
|
1017
1018
|
}
|
|
1018
1019
|
/**
|
|
1019
1020
|
* Check if this card can be declared with the given opcode filter
|
|
@@ -1021,6 +1022,9 @@ var _CardData = class _CardData extends PayloadBase {
|
|
|
1021
1022
|
* @returns true if the card can be declared
|
|
1022
1023
|
*/
|
|
1023
1024
|
isDeclarable(opcode) {
|
|
1025
|
+
if (this.alias) {
|
|
1026
|
+
return false;
|
|
1027
|
+
}
|
|
1024
1028
|
const stack = [];
|
|
1025
1029
|
for (const it of opcode) {
|
|
1026
1030
|
switch (it) {
|
|
@@ -1052,7 +1056,7 @@ var _CardData = class _CardData extends PayloadBase {
|
|
|
1052
1056
|
if (stack.length >= 2) {
|
|
1053
1057
|
const rhs = stack.pop();
|
|
1054
1058
|
const lhs = stack.pop();
|
|
1055
|
-
stack.push(Math.floor(lhs / rhs));
|
|
1059
|
+
stack.push(rhs !== 0 ? Math.floor(lhs / rhs) : 0);
|
|
1056
1060
|
}
|
|
1057
1061
|
break;
|
|
1058
1062
|
}
|
|
@@ -1131,7 +1135,10 @@ var _CardData = class _CardData extends PayloadBase {
|
|
|
1131
1135
|
if (stack.length !== 1 || stack[0] === 0) {
|
|
1132
1136
|
return false;
|
|
1133
1137
|
}
|
|
1134
|
-
|
|
1138
|
+
if (!SECOND_CODE_CARDS.has(this.code) && (this.ruleCode || this.type & OcgcoreCommonConstants.TYPE_TOKEN)) {
|
|
1139
|
+
return false;
|
|
1140
|
+
}
|
|
1141
|
+
return true;
|
|
1135
1142
|
}
|
|
1136
1143
|
};
|
|
1137
1144
|
__name(_CardData, "CardData");
|
|
@@ -1171,6 +1178,9 @@ __decorateClass([
|
|
|
1171
1178
|
__decorateClass([
|
|
1172
1179
|
BinaryField("u32", 72)
|
|
1173
1180
|
], _CardData.prototype, "linkMarker", 2);
|
|
1181
|
+
__decorateClass([
|
|
1182
|
+
BinaryField("u32", 76)
|
|
1183
|
+
], _CardData.prototype, "ruleCode", 2);
|
|
1174
1184
|
var CardData = _CardData;
|
|
1175
1185
|
|
|
1176
1186
|
// src/protos/common/card-query.ts
|
|
@@ -1202,7 +1212,9 @@ var _CardQuery = class _CardQuery {
|
|
|
1202
1212
|
}
|
|
1203
1213
|
if (this.flags & OcgcoreCommonConstants.QUERY_POSITION) {
|
|
1204
1214
|
const pdata = view.getUint32(offset, true);
|
|
1205
|
-
this.
|
|
1215
|
+
this.controller = pdata & 255;
|
|
1216
|
+
this.location = pdata >>> 8 & 255;
|
|
1217
|
+
this.sequence = pdata >>> 16 & 255;
|
|
1206
1218
|
this.position = (pdata >>> 24 & 255) >>> 0;
|
|
1207
1219
|
offset += 4;
|
|
1208
1220
|
}
|
|
@@ -1251,16 +1263,20 @@ var _CardQuery = class _CardQuery {
|
|
|
1251
1263
|
offset += 4;
|
|
1252
1264
|
}
|
|
1253
1265
|
if (this.flags & OcgcoreCommonConstants.QUERY_REASON_CARD) {
|
|
1254
|
-
this.
|
|
1266
|
+
this.reasonCard = {
|
|
1267
|
+
controller: view.getUint8(offset),
|
|
1268
|
+
location: view.getUint8(offset + 1),
|
|
1269
|
+
sequence: view.getUint8(offset + 2),
|
|
1270
|
+
position: view.getUint8(offset + 3)
|
|
1271
|
+
};
|
|
1255
1272
|
offset += 4;
|
|
1256
1273
|
}
|
|
1257
1274
|
if (this.flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) {
|
|
1258
|
-
const pdata = view.getUint32(offset, true);
|
|
1259
|
-
this.equipCardData = pdata;
|
|
1260
1275
|
this.equipCard = {
|
|
1261
1276
|
controller: view.getUint8(offset),
|
|
1262
1277
|
location: view.getUint8(offset + 1),
|
|
1263
|
-
sequence: view.getUint8(offset + 2)
|
|
1278
|
+
sequence: view.getUint8(offset + 2),
|
|
1279
|
+
position: view.getUint8(offset + 3)
|
|
1264
1280
|
};
|
|
1265
1281
|
offset += 4;
|
|
1266
1282
|
}
|
|
@@ -1268,13 +1284,12 @@ var _CardQuery = class _CardQuery {
|
|
|
1268
1284
|
const count = view.getInt32(offset, true);
|
|
1269
1285
|
offset += 4;
|
|
1270
1286
|
this.targetCards = [];
|
|
1271
|
-
this.targetCardData = [];
|
|
1272
1287
|
for (let i = 0; i < count; i++) {
|
|
1273
|
-
this.targetCardData.push(view.getUint32(offset, true));
|
|
1274
1288
|
this.targetCards.push({
|
|
1275
1289
|
controller: view.getUint8(offset),
|
|
1276
1290
|
location: view.getUint8(offset + 1),
|
|
1277
|
-
sequence: view.getUint8(offset + 2)
|
|
1291
|
+
sequence: view.getUint8(offset + 2),
|
|
1292
|
+
position: view.getUint8(offset + 3)
|
|
1278
1293
|
});
|
|
1279
1294
|
offset += 4;
|
|
1280
1295
|
}
|
|
@@ -1376,7 +1391,7 @@ function serializeCardQuery(card) {
|
|
|
1376
1391
|
offset += 4;
|
|
1377
1392
|
}
|
|
1378
1393
|
if (flags & OcgcoreCommonConstants.QUERY_POSITION) {
|
|
1379
|
-
const pdata = source.
|
|
1394
|
+
const pdata = (source.controller || 0) & 255 | ((source.location || 0) & 255) << 8 | ((source.sequence || 0) & 255) << 16 | ((source.position || 0) & 255) << 24;
|
|
1380
1395
|
view.setUint32(offset, pdata, true);
|
|
1381
1396
|
offset += 4;
|
|
1382
1397
|
}
|
|
@@ -1425,25 +1440,30 @@ function serializeCardQuery(card) {
|
|
|
1425
1440
|
offset += 4;
|
|
1426
1441
|
}
|
|
1427
1442
|
if (flags & OcgcoreCommonConstants.QUERY_REASON_CARD) {
|
|
1428
|
-
|
|
1443
|
+
const reasonCard = source.reasonCard || {
|
|
1444
|
+
controller: 0,
|
|
1445
|
+
location: 0,
|
|
1446
|
+
sequence: 0,
|
|
1447
|
+
position: 0
|
|
1448
|
+
};
|
|
1449
|
+
view.setUint8(offset, reasonCard.controller);
|
|
1450
|
+
view.setUint8(offset + 1, reasonCard.location);
|
|
1451
|
+
view.setUint8(offset + 2, reasonCard.sequence);
|
|
1452
|
+
view.setUint8(offset + 3, reasonCard.position || 0);
|
|
1429
1453
|
offset += 4;
|
|
1430
1454
|
}
|
|
1431
1455
|
if (flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) {
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
view.setUint8(offset + 2, equipCard.sequence);
|
|
1444
|
-
view.setUint8(offset + 3, 0);
|
|
1445
|
-
offset += 4;
|
|
1446
|
-
}
|
|
1456
|
+
const equipCard = source.equipCard || {
|
|
1457
|
+
controller: 0,
|
|
1458
|
+
location: 0,
|
|
1459
|
+
sequence: 0,
|
|
1460
|
+
position: 0
|
|
1461
|
+
};
|
|
1462
|
+
view.setUint8(offset, equipCard.controller);
|
|
1463
|
+
view.setUint8(offset + 1, equipCard.location);
|
|
1464
|
+
view.setUint8(offset + 2, equipCard.sequence);
|
|
1465
|
+
view.setUint8(offset + 3, equipCard.position || 0);
|
|
1466
|
+
offset += 4;
|
|
1447
1467
|
}
|
|
1448
1468
|
if (flags & OcgcoreCommonConstants.QUERY_TARGET_CARD) {
|
|
1449
1469
|
const targets = source.targetCards || [];
|
|
@@ -1451,15 +1471,10 @@ function serializeCardQuery(card) {
|
|
|
1451
1471
|
offset += 4;
|
|
1452
1472
|
for (let i = 0; i < targets.length; i++) {
|
|
1453
1473
|
const target = targets[i];
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
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
|
-
}
|
|
1474
|
+
view.setUint8(offset, target.controller);
|
|
1475
|
+
view.setUint8(offset + 1, target.location);
|
|
1476
|
+
view.setUint8(offset + 2, target.sequence);
|
|
1477
|
+
view.setUint8(offset + 3, target.position || 0);
|
|
1463
1478
|
offset += 4;
|
|
1464
1479
|
}
|
|
1465
1480
|
}
|
|
@@ -1582,6 +1597,13 @@ function createCodeHiddenCardQuery(source) {
|
|
|
1582
1597
|
return card;
|
|
1583
1598
|
}
|
|
1584
1599
|
__name(createCodeHiddenCardQuery, "createCodeHiddenCardQuery");
|
|
1600
|
+
function getCardQueryPosition(card) {
|
|
1601
|
+
if (!card) {
|
|
1602
|
+
return void 0;
|
|
1603
|
+
}
|
|
1604
|
+
return typeof card.position === "number" ? card.position : void 0;
|
|
1605
|
+
}
|
|
1606
|
+
__name(getCardQueryPosition, "getCardQueryPosition");
|
|
1585
1607
|
|
|
1586
1608
|
// src/proto-base/ygopro-proto-base.ts
|
|
1587
1609
|
var _YGOProProtoBase = class _YGOProProtoBase extends PayloadBase {
|
|
@@ -6006,7 +6028,8 @@ var YGOProMsgUnequip = _YGOProMsgUnequip;
|
|
|
6006
6028
|
var _YGOProMsgUpdateCard = class _YGOProMsgUpdateCard extends YGOProMsgBase {
|
|
6007
6029
|
opponentView() {
|
|
6008
6030
|
const copy = this.copy();
|
|
6009
|
-
|
|
6031
|
+
const position = getCardQueryPosition(copy.card);
|
|
6032
|
+
if (position && position & OcgcoreCommonConstants.POS_FACEDOWN) {
|
|
6010
6033
|
copy.card = createCodeHiddenCardQuery(copy.card);
|
|
6011
6034
|
}
|
|
6012
6035
|
return copy;
|
|
@@ -6088,23 +6111,25 @@ var _YGOProMsgUpdateData = class _YGOProMsgUpdateData extends YGOProMsgBase {
|
|
|
6088
6111
|
return void 0;
|
|
6089
6112
|
}
|
|
6090
6113
|
shouldHideForOpponent(card) {
|
|
6114
|
+
const position = getCardQueryPosition(card);
|
|
6091
6115
|
if (this.location === OcgcoreScriptConstants.LOCATION_GRAVE) {
|
|
6092
6116
|
return false;
|
|
6093
6117
|
}
|
|
6094
6118
|
if (this.location === OcgcoreScriptConstants.LOCATION_HAND) {
|
|
6095
|
-
return !
|
|
6119
|
+
return !position || !(position & OcgcoreCommonConstants.POS_FACEUP);
|
|
6096
6120
|
}
|
|
6097
|
-
return !!(
|
|
6121
|
+
return !!(position && position & OcgcoreCommonConstants.POS_FACEDOWN);
|
|
6098
6122
|
}
|
|
6099
6123
|
shouldHideForTeammate(card) {
|
|
6124
|
+
const position = getCardQueryPosition(card);
|
|
6100
6125
|
if (this.location === OcgcoreScriptConstants.LOCATION_MZONE || this.location === OcgcoreScriptConstants.LOCATION_SZONE || this.location === OcgcoreScriptConstants.LOCATION_REMOVED || this.location === OcgcoreScriptConstants.LOCATION_GRAVE) {
|
|
6101
6126
|
return false;
|
|
6102
6127
|
}
|
|
6103
6128
|
if (this.location === OcgcoreScriptConstants.LOCATION_HAND) {
|
|
6104
|
-
return !
|
|
6129
|
+
return !position || !(position & OcgcoreCommonConstants.POS_FACEUP);
|
|
6105
6130
|
}
|
|
6106
6131
|
if (this.location === OcgcoreScriptConstants.LOCATION_EXTRA) {
|
|
6107
|
-
return !!(
|
|
6132
|
+
return !!(position && position & OcgcoreCommonConstants.POS_FACEDOWN);
|
|
6108
6133
|
}
|
|
6109
6134
|
return false;
|
|
6110
6135
|
}
|
|
@@ -6936,6 +6961,7 @@ YGOProStoc.register(YGOProStocSrvproRoomlist);
|
|
|
6936
6961
|
createClearedCardQuery,
|
|
6937
6962
|
createCodeHiddenCardQuery,
|
|
6938
6963
|
fillBinaryFields,
|
|
6964
|
+
getCardQueryPosition,
|
|
6939
6965
|
isIndexResponse,
|
|
6940
6966
|
parseCardQueryChunk,
|
|
6941
6967
|
serializeCardQuery,
|