ygopro-msg-encode 1.1.26 → 1.1.27

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
@@ -6049,6 +6049,15 @@ var YGOProMsgUpdateCard = _YGOProMsgUpdateCard;
6049
6049
 
6050
6050
  // src/protos/msg/proto/update-data.ts
6051
6051
  var _YGOProMsgUpdateData = class _YGOProMsgUpdateData extends YGOProMsgBase {
6052
+ getFixedSlotCount() {
6053
+ if (this.location === OcgcoreScriptConstants.LOCATION_MZONE) {
6054
+ return 7;
6055
+ }
6056
+ if (this.location === OcgcoreScriptConstants.LOCATION_SZONE) {
6057
+ return 8;
6058
+ }
6059
+ return void 0;
6060
+ }
6052
6061
  shouldHideForOpponent(card) {
6053
6062
  if (this.location === OcgcoreScriptConstants.LOCATION_GRAVE) {
6054
6063
  return false;
@@ -6123,9 +6132,25 @@ var _YGOProMsgUpdateData = class _YGOProMsgUpdateData extends YGOProMsgBase {
6123
6132
  return this;
6124
6133
  }
6125
6134
  toPayload() {
6135
+ const inputCards = this.cards || [];
6136
+ const fixedSlotCount = this.getFixedSlotCount();
6137
+ let cardsToEncode = inputCards;
6138
+ if (fixedSlotCount !== void 0) {
6139
+ if (inputCards.length > fixedSlotCount) {
6140
+ throw new Error(
6141
+ `MSG_UPDATE_DATA location ${this.location} expects at most ${fixedSlotCount} chunks, got ${inputCards.length}`
6142
+ );
6143
+ }
6144
+ if (inputCards.length < fixedSlotCount) {
6145
+ cardsToEncode = inputCards.slice();
6146
+ for (let i = inputCards.length; i < fixedSlotCount; i++) {
6147
+ cardsToEncode.push(createClearedCardQuery());
6148
+ }
6149
+ }
6150
+ }
6126
6151
  let totalSize = 3;
6127
6152
  const chunks = [];
6128
- for (const card of this.cards || []) {
6153
+ for (const card of cardsToEncode) {
6129
6154
  const chunk = serializeCardQueryChunk(card);
6130
6155
  chunks.push(chunk);
6131
6156
  totalSize += chunk.length;