ygopro-msg-encode 1.1.31 → 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 CHANGED
@@ -975,23 +975,24 @@ var OcgcoreCommonConstants = {
975
975
  };
976
976
 
977
977
  // src/protos/common/card-data.ts
978
- var CARD_ARTWORK_VERSIONS_OFFSET = 20;
979
- var CARD_BLACK_LUSTER_SOLDIER2 = 5405695;
980
- var CARD_MARINE_DOLPHIN = 78734254;
981
- var CARD_TWINKLE_MOSS = 13857930;
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
+ ]);
982
990
  function checkSetcode(setcode, value) {
983
991
  const settype = value & 4095;
984
992
  const setsubtype = value & 61440;
985
- return setcode && (setcode & 4095) === settype && (setcode & setsubtype) === setsubtype;
993
+ return !!setcode && (setcode & 4095) === settype && (setcode & setsubtype) === setsubtype;
986
994
  }
987
995
  __name(checkSetcode, "checkSetcode");
988
- function isAlternative(code, alias) {
989
- if (code === CARD_BLACK_LUSTER_SOLDIER2) {
990
- return false;
991
- }
992
- return alias && alias < code + CARD_ARTWORK_VERSIONS_OFFSET && code < alias + CARD_ARTWORK_VERSIONS_OFFSET;
993
- }
994
- __name(isAlternative, "isAlternative");
995
996
  var _CardData = class _CardData extends PayloadBase {
996
997
  /**
997
998
  * Check if this card belongs to a specific setcode
@@ -1009,12 +1010,11 @@ var _CardData = class _CardData extends PayloadBase {
1009
1010
  }
1010
1011
  return false;
1011
1012
  }
1012
- /**
1013
- * Get the original code of this card (handles alternate artworks)
1014
- * @returns The original card code
1015
- */
1016
1013
  getOriginalCode() {
1017
- return isAlternative(this.code, this.alias) ? this.alias : this.code;
1014
+ return this.alias ? this.alias : this.code;
1015
+ }
1016
+ getDuelCode() {
1017
+ return this.ruleCode ? this.ruleCode : this.getOriginalCode();
1018
1018
  }
1019
1019
  /**
1020
1020
  * Check if this card can be declared with the given opcode filter
@@ -1022,6 +1022,9 @@ var _CardData = class _CardData extends PayloadBase {
1022
1022
  * @returns true if the card can be declared
1023
1023
  */
1024
1024
  isDeclarable(opcode) {
1025
+ if (this.alias) {
1026
+ return false;
1027
+ }
1025
1028
  const stack = [];
1026
1029
  for (const it of opcode) {
1027
1030
  switch (it) {
@@ -1053,7 +1056,7 @@ var _CardData = class _CardData extends PayloadBase {
1053
1056
  if (stack.length >= 2) {
1054
1057
  const rhs = stack.pop();
1055
1058
  const lhs = stack.pop();
1056
- stack.push(Math.floor(lhs / rhs));
1059
+ stack.push(rhs !== 0 ? Math.floor(lhs / rhs) : 0);
1057
1060
  }
1058
1061
  break;
1059
1062
  }
@@ -1132,7 +1135,10 @@ var _CardData = class _CardData extends PayloadBase {
1132
1135
  if (stack.length !== 1 || stack[0] === 0) {
1133
1136
  return false;
1134
1137
  }
1135
- return this.code === CARD_MARINE_DOLPHIN || this.code === CARD_TWINKLE_MOSS || !this.alias && (this.type & (OcgcoreCommonConstants.TYPE_MONSTER | OcgcoreCommonConstants.TYPE_TOKEN)) !== (OcgcoreCommonConstants.TYPE_MONSTER | OcgcoreCommonConstants.TYPE_TOKEN);
1138
+ if (!SECOND_CODE_CARDS.has(this.code) && (this.ruleCode || this.type & OcgcoreCommonConstants.TYPE_TOKEN)) {
1139
+ return false;
1140
+ }
1141
+ return true;
1136
1142
  }
1137
1143
  };
1138
1144
  __name(_CardData, "CardData");
@@ -1172,6 +1178,9 @@ __decorateClass([
1172
1178
  __decorateClass([
1173
1179
  BinaryField("u32", 72)
1174
1180
  ], _CardData.prototype, "linkMarker", 2);
1181
+ __decorateClass([
1182
+ BinaryField("u32", 76)
1183
+ ], _CardData.prototype, "ruleCode", 2);
1175
1184
  var CardData = _CardData;
1176
1185
 
1177
1186
  // src/protos/common/card-query.ts