ygopro-msg-encode 1.1.31 → 1.2.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.mjs CHANGED
@@ -744,23 +744,24 @@ var OcgcoreCommonConstants = {
744
744
  };
745
745
 
746
746
  // src/protos/common/card-data.ts
747
- var CARD_ARTWORK_VERSIONS_OFFSET = 20;
748
- var CARD_BLACK_LUSTER_SOLDIER2 = 5405695;
749
- var CARD_MARINE_DOLPHIN = 78734254;
750
- var CARD_TWINKLE_MOSS = 13857930;
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 isAlternative(this.code, this.alias) ? this.alias : this.code;
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
- 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);
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 {