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.mjs
CHANGED
|
@@ -744,23 +744,24 @@ var OcgcoreCommonConstants = {
|
|
|
744
744
|
};
|
|
745
745
|
|
|
746
746
|
// src/protos/common/card-data.ts
|
|
747
|
-
var
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
747
|
+
var SECOND_CODE_CARDS = /* @__PURE__ */ new Set([
|
|
748
|
+
78734254,
|
|
749
|
+
// CARD_MARINE_DOLPHIN
|
|
750
|
+
13857930,
|
|
751
|
+
// CARD_TWINKLE_MOSS
|
|
752
|
+
1784686,
|
|
753
|
+
// CARD_TIMAEUS
|
|
754
|
+
11082056,
|
|
755
|
+
// CARD_CRITIAS
|
|
756
|
+
46232525
|
|
757
|
+
// CARD_HERMOS
|
|
758
|
+
]);
|
|
751
759
|
function checkSetcode(setcode, value) {
|
|
752
760
|
const settype = value & 4095;
|
|
753
761
|
const setsubtype = value & 61440;
|
|
754
|
-
return setcode && (setcode & 4095) === settype && (setcode & setsubtype) === setsubtype;
|
|
762
|
+
return !!setcode && (setcode & 4095) === settype && (setcode & setsubtype) === setsubtype;
|
|
755
763
|
}
|
|
756
764
|
__name(checkSetcode, "checkSetcode");
|
|
757
|
-
function isAlternative(code, alias) {
|
|
758
|
-
if (code === CARD_BLACK_LUSTER_SOLDIER2) {
|
|
759
|
-
return false;
|
|
760
|
-
}
|
|
761
|
-
return alias && alias < code + CARD_ARTWORK_VERSIONS_OFFSET && code < alias + CARD_ARTWORK_VERSIONS_OFFSET;
|
|
762
|
-
}
|
|
763
|
-
__name(isAlternative, "isAlternative");
|
|
764
765
|
var CardData = class extends PayloadBase {
|
|
765
766
|
static {
|
|
766
767
|
__name(this, "CardData");
|
|
@@ -781,12 +782,11 @@ var CardData = class extends PayloadBase {
|
|
|
781
782
|
}
|
|
782
783
|
return false;
|
|
783
784
|
}
|
|
784
|
-
/**
|
|
785
|
-
* Get the original code of this card (handles alternate artworks)
|
|
786
|
-
* @returns The original card code
|
|
787
|
-
*/
|
|
788
785
|
getOriginalCode() {
|
|
789
|
-
return
|
|
786
|
+
return this.alias ? this.alias : this.code;
|
|
787
|
+
}
|
|
788
|
+
getDuelCode() {
|
|
789
|
+
return this.ruleCode ? this.ruleCode : this.getOriginalCode();
|
|
790
790
|
}
|
|
791
791
|
/**
|
|
792
792
|
* Check if this card can be declared with the given opcode filter
|
|
@@ -794,6 +794,9 @@ var CardData = class extends PayloadBase {
|
|
|
794
794
|
* @returns true if the card can be declared
|
|
795
795
|
*/
|
|
796
796
|
isDeclarable(opcode) {
|
|
797
|
+
if (this.alias) {
|
|
798
|
+
return false;
|
|
799
|
+
}
|
|
797
800
|
const stack = [];
|
|
798
801
|
for (const it of opcode) {
|
|
799
802
|
switch (it) {
|
|
@@ -825,7 +828,7 @@ var CardData = class extends PayloadBase {
|
|
|
825
828
|
if (stack.length >= 2) {
|
|
826
829
|
const rhs = stack.pop();
|
|
827
830
|
const lhs = stack.pop();
|
|
828
|
-
stack.push(Math.floor(lhs / rhs));
|
|
831
|
+
stack.push(rhs !== 0 ? Math.floor(lhs / rhs) : 0);
|
|
829
832
|
}
|
|
830
833
|
break;
|
|
831
834
|
}
|
|
@@ -904,7 +907,10 @@ var CardData = class extends PayloadBase {
|
|
|
904
907
|
if (stack.length !== 1 || stack[0] === 0) {
|
|
905
908
|
return false;
|
|
906
909
|
}
|
|
907
|
-
|
|
910
|
+
if (!SECOND_CODE_CARDS.has(this.code) && (this.ruleCode || this.type & OcgcoreCommonConstants.TYPE_TOKEN)) {
|
|
911
|
+
return false;
|
|
912
|
+
}
|
|
913
|
+
return true;
|
|
908
914
|
}
|
|
909
915
|
};
|
|
910
916
|
__decorateClass([
|
|
@@ -943,6 +949,9 @@ __decorateClass([
|
|
|
943
949
|
__decorateClass([
|
|
944
950
|
BinaryField("u32", 72)
|
|
945
951
|
], CardData.prototype, "linkMarker", 2);
|
|
952
|
+
__decorateClass([
|
|
953
|
+
BinaryField("u32", 76)
|
|
954
|
+
], CardData.prototype, "ruleCode", 2);
|
|
946
955
|
|
|
947
956
|
// src/protos/common/card-query.ts
|
|
948
957
|
var CardQuery_CardLocation = class {
|
|
@@ -978,7 +987,9 @@ var CardQuery = class {
|
|
|
978
987
|
}
|
|
979
988
|
if (this.flags & OcgcoreCommonConstants.QUERY_POSITION) {
|
|
980
989
|
const pdata = view.getUint32(offset, true);
|
|
981
|
-
this.
|
|
990
|
+
this.controller = pdata & 255;
|
|
991
|
+
this.location = pdata >>> 8 & 255;
|
|
992
|
+
this.sequence = pdata >>> 16 & 255;
|
|
982
993
|
this.position = (pdata >>> 24 & 255) >>> 0;
|
|
983
994
|
offset += 4;
|
|
984
995
|
}
|
|
@@ -1027,16 +1038,20 @@ var CardQuery = class {
|
|
|
1027
1038
|
offset += 4;
|
|
1028
1039
|
}
|
|
1029
1040
|
if (this.flags & OcgcoreCommonConstants.QUERY_REASON_CARD) {
|
|
1030
|
-
this.
|
|
1041
|
+
this.reasonCard = {
|
|
1042
|
+
controller: view.getUint8(offset),
|
|
1043
|
+
location: view.getUint8(offset + 1),
|
|
1044
|
+
sequence: view.getUint8(offset + 2),
|
|
1045
|
+
position: view.getUint8(offset + 3)
|
|
1046
|
+
};
|
|
1031
1047
|
offset += 4;
|
|
1032
1048
|
}
|
|
1033
1049
|
if (this.flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) {
|
|
1034
|
-
const pdata = view.getUint32(offset, true);
|
|
1035
|
-
this.equipCardData = pdata;
|
|
1036
1050
|
this.equipCard = {
|
|
1037
1051
|
controller: view.getUint8(offset),
|
|
1038
1052
|
location: view.getUint8(offset + 1),
|
|
1039
|
-
sequence: view.getUint8(offset + 2)
|
|
1053
|
+
sequence: view.getUint8(offset + 2),
|
|
1054
|
+
position: view.getUint8(offset + 3)
|
|
1040
1055
|
};
|
|
1041
1056
|
offset += 4;
|
|
1042
1057
|
}
|
|
@@ -1044,13 +1059,12 @@ var CardQuery = class {
|
|
|
1044
1059
|
const count = view.getInt32(offset, true);
|
|
1045
1060
|
offset += 4;
|
|
1046
1061
|
this.targetCards = [];
|
|
1047
|
-
this.targetCardData = [];
|
|
1048
1062
|
for (let i = 0; i < count; i++) {
|
|
1049
|
-
this.targetCardData.push(view.getUint32(offset, true));
|
|
1050
1063
|
this.targetCards.push({
|
|
1051
1064
|
controller: view.getUint8(offset),
|
|
1052
1065
|
location: view.getUint8(offset + 1),
|
|
1053
|
-
sequence: view.getUint8(offset + 2)
|
|
1066
|
+
sequence: view.getUint8(offset + 2),
|
|
1067
|
+
position: view.getUint8(offset + 3)
|
|
1054
1068
|
});
|
|
1055
1069
|
offset += 4;
|
|
1056
1070
|
}
|
|
@@ -1150,7 +1164,7 @@ function serializeCardQuery(card) {
|
|
|
1150
1164
|
offset += 4;
|
|
1151
1165
|
}
|
|
1152
1166
|
if (flags & OcgcoreCommonConstants.QUERY_POSITION) {
|
|
1153
|
-
const pdata = source.
|
|
1167
|
+
const pdata = (source.controller || 0) & 255 | ((source.location || 0) & 255) << 8 | ((source.sequence || 0) & 255) << 16 | ((source.position || 0) & 255) << 24;
|
|
1154
1168
|
view.setUint32(offset, pdata, true);
|
|
1155
1169
|
offset += 4;
|
|
1156
1170
|
}
|
|
@@ -1199,25 +1213,30 @@ function serializeCardQuery(card) {
|
|
|
1199
1213
|
offset += 4;
|
|
1200
1214
|
}
|
|
1201
1215
|
if (flags & OcgcoreCommonConstants.QUERY_REASON_CARD) {
|
|
1202
|
-
|
|
1216
|
+
const reasonCard = source.reasonCard || {
|
|
1217
|
+
controller: 0,
|
|
1218
|
+
location: 0,
|
|
1219
|
+
sequence: 0,
|
|
1220
|
+
position: 0
|
|
1221
|
+
};
|
|
1222
|
+
view.setUint8(offset, reasonCard.controller);
|
|
1223
|
+
view.setUint8(offset + 1, reasonCard.location);
|
|
1224
|
+
view.setUint8(offset + 2, reasonCard.sequence);
|
|
1225
|
+
view.setUint8(offset + 3, reasonCard.position || 0);
|
|
1203
1226
|
offset += 4;
|
|
1204
1227
|
}
|
|
1205
1228
|
if (flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) {
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
view.setUint8(offset + 2, equipCard.sequence);
|
|
1218
|
-
view.setUint8(offset + 3, 0);
|
|
1219
|
-
offset += 4;
|
|
1220
|
-
}
|
|
1229
|
+
const equipCard = source.equipCard || {
|
|
1230
|
+
controller: 0,
|
|
1231
|
+
location: 0,
|
|
1232
|
+
sequence: 0,
|
|
1233
|
+
position: 0
|
|
1234
|
+
};
|
|
1235
|
+
view.setUint8(offset, equipCard.controller);
|
|
1236
|
+
view.setUint8(offset + 1, equipCard.location);
|
|
1237
|
+
view.setUint8(offset + 2, equipCard.sequence);
|
|
1238
|
+
view.setUint8(offset + 3, equipCard.position || 0);
|
|
1239
|
+
offset += 4;
|
|
1221
1240
|
}
|
|
1222
1241
|
if (flags & OcgcoreCommonConstants.QUERY_TARGET_CARD) {
|
|
1223
1242
|
const targets = source.targetCards || [];
|
|
@@ -1225,15 +1244,10 @@ function serializeCardQuery(card) {
|
|
|
1225
1244
|
offset += 4;
|
|
1226
1245
|
for (let i = 0; i < targets.length; i++) {
|
|
1227
1246
|
const target = targets[i];
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
view.setUint8(offset, target.controller);
|
|
1233
|
-
view.setUint8(offset + 1, target.location);
|
|
1234
|
-
view.setUint8(offset + 2, target.sequence);
|
|
1235
|
-
view.setUint8(offset + 3, 0);
|
|
1236
|
-
}
|
|
1247
|
+
view.setUint8(offset, target.controller);
|
|
1248
|
+
view.setUint8(offset + 1, target.location);
|
|
1249
|
+
view.setUint8(offset + 2, target.sequence);
|
|
1250
|
+
view.setUint8(offset + 3, target.position || 0);
|
|
1237
1251
|
offset += 4;
|
|
1238
1252
|
}
|
|
1239
1253
|
}
|
|
@@ -1356,6 +1370,13 @@ function createCodeHiddenCardQuery(source) {
|
|
|
1356
1370
|
return card;
|
|
1357
1371
|
}
|
|
1358
1372
|
__name(createCodeHiddenCardQuery, "createCodeHiddenCardQuery");
|
|
1373
|
+
function getCardQueryPosition(card) {
|
|
1374
|
+
if (!card) {
|
|
1375
|
+
return void 0;
|
|
1376
|
+
}
|
|
1377
|
+
return typeof card.position === "number" ? card.position : void 0;
|
|
1378
|
+
}
|
|
1379
|
+
__name(getCardQueryPosition, "getCardQueryPosition");
|
|
1359
1380
|
|
|
1360
1381
|
// src/proto-base/ygopro-proto-base.ts
|
|
1361
1382
|
var YGOProProtoBase = class extends PayloadBase {
|
|
@@ -6137,7 +6158,8 @@ var YGOProMsgUpdateCard = class extends YGOProMsgBase {
|
|
|
6137
6158
|
}
|
|
6138
6159
|
opponentView() {
|
|
6139
6160
|
const copy = this.copy();
|
|
6140
|
-
|
|
6161
|
+
const position = getCardQueryPosition(copy.card);
|
|
6162
|
+
if (position && position & OcgcoreCommonConstants.POS_FACEDOWN) {
|
|
6141
6163
|
copy.card = createCodeHiddenCardQuery(copy.card);
|
|
6142
6164
|
}
|
|
6143
6165
|
return copy;
|
|
@@ -6222,23 +6244,25 @@ var YGOProMsgUpdateData = class extends YGOProMsgBase {
|
|
|
6222
6244
|
return void 0;
|
|
6223
6245
|
}
|
|
6224
6246
|
shouldHideForOpponent(card) {
|
|
6247
|
+
const position = getCardQueryPosition(card);
|
|
6225
6248
|
if (this.location === OcgcoreScriptConstants.LOCATION_GRAVE) {
|
|
6226
6249
|
return false;
|
|
6227
6250
|
}
|
|
6228
6251
|
if (this.location === OcgcoreScriptConstants.LOCATION_HAND) {
|
|
6229
|
-
return !
|
|
6252
|
+
return !position || !(position & OcgcoreCommonConstants.POS_FACEUP);
|
|
6230
6253
|
}
|
|
6231
|
-
return !!(
|
|
6254
|
+
return !!(position && position & OcgcoreCommonConstants.POS_FACEDOWN);
|
|
6232
6255
|
}
|
|
6233
6256
|
shouldHideForTeammate(card) {
|
|
6257
|
+
const position = getCardQueryPosition(card);
|
|
6234
6258
|
if (this.location === OcgcoreScriptConstants.LOCATION_MZONE || this.location === OcgcoreScriptConstants.LOCATION_SZONE || this.location === OcgcoreScriptConstants.LOCATION_REMOVED || this.location === OcgcoreScriptConstants.LOCATION_GRAVE) {
|
|
6235
6259
|
return false;
|
|
6236
6260
|
}
|
|
6237
6261
|
if (this.location === OcgcoreScriptConstants.LOCATION_HAND) {
|
|
6238
|
-
return !
|
|
6262
|
+
return !position || !(position & OcgcoreCommonConstants.POS_FACEUP);
|
|
6239
6263
|
}
|
|
6240
6264
|
if (this.location === OcgcoreScriptConstants.LOCATION_EXTRA) {
|
|
6241
|
-
return !!(
|
|
6265
|
+
return !!(position && position & OcgcoreCommonConstants.POS_FACEDOWN);
|
|
6242
6266
|
}
|
|
6243
6267
|
return false;
|
|
6244
6268
|
}
|
|
@@ -7148,6 +7172,7 @@ export {
|
|
|
7148
7172
|
createClearedCardQuery,
|
|
7149
7173
|
createCodeHiddenCardQuery,
|
|
7150
7174
|
fillBinaryFields,
|
|
7175
|
+
getCardQueryPosition,
|
|
7151
7176
|
isIndexResponse,
|
|
7152
7177
|
parseCardQueryChunk,
|
|
7153
7178
|
serializeCardQuery,
|