ygopro-msg-encode 1.1.2 → 1.1.4

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
@@ -927,166 +927,473 @@ __decorateClass([
927
927
  BinaryField("u32", 72)
928
928
  ], CardData.prototype, "linkMarker", 2);
929
929
 
930
- // src/protos/ctos/base.ts
931
- var YGOProCtosBase = class extends PayloadBase {
932
- /**
933
- * Serialize to full payload including header (length + identifier + body)
934
- * Format: [length 2 bytes LE][identifier 1 byte][body]
935
- * Length = 1 (identifier) + body.length
936
- */
937
- toFullPayload() {
938
- const body = this.toPayload();
939
- const length = 1 + body.length;
940
- const fullPayload = new Uint8Array(3 + body.length);
941
- fullPayload[0] = length & 255;
942
- fullPayload[1] = length >> 8 & 255;
943
- fullPayload[2] = this.identifier;
944
- fullPayload.set(body, 3);
945
- return fullPayload;
946
- }
947
- /**
948
- * Deserialize from full payload including header (length + identifier + body)
949
- * Format: [length 2 bytes LE][identifier 1 byte][body]
950
- * @param data - Full payload data
951
- * @returns this instance
952
- * @throws Error if data is too short or identifier mismatch
953
- */
954
- fromFullPayload(data) {
955
- if (data.length < 3) {
956
- throw new Error(
957
- `CTOS payload too short: expected at least 3 bytes, got ${data.length}`
958
- );
959
- }
960
- const declaredLength = data[0] | data[1] << 8;
961
- const identifier = data[2];
962
- if (identifier !== this.identifier) {
963
- throw new Error(
964
- `CTOS identifier mismatch: expected 0x${this.identifier.toString(16)}, got 0x${identifier.toString(16)}`
965
- );
966
- }
967
- const expectedTotalLength = 3 + declaredLength - 1;
968
- if (data.length < expectedTotalLength) {
969
- throw new Error(
970
- `CTOS payload too short: declared length ${declaredLength} requires ${expectedTotalLength} bytes total, got ${data.length}`
971
- );
972
- }
973
- const bodyData = data.length > expectedTotalLength ? data.slice(3, expectedTotalLength) : data.slice(3);
974
- return this.fromPayload(bodyData);
975
- }
976
- };
977
-
978
- // src/proto-base/registry-base.ts
979
- var RegistryBase = class {
980
- constructor(payloadClass, options = {}) {
981
- this.payloadClass = payloadClass;
982
- this.options = options;
983
- this.protos = /* @__PURE__ */ new Map();
984
- }
985
- register(proto) {
986
- const identifier = proto.identifier;
987
- this.protos.set(identifier, proto);
988
- }
989
- get(identifier) {
990
- return this.protos.get(identifier);
991
- }
992
- getInstanceFromPayload(data) {
993
- const identifier = data[this.options.identifierOffset ?? 0];
994
- const proto = this.get(identifier);
995
- if (!proto) {
996
- return void 0;
997
- }
998
- return new proto().fromPayload(
999
- data.slice(this.options.dataOffset ?? 0)
1000
- );
1001
- }
930
+ // src/protos/common/card-query.ts
931
+ var CardQuery_CardLocation = class {
1002
932
  };
1003
-
1004
- // src/protos/ctos/proto/response.ts
1005
- var YGOProCtosResponse = class extends YGOProCtosBase {
1006
- static {
1007
- this.identifier = 1;
1008
- }
1009
- fromPayload(data) {
1010
- this.response = data;
1011
- return this;
1012
- }
1013
- toPayload() {
1014
- return this.response || new Uint8Array(0);
1015
- }
933
+ var CardQuery_Counter = class {
1016
934
  };
1017
-
1018
- // src/protos/ctos/proto/update-deck.ts
1019
- import YGOProDeck from "ygopro-deck-encode";
1020
- var YGOProCtosUpdateDeck = class extends YGOProCtosBase {
1021
- static {
1022
- this.identifier = 2;
1023
- }
935
+ var CardQuery = class {
1024
936
  constructor() {
1025
- super();
1026
- this.deck = new YGOProDeck();
937
+ this.flags = 0;
1027
938
  }
1028
939
  fromPayload(data) {
1029
- this.deck = YGOProDeck.fromUpdateDeckPayload(data);
940
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
941
+ let offset = 0;
942
+ this.flags = view.getInt32(offset, true) >>> 0;
943
+ offset += 4;
944
+ if (this.flags === 0) {
945
+ this.empty = true;
946
+ return this;
947
+ }
948
+ this.empty = false;
949
+ if (this.flags & OcgcoreCommonConstants.QUERY_CODE) {
950
+ this.code = view.getInt32(offset, true);
951
+ offset += 4;
952
+ }
953
+ if (this.flags & OcgcoreCommonConstants.QUERY_POSITION) {
954
+ const pdata = view.getInt32(offset, true);
955
+ this.position = (pdata >>> 24 & 255) >>> 0;
956
+ offset += 4;
957
+ }
958
+ if (this.flags & OcgcoreCommonConstants.QUERY_ALIAS) {
959
+ this.alias = view.getInt32(offset, true);
960
+ offset += 4;
961
+ }
962
+ if (this.flags & OcgcoreCommonConstants.QUERY_TYPE) {
963
+ this.type = view.getInt32(offset, true);
964
+ offset += 4;
965
+ }
966
+ if (this.flags & OcgcoreCommonConstants.QUERY_LEVEL) {
967
+ this.level = view.getInt32(offset, true);
968
+ offset += 4;
969
+ }
970
+ if (this.flags & OcgcoreCommonConstants.QUERY_RANK) {
971
+ this.rank = view.getInt32(offset, true);
972
+ offset += 4;
973
+ }
974
+ if (this.flags & OcgcoreCommonConstants.QUERY_ATTRIBUTE) {
975
+ this.attribute = view.getInt32(offset, true);
976
+ offset += 4;
977
+ }
978
+ if (this.flags & OcgcoreCommonConstants.QUERY_RACE) {
979
+ this.race = view.getInt32(offset, true);
980
+ offset += 4;
981
+ }
982
+ if (this.flags & OcgcoreCommonConstants.QUERY_ATTACK) {
983
+ this.attack = view.getInt32(offset, true);
984
+ offset += 4;
985
+ }
986
+ if (this.flags & OcgcoreCommonConstants.QUERY_DEFENSE) {
987
+ this.defense = view.getInt32(offset, true);
988
+ offset += 4;
989
+ }
990
+ if (this.flags & OcgcoreCommonConstants.QUERY_BASE_ATTACK) {
991
+ this.baseAttack = view.getInt32(offset, true);
992
+ offset += 4;
993
+ }
994
+ if (this.flags & OcgcoreCommonConstants.QUERY_BASE_DEFENSE) {
995
+ this.baseDefense = view.getInt32(offset, true);
996
+ offset += 4;
997
+ }
998
+ if (this.flags & OcgcoreCommonConstants.QUERY_REASON) {
999
+ this.reason = view.getInt32(offset, true);
1000
+ offset += 4;
1001
+ }
1002
+ if (this.flags & OcgcoreCommonConstants.QUERY_REASON_CARD) {
1003
+ offset += 4;
1004
+ }
1005
+ if (this.flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) {
1006
+ this.equipCard = {
1007
+ controller: view.getUint8(offset),
1008
+ location: view.getUint8(offset + 1),
1009
+ sequence: view.getUint8(offset + 2)
1010
+ };
1011
+ offset += 4;
1012
+ }
1013
+ if (this.flags & OcgcoreCommonConstants.QUERY_TARGET_CARD) {
1014
+ const count = view.getInt32(offset, true);
1015
+ offset += 4;
1016
+ this.targetCards = [];
1017
+ for (let i = 0; i < count; i++) {
1018
+ this.targetCards.push({
1019
+ controller: view.getUint8(offset),
1020
+ location: view.getUint8(offset + 1),
1021
+ sequence: view.getUint8(offset + 2)
1022
+ });
1023
+ offset += 4;
1024
+ }
1025
+ }
1026
+ if (this.flags & OcgcoreCommonConstants.QUERY_OVERLAY_CARD) {
1027
+ const count = view.getInt32(offset, true);
1028
+ offset += 4;
1029
+ this.overlayCards = [];
1030
+ for (let i = 0; i < count; i++) {
1031
+ this.overlayCards.push(view.getInt32(offset, true));
1032
+ offset += 4;
1033
+ }
1034
+ }
1035
+ if (this.flags & OcgcoreCommonConstants.QUERY_COUNTERS) {
1036
+ const count = view.getInt32(offset, true);
1037
+ offset += 4;
1038
+ this.counters = [];
1039
+ for (let i = 0; i < count; i++) {
1040
+ this.counters.push({
1041
+ type: view.getUint16(offset, true),
1042
+ count: view.getUint16(offset + 2, true)
1043
+ });
1044
+ offset += 4;
1045
+ }
1046
+ }
1047
+ if (this.flags & OcgcoreCommonConstants.QUERY_OWNER) {
1048
+ this.owner = view.getInt32(offset, true);
1049
+ offset += 4;
1050
+ }
1051
+ if (this.flags & OcgcoreCommonConstants.QUERY_STATUS) {
1052
+ this.status = view.getInt32(offset, true);
1053
+ offset += 4;
1054
+ }
1055
+ if (this.flags & OcgcoreCommonConstants.QUERY_LSCALE) {
1056
+ this.lscale = view.getInt32(offset, true);
1057
+ offset += 4;
1058
+ }
1059
+ if (this.flags & OcgcoreCommonConstants.QUERY_RSCALE) {
1060
+ this.rscale = view.getInt32(offset, true);
1061
+ offset += 4;
1062
+ }
1063
+ if (this.flags & OcgcoreCommonConstants.QUERY_LINK) {
1064
+ this.link = view.getInt32(offset, true);
1065
+ offset += 4;
1066
+ this.linkMarker = view.getInt32(offset, true);
1067
+ offset += 4;
1068
+ }
1030
1069
  return this;
1031
1070
  }
1032
1071
  toPayload() {
1033
- return this.deck.toUpdateDeckPayload();
1034
- }
1035
- fromPartial(data) {
1036
- if (data.deck) {
1037
- this.deck = new YGOProDeck(data.deck);
1072
+ let size = 4;
1073
+ const flags = this.flags;
1074
+ if (flags & OcgcoreCommonConstants.QUERY_CODE) size += 4;
1075
+ if (flags & OcgcoreCommonConstants.QUERY_POSITION) size += 4;
1076
+ if (flags & OcgcoreCommonConstants.QUERY_ALIAS) size += 4;
1077
+ if (flags & OcgcoreCommonConstants.QUERY_TYPE) size += 4;
1078
+ if (flags & OcgcoreCommonConstants.QUERY_LEVEL) size += 4;
1079
+ if (flags & OcgcoreCommonConstants.QUERY_RANK) size += 4;
1080
+ if (flags & OcgcoreCommonConstants.QUERY_ATTRIBUTE) size += 4;
1081
+ if (flags & OcgcoreCommonConstants.QUERY_RACE) size += 4;
1082
+ if (flags & OcgcoreCommonConstants.QUERY_ATTACK) size += 4;
1083
+ if (flags & OcgcoreCommonConstants.QUERY_DEFENSE) size += 4;
1084
+ if (flags & OcgcoreCommonConstants.QUERY_BASE_ATTACK) size += 4;
1085
+ if (flags & OcgcoreCommonConstants.QUERY_BASE_DEFENSE) size += 4;
1086
+ if (flags & OcgcoreCommonConstants.QUERY_REASON) size += 4;
1087
+ if (flags & OcgcoreCommonConstants.QUERY_REASON_CARD) size += 4;
1088
+ if (flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) size += 4;
1089
+ if (flags & OcgcoreCommonConstants.QUERY_TARGET_CARD) {
1090
+ size += 4 + (this.targetCards?.length || 0) * 4;
1038
1091
  }
1039
- return this;
1040
- }
1041
- copy() {
1042
- const copied = new this.constructor();
1043
- copied.deck = new YGOProDeck(this.deck);
1044
- return copied;
1092
+ if (flags & OcgcoreCommonConstants.QUERY_OVERLAY_CARD) {
1093
+ size += 4 + (this.overlayCards?.length || 0) * 4;
1094
+ }
1095
+ if (flags & OcgcoreCommonConstants.QUERY_COUNTERS) {
1096
+ size += 4 + (this.counters?.length || 0) * 4;
1097
+ }
1098
+ if (flags & OcgcoreCommonConstants.QUERY_OWNER) size += 4;
1099
+ if (flags & OcgcoreCommonConstants.QUERY_STATUS) size += 4;
1100
+ if (flags & OcgcoreCommonConstants.QUERY_LSCALE) size += 4;
1101
+ if (flags & OcgcoreCommonConstants.QUERY_RSCALE) size += 4;
1102
+ if (flags & OcgcoreCommonConstants.QUERY_LINK) size += 8;
1103
+ const result = new Uint8Array(size);
1104
+ const view = new DataView(result.buffer);
1105
+ let offset = 0;
1106
+ view.setInt32(offset, this.flags, true);
1107
+ offset += 4;
1108
+ if (this.empty || this.flags === 0) {
1109
+ return result;
1110
+ }
1111
+ if (flags & OcgcoreCommonConstants.QUERY_CODE) {
1112
+ view.setInt32(offset, this.code || 0, true);
1113
+ offset += 4;
1114
+ }
1115
+ if (flags & OcgcoreCommonConstants.QUERY_POSITION) {
1116
+ const pdata = (this.position || 0) << 24 >>> 0;
1117
+ view.setInt32(offset, pdata, true);
1118
+ offset += 4;
1119
+ }
1120
+ if (flags & OcgcoreCommonConstants.QUERY_ALIAS) {
1121
+ view.setInt32(offset, this.alias || 0, true);
1122
+ offset += 4;
1123
+ }
1124
+ if (flags & OcgcoreCommonConstants.QUERY_TYPE) {
1125
+ view.setInt32(offset, this.type || 0, true);
1126
+ offset += 4;
1127
+ }
1128
+ if (flags & OcgcoreCommonConstants.QUERY_LEVEL) {
1129
+ view.setInt32(offset, this.level || 0, true);
1130
+ offset += 4;
1131
+ }
1132
+ if (flags & OcgcoreCommonConstants.QUERY_RANK) {
1133
+ view.setInt32(offset, this.rank || 0, true);
1134
+ offset += 4;
1135
+ }
1136
+ if (flags & OcgcoreCommonConstants.QUERY_ATTRIBUTE) {
1137
+ view.setInt32(offset, this.attribute || 0, true);
1138
+ offset += 4;
1139
+ }
1140
+ if (flags & OcgcoreCommonConstants.QUERY_RACE) {
1141
+ view.setInt32(offset, this.race || 0, true);
1142
+ offset += 4;
1143
+ }
1144
+ if (flags & OcgcoreCommonConstants.QUERY_ATTACK) {
1145
+ view.setInt32(offset, this.attack || 0, true);
1146
+ offset += 4;
1147
+ }
1148
+ if (flags & OcgcoreCommonConstants.QUERY_DEFENSE) {
1149
+ view.setInt32(offset, this.defense || 0, true);
1150
+ offset += 4;
1151
+ }
1152
+ if (flags & OcgcoreCommonConstants.QUERY_BASE_ATTACK) {
1153
+ view.setInt32(offset, this.baseAttack || 0, true);
1154
+ offset += 4;
1155
+ }
1156
+ if (flags & OcgcoreCommonConstants.QUERY_BASE_DEFENSE) {
1157
+ view.setInt32(offset, this.baseDefense || 0, true);
1158
+ offset += 4;
1159
+ }
1160
+ if (flags & OcgcoreCommonConstants.QUERY_REASON) {
1161
+ view.setInt32(offset, this.reason || 0, true);
1162
+ offset += 4;
1163
+ }
1164
+ if (flags & OcgcoreCommonConstants.QUERY_REASON_CARD) {
1165
+ view.setInt32(offset, 0, true);
1166
+ offset += 4;
1167
+ }
1168
+ if (flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) {
1169
+ const card = this.equipCard || {
1170
+ controller: 0,
1171
+ location: 0,
1172
+ sequence: 0
1173
+ };
1174
+ view.setUint8(offset, card.controller);
1175
+ view.setUint8(offset + 1, card.location);
1176
+ view.setUint8(offset + 2, card.sequence);
1177
+ view.setUint8(offset + 3, 0);
1178
+ offset += 4;
1179
+ }
1180
+ if (flags & OcgcoreCommonConstants.QUERY_TARGET_CARD) {
1181
+ const targets = this.targetCards || [];
1182
+ view.setInt32(offset, targets.length, true);
1183
+ offset += 4;
1184
+ for (const target of targets) {
1185
+ view.setUint8(offset, target.controller);
1186
+ view.setUint8(offset + 1, target.location);
1187
+ view.setUint8(offset + 2, target.sequence);
1188
+ view.setUint8(offset + 3, 0);
1189
+ offset += 4;
1190
+ }
1191
+ }
1192
+ if (flags & OcgcoreCommonConstants.QUERY_OVERLAY_CARD) {
1193
+ const overlays = this.overlayCards || [];
1194
+ view.setInt32(offset, overlays.length, true);
1195
+ offset += 4;
1196
+ for (const card of overlays) {
1197
+ view.setInt32(offset, card, true);
1198
+ offset += 4;
1199
+ }
1200
+ }
1201
+ if (flags & OcgcoreCommonConstants.QUERY_COUNTERS) {
1202
+ const counters = this.counters || [];
1203
+ view.setInt32(offset, counters.length, true);
1204
+ offset += 4;
1205
+ for (const counter of counters) {
1206
+ view.setUint16(offset, counter.type, true);
1207
+ view.setUint16(offset + 2, counter.count, true);
1208
+ offset += 4;
1209
+ }
1210
+ }
1211
+ if (flags & OcgcoreCommonConstants.QUERY_OWNER) {
1212
+ view.setInt32(offset, this.owner || 0, true);
1213
+ offset += 4;
1214
+ }
1215
+ if (flags & OcgcoreCommonConstants.QUERY_STATUS) {
1216
+ view.setInt32(offset, this.status || 0, true);
1217
+ offset += 4;
1218
+ }
1219
+ if (flags & OcgcoreCommonConstants.QUERY_LSCALE) {
1220
+ view.setInt32(offset, this.lscale || 0, true);
1221
+ offset += 4;
1222
+ }
1223
+ if (flags & OcgcoreCommonConstants.QUERY_RSCALE) {
1224
+ view.setInt32(offset, this.rscale || 0, true);
1225
+ offset += 4;
1226
+ }
1227
+ if (flags & OcgcoreCommonConstants.QUERY_LINK) {
1228
+ view.setInt32(offset, this.link || 0, true);
1229
+ offset += 4;
1230
+ view.setInt32(offset, this.linkMarker || 0, true);
1231
+ offset += 4;
1232
+ }
1233
+ return new Uint8Array(view.buffer, view.byteOffset, offset);
1045
1234
  }
1046
1235
  };
1047
1236
 
1048
- // src/protos/ctos/proto/hand-result.ts
1049
- var YGOProCtosHandResult = class extends YGOProCtosBase {
1050
- static {
1051
- this.identifier = 3;
1237
+ // src/protos/ctos/base.ts
1238
+ var YGOProCtosBase = class extends PayloadBase {
1239
+ /**
1240
+ * Serialize to full payload including header (length + identifier + body)
1241
+ * Format: [length 2 bytes LE][identifier 1 byte][body]
1242
+ * Length = 1 (identifier) + body.length
1243
+ */
1244
+ toFullPayload() {
1245
+ const body = this.toPayload();
1246
+ const length = 1 + body.length;
1247
+ const fullPayload = new Uint8Array(3 + body.length);
1248
+ fullPayload[0] = length & 255;
1249
+ fullPayload[1] = length >> 8 & 255;
1250
+ fullPayload[2] = this.identifier;
1251
+ fullPayload.set(body, 3);
1252
+ return fullPayload;
1253
+ }
1254
+ /**
1255
+ * Deserialize from full payload including header (length + identifier + body)
1256
+ * Format: [length 2 bytes LE][identifier 1 byte][body]
1257
+ * @param data - Full payload data
1258
+ * @returns this instance
1259
+ * @throws Error if data is too short or identifier mismatch
1260
+ */
1261
+ fromFullPayload(data) {
1262
+ if (data.length < 3) {
1263
+ throw new Error(
1264
+ `CTOS payload too short: expected at least 3 bytes, got ${data.length}`
1265
+ );
1266
+ }
1267
+ const declaredLength = data[0] | data[1] << 8;
1268
+ const identifier = data[2];
1269
+ if (identifier !== this.identifier) {
1270
+ throw new Error(
1271
+ `CTOS identifier mismatch: expected 0x${this.identifier.toString(16)}, got 0x${identifier.toString(16)}`
1272
+ );
1273
+ }
1274
+ const expectedTotalLength = 3 + declaredLength - 1;
1275
+ if (data.length < expectedTotalLength) {
1276
+ throw new Error(
1277
+ `CTOS payload too short: declared length ${declaredLength} requires ${expectedTotalLength} bytes total, got ${data.length}`
1278
+ );
1279
+ }
1280
+ const bodyData = data.length > expectedTotalLength ? data.slice(3, expectedTotalLength) : data.slice(3);
1281
+ return this.fromPayload(bodyData);
1052
1282
  }
1053
1283
  };
1054
- __decorateClass([
1055
- BinaryField("u8", 0)
1056
- ], YGOProCtosHandResult.prototype, "res", 2);
1057
1284
 
1058
- // src/protos/ctos/proto/tp-result.ts
1059
- var YGOProCtosTpResult = class extends YGOProCtosBase {
1060
- static {
1061
- this.identifier = 4;
1285
+ // src/proto-base/registry-base.ts
1286
+ var RegistryBase = class {
1287
+ constructor(payloadClass, options = {}) {
1288
+ this.payloadClass = payloadClass;
1289
+ this.options = options;
1290
+ this.protos = /* @__PURE__ */ new Map();
1291
+ }
1292
+ register(proto) {
1293
+ const identifier = proto.identifier;
1294
+ this.protos.set(identifier, proto);
1295
+ }
1296
+ get(identifier) {
1297
+ return this.protos.get(identifier);
1298
+ }
1299
+ getInstanceFromPayload(data) {
1300
+ const identifier = data[this.options.identifierOffset ?? 0];
1301
+ const proto = this.get(identifier);
1302
+ if (!proto) {
1303
+ return void 0;
1304
+ }
1305
+ return new proto().fromPayload(
1306
+ data.slice(this.options.dataOffset ?? 0)
1307
+ );
1062
1308
  }
1063
1309
  };
1064
- __decorateClass([
1065
- BinaryField("u8", 0)
1066
- ], YGOProCtosTpResult.prototype, "res", 2);
1067
1310
 
1068
- // src/protos/ctos/proto/player-info.ts
1069
- var YGOProCtosPlayerInfo = class extends YGOProCtosBase {
1311
+ // src/protos/ctos/proto/response.ts
1312
+ var YGOProCtosResponse = class extends YGOProCtosBase {
1070
1313
  static {
1071
- this.identifier = 16;
1314
+ this.identifier = 1;
1315
+ }
1316
+ fromPayload(data) {
1317
+ this.response = data;
1318
+ return this;
1319
+ }
1320
+ toPayload() {
1321
+ return this.response || new Uint8Array(0);
1072
1322
  }
1073
1323
  };
1074
- __decorateClass([
1075
- BinaryField("utf16", 0, 20)
1076
- ], YGOProCtosPlayerInfo.prototype, "name", 2);
1077
1324
 
1078
- // src/protos/ctos/proto/create-game.ts
1079
- var YGOProCtosCreateGame = class extends YGOProCtosBase {
1325
+ // src/protos/ctos/proto/update-deck.ts
1326
+ import YGOProDeck from "ygopro-deck-encode";
1327
+ var YGOProCtosUpdateDeck = class extends YGOProCtosBase {
1080
1328
  static {
1081
- this.identifier = 17;
1329
+ this.identifier = 2;
1082
1330
  }
1083
- };
1084
- __decorateClass([
1085
- BinaryField(() => HostInfo, 0)
1086
- ], YGOProCtosCreateGame.prototype, "info", 2);
1087
- __decorateClass([
1088
- BinaryField("utf16", 20, 20)
1089
- ], YGOProCtosCreateGame.prototype, "name", 2);
1331
+ constructor() {
1332
+ super();
1333
+ this.deck = new YGOProDeck();
1334
+ }
1335
+ fromPayload(data) {
1336
+ this.deck = YGOProDeck.fromUpdateDeckPayload(data);
1337
+ return this;
1338
+ }
1339
+ toPayload() {
1340
+ return this.deck.toUpdateDeckPayload();
1341
+ }
1342
+ fromPartial(data) {
1343
+ if (data.deck) {
1344
+ this.deck = new YGOProDeck(data.deck);
1345
+ }
1346
+ return this;
1347
+ }
1348
+ copy() {
1349
+ const copied = new this.constructor();
1350
+ copied.deck = new YGOProDeck(this.deck);
1351
+ return copied;
1352
+ }
1353
+ };
1354
+
1355
+ // src/protos/ctos/proto/hand-result.ts
1356
+ var YGOProCtosHandResult = class extends YGOProCtosBase {
1357
+ static {
1358
+ this.identifier = 3;
1359
+ }
1360
+ };
1361
+ __decorateClass([
1362
+ BinaryField("u8", 0)
1363
+ ], YGOProCtosHandResult.prototype, "res", 2);
1364
+
1365
+ // src/protos/ctos/proto/tp-result.ts
1366
+ var YGOProCtosTpResult = class extends YGOProCtosBase {
1367
+ static {
1368
+ this.identifier = 4;
1369
+ }
1370
+ };
1371
+ __decorateClass([
1372
+ BinaryField("u8", 0)
1373
+ ], YGOProCtosTpResult.prototype, "res", 2);
1374
+
1375
+ // src/protos/ctos/proto/player-info.ts
1376
+ var YGOProCtosPlayerInfo = class extends YGOProCtosBase {
1377
+ static {
1378
+ this.identifier = 16;
1379
+ }
1380
+ };
1381
+ __decorateClass([
1382
+ BinaryField("utf16", 0, 20)
1383
+ ], YGOProCtosPlayerInfo.prototype, "name", 2);
1384
+
1385
+ // src/protos/ctos/proto/create-game.ts
1386
+ var YGOProCtosCreateGame = class extends YGOProCtosBase {
1387
+ static {
1388
+ this.identifier = 17;
1389
+ }
1390
+ };
1391
+ __decorateClass([
1392
+ BinaryField(() => HostInfo, 0)
1393
+ ], YGOProCtosCreateGame.prototype, "info", 2);
1394
+ __decorateClass([
1395
+ BinaryField("utf16", 20, 20)
1396
+ ], YGOProCtosCreateGame.prototype, "name", 2);
1090
1397
  __decorateClass([
1091
1398
  BinaryField("utf16", 60, 20)
1092
1399
  ], YGOProCtosCreateGame.prototype, "pass", 2);
@@ -1366,7 +1673,83 @@ var YGOProStocBase = class extends PayloadBase {
1366
1673
  }
1367
1674
  };
1368
1675
 
1676
+ // src/protos/network-enums.ts
1677
+ var HandResult = /* @__PURE__ */ ((HandResult2) => {
1678
+ HandResult2[HandResult2["ROCK"] = 1] = "ROCK";
1679
+ HandResult2[HandResult2["SCISSORS"] = 2] = "SCISSORS";
1680
+ HandResult2[HandResult2["PAPER"] = 3] = "PAPER";
1681
+ return HandResult2;
1682
+ })(HandResult || {});
1683
+ var TurnPlayerResult = /* @__PURE__ */ ((TurnPlayerResult2) => {
1684
+ TurnPlayerResult2[TurnPlayerResult2["SECOND"] = 0] = "SECOND";
1685
+ TurnPlayerResult2[TurnPlayerResult2["FIRST"] = 1] = "FIRST";
1686
+ return TurnPlayerResult2;
1687
+ })(TurnPlayerResult || {});
1688
+ var NetPlayerType = /* @__PURE__ */ ((NetPlayerType2) => {
1689
+ NetPlayerType2[NetPlayerType2["PLAYER1"] = 0] = "PLAYER1";
1690
+ NetPlayerType2[NetPlayerType2["PLAYER2"] = 1] = "PLAYER2";
1691
+ NetPlayerType2[NetPlayerType2["PLAYER3"] = 2] = "PLAYER3";
1692
+ NetPlayerType2[NetPlayerType2["PLAYER4"] = 3] = "PLAYER4";
1693
+ NetPlayerType2[NetPlayerType2["PLAYER5"] = 4] = "PLAYER5";
1694
+ NetPlayerType2[NetPlayerType2["PLAYER6"] = 5] = "PLAYER6";
1695
+ NetPlayerType2[NetPlayerType2["OBSERVER"] = 7] = "OBSERVER";
1696
+ return NetPlayerType2;
1697
+ })(NetPlayerType || {});
1698
+ var ChatColor = /* @__PURE__ */ ((ChatColor2) => {
1699
+ ChatColor2[ChatColor2["LIGHTBLUE"] = 8] = "LIGHTBLUE";
1700
+ ChatColor2[ChatColor2["RED"] = 11] = "RED";
1701
+ ChatColor2[ChatColor2["GREEN"] = 12] = "GREEN";
1702
+ ChatColor2[ChatColor2["BLUE"] = 13] = "BLUE";
1703
+ ChatColor2[ChatColor2["BABYBLUE"] = 14] = "BABYBLUE";
1704
+ ChatColor2[ChatColor2["PINK"] = 15] = "PINK";
1705
+ ChatColor2[ChatColor2["YELLOW"] = 16] = "YELLOW";
1706
+ ChatColor2[ChatColor2["WHITE"] = 17] = "WHITE";
1707
+ ChatColor2[ChatColor2["GRAY"] = 18] = "GRAY";
1708
+ ChatColor2[ChatColor2["DARKGRAY"] = 19] = "DARKGRAY";
1709
+ return ChatColor2;
1710
+ })(ChatColor || {});
1711
+ var GameMode = /* @__PURE__ */ ((GameMode2) => {
1712
+ GameMode2[GameMode2["SINGLE"] = 0] = "SINGLE";
1713
+ GameMode2[GameMode2["MATCH"] = 1] = "MATCH";
1714
+ GameMode2[GameMode2["TAG"] = 2] = "TAG";
1715
+ return GameMode2;
1716
+ })(GameMode || {});
1717
+ var ErrorMessageType = /* @__PURE__ */ ((ErrorMessageType2) => {
1718
+ ErrorMessageType2[ErrorMessageType2["JOINERROR"] = 1] = "JOINERROR";
1719
+ ErrorMessageType2[ErrorMessageType2["DECKERROR"] = 2] = "DECKERROR";
1720
+ ErrorMessageType2[ErrorMessageType2["SIDEERROR"] = 3] = "SIDEERROR";
1721
+ ErrorMessageType2[ErrorMessageType2["VERERROR"] = 4] = "VERERROR";
1722
+ return ErrorMessageType2;
1723
+ })(ErrorMessageType || {});
1724
+ var DeckErrorType = /* @__PURE__ */ ((DeckErrorType2) => {
1725
+ DeckErrorType2[DeckErrorType2["LFLIST"] = 1] = "LFLIST";
1726
+ DeckErrorType2[DeckErrorType2["OCGONLY"] = 2] = "OCGONLY";
1727
+ DeckErrorType2[DeckErrorType2["TCGONLY"] = 3] = "TCGONLY";
1728
+ DeckErrorType2[DeckErrorType2["UNKNOWNCARD"] = 4] = "UNKNOWNCARD";
1729
+ DeckErrorType2[DeckErrorType2["CARDCOUNT"] = 5] = "CARDCOUNT";
1730
+ DeckErrorType2[DeckErrorType2["MAINCOUNT"] = 6] = "MAINCOUNT";
1731
+ DeckErrorType2[DeckErrorType2["EXTRACOUNT"] = 7] = "EXTRACOUNT";
1732
+ DeckErrorType2[DeckErrorType2["SIDECOUNT"] = 8] = "SIDECOUNT";
1733
+ DeckErrorType2[DeckErrorType2["NOTAVAIL"] = 9] = "NOTAVAIL";
1734
+ return DeckErrorType2;
1735
+ })(DeckErrorType || {});
1736
+ var PlayerChangeState = /* @__PURE__ */ ((PlayerChangeState2) => {
1737
+ PlayerChangeState2[PlayerChangeState2["OBSERVE"] = 8] = "OBSERVE";
1738
+ PlayerChangeState2[PlayerChangeState2["READY"] = 9] = "READY";
1739
+ PlayerChangeState2[PlayerChangeState2["NOTREADY"] = 10] = "NOTREADY";
1740
+ PlayerChangeState2[PlayerChangeState2["LEAVE"] = 11] = "LEAVE";
1741
+ return PlayerChangeState2;
1742
+ })(PlayerChangeState || {});
1743
+ var RoomStatus = /* @__PURE__ */ ((RoomStatus2) => {
1744
+ RoomStatus2[RoomStatus2["WAITING"] = 0] = "WAITING";
1745
+ RoomStatus2[RoomStatus2["DUELING"] = 1] = "DUELING";
1746
+ RoomStatus2[RoomStatus2["SIDING"] = 2] = "SIDING";
1747
+ return RoomStatus2;
1748
+ })(RoomStatus || {});
1749
+
1369
1750
  // src/protos/msg/base.ts
1751
+ var SEND_TO_PLAYERS = [0, 1];
1752
+ var SEND_TO_ALL = [0, 1, 7 /* OBSERVER */];
1370
1753
  var YGOProMsgBase = class extends PayloadBase {
1371
1754
  fromPayload(data) {
1372
1755
  if (data.length < 1) {
@@ -1397,6 +1780,9 @@ var YGOProMsgBase = class extends PayloadBase {
1397
1780
  return this.opponentView();
1398
1781
  }
1399
1782
  playerView(playerId) {
1783
+ if (playerId === 7 /* OBSERVER */) {
1784
+ return this.observerView();
1785
+ }
1400
1786
  if (typeof this["player"] === "number") {
1401
1787
  const selfPlayerId = this["player"];
1402
1788
  if (selfPlayerId === playerId) {
@@ -1406,6 +1792,9 @@ var YGOProMsgBase = class extends PayloadBase {
1406
1792
  }
1407
1793
  return this.copy();
1408
1794
  }
1795
+ getSendTargets() {
1796
+ return SEND_TO_ALL;
1797
+ }
1409
1798
  };
1410
1799
 
1411
1800
  // src/protos/msg/proto/add-counter.ts
@@ -1435,6 +1824,9 @@ var YGOProMsgResponseBase = class extends YGOProMsgBase {
1435
1824
  defaultResponse() {
1436
1825
  return void 0;
1437
1826
  }
1827
+ getSendTargets() {
1828
+ return [this.responsePlayer()];
1829
+ }
1438
1830
  };
1439
1831
 
1440
1832
  // src/protos/msg/proto/announce-attrib.ts
@@ -1696,341 +2088,34 @@ __decorateClass([
1696
2088
  BinaryField("i32", 5)
1697
2089
  ], YGOProMsgCardHint.prototype, "value", 2);
1698
2090
 
1699
- // src/protos/msg/proto/card-query.ts
1700
- var CardQuery_CardLocation = class {
2091
+ // src/protos/msg/proto/card-target.ts
2092
+ var YGOProMsgCardTarget_CardLocation = class {
1701
2093
  };
1702
- var CardQuery_Counter = class {
2094
+ __decorateClass([
2095
+ BinaryField("u8", 0)
2096
+ ], YGOProMsgCardTarget_CardLocation.prototype, "controller", 2);
2097
+ __decorateClass([
2098
+ BinaryField("u8", 1)
2099
+ ], YGOProMsgCardTarget_CardLocation.prototype, "location", 2);
2100
+ __decorateClass([
2101
+ BinaryField("u8", 2)
2102
+ ], YGOProMsgCardTarget_CardLocation.prototype, "sequence", 2);
2103
+ var YGOProMsgCardTarget = class extends YGOProMsgBase {
2104
+ static {
2105
+ this.identifier = OcgcoreCommonConstants.MSG_CARD_TARGET;
2106
+ }
1703
2107
  };
1704
- var CardQuery = class {
1705
- constructor() {
1706
- this.flags = 0;
1707
- }
1708
- fromPayload(data) {
1709
- const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
1710
- let offset = 0;
1711
- this.flags = view.getInt32(offset, true) >>> 0;
1712
- offset += 4;
1713
- if (this.flags === 0) {
1714
- this.empty = true;
1715
- return this;
1716
- }
1717
- this.empty = false;
1718
- if (this.flags & OcgcoreCommonConstants.QUERY_CODE) {
1719
- this.code = view.getInt32(offset, true);
1720
- offset += 4;
1721
- }
1722
- if (this.flags & OcgcoreCommonConstants.QUERY_POSITION) {
1723
- const pdata = view.getInt32(offset, true);
1724
- this.position = (pdata >>> 24 & 255) >>> 0;
1725
- offset += 4;
1726
- }
1727
- if (this.flags & OcgcoreCommonConstants.QUERY_ALIAS) {
1728
- this.alias = view.getInt32(offset, true);
1729
- offset += 4;
1730
- }
1731
- if (this.flags & OcgcoreCommonConstants.QUERY_TYPE) {
1732
- this.type = view.getInt32(offset, true);
1733
- offset += 4;
1734
- }
1735
- if (this.flags & OcgcoreCommonConstants.QUERY_LEVEL) {
1736
- this.level = view.getInt32(offset, true);
1737
- offset += 4;
1738
- }
1739
- if (this.flags & OcgcoreCommonConstants.QUERY_RANK) {
1740
- this.rank = view.getInt32(offset, true);
1741
- offset += 4;
1742
- }
1743
- if (this.flags & OcgcoreCommonConstants.QUERY_ATTRIBUTE) {
1744
- this.attribute = view.getInt32(offset, true);
1745
- offset += 4;
1746
- }
1747
- if (this.flags & OcgcoreCommonConstants.QUERY_RACE) {
1748
- this.race = view.getInt32(offset, true);
1749
- offset += 4;
1750
- }
1751
- if (this.flags & OcgcoreCommonConstants.QUERY_ATTACK) {
1752
- this.attack = view.getInt32(offset, true);
1753
- offset += 4;
1754
- }
1755
- if (this.flags & OcgcoreCommonConstants.QUERY_DEFENSE) {
1756
- this.defense = view.getInt32(offset, true);
1757
- offset += 4;
1758
- }
1759
- if (this.flags & OcgcoreCommonConstants.QUERY_BASE_ATTACK) {
1760
- this.baseAttack = view.getInt32(offset, true);
1761
- offset += 4;
1762
- }
1763
- if (this.flags & OcgcoreCommonConstants.QUERY_BASE_DEFENSE) {
1764
- this.baseDefense = view.getInt32(offset, true);
1765
- offset += 4;
1766
- }
1767
- if (this.flags & OcgcoreCommonConstants.QUERY_REASON) {
1768
- this.reason = view.getInt32(offset, true);
1769
- offset += 4;
1770
- }
1771
- if (this.flags & OcgcoreCommonConstants.QUERY_REASON_CARD) {
1772
- offset += 4;
1773
- }
1774
- if (this.flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) {
1775
- this.equipCard = {
1776
- controller: view.getUint8(offset),
1777
- location: view.getUint8(offset + 1),
1778
- sequence: view.getUint8(offset + 2)
1779
- };
1780
- offset += 4;
1781
- }
1782
- if (this.flags & OcgcoreCommonConstants.QUERY_TARGET_CARD) {
1783
- const count = view.getInt32(offset, true);
1784
- offset += 4;
1785
- this.targetCards = [];
1786
- for (let i = 0; i < count; i++) {
1787
- this.targetCards.push({
1788
- controller: view.getUint8(offset),
1789
- location: view.getUint8(offset + 1),
1790
- sequence: view.getUint8(offset + 2)
1791
- });
1792
- offset += 4;
1793
- }
1794
- }
1795
- if (this.flags & OcgcoreCommonConstants.QUERY_OVERLAY_CARD) {
1796
- const count = view.getInt32(offset, true);
1797
- offset += 4;
1798
- this.overlayCards = [];
1799
- for (let i = 0; i < count; i++) {
1800
- this.overlayCards.push(view.getInt32(offset, true));
1801
- offset += 4;
1802
- }
1803
- }
1804
- if (this.flags & OcgcoreCommonConstants.QUERY_COUNTERS) {
1805
- const count = view.getInt32(offset, true);
1806
- offset += 4;
1807
- this.counters = [];
1808
- for (let i = 0; i < count; i++) {
1809
- this.counters.push({
1810
- type: view.getUint16(offset, true),
1811
- count: view.getUint16(offset + 2, true)
1812
- });
1813
- offset += 4;
1814
- }
1815
- }
1816
- if (this.flags & OcgcoreCommonConstants.QUERY_OWNER) {
1817
- this.owner = view.getInt32(offset, true);
1818
- offset += 4;
1819
- }
1820
- if (this.flags & OcgcoreCommonConstants.QUERY_STATUS) {
1821
- this.status = view.getInt32(offset, true);
1822
- offset += 4;
1823
- }
1824
- if (this.flags & OcgcoreCommonConstants.QUERY_LSCALE) {
1825
- this.lscale = view.getInt32(offset, true);
1826
- offset += 4;
1827
- }
1828
- if (this.flags & OcgcoreCommonConstants.QUERY_RSCALE) {
1829
- this.rscale = view.getInt32(offset, true);
1830
- offset += 4;
1831
- }
1832
- if (this.flags & OcgcoreCommonConstants.QUERY_LINK) {
1833
- this.link = view.getInt32(offset, true);
1834
- offset += 4;
1835
- this.linkMarker = view.getInt32(offset, true);
1836
- offset += 4;
1837
- }
1838
- return this;
1839
- }
1840
- toPayload() {
1841
- let size = 4;
1842
- const flags = this.flags;
1843
- if (flags & OcgcoreCommonConstants.QUERY_CODE) size += 4;
1844
- if (flags & OcgcoreCommonConstants.QUERY_POSITION) size += 4;
1845
- if (flags & OcgcoreCommonConstants.QUERY_ALIAS) size += 4;
1846
- if (flags & OcgcoreCommonConstants.QUERY_TYPE) size += 4;
1847
- if (flags & OcgcoreCommonConstants.QUERY_LEVEL) size += 4;
1848
- if (flags & OcgcoreCommonConstants.QUERY_RANK) size += 4;
1849
- if (flags & OcgcoreCommonConstants.QUERY_ATTRIBUTE) size += 4;
1850
- if (flags & OcgcoreCommonConstants.QUERY_RACE) size += 4;
1851
- if (flags & OcgcoreCommonConstants.QUERY_ATTACK) size += 4;
1852
- if (flags & OcgcoreCommonConstants.QUERY_DEFENSE) size += 4;
1853
- if (flags & OcgcoreCommonConstants.QUERY_BASE_ATTACK) size += 4;
1854
- if (flags & OcgcoreCommonConstants.QUERY_BASE_DEFENSE) size += 4;
1855
- if (flags & OcgcoreCommonConstants.QUERY_REASON) size += 4;
1856
- if (flags & OcgcoreCommonConstants.QUERY_REASON_CARD) size += 4;
1857
- if (flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) size += 4;
1858
- if (flags & OcgcoreCommonConstants.QUERY_TARGET_CARD) {
1859
- size += 4 + (this.targetCards?.length || 0) * 4;
1860
- }
1861
- if (flags & OcgcoreCommonConstants.QUERY_OVERLAY_CARD) {
1862
- size += 4 + (this.overlayCards?.length || 0) * 4;
1863
- }
1864
- if (flags & OcgcoreCommonConstants.QUERY_COUNTERS) {
1865
- size += 4 + (this.counters?.length || 0) * 4;
1866
- }
1867
- if (flags & OcgcoreCommonConstants.QUERY_OWNER) size += 4;
1868
- if (flags & OcgcoreCommonConstants.QUERY_STATUS) size += 4;
1869
- if (flags & OcgcoreCommonConstants.QUERY_LSCALE) size += 4;
1870
- if (flags & OcgcoreCommonConstants.QUERY_RSCALE) size += 4;
1871
- if (flags & OcgcoreCommonConstants.QUERY_LINK) size += 8;
1872
- const result = new Uint8Array(size);
1873
- const view = new DataView(result.buffer);
1874
- let offset = 0;
1875
- view.setInt32(offset, this.flags, true);
1876
- offset += 4;
1877
- if (this.empty || this.flags === 0) {
1878
- return result;
1879
- }
1880
- if (flags & OcgcoreCommonConstants.QUERY_CODE) {
1881
- view.setInt32(offset, this.code || 0, true);
1882
- offset += 4;
1883
- }
1884
- if (flags & OcgcoreCommonConstants.QUERY_POSITION) {
1885
- const pdata = (this.position || 0) << 24 >>> 0;
1886
- view.setInt32(offset, pdata, true);
1887
- offset += 4;
1888
- }
1889
- if (flags & OcgcoreCommonConstants.QUERY_ALIAS) {
1890
- view.setInt32(offset, this.alias || 0, true);
1891
- offset += 4;
1892
- }
1893
- if (flags & OcgcoreCommonConstants.QUERY_TYPE) {
1894
- view.setInt32(offset, this.type || 0, true);
1895
- offset += 4;
1896
- }
1897
- if (flags & OcgcoreCommonConstants.QUERY_LEVEL) {
1898
- view.setInt32(offset, this.level || 0, true);
1899
- offset += 4;
1900
- }
1901
- if (flags & OcgcoreCommonConstants.QUERY_RANK) {
1902
- view.setInt32(offset, this.rank || 0, true);
1903
- offset += 4;
1904
- }
1905
- if (flags & OcgcoreCommonConstants.QUERY_ATTRIBUTE) {
1906
- view.setInt32(offset, this.attribute || 0, true);
1907
- offset += 4;
1908
- }
1909
- if (flags & OcgcoreCommonConstants.QUERY_RACE) {
1910
- view.setInt32(offset, this.race || 0, true);
1911
- offset += 4;
1912
- }
1913
- if (flags & OcgcoreCommonConstants.QUERY_ATTACK) {
1914
- view.setInt32(offset, this.attack || 0, true);
1915
- offset += 4;
1916
- }
1917
- if (flags & OcgcoreCommonConstants.QUERY_DEFENSE) {
1918
- view.setInt32(offset, this.defense || 0, true);
1919
- offset += 4;
1920
- }
1921
- if (flags & OcgcoreCommonConstants.QUERY_BASE_ATTACK) {
1922
- view.setInt32(offset, this.baseAttack || 0, true);
1923
- offset += 4;
1924
- }
1925
- if (flags & OcgcoreCommonConstants.QUERY_BASE_DEFENSE) {
1926
- view.setInt32(offset, this.baseDefense || 0, true);
1927
- offset += 4;
1928
- }
1929
- if (flags & OcgcoreCommonConstants.QUERY_REASON) {
1930
- view.setInt32(offset, this.reason || 0, true);
1931
- offset += 4;
1932
- }
1933
- if (flags & OcgcoreCommonConstants.QUERY_REASON_CARD) {
1934
- view.setInt32(offset, 0, true);
1935
- offset += 4;
1936
- }
1937
- if (flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) {
1938
- const card = this.equipCard || {
1939
- controller: 0,
1940
- location: 0,
1941
- sequence: 0
1942
- };
1943
- view.setUint8(offset, card.controller);
1944
- view.setUint8(offset + 1, card.location);
1945
- view.setUint8(offset + 2, card.sequence);
1946
- view.setUint8(offset + 3, 0);
1947
- offset += 4;
1948
- }
1949
- if (flags & OcgcoreCommonConstants.QUERY_TARGET_CARD) {
1950
- const targets = this.targetCards || [];
1951
- view.setInt32(offset, targets.length, true);
1952
- offset += 4;
1953
- for (const target of targets) {
1954
- view.setUint8(offset, target.controller);
1955
- view.setUint8(offset + 1, target.location);
1956
- view.setUint8(offset + 2, target.sequence);
1957
- view.setUint8(offset + 3, 0);
1958
- offset += 4;
1959
- }
1960
- }
1961
- if (flags & OcgcoreCommonConstants.QUERY_OVERLAY_CARD) {
1962
- const overlays = this.overlayCards || [];
1963
- view.setInt32(offset, overlays.length, true);
1964
- offset += 4;
1965
- for (const card of overlays) {
1966
- view.setInt32(offset, card, true);
1967
- offset += 4;
1968
- }
1969
- }
1970
- if (flags & OcgcoreCommonConstants.QUERY_COUNTERS) {
1971
- const counters = this.counters || [];
1972
- view.setInt32(offset, counters.length, true);
1973
- offset += 4;
1974
- for (const counter of counters) {
1975
- view.setUint16(offset, counter.type, true);
1976
- view.setUint16(offset + 2, counter.count, true);
1977
- offset += 4;
1978
- }
1979
- }
1980
- if (flags & OcgcoreCommonConstants.QUERY_OWNER) {
1981
- view.setInt32(offset, this.owner || 0, true);
1982
- offset += 4;
1983
- }
1984
- if (flags & OcgcoreCommonConstants.QUERY_STATUS) {
1985
- view.setInt32(offset, this.status || 0, true);
1986
- offset += 4;
1987
- }
1988
- if (flags & OcgcoreCommonConstants.QUERY_LSCALE) {
1989
- view.setInt32(offset, this.lscale || 0, true);
1990
- offset += 4;
1991
- }
1992
- if (flags & OcgcoreCommonConstants.QUERY_RSCALE) {
1993
- view.setInt32(offset, this.rscale || 0, true);
1994
- offset += 4;
1995
- }
1996
- if (flags & OcgcoreCommonConstants.QUERY_LINK) {
1997
- view.setInt32(offset, this.link || 0, true);
1998
- offset += 4;
1999
- view.setInt32(offset, this.linkMarker || 0, true);
2000
- offset += 4;
2001
- }
2002
- return new Uint8Array(view.buffer, view.byteOffset, offset);
2003
- }
2004
- };
2005
-
2006
- // src/protos/msg/proto/card-target.ts
2007
- var YGOProMsgCardTarget_CardLocation = class {
2008
- };
2009
- __decorateClass([
2010
- BinaryField("u8", 0)
2011
- ], YGOProMsgCardTarget_CardLocation.prototype, "controller", 2);
2012
- __decorateClass([
2013
- BinaryField("u8", 1)
2014
- ], YGOProMsgCardTarget_CardLocation.prototype, "location", 2);
2015
- __decorateClass([
2016
- BinaryField("u8", 2)
2017
- ], YGOProMsgCardTarget_CardLocation.prototype, "sequence", 2);
2018
- var YGOProMsgCardTarget = class extends YGOProMsgBase {
2019
- static {
2020
- this.identifier = OcgcoreCommonConstants.MSG_CARD_TARGET;
2021
- }
2022
- };
2023
- __decorateClass([
2024
- BinaryField(() => YGOProMsgCardTarget_CardLocation, 0)
2025
- ], YGOProMsgCardTarget.prototype, "card1", 2);
2026
- __decorateClass([
2027
- BinaryField(() => YGOProMsgCardTarget_CardLocation, 3)
2028
- ], YGOProMsgCardTarget.prototype, "card2", 2);
2029
-
2030
- // src/protos/msg/proto/chain-disabled.ts
2031
- var YGOProMsgChainDisabled = class extends YGOProMsgBase {
2032
- static {
2033
- this.identifier = OcgcoreCommonConstants.MSG_CHAIN_DISABLED;
2108
+ __decorateClass([
2109
+ BinaryField(() => YGOProMsgCardTarget_CardLocation, 0)
2110
+ ], YGOProMsgCardTarget.prototype, "card1", 2);
2111
+ __decorateClass([
2112
+ BinaryField(() => YGOProMsgCardTarget_CardLocation, 3)
2113
+ ], YGOProMsgCardTarget.prototype, "card2", 2);
2114
+
2115
+ // src/protos/msg/proto/chain-disabled.ts
2116
+ var YGOProMsgChainDisabled = class extends YGOProMsgBase {
2117
+ static {
2118
+ this.identifier = OcgcoreCommonConstants.MSG_CHAIN_DISABLED;
2034
2119
  }
2035
2120
  };
2036
2121
  __decorateClass([
@@ -2149,6 +2234,12 @@ var YGOProMsgConfirmCards = class extends YGOProMsgBase {
2149
2234
  });
2150
2235
  return view;
2151
2236
  }
2237
+ getSendTargets() {
2238
+ if (this.cards.length > 0 && this.cards[0].location === 1) {
2239
+ return [this.player];
2240
+ }
2241
+ return SEND_TO_ALL;
2242
+ }
2152
2243
  };
2153
2244
  __decorateClass([
2154
2245
  BinaryField("u8", 0)
@@ -2194,6 +2285,7 @@ var YGOProMsgConfirmDeckTop = class extends YGOProMsgBase {
2194
2285
  });
2195
2286
  return view;
2196
2287
  }
2288
+ // confirm-decktop 使用基类的 playerView (基于 player 字段)
2197
2289
  };
2198
2290
  __decorateClass([
2199
2291
  BinaryField("u8", 0)
@@ -2236,6 +2328,7 @@ var YGOProMsgConfirmExtraTop = class extends YGOProMsgBase {
2236
2328
  });
2237
2329
  return view;
2238
2330
  }
2331
+ // confirm-extratop 使用基类的 playerView (基于 player 字段)
2239
2332
  };
2240
2333
  __decorateClass([
2241
2334
  BinaryField("u8", 0)
@@ -2287,6 +2380,7 @@ var YGOProMsgDeckTop = class extends YGOProMsgBase {
2287
2380
  }
2288
2381
  return view;
2289
2382
  }
2383
+ // deck-top 使用基类的 playerView (基于 player 字段)
2290
2384
  };
2291
2385
  __decorateClass([
2292
2386
  BinaryField("u8", 0)
@@ -2402,10 +2496,21 @@ __decorateClass([
2402
2496
  ], YGOProMsgHandRes.prototype, "result", 2);
2403
2497
 
2404
2498
  // src/protos/msg/proto/hint.ts
2499
+ var HINT_TYPES_SEND_TO_SELF = /* @__PURE__ */ new Set([1, 2, 3, 5]);
2500
+ var HINT_TYPES_SEND_TO_OPPONENT = /* @__PURE__ */ new Set([4, 6, 7, 8, 9, 11]);
2405
2501
  var YGOProMsgHint = class extends YGOProMsgBase {
2406
2502
  static {
2407
2503
  this.identifier = OcgcoreCommonConstants.MSG_HINT;
2408
2504
  }
2505
+ getSendTargets() {
2506
+ if (HINT_TYPES_SEND_TO_SELF.has(this.type)) {
2507
+ return [this.player];
2508
+ }
2509
+ if (HINT_TYPES_SEND_TO_OPPONENT.has(this.type)) {
2510
+ return [1 - this.player, 7 /* OBSERVER */];
2511
+ }
2512
+ return SEND_TO_ALL;
2513
+ }
2409
2514
  };
2410
2515
  __decorateClass([
2411
2516
  BinaryField("u8", 0)
@@ -2445,6 +2550,9 @@ var YGOProMsgMissedEffect = class extends YGOProMsgBase {
2445
2550
  static {
2446
2551
  this.identifier = OcgcoreCommonConstants.MSG_MISSED_EFFECT;
2447
2552
  }
2553
+ getSendTargets() {
2554
+ return [this.player];
2555
+ }
2448
2556
  };
2449
2557
  __decorateClass([
2450
2558
  BinaryField("u8", 0)
@@ -2456,731 +2564,6 @@ __decorateClass([
2456
2564
  BinaryField("i32", 5)
2457
2565
  ], YGOProMsgMissedEffect.prototype, "desc", 2);
2458
2566
 
2459
- // src/protos/msg/proto/move.ts
2460
- var YGOProMsgMove_CardLocation = class {
2461
- };
2462
- __decorateClass([
2463
- BinaryField("u8", 0)
2464
- ], YGOProMsgMove_CardLocation.prototype, "controller", 2);
2465
- __decorateClass([
2466
- BinaryField("u8", 1)
2467
- ], YGOProMsgMove_CardLocation.prototype, "location", 2);
2468
- __decorateClass([
2469
- BinaryField("u8", 2)
2470
- ], YGOProMsgMove_CardLocation.prototype, "sequence", 2);
2471
- __decorateClass([
2472
- BinaryField("u8", 3)
2473
- ], YGOProMsgMove_CardLocation.prototype, "position", 2);
2474
- var YGOProMsgMove = class extends YGOProMsgBase {
2475
- static {
2476
- this.identifier = OcgcoreCommonConstants.MSG_MOVE;
2477
- }
2478
- };
2479
- __decorateClass([
2480
- BinaryField("i32", 0)
2481
- ], YGOProMsgMove.prototype, "code", 2);
2482
- __decorateClass([
2483
- BinaryField(() => YGOProMsgMove_CardLocation, 4)
2484
- ], YGOProMsgMove.prototype, "previous", 2);
2485
- __decorateClass([
2486
- BinaryField(() => YGOProMsgMove_CardLocation, 8)
2487
- ], YGOProMsgMove.prototype, "current", 2);
2488
- __decorateClass([
2489
- BinaryField("i32", 12)
2490
- ], YGOProMsgMove.prototype, "reason", 2);
2491
-
2492
- // src/protos/msg/proto/new-phase.ts
2493
- var YGOProMsgNewPhase = class extends YGOProMsgBase {
2494
- static {
2495
- this.identifier = OcgcoreCommonConstants.MSG_NEW_PHASE;
2496
- }
2497
- };
2498
- __decorateClass([
2499
- BinaryField("u16", 0)
2500
- ], YGOProMsgNewPhase.prototype, "phase", 2);
2501
-
2502
- // src/protos/msg/proto/new-turn.ts
2503
- var YGOProMsgNewTurn = class extends YGOProMsgBase {
2504
- static {
2505
- this.identifier = OcgcoreCommonConstants.MSG_NEW_TURN;
2506
- }
2507
- };
2508
- __decorateClass([
2509
- BinaryField("u8", 0)
2510
- ], YGOProMsgNewTurn.prototype, "player", 2);
2511
-
2512
- // src/protos/msg/proto/pay-lpcost.ts
2513
- var YGOProMsgPayLpCost = class extends YGOProMsgBase {
2514
- static {
2515
- this.identifier = OcgcoreCommonConstants.MSG_PAY_LPCOST;
2516
- }
2517
- };
2518
- __decorateClass([
2519
- BinaryField("u8", 0)
2520
- ], YGOProMsgPayLpCost.prototype, "player", 2);
2521
- __decorateClass([
2522
- BinaryField("i32", 1)
2523
- ], YGOProMsgPayLpCost.prototype, "cost", 2);
2524
-
2525
- // src/protos/msg/proto/player-hint.ts
2526
- var YGOProMsgPlayerHint = class extends YGOProMsgBase {
2527
- static {
2528
- this.identifier = OcgcoreCommonConstants.MSG_PLAYER_HINT;
2529
- }
2530
- };
2531
- __decorateClass([
2532
- BinaryField("u8", 0)
2533
- ], YGOProMsgPlayerHint.prototype, "player", 2);
2534
- __decorateClass([
2535
- BinaryField("u8", 1)
2536
- ], YGOProMsgPlayerHint.prototype, "type", 2);
2537
- __decorateClass([
2538
- BinaryField("i32", 2)
2539
- ], YGOProMsgPlayerHint.prototype, "value", 2);
2540
-
2541
- // src/protos/msg/proto/pos-change.ts
2542
- var YGOProMsgPosChange_CardLocation = class {
2543
- };
2544
- __decorateClass([
2545
- BinaryField("u8", 0)
2546
- ], YGOProMsgPosChange_CardLocation.prototype, "controller", 2);
2547
- __decorateClass([
2548
- BinaryField("u8", 1)
2549
- ], YGOProMsgPosChange_CardLocation.prototype, "location", 2);
2550
- __decorateClass([
2551
- BinaryField("u8", 2)
2552
- ], YGOProMsgPosChange_CardLocation.prototype, "sequence", 2);
2553
- var YGOProMsgPosChange = class extends YGOProMsgBase {
2554
- static {
2555
- this.identifier = OcgcoreCommonConstants.MSG_POS_CHANGE;
2556
- }
2557
- };
2558
- __decorateClass([
2559
- BinaryField(() => YGOProMsgPosChange_CardLocation, 0)
2560
- ], YGOProMsgPosChange.prototype, "card", 2);
2561
- __decorateClass([
2562
- BinaryField("u8", 3)
2563
- ], YGOProMsgPosChange.prototype, "previousPosition", 2);
2564
- __decorateClass([
2565
- BinaryField("u8", 4)
2566
- ], YGOProMsgPosChange.prototype, "currentPosition", 2);
2567
-
2568
- // src/protos/msg/proto/random-selected.ts
2569
- var YGOProMsgRandomSelected = class extends YGOProMsgBase {
2570
- static {
2571
- this.identifier = OcgcoreCommonConstants.MSG_RANDOM_SELECTED;
2572
- }
2573
- };
2574
- __decorateClass([
2575
- BinaryField("u8", 0)
2576
- ], YGOProMsgRandomSelected.prototype, "player", 2);
2577
- __decorateClass([
2578
- BinaryField("u8", 1)
2579
- ], YGOProMsgRandomSelected.prototype, "count", 2);
2580
- __decorateClass([
2581
- BinaryField("i32", 2, (obj) => obj.count)
2582
- ], YGOProMsgRandomSelected.prototype, "cards", 2);
2583
-
2584
- // src/protos/msg/proto/recover.ts
2585
- var YGOProMsgRecover = class extends YGOProMsgBase {
2586
- static {
2587
- this.identifier = OcgcoreCommonConstants.MSG_RECOVER;
2588
- }
2589
- };
2590
- __decorateClass([
2591
- BinaryField("u8", 0)
2592
- ], YGOProMsgRecover.prototype, "player", 2);
2593
- __decorateClass([
2594
- BinaryField("i32", 1)
2595
- ], YGOProMsgRecover.prototype, "value", 2);
2596
-
2597
- // src/protos/msg/proto/reload-field.ts
2598
- var YGOProMsgReloadField_ZoneCard = class {
2599
- };
2600
- var YGOProMsgReloadField_PlayerInfo = class {
2601
- };
2602
- var YGOProMsgReloadField_ChainInfo = class {
2603
- };
2604
- var YGOProMsgReloadField = class extends YGOProMsgBase {
2605
- static {
2606
- this.identifier = 162;
2607
- }
2608
- fromPayload(data) {
2609
- if (data.length < 1) {
2610
- throw new Error("MSG data too short");
2611
- }
2612
- const msgType = data[0];
2613
- if (msgType !== this.identifier) {
2614
- throw new Error(
2615
- `MSG type mismatch: expected ${this.identifier}, got ${msgType}`
2616
- );
2617
- }
2618
- const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
2619
- let offset = 1;
2620
- this.duelRule = view.getUint8(offset++);
2621
- this.players = [];
2622
- for (let i = 0; i < 2; i++) {
2623
- const player = {
2624
- lp: view.getInt32(offset, true),
2625
- mzone: [],
2626
- szone: [],
2627
- deckCount: 0,
2628
- handCount: 0,
2629
- graveCount: 0,
2630
- removedCount: 0,
2631
- extraCount: 0,
2632
- extraPCount: 0
2633
- };
2634
- offset += 4;
2635
- for (let seq = 0; seq < 7; seq++) {
2636
- const occupied = view.getUint8(offset++);
2637
- const card = { occupied };
2638
- if (occupied) {
2639
- card.position = view.getUint8(offset++);
2640
- card.xyzCount = view.getUint8(offset++);
2641
- }
2642
- player.mzone.push(card);
2643
- }
2644
- for (let seq = 0; seq < 8; seq++) {
2645
- const occupied = view.getUint8(offset++);
2646
- const card = { occupied };
2647
- if (occupied) {
2648
- card.position = view.getUint8(offset++);
2649
- }
2650
- player.szone.push(card);
2651
- }
2652
- player.deckCount = view.getUint8(offset++);
2653
- player.handCount = view.getUint8(offset++);
2654
- player.graveCount = view.getUint8(offset++);
2655
- player.removedCount = view.getUint8(offset++);
2656
- player.extraCount = view.getUint8(offset++);
2657
- player.extraPCount = view.getUint8(offset++);
2658
- this.players.push(player);
2659
- }
2660
- const chainCount = view.getUint8(offset++);
2661
- this.chains = [];
2662
- for (let i = 0; i < chainCount; i++) {
2663
- const chain = {
2664
- code: view.getInt32(offset, true),
2665
- chainCardController: view.getUint8(offset + 4),
2666
- chainCardLocation: view.getUint8(offset + 5),
2667
- chainCardSequence: view.getUint8(offset + 6),
2668
- chainCardSubsequence: view.getUint8(offset + 7),
2669
- triggerController: view.getUint8(offset + 8),
2670
- triggerLocation: view.getUint8(offset + 9),
2671
- triggerSequence: view.getUint8(offset + 10),
2672
- desc: view.getInt32(offset + 11, true)
2673
- };
2674
- offset += 15;
2675
- this.chains.push(chain);
2676
- }
2677
- return this;
2678
- }
2679
- toPayload() {
2680
- let size = 1 + 1;
2681
- for (const player of this.players) {
2682
- size += 4;
2683
- for (const card of player.mzone) {
2684
- size += 1;
2685
- if (card.occupied) {
2686
- size += 2;
2687
- }
2688
- }
2689
- for (const card of player.szone) {
2690
- size += 1;
2691
- if (card.occupied) {
2692
- size += 1;
2693
- }
2694
- }
2695
- size += 6;
2696
- }
2697
- size += 1;
2698
- size += this.chains.length * 15;
2699
- const result = new Uint8Array(size);
2700
- const view = new DataView(result.buffer);
2701
- let offset = 0;
2702
- result[offset++] = this.identifier;
2703
- result[offset++] = this.duelRule;
2704
- for (const player of this.players) {
2705
- view.setInt32(offset, player.lp, true);
2706
- offset += 4;
2707
- for (const card of player.mzone) {
2708
- result[offset++] = card.occupied;
2709
- if (card.occupied) {
2710
- result[offset++] = card.position || 0;
2711
- result[offset++] = card.xyzCount || 0;
2712
- }
2713
- }
2714
- for (const card of player.szone) {
2715
- result[offset++] = card.occupied;
2716
- if (card.occupied) {
2717
- result[offset++] = card.position || 0;
2718
- }
2719
- }
2720
- result[offset++] = player.deckCount;
2721
- result[offset++] = player.handCount;
2722
- result[offset++] = player.graveCount;
2723
- result[offset++] = player.removedCount;
2724
- result[offset++] = player.extraCount;
2725
- result[offset++] = player.extraPCount;
2726
- }
2727
- result[offset++] = this.chains.length;
2728
- for (const chain of this.chains) {
2729
- view.setInt32(offset, chain.code, true);
2730
- result[offset + 4] = chain.chainCardController;
2731
- result[offset + 5] = chain.chainCardLocation;
2732
- result[offset + 6] = chain.chainCardSequence;
2733
- result[offset + 7] = chain.chainCardSubsequence;
2734
- result[offset + 8] = chain.triggerController;
2735
- result[offset + 9] = chain.triggerLocation;
2736
- result[offset + 10] = chain.triggerSequence;
2737
- view.setInt32(offset + 11, chain.desc, true);
2738
- offset += 15;
2739
- }
2740
- return result;
2741
- }
2742
- };
2743
-
2744
- // src/protos/msg/proto/remove-counter.ts
2745
- var YGOProMsgRemoveCounter = class extends YGOProMsgBase {
2746
- static {
2747
- this.identifier = OcgcoreCommonConstants.MSG_REMOVE_COUNTER;
2748
- }
2749
- };
2750
- __decorateClass([
2751
- BinaryField("u16", 0)
2752
- ], YGOProMsgRemoveCounter.prototype, "counterType", 2);
2753
- __decorateClass([
2754
- BinaryField("u8", 2)
2755
- ], YGOProMsgRemoveCounter.prototype, "controller", 2);
2756
- __decorateClass([
2757
- BinaryField("u8", 3)
2758
- ], YGOProMsgRemoveCounter.prototype, "location", 2);
2759
- __decorateClass([
2760
- BinaryField("u8", 4)
2761
- ], YGOProMsgRemoveCounter.prototype, "sequence", 2);
2762
- __decorateClass([
2763
- BinaryField("u16", 5)
2764
- ], YGOProMsgRemoveCounter.prototype, "count", 2);
2765
-
2766
- // src/protos/msg/proto/reset-time.ts
2767
- var YGOProMsgResetTime = class extends YGOProMsgBase {
2768
- static {
2769
- this.identifier = OcgcoreCommonConstants.MSG_RESET_TIME;
2770
- }
2771
- };
2772
- __decorateClass([
2773
- BinaryField("i8", 0)
2774
- ], YGOProMsgResetTime.prototype, "player", 2);
2775
- __decorateClass([
2776
- BinaryField("i16", 1)
2777
- ], YGOProMsgResetTime.prototype, "time", 2);
2778
-
2779
- // src/protos/msg/proto/retry.ts
2780
- var YGOProMsgRetry = class extends YGOProMsgBase {
2781
- static {
2782
- this.identifier = OcgcoreCommonConstants.MSG_RETRY;
2783
- }
2784
- };
2785
-
2786
- // src/protos/msg/proto/reverse-deck.ts
2787
- var YGOProMsgReverseDeck = class extends YGOProMsgBase {
2788
- static {
2789
- this.identifier = OcgcoreCommonConstants.MSG_REVERSE_DECK;
2790
- }
2791
- };
2792
-
2793
- // src/protos/msg/proto/rock-paper-scissors.ts
2794
- var YGOProMsgRockPaperScissors = class extends YGOProMsgBase {
2795
- static {
2796
- this.identifier = OcgcoreCommonConstants.MSG_ROCK_PAPER_SCISSORS;
2797
- }
2798
- };
2799
- __decorateClass([
2800
- BinaryField("u8", 0)
2801
- ], YGOProMsgRockPaperScissors.prototype, "player", 2);
2802
-
2803
- // src/protos/msg/proto/select-battlecmd.ts
2804
- var BattleCmdType = /* @__PURE__ */ ((BattleCmdType2) => {
2805
- BattleCmdType2[BattleCmdType2["ACTIVATE"] = 0] = "ACTIVATE";
2806
- BattleCmdType2[BattleCmdType2["ATTACK"] = 1] = "ATTACK";
2807
- BattleCmdType2[BattleCmdType2["TO_M2"] = 2] = "TO_M2";
2808
- BattleCmdType2[BattleCmdType2["TO_EP"] = 3] = "TO_EP";
2809
- return BattleCmdType2;
2810
- })(BattleCmdType || {});
2811
- var YGOProMsgSelectBattleCmd_ActivatableInfo = class {
2812
- };
2813
- __decorateClass([
2814
- BinaryField("i32", 0)
2815
- ], YGOProMsgSelectBattleCmd_ActivatableInfo.prototype, "code", 2);
2816
- __decorateClass([
2817
- BinaryField("u8", 4)
2818
- ], YGOProMsgSelectBattleCmd_ActivatableInfo.prototype, "controller", 2);
2819
- __decorateClass([
2820
- BinaryField("u8", 5)
2821
- ], YGOProMsgSelectBattleCmd_ActivatableInfo.prototype, "location", 2);
2822
- __decorateClass([
2823
- BinaryField("u8", 6)
2824
- ], YGOProMsgSelectBattleCmd_ActivatableInfo.prototype, "sequence", 2);
2825
- __decorateClass([
2826
- BinaryField("i32", 7)
2827
- ], YGOProMsgSelectBattleCmd_ActivatableInfo.prototype, "desc", 2);
2828
- var YGOProMsgSelectBattleCmd_AttackableInfo = class {
2829
- };
2830
- __decorateClass([
2831
- BinaryField("i32", 0)
2832
- ], YGOProMsgSelectBattleCmd_AttackableInfo.prototype, "code", 2);
2833
- __decorateClass([
2834
- BinaryField("u8", 4)
2835
- ], YGOProMsgSelectBattleCmd_AttackableInfo.prototype, "controller", 2);
2836
- __decorateClass([
2837
- BinaryField("u8", 5)
2838
- ], YGOProMsgSelectBattleCmd_AttackableInfo.prototype, "location", 2);
2839
- __decorateClass([
2840
- BinaryField("u8", 6)
2841
- ], YGOProMsgSelectBattleCmd_AttackableInfo.prototype, "sequence", 2);
2842
- __decorateClass([
2843
- BinaryField("u8", 7)
2844
- ], YGOProMsgSelectBattleCmd_AttackableInfo.prototype, "directAttack", 2);
2845
- var YGOProMsgSelectBattleCmd = class extends YGOProMsgResponseBase {
2846
- static {
2847
- this.identifier = OcgcoreCommonConstants.MSG_SELECT_BATTLECMD;
2848
- }
2849
- responsePlayer() {
2850
- return this.player;
2851
- }
2852
- prepareResponse(type, option) {
2853
- let sequence;
2854
- if (type === 0 /* ACTIVATE */) {
2855
- if (option == null) {
2856
- throw new TypeError("Option required for ACTIVATE");
2857
- }
2858
- if (isIndexResponse(option)) {
2859
- sequence = option.index;
2860
- if (sequence < 0 || sequence >= this.activatableCount) {
2861
- throw new TypeError(`Index out of range: ${sequence}`);
2862
- }
2863
- } else {
2864
- const idx = this.activatableCards.findIndex(
2865
- (card) => (option.code == null || card.code === option.code) && (option.controller == null || card.controller === option.controller) && (option.location == null || card.location === option.location) && (option.sequence == null || card.sequence === option.sequence) && (option.desc == null || card.desc === option.desc)
2866
- );
2867
- if (idx === -1) {
2868
- throw new TypeError("Activatable card not found");
2869
- }
2870
- sequence = idx;
2871
- }
2872
- } else if (type === 1 /* ATTACK */) {
2873
- if (option == null) {
2874
- throw new TypeError("Option required for ATTACK");
2875
- }
2876
- if (isIndexResponse(option)) {
2877
- sequence = option.index;
2878
- if (sequence < 0 || sequence >= this.attackableCount) {
2879
- throw new TypeError(`Index out of range: ${sequence}`);
2880
- }
2881
- } else {
2882
- const idx = this.attackableCards.findIndex(
2883
- (card) => (option.code == null || card.code === option.code) && (option.controller == null || card.controller === option.controller) && (option.location == null || card.location === option.location) && (option.sequence == null || card.sequence === option.sequence)
2884
- );
2885
- if (idx === -1) {
2886
- throw new TypeError("Attackable card not found");
2887
- }
2888
- sequence = idx;
2889
- }
2890
- } else if (type === 2 /* TO_M2 */) {
2891
- if (this.canM2 === 0) {
2892
- throw new TypeError("Cannot go to M2");
2893
- }
2894
- sequence = 0;
2895
- } else if (type === 3 /* TO_EP */) {
2896
- if (this.canEp === 0) {
2897
- throw new TypeError("Cannot go to EP");
2898
- }
2899
- sequence = 0;
2900
- } else {
2901
- throw new TypeError(`Unknown type: ${type}`);
2902
- }
2903
- const buffer = new Uint8Array(4);
2904
- const view = new DataView(buffer.buffer);
2905
- view.setUint32(0, sequence << 16 | type, true);
2906
- return buffer;
2907
- }
2908
- };
2909
- __decorateClass([
2910
- BinaryField("u8", 0)
2911
- ], YGOProMsgSelectBattleCmd.prototype, "player", 2);
2912
- __decorateClass([
2913
- BinaryField("u8", 1)
2914
- ], YGOProMsgSelectBattleCmd.prototype, "activatableCount", 2);
2915
- __decorateClass([
2916
- BinaryField(
2917
- () => YGOProMsgSelectBattleCmd_ActivatableInfo,
2918
- 2,
2919
- (obj) => obj.activatableCount
2920
- )
2921
- ], YGOProMsgSelectBattleCmd.prototype, "activatableCards", 2);
2922
- __decorateClass([
2923
- BinaryField("u8", (obj) => {
2924
- return 2 + obj.activatableCount * 11;
2925
- })
2926
- ], YGOProMsgSelectBattleCmd.prototype, "attackableCount", 2);
2927
- __decorateClass([
2928
- BinaryField(
2929
- () => YGOProMsgSelectBattleCmd_AttackableInfo,
2930
- (obj) => {
2931
- return 3 + obj.activatableCount * 11;
2932
- },
2933
- (obj) => obj.attackableCount
2934
- )
2935
- ], YGOProMsgSelectBattleCmd.prototype, "attackableCards", 2);
2936
- __decorateClass([
2937
- BinaryField("u8", (obj) => {
2938
- return 3 + obj.activatableCount * 11 + obj.attackableCount * 8;
2939
- })
2940
- ], YGOProMsgSelectBattleCmd.prototype, "canM2", 2);
2941
- __decorateClass([
2942
- BinaryField("u8", (obj) => {
2943
- return 4 + obj.activatableCount * 11 + obj.attackableCount * 8;
2944
- })
2945
- ], YGOProMsgSelectBattleCmd.prototype, "canEp", 2);
2946
-
2947
- // src/protos/msg/proto/select-card.ts
2948
- var YGOProMsgSelectCard_CardInfo = class {
2949
- };
2950
- __decorateClass([
2951
- BinaryField("i32", 0)
2952
- ], YGOProMsgSelectCard_CardInfo.prototype, "code", 2);
2953
- __decorateClass([
2954
- BinaryField("u8", 4)
2955
- ], YGOProMsgSelectCard_CardInfo.prototype, "controller", 2);
2956
- __decorateClass([
2957
- BinaryField("u8", 5)
2958
- ], YGOProMsgSelectCard_CardInfo.prototype, "location", 2);
2959
- __decorateClass([
2960
- BinaryField("u8", 6)
2961
- ], YGOProMsgSelectCard_CardInfo.prototype, "sequence", 2);
2962
- __decorateClass([
2963
- BinaryField("u8", 7)
2964
- ], YGOProMsgSelectCard_CardInfo.prototype, "subsequence", 2);
2965
- var YGOProMsgSelectCard = class extends YGOProMsgResponseBase {
2966
- static {
2967
- this.identifier = OcgcoreCommonConstants.MSG_SELECT_CARD;
2968
- }
2969
- responsePlayer() {
2970
- return this.player;
2971
- }
2972
- defaultResponse() {
2973
- if (this.cancelable === 0) {
2974
- return void 0;
2975
- }
2976
- return this.prepareResponse(null);
2977
- }
2978
- prepareResponse(cardOptions) {
2979
- if (cardOptions == null) {
2980
- const buffer2 = new Uint8Array(4);
2981
- const view = new DataView(buffer2.buffer);
2982
- view.setInt32(0, -1, true);
2983
- return buffer2;
2984
- }
2985
- const indices = [];
2986
- const usedIndices = /* @__PURE__ */ new Set();
2987
- for (const option of cardOptions) {
2988
- let index;
2989
- if (isIndexResponse(option)) {
2990
- index = option.index;
2991
- if (index < 0 || index >= this.count) {
2992
- throw new TypeError(`Index out of range: ${index}`);
2993
- }
2994
- } else {
2995
- index = this.cards.findIndex(
2996
- (card, idx) => !usedIndices.has(idx) && (option.code == null || card.code === option.code) && (option.controller == null || card.controller === option.controller) && (option.location == null || card.location === option.location) && (option.sequence == null || card.sequence === option.sequence)
2997
- );
2998
- if (index === -1) {
2999
- throw new TypeError("Card not found");
3000
- }
3001
- }
3002
- indices.push(index);
3003
- usedIndices.add(index);
3004
- }
3005
- const buffer = new Uint8Array(1 + indices.length);
3006
- buffer[0] = indices.length;
3007
- indices.forEach((idx, i) => {
3008
- buffer[1 + i] = idx;
3009
- });
3010
- return buffer;
3011
- }
3012
- };
3013
- __decorateClass([
3014
- BinaryField("u8", 0)
3015
- ], YGOProMsgSelectCard.prototype, "player", 2);
3016
- __decorateClass([
3017
- BinaryField("u8", 1)
3018
- ], YGOProMsgSelectCard.prototype, "cancelable", 2);
3019
- __decorateClass([
3020
- BinaryField("u8", 2)
3021
- ], YGOProMsgSelectCard.prototype, "min", 2);
3022
- __decorateClass([
3023
- BinaryField("u8", 3)
3024
- ], YGOProMsgSelectCard.prototype, "max", 2);
3025
- __decorateClass([
3026
- BinaryField("u8", 4)
3027
- ], YGOProMsgSelectCard.prototype, "count", 2);
3028
- __decorateClass([
3029
- BinaryField(() => YGOProMsgSelectCard_CardInfo, 5, (obj) => obj.count)
3030
- ], YGOProMsgSelectCard.prototype, "cards", 2);
3031
-
3032
- // src/protos/msg/proto/select-chain.ts
3033
- var YGOProMsgSelectChain_ChainInfo = class {
3034
- };
3035
- __decorateClass([
3036
- BinaryField("u8", 0)
3037
- ], YGOProMsgSelectChain_ChainInfo.prototype, "edesc", 2);
3038
- __decorateClass([
3039
- BinaryField("u8", 1)
3040
- ], YGOProMsgSelectChain_ChainInfo.prototype, "forced", 2);
3041
- __decorateClass([
3042
- BinaryField("i32", 2)
3043
- ], YGOProMsgSelectChain_ChainInfo.prototype, "code", 2);
3044
- __decorateClass([
3045
- BinaryField("u8", 6)
3046
- ], YGOProMsgSelectChain_ChainInfo.prototype, "controller", 2);
3047
- __decorateClass([
3048
- BinaryField("u8", 7)
3049
- ], YGOProMsgSelectChain_ChainInfo.prototype, "location", 2);
3050
- __decorateClass([
3051
- BinaryField("u8", 8)
3052
- ], YGOProMsgSelectChain_ChainInfo.prototype, "sequence", 2);
3053
- __decorateClass([
3054
- BinaryField("u8", 9)
3055
- ], YGOProMsgSelectChain_ChainInfo.prototype, "subsequence", 2);
3056
- __decorateClass([
3057
- BinaryField("i32", 10)
3058
- ], YGOProMsgSelectChain_ChainInfo.prototype, "desc", 2);
3059
- var YGOProMsgSelectChain = class extends YGOProMsgResponseBase {
3060
- static {
3061
- this.identifier = OcgcoreCommonConstants.MSG_SELECT_CHAIN;
3062
- }
3063
- responsePlayer() {
3064
- return this.player;
3065
- }
3066
- defaultResponse() {
3067
- const hasForced = this.chains.some((chain) => chain.forced !== 0);
3068
- if (hasForced) {
3069
- return void 0;
3070
- }
3071
- return this.prepareResponse(null);
3072
- }
3073
- prepareResponse(option) {
3074
- let index;
3075
- if (option == null) {
3076
- index = -1;
3077
- } else if (isIndexResponse(option)) {
3078
- index = option.index;
3079
- if (index < -1 || index >= this.count) {
3080
- throw new TypeError(`Index out of range: ${index}`);
3081
- }
3082
- } else {
3083
- index = this.chains.findIndex(
3084
- (chain) => (option.code == null || chain.code === option.code) && (option.controller == null || chain.controller === option.controller) && (option.location == null || chain.location === option.location) && (option.sequence == null || chain.sequence === option.sequence) && (option.desc == null || chain.desc === option.desc)
3085
- );
3086
- if (index === -1) {
3087
- throw new TypeError("Chain not found");
3088
- }
3089
- }
3090
- const buffer = new Uint8Array(4);
3091
- const view = new DataView(buffer.buffer);
3092
- view.setInt32(0, index, true);
3093
- return buffer;
3094
- }
3095
- };
3096
- __decorateClass([
3097
- BinaryField("u8", 0)
3098
- ], YGOProMsgSelectChain.prototype, "player", 2);
3099
- __decorateClass([
3100
- BinaryField("u8", 1)
3101
- ], YGOProMsgSelectChain.prototype, "count", 2);
3102
- __decorateClass([
3103
- BinaryField("u8", 2)
3104
- ], YGOProMsgSelectChain.prototype, "specialCount", 2);
3105
- __decorateClass([
3106
- BinaryField("i32", 3)
3107
- ], YGOProMsgSelectChain.prototype, "hint0", 2);
3108
- __decorateClass([
3109
- BinaryField("i32", 7)
3110
- ], YGOProMsgSelectChain.prototype, "hint1", 2);
3111
- __decorateClass([
3112
- BinaryField(() => YGOProMsgSelectChain_ChainInfo, 11, (obj) => obj.count)
3113
- ], YGOProMsgSelectChain.prototype, "chains", 2);
3114
-
3115
- // src/protos/msg/proto/select-counter.ts
3116
- var YGOProMsgSelectCounter_CardInfo = class {
3117
- };
3118
- __decorateClass([
3119
- BinaryField("i32", 0)
3120
- ], YGOProMsgSelectCounter_CardInfo.prototype, "code", 2);
3121
- __decorateClass([
3122
- BinaryField("u8", 4)
3123
- ], YGOProMsgSelectCounter_CardInfo.prototype, "controller", 2);
3124
- __decorateClass([
3125
- BinaryField("u8", 5)
3126
- ], YGOProMsgSelectCounter_CardInfo.prototype, "location", 2);
3127
- __decorateClass([
3128
- BinaryField("u8", 6)
3129
- ], YGOProMsgSelectCounter_CardInfo.prototype, "sequence", 2);
3130
- __decorateClass([
3131
- BinaryField("u16", 7)
3132
- ], YGOProMsgSelectCounter_CardInfo.prototype, "counterCount", 2);
3133
- var YGOProMsgSelectCounter = class extends YGOProMsgResponseBase {
3134
- static {
3135
- this.identifier = OcgcoreCommonConstants.MSG_SELECT_COUNTER;
3136
- }
3137
- responsePlayer() {
3138
- return this.player;
3139
- }
3140
- prepareResponse(counterOptions) {
3141
- const counterCounts = new Array(this.count).fill(0);
3142
- for (const option of counterOptions) {
3143
- let index;
3144
- if (isIndexResponse(option.card)) {
3145
- index = option.card.index;
3146
- if (index < 0 || index >= this.count) {
3147
- throw new TypeError(`Index out of range: ${index}`);
3148
- }
3149
- } else {
3150
- const card = option.card;
3151
- index = this.cards.findIndex(
3152
- (card2) => (card2.code == null || card2.code === card2.code) && (card2.controller == null || card2.controller === card2.controller) && (card2.location == null || card2.location === card2.location) && (card2.sequence == null || card2.sequence === card2.sequence)
3153
- );
3154
- if (index === -1) {
3155
- throw new TypeError("Card not found");
3156
- }
3157
- }
3158
- counterCounts[index] = option.count;
3159
- }
3160
- const buffer = new Uint8Array(counterCounts.length * 2);
3161
- const view = new DataView(buffer.buffer);
3162
- counterCounts.forEach((count, i) => {
3163
- view.setUint16(i * 2, count, true);
3164
- });
3165
- return buffer;
3166
- }
3167
- };
3168
- __decorateClass([
3169
- BinaryField("u8", 0)
3170
- ], YGOProMsgSelectCounter.prototype, "player", 2);
3171
- __decorateClass([
3172
- BinaryField("u16", 1)
3173
- ], YGOProMsgSelectCounter.prototype, "counterType", 2);
3174
- __decorateClass([
3175
- BinaryField("u16", 3)
3176
- ], YGOProMsgSelectCounter.prototype, "counterCount", 2);
3177
- __decorateClass([
3178
- BinaryField("u8", 5)
3179
- ], YGOProMsgSelectCounter.prototype, "count", 2);
3180
- __decorateClass([
3181
- BinaryField(() => YGOProMsgSelectCounter_CardInfo, 6, (obj) => obj.count)
3182
- ], YGOProMsgSelectCounter.prototype, "cards", 2);
3183
-
3184
2567
  // src/vendor/script-constants.ts
3185
2568
  var OcgcoreScriptConstants = {
3186
2569
  ACTIVITY_ATTACK: 5,
@@ -4019,6 +3402,783 @@ var OcgcoreScriptConstants = {
4019
3402
  TYPE_XYZ: 8388608
4020
3403
  };
4021
3404
 
3405
+ // src/protos/msg/proto/move.ts
3406
+ var YGOProMsgMove_CardLocation = class {
3407
+ };
3408
+ __decorateClass([
3409
+ BinaryField("u8", 0)
3410
+ ], YGOProMsgMove_CardLocation.prototype, "controller", 2);
3411
+ __decorateClass([
3412
+ BinaryField("u8", 1)
3413
+ ], YGOProMsgMove_CardLocation.prototype, "location", 2);
3414
+ __decorateClass([
3415
+ BinaryField("u8", 2)
3416
+ ], YGOProMsgMove_CardLocation.prototype, "sequence", 2);
3417
+ __decorateClass([
3418
+ BinaryField("u8", 3)
3419
+ ], YGOProMsgMove_CardLocation.prototype, "position", 2);
3420
+ var YGOProMsgMove = class extends YGOProMsgBase {
3421
+ static {
3422
+ this.identifier = OcgcoreCommonConstants.MSG_MOVE;
3423
+ }
3424
+ opponentView() {
3425
+ const view = this.copy();
3426
+ const cl = view.current.location;
3427
+ const cp = view.current.position;
3428
+ if (cl & (OcgcoreScriptConstants.LOCATION_GRAVE | OcgcoreScriptConstants.LOCATION_OVERLAY)) {
3429
+ return view;
3430
+ }
3431
+ if (cl & (OcgcoreScriptConstants.LOCATION_DECK | OcgcoreScriptConstants.LOCATION_HAND) || cp & OcgcoreCommonConstants.POS_FACEDOWN) {
3432
+ view.code = 0;
3433
+ }
3434
+ return view;
3435
+ }
3436
+ teammateView() {
3437
+ const view = this.copy();
3438
+ const cl = view.current.location;
3439
+ const cp = view.current.position;
3440
+ if (cl & (OcgcoreScriptConstants.LOCATION_GRAVE | OcgcoreScriptConstants.LOCATION_OVERLAY)) {
3441
+ return view;
3442
+ }
3443
+ if (cl & (OcgcoreScriptConstants.LOCATION_DECK | OcgcoreScriptConstants.LOCATION_HAND)) {
3444
+ view.code = 0;
3445
+ }
3446
+ return view;
3447
+ }
3448
+ playerView(playerId) {
3449
+ if (playerId === 7 /* OBSERVER */) {
3450
+ return this.observerView();
3451
+ }
3452
+ if (playerId === this.current.controller) {
3453
+ return this.copy();
3454
+ }
3455
+ return this.opponentView();
3456
+ }
3457
+ };
3458
+ __decorateClass([
3459
+ BinaryField("i32", 0)
3460
+ ], YGOProMsgMove.prototype, "code", 2);
3461
+ __decorateClass([
3462
+ BinaryField(() => YGOProMsgMove_CardLocation, 4)
3463
+ ], YGOProMsgMove.prototype, "previous", 2);
3464
+ __decorateClass([
3465
+ BinaryField(() => YGOProMsgMove_CardLocation, 8)
3466
+ ], YGOProMsgMove.prototype, "current", 2);
3467
+ __decorateClass([
3468
+ BinaryField("i32", 12)
3469
+ ], YGOProMsgMove.prototype, "reason", 2);
3470
+
3471
+ // src/protos/msg/proto/new-phase.ts
3472
+ var YGOProMsgNewPhase = class extends YGOProMsgBase {
3473
+ static {
3474
+ this.identifier = OcgcoreCommonConstants.MSG_NEW_PHASE;
3475
+ }
3476
+ };
3477
+ __decorateClass([
3478
+ BinaryField("u16", 0)
3479
+ ], YGOProMsgNewPhase.prototype, "phase", 2);
3480
+
3481
+ // src/protos/msg/proto/new-turn.ts
3482
+ var YGOProMsgNewTurn = class extends YGOProMsgBase {
3483
+ static {
3484
+ this.identifier = OcgcoreCommonConstants.MSG_NEW_TURN;
3485
+ }
3486
+ };
3487
+ __decorateClass([
3488
+ BinaryField("u8", 0)
3489
+ ], YGOProMsgNewTurn.prototype, "player", 2);
3490
+
3491
+ // src/protos/msg/proto/pay-lpcost.ts
3492
+ var YGOProMsgPayLpCost = class extends YGOProMsgBase {
3493
+ static {
3494
+ this.identifier = OcgcoreCommonConstants.MSG_PAY_LPCOST;
3495
+ }
3496
+ };
3497
+ __decorateClass([
3498
+ BinaryField("u8", 0)
3499
+ ], YGOProMsgPayLpCost.prototype, "player", 2);
3500
+ __decorateClass([
3501
+ BinaryField("i32", 1)
3502
+ ], YGOProMsgPayLpCost.prototype, "cost", 2);
3503
+
3504
+ // src/protos/msg/proto/player-hint.ts
3505
+ var YGOProMsgPlayerHint = class extends YGOProMsgBase {
3506
+ static {
3507
+ this.identifier = OcgcoreCommonConstants.MSG_PLAYER_HINT;
3508
+ }
3509
+ };
3510
+ __decorateClass([
3511
+ BinaryField("u8", 0)
3512
+ ], YGOProMsgPlayerHint.prototype, "player", 2);
3513
+ __decorateClass([
3514
+ BinaryField("u8", 1)
3515
+ ], YGOProMsgPlayerHint.prototype, "type", 2);
3516
+ __decorateClass([
3517
+ BinaryField("i32", 2)
3518
+ ], YGOProMsgPlayerHint.prototype, "value", 2);
3519
+
3520
+ // src/protos/msg/proto/pos-change.ts
3521
+ var YGOProMsgPosChange_CardLocation = class {
3522
+ };
3523
+ __decorateClass([
3524
+ BinaryField("u8", 0)
3525
+ ], YGOProMsgPosChange_CardLocation.prototype, "controller", 2);
3526
+ __decorateClass([
3527
+ BinaryField("u8", 1)
3528
+ ], YGOProMsgPosChange_CardLocation.prototype, "location", 2);
3529
+ __decorateClass([
3530
+ BinaryField("u8", 2)
3531
+ ], YGOProMsgPosChange_CardLocation.prototype, "sequence", 2);
3532
+ var YGOProMsgPosChange = class extends YGOProMsgBase {
3533
+ static {
3534
+ this.identifier = OcgcoreCommonConstants.MSG_POS_CHANGE;
3535
+ }
3536
+ };
3537
+ __decorateClass([
3538
+ BinaryField(() => YGOProMsgPosChange_CardLocation, 0)
3539
+ ], YGOProMsgPosChange.prototype, "card", 2);
3540
+ __decorateClass([
3541
+ BinaryField("u8", 3)
3542
+ ], YGOProMsgPosChange.prototype, "previousPosition", 2);
3543
+ __decorateClass([
3544
+ BinaryField("u8", 4)
3545
+ ], YGOProMsgPosChange.prototype, "currentPosition", 2);
3546
+
3547
+ // src/protos/msg/proto/random-selected.ts
3548
+ var YGOProMsgRandomSelected = class extends YGOProMsgBase {
3549
+ static {
3550
+ this.identifier = OcgcoreCommonConstants.MSG_RANDOM_SELECTED;
3551
+ }
3552
+ };
3553
+ __decorateClass([
3554
+ BinaryField("u8", 0)
3555
+ ], YGOProMsgRandomSelected.prototype, "player", 2);
3556
+ __decorateClass([
3557
+ BinaryField("u8", 1)
3558
+ ], YGOProMsgRandomSelected.prototype, "count", 2);
3559
+ __decorateClass([
3560
+ BinaryField("i32", 2, (obj) => obj.count)
3561
+ ], YGOProMsgRandomSelected.prototype, "cards", 2);
3562
+
3563
+ // src/protos/msg/proto/recover.ts
3564
+ var YGOProMsgRecover = class extends YGOProMsgBase {
3565
+ static {
3566
+ this.identifier = OcgcoreCommonConstants.MSG_RECOVER;
3567
+ }
3568
+ };
3569
+ __decorateClass([
3570
+ BinaryField("u8", 0)
3571
+ ], YGOProMsgRecover.prototype, "player", 2);
3572
+ __decorateClass([
3573
+ BinaryField("i32", 1)
3574
+ ], YGOProMsgRecover.prototype, "value", 2);
3575
+
3576
+ // src/protos/msg/proto/reload-field.ts
3577
+ var YGOProMsgReloadField_ZoneCard = class {
3578
+ };
3579
+ var YGOProMsgReloadField_PlayerInfo = class {
3580
+ };
3581
+ var YGOProMsgReloadField_ChainInfo = class {
3582
+ };
3583
+ var YGOProMsgReloadField = class extends YGOProMsgBase {
3584
+ static {
3585
+ this.identifier = 162;
3586
+ }
3587
+ fromPayload(data) {
3588
+ if (data.length < 1) {
3589
+ throw new Error("MSG data too short");
3590
+ }
3591
+ const msgType = data[0];
3592
+ if (msgType !== this.identifier) {
3593
+ throw new Error(
3594
+ `MSG type mismatch: expected ${this.identifier}, got ${msgType}`
3595
+ );
3596
+ }
3597
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
3598
+ let offset = 1;
3599
+ this.duelRule = view.getUint8(offset++);
3600
+ this.players = [];
3601
+ for (let i = 0; i < 2; i++) {
3602
+ const player = {
3603
+ lp: view.getInt32(offset, true),
3604
+ mzone: [],
3605
+ szone: [],
3606
+ deckCount: 0,
3607
+ handCount: 0,
3608
+ graveCount: 0,
3609
+ removedCount: 0,
3610
+ extraCount: 0,
3611
+ extraPCount: 0
3612
+ };
3613
+ offset += 4;
3614
+ for (let seq = 0; seq < 7; seq++) {
3615
+ const occupied = view.getUint8(offset++);
3616
+ const card = { occupied };
3617
+ if (occupied) {
3618
+ card.position = view.getUint8(offset++);
3619
+ card.xyzCount = view.getUint8(offset++);
3620
+ }
3621
+ player.mzone.push(card);
3622
+ }
3623
+ for (let seq = 0; seq < 8; seq++) {
3624
+ const occupied = view.getUint8(offset++);
3625
+ const card = { occupied };
3626
+ if (occupied) {
3627
+ card.position = view.getUint8(offset++);
3628
+ }
3629
+ player.szone.push(card);
3630
+ }
3631
+ player.deckCount = view.getUint8(offset++);
3632
+ player.handCount = view.getUint8(offset++);
3633
+ player.graveCount = view.getUint8(offset++);
3634
+ player.removedCount = view.getUint8(offset++);
3635
+ player.extraCount = view.getUint8(offset++);
3636
+ player.extraPCount = view.getUint8(offset++);
3637
+ this.players.push(player);
3638
+ }
3639
+ const chainCount = view.getUint8(offset++);
3640
+ this.chains = [];
3641
+ for (let i = 0; i < chainCount; i++) {
3642
+ const chain = {
3643
+ code: view.getInt32(offset, true),
3644
+ chainCardController: view.getUint8(offset + 4),
3645
+ chainCardLocation: view.getUint8(offset + 5),
3646
+ chainCardSequence: view.getUint8(offset + 6),
3647
+ chainCardSubsequence: view.getUint8(offset + 7),
3648
+ triggerController: view.getUint8(offset + 8),
3649
+ triggerLocation: view.getUint8(offset + 9),
3650
+ triggerSequence: view.getUint8(offset + 10),
3651
+ desc: view.getInt32(offset + 11, true)
3652
+ };
3653
+ offset += 15;
3654
+ this.chains.push(chain);
3655
+ }
3656
+ return this;
3657
+ }
3658
+ toPayload() {
3659
+ let size = 1 + 1;
3660
+ for (const player of this.players) {
3661
+ size += 4;
3662
+ for (const card of player.mzone) {
3663
+ size += 1;
3664
+ if (card.occupied) {
3665
+ size += 2;
3666
+ }
3667
+ }
3668
+ for (const card of player.szone) {
3669
+ size += 1;
3670
+ if (card.occupied) {
3671
+ size += 1;
3672
+ }
3673
+ }
3674
+ size += 6;
3675
+ }
3676
+ size += 1;
3677
+ size += this.chains.length * 15;
3678
+ const result = new Uint8Array(size);
3679
+ const view = new DataView(result.buffer);
3680
+ let offset = 0;
3681
+ result[offset++] = this.identifier;
3682
+ result[offset++] = this.duelRule;
3683
+ for (const player of this.players) {
3684
+ view.setInt32(offset, player.lp, true);
3685
+ offset += 4;
3686
+ for (const card of player.mzone) {
3687
+ result[offset++] = card.occupied;
3688
+ if (card.occupied) {
3689
+ result[offset++] = card.position || 0;
3690
+ result[offset++] = card.xyzCount || 0;
3691
+ }
3692
+ }
3693
+ for (const card of player.szone) {
3694
+ result[offset++] = card.occupied;
3695
+ if (card.occupied) {
3696
+ result[offset++] = card.position || 0;
3697
+ }
3698
+ }
3699
+ result[offset++] = player.deckCount;
3700
+ result[offset++] = player.handCount;
3701
+ result[offset++] = player.graveCount;
3702
+ result[offset++] = player.removedCount;
3703
+ result[offset++] = player.extraCount;
3704
+ result[offset++] = player.extraPCount;
3705
+ }
3706
+ result[offset++] = this.chains.length;
3707
+ for (const chain of this.chains) {
3708
+ view.setInt32(offset, chain.code, true);
3709
+ result[offset + 4] = chain.chainCardController;
3710
+ result[offset + 5] = chain.chainCardLocation;
3711
+ result[offset + 6] = chain.chainCardSequence;
3712
+ result[offset + 7] = chain.chainCardSubsequence;
3713
+ result[offset + 8] = chain.triggerController;
3714
+ result[offset + 9] = chain.triggerLocation;
3715
+ result[offset + 10] = chain.triggerSequence;
3716
+ view.setInt32(offset + 11, chain.desc, true);
3717
+ offset += 15;
3718
+ }
3719
+ return result;
3720
+ }
3721
+ };
3722
+
3723
+ // src/protos/msg/proto/remove-counter.ts
3724
+ var YGOProMsgRemoveCounter = class extends YGOProMsgBase {
3725
+ static {
3726
+ this.identifier = OcgcoreCommonConstants.MSG_REMOVE_COUNTER;
3727
+ }
3728
+ };
3729
+ __decorateClass([
3730
+ BinaryField("u16", 0)
3731
+ ], YGOProMsgRemoveCounter.prototype, "counterType", 2);
3732
+ __decorateClass([
3733
+ BinaryField("u8", 2)
3734
+ ], YGOProMsgRemoveCounter.prototype, "controller", 2);
3735
+ __decorateClass([
3736
+ BinaryField("u8", 3)
3737
+ ], YGOProMsgRemoveCounter.prototype, "location", 2);
3738
+ __decorateClass([
3739
+ BinaryField("u8", 4)
3740
+ ], YGOProMsgRemoveCounter.prototype, "sequence", 2);
3741
+ __decorateClass([
3742
+ BinaryField("u16", 5)
3743
+ ], YGOProMsgRemoveCounter.prototype, "count", 2);
3744
+
3745
+ // src/protos/msg/proto/reset-time.ts
3746
+ var YGOProMsgResetTime = class extends YGOProMsgBase {
3747
+ static {
3748
+ this.identifier = OcgcoreCommonConstants.MSG_RESET_TIME;
3749
+ }
3750
+ getSendTargets() {
3751
+ return [];
3752
+ }
3753
+ };
3754
+ __decorateClass([
3755
+ BinaryField("i8", 0)
3756
+ ], YGOProMsgResetTime.prototype, "player", 2);
3757
+ __decorateClass([
3758
+ BinaryField("i16", 1)
3759
+ ], YGOProMsgResetTime.prototype, "time", 2);
3760
+
3761
+ // src/protos/msg/proto/retry.ts
3762
+ var YGOProMsgRetry = class extends YGOProMsgBase {
3763
+ static {
3764
+ this.identifier = OcgcoreCommonConstants.MSG_RETRY;
3765
+ }
3766
+ getSendTargets() {
3767
+ return [];
3768
+ }
3769
+ };
3770
+
3771
+ // src/protos/msg/proto/reverse-deck.ts
3772
+ var YGOProMsgReverseDeck = class extends YGOProMsgBase {
3773
+ static {
3774
+ this.identifier = OcgcoreCommonConstants.MSG_REVERSE_DECK;
3775
+ }
3776
+ };
3777
+
3778
+ // src/protos/msg/proto/rock-paper-scissors.ts
3779
+ var YGOProMsgRockPaperScissors = class extends YGOProMsgResponseBase {
3780
+ static {
3781
+ this.identifier = OcgcoreCommonConstants.MSG_ROCK_PAPER_SCISSORS;
3782
+ }
3783
+ responsePlayer() {
3784
+ return this.player;
3785
+ }
3786
+ prepareResponse(choice) {
3787
+ if (choice < 1 /* ROCK */ || choice > 3 /* PAPER */) {
3788
+ throw new TypeError(
3789
+ `Invalid choice: ${choice}. Must be 1 (ROCK), 2 (SCISSORS), or 3 (PAPER)`
3790
+ );
3791
+ }
3792
+ const buffer = new Uint8Array(1);
3793
+ buffer[0] = choice;
3794
+ return buffer;
3795
+ }
3796
+ };
3797
+ __decorateClass([
3798
+ BinaryField("u8", 0)
3799
+ ], YGOProMsgRockPaperScissors.prototype, "player", 2);
3800
+
3801
+ // src/protos/msg/proto/select-battlecmd.ts
3802
+ var BattleCmdType = /* @__PURE__ */ ((BattleCmdType2) => {
3803
+ BattleCmdType2[BattleCmdType2["ACTIVATE"] = 0] = "ACTIVATE";
3804
+ BattleCmdType2[BattleCmdType2["ATTACK"] = 1] = "ATTACK";
3805
+ BattleCmdType2[BattleCmdType2["TO_M2"] = 2] = "TO_M2";
3806
+ BattleCmdType2[BattleCmdType2["TO_EP"] = 3] = "TO_EP";
3807
+ return BattleCmdType2;
3808
+ })(BattleCmdType || {});
3809
+ var YGOProMsgSelectBattleCmd_ActivatableInfo = class {
3810
+ };
3811
+ __decorateClass([
3812
+ BinaryField("i32", 0)
3813
+ ], YGOProMsgSelectBattleCmd_ActivatableInfo.prototype, "code", 2);
3814
+ __decorateClass([
3815
+ BinaryField("u8", 4)
3816
+ ], YGOProMsgSelectBattleCmd_ActivatableInfo.prototype, "controller", 2);
3817
+ __decorateClass([
3818
+ BinaryField("u8", 5)
3819
+ ], YGOProMsgSelectBattleCmd_ActivatableInfo.prototype, "location", 2);
3820
+ __decorateClass([
3821
+ BinaryField("u8", 6)
3822
+ ], YGOProMsgSelectBattleCmd_ActivatableInfo.prototype, "sequence", 2);
3823
+ __decorateClass([
3824
+ BinaryField("i32", 7)
3825
+ ], YGOProMsgSelectBattleCmd_ActivatableInfo.prototype, "desc", 2);
3826
+ var YGOProMsgSelectBattleCmd_AttackableInfo = class {
3827
+ };
3828
+ __decorateClass([
3829
+ BinaryField("i32", 0)
3830
+ ], YGOProMsgSelectBattleCmd_AttackableInfo.prototype, "code", 2);
3831
+ __decorateClass([
3832
+ BinaryField("u8", 4)
3833
+ ], YGOProMsgSelectBattleCmd_AttackableInfo.prototype, "controller", 2);
3834
+ __decorateClass([
3835
+ BinaryField("u8", 5)
3836
+ ], YGOProMsgSelectBattleCmd_AttackableInfo.prototype, "location", 2);
3837
+ __decorateClass([
3838
+ BinaryField("u8", 6)
3839
+ ], YGOProMsgSelectBattleCmd_AttackableInfo.prototype, "sequence", 2);
3840
+ __decorateClass([
3841
+ BinaryField("u8", 7)
3842
+ ], YGOProMsgSelectBattleCmd_AttackableInfo.prototype, "directAttack", 2);
3843
+ var YGOProMsgSelectBattleCmd = class extends YGOProMsgResponseBase {
3844
+ static {
3845
+ this.identifier = OcgcoreCommonConstants.MSG_SELECT_BATTLECMD;
3846
+ }
3847
+ responsePlayer() {
3848
+ return this.player;
3849
+ }
3850
+ prepareResponse(type, option) {
3851
+ let sequence;
3852
+ if (type === 0 /* ACTIVATE */) {
3853
+ if (option == null) {
3854
+ throw new TypeError("Option required for ACTIVATE");
3855
+ }
3856
+ if (isIndexResponse(option)) {
3857
+ sequence = option.index;
3858
+ if (sequence < 0 || sequence >= this.activatableCount) {
3859
+ throw new TypeError(`Index out of range: ${sequence}`);
3860
+ }
3861
+ } else {
3862
+ const idx = this.activatableCards.findIndex(
3863
+ (card) => (option.code == null || card.code === option.code) && (option.controller == null || card.controller === option.controller) && (option.location == null || card.location === option.location) && (option.sequence == null || card.sequence === option.sequence) && (option.desc == null || card.desc === option.desc)
3864
+ );
3865
+ if (idx === -1) {
3866
+ throw new TypeError("Activatable card not found");
3867
+ }
3868
+ sequence = idx;
3869
+ }
3870
+ } else if (type === 1 /* ATTACK */) {
3871
+ if (option == null) {
3872
+ throw new TypeError("Option required for ATTACK");
3873
+ }
3874
+ if (isIndexResponse(option)) {
3875
+ sequence = option.index;
3876
+ if (sequence < 0 || sequence >= this.attackableCount) {
3877
+ throw new TypeError(`Index out of range: ${sequence}`);
3878
+ }
3879
+ } else {
3880
+ const idx = this.attackableCards.findIndex(
3881
+ (card) => (option.code == null || card.code === option.code) && (option.controller == null || card.controller === option.controller) && (option.location == null || card.location === option.location) && (option.sequence == null || card.sequence === option.sequence)
3882
+ );
3883
+ if (idx === -1) {
3884
+ throw new TypeError("Attackable card not found");
3885
+ }
3886
+ sequence = idx;
3887
+ }
3888
+ } else if (type === 2 /* TO_M2 */) {
3889
+ if (this.canM2 === 0) {
3890
+ throw new TypeError("Cannot go to M2");
3891
+ }
3892
+ sequence = 0;
3893
+ } else if (type === 3 /* TO_EP */) {
3894
+ if (this.canEp === 0) {
3895
+ throw new TypeError("Cannot go to EP");
3896
+ }
3897
+ sequence = 0;
3898
+ } else {
3899
+ throw new TypeError(`Unknown type: ${type}`);
3900
+ }
3901
+ const buffer = new Uint8Array(4);
3902
+ const view = new DataView(buffer.buffer);
3903
+ view.setUint32(0, sequence << 16 | type, true);
3904
+ return buffer;
3905
+ }
3906
+ };
3907
+ __decorateClass([
3908
+ BinaryField("u8", 0)
3909
+ ], YGOProMsgSelectBattleCmd.prototype, "player", 2);
3910
+ __decorateClass([
3911
+ BinaryField("u8", 1)
3912
+ ], YGOProMsgSelectBattleCmd.prototype, "activatableCount", 2);
3913
+ __decorateClass([
3914
+ BinaryField(
3915
+ () => YGOProMsgSelectBattleCmd_ActivatableInfo,
3916
+ 2,
3917
+ (obj) => obj.activatableCount
3918
+ )
3919
+ ], YGOProMsgSelectBattleCmd.prototype, "activatableCards", 2);
3920
+ __decorateClass([
3921
+ BinaryField("u8", (obj) => {
3922
+ return 2 + obj.activatableCount * 11;
3923
+ })
3924
+ ], YGOProMsgSelectBattleCmd.prototype, "attackableCount", 2);
3925
+ __decorateClass([
3926
+ BinaryField(
3927
+ () => YGOProMsgSelectBattleCmd_AttackableInfo,
3928
+ (obj) => {
3929
+ return 3 + obj.activatableCount * 11;
3930
+ },
3931
+ (obj) => obj.attackableCount
3932
+ )
3933
+ ], YGOProMsgSelectBattleCmd.prototype, "attackableCards", 2);
3934
+ __decorateClass([
3935
+ BinaryField("u8", (obj) => {
3936
+ return 3 + obj.activatableCount * 11 + obj.attackableCount * 8;
3937
+ })
3938
+ ], YGOProMsgSelectBattleCmd.prototype, "canM2", 2);
3939
+ __decorateClass([
3940
+ BinaryField("u8", (obj) => {
3941
+ return 4 + obj.activatableCount * 11 + obj.attackableCount * 8;
3942
+ })
3943
+ ], YGOProMsgSelectBattleCmd.prototype, "canEp", 2);
3944
+
3945
+ // src/protos/msg/proto/select-card.ts
3946
+ var YGOProMsgSelectCard_CardInfo = class {
3947
+ };
3948
+ __decorateClass([
3949
+ BinaryField("i32", 0)
3950
+ ], YGOProMsgSelectCard_CardInfo.prototype, "code", 2);
3951
+ __decorateClass([
3952
+ BinaryField("u8", 4)
3953
+ ], YGOProMsgSelectCard_CardInfo.prototype, "controller", 2);
3954
+ __decorateClass([
3955
+ BinaryField("u8", 5)
3956
+ ], YGOProMsgSelectCard_CardInfo.prototype, "location", 2);
3957
+ __decorateClass([
3958
+ BinaryField("u8", 6)
3959
+ ], YGOProMsgSelectCard_CardInfo.prototype, "sequence", 2);
3960
+ __decorateClass([
3961
+ BinaryField("u8", 7)
3962
+ ], YGOProMsgSelectCard_CardInfo.prototype, "subsequence", 2);
3963
+ var YGOProMsgSelectCard = class extends YGOProMsgResponseBase {
3964
+ static {
3965
+ this.identifier = OcgcoreCommonConstants.MSG_SELECT_CARD;
3966
+ }
3967
+ responsePlayer() {
3968
+ return this.player;
3969
+ }
3970
+ defaultResponse() {
3971
+ if (this.cancelable === 0) {
3972
+ return void 0;
3973
+ }
3974
+ return this.prepareResponse(null);
3975
+ }
3976
+ prepareResponse(cardOptions) {
3977
+ if (cardOptions == null) {
3978
+ const buffer2 = new Uint8Array(4);
3979
+ const view = new DataView(buffer2.buffer);
3980
+ view.setInt32(0, -1, true);
3981
+ return buffer2;
3982
+ }
3983
+ const indices = [];
3984
+ const usedIndices = /* @__PURE__ */ new Set();
3985
+ for (const option of cardOptions) {
3986
+ let index;
3987
+ if (isIndexResponse(option)) {
3988
+ index = option.index;
3989
+ if (index < 0 || index >= this.count) {
3990
+ throw new TypeError(`Index out of range: ${index}`);
3991
+ }
3992
+ } else {
3993
+ index = this.cards.findIndex(
3994
+ (card, idx) => !usedIndices.has(idx) && (option.code == null || card.code === option.code) && (option.controller == null || card.controller === option.controller) && (option.location == null || card.location === option.location) && (option.sequence == null || card.sequence === option.sequence)
3995
+ );
3996
+ if (index === -1) {
3997
+ throw new TypeError("Card not found");
3998
+ }
3999
+ }
4000
+ indices.push(index);
4001
+ usedIndices.add(index);
4002
+ }
4003
+ const buffer = new Uint8Array(1 + indices.length);
4004
+ buffer[0] = indices.length;
4005
+ indices.forEach((idx, i) => {
4006
+ buffer[1 + i] = idx;
4007
+ });
4008
+ return buffer;
4009
+ }
4010
+ };
4011
+ __decorateClass([
4012
+ BinaryField("u8", 0)
4013
+ ], YGOProMsgSelectCard.prototype, "player", 2);
4014
+ __decorateClass([
4015
+ BinaryField("u8", 1)
4016
+ ], YGOProMsgSelectCard.prototype, "cancelable", 2);
4017
+ __decorateClass([
4018
+ BinaryField("u8", 2)
4019
+ ], YGOProMsgSelectCard.prototype, "min", 2);
4020
+ __decorateClass([
4021
+ BinaryField("u8", 3)
4022
+ ], YGOProMsgSelectCard.prototype, "max", 2);
4023
+ __decorateClass([
4024
+ BinaryField("u8", 4)
4025
+ ], YGOProMsgSelectCard.prototype, "count", 2);
4026
+ __decorateClass([
4027
+ BinaryField(() => YGOProMsgSelectCard_CardInfo, 5, (obj) => obj.count)
4028
+ ], YGOProMsgSelectCard.prototype, "cards", 2);
4029
+
4030
+ // src/protos/msg/proto/select-chain.ts
4031
+ var YGOProMsgSelectChain_ChainInfo = class {
4032
+ };
4033
+ __decorateClass([
4034
+ BinaryField("u8", 0)
4035
+ ], YGOProMsgSelectChain_ChainInfo.prototype, "edesc", 2);
4036
+ __decorateClass([
4037
+ BinaryField("u8", 1)
4038
+ ], YGOProMsgSelectChain_ChainInfo.prototype, "forced", 2);
4039
+ __decorateClass([
4040
+ BinaryField("i32", 2)
4041
+ ], YGOProMsgSelectChain_ChainInfo.prototype, "code", 2);
4042
+ __decorateClass([
4043
+ BinaryField("u8", 6)
4044
+ ], YGOProMsgSelectChain_ChainInfo.prototype, "controller", 2);
4045
+ __decorateClass([
4046
+ BinaryField("u8", 7)
4047
+ ], YGOProMsgSelectChain_ChainInfo.prototype, "location", 2);
4048
+ __decorateClass([
4049
+ BinaryField("u8", 8)
4050
+ ], YGOProMsgSelectChain_ChainInfo.prototype, "sequence", 2);
4051
+ __decorateClass([
4052
+ BinaryField("u8", 9)
4053
+ ], YGOProMsgSelectChain_ChainInfo.prototype, "subsequence", 2);
4054
+ __decorateClass([
4055
+ BinaryField("i32", 10)
4056
+ ], YGOProMsgSelectChain_ChainInfo.prototype, "desc", 2);
4057
+ var YGOProMsgSelectChain = class extends YGOProMsgResponseBase {
4058
+ static {
4059
+ this.identifier = OcgcoreCommonConstants.MSG_SELECT_CHAIN;
4060
+ }
4061
+ responsePlayer() {
4062
+ return this.player;
4063
+ }
4064
+ defaultResponse() {
4065
+ const hasForced = this.chains.some((chain) => chain.forced !== 0);
4066
+ if (hasForced) {
4067
+ return void 0;
4068
+ }
4069
+ return this.prepareResponse(null);
4070
+ }
4071
+ prepareResponse(option) {
4072
+ let index;
4073
+ if (option == null) {
4074
+ index = -1;
4075
+ } else if (isIndexResponse(option)) {
4076
+ index = option.index;
4077
+ if (index < -1 || index >= this.count) {
4078
+ throw new TypeError(`Index out of range: ${index}`);
4079
+ }
4080
+ } else {
4081
+ index = this.chains.findIndex(
4082
+ (chain) => (option.code == null || chain.code === option.code) && (option.controller == null || chain.controller === option.controller) && (option.location == null || chain.location === option.location) && (option.sequence == null || chain.sequence === option.sequence) && (option.desc == null || chain.desc === option.desc)
4083
+ );
4084
+ if (index === -1) {
4085
+ throw new TypeError("Chain not found");
4086
+ }
4087
+ }
4088
+ const buffer = new Uint8Array(4);
4089
+ const view = new DataView(buffer.buffer);
4090
+ view.setInt32(0, index, true);
4091
+ return buffer;
4092
+ }
4093
+ };
4094
+ __decorateClass([
4095
+ BinaryField("u8", 0)
4096
+ ], YGOProMsgSelectChain.prototype, "player", 2);
4097
+ __decorateClass([
4098
+ BinaryField("u8", 1)
4099
+ ], YGOProMsgSelectChain.prototype, "count", 2);
4100
+ __decorateClass([
4101
+ BinaryField("u8", 2)
4102
+ ], YGOProMsgSelectChain.prototype, "specialCount", 2);
4103
+ __decorateClass([
4104
+ BinaryField("i32", 3)
4105
+ ], YGOProMsgSelectChain.prototype, "hint0", 2);
4106
+ __decorateClass([
4107
+ BinaryField("i32", 7)
4108
+ ], YGOProMsgSelectChain.prototype, "hint1", 2);
4109
+ __decorateClass([
4110
+ BinaryField(() => YGOProMsgSelectChain_ChainInfo, 11, (obj) => obj.count)
4111
+ ], YGOProMsgSelectChain.prototype, "chains", 2);
4112
+
4113
+ // src/protos/msg/proto/select-counter.ts
4114
+ var YGOProMsgSelectCounter_CardInfo = class {
4115
+ };
4116
+ __decorateClass([
4117
+ BinaryField("i32", 0)
4118
+ ], YGOProMsgSelectCounter_CardInfo.prototype, "code", 2);
4119
+ __decorateClass([
4120
+ BinaryField("u8", 4)
4121
+ ], YGOProMsgSelectCounter_CardInfo.prototype, "controller", 2);
4122
+ __decorateClass([
4123
+ BinaryField("u8", 5)
4124
+ ], YGOProMsgSelectCounter_CardInfo.prototype, "location", 2);
4125
+ __decorateClass([
4126
+ BinaryField("u8", 6)
4127
+ ], YGOProMsgSelectCounter_CardInfo.prototype, "sequence", 2);
4128
+ __decorateClass([
4129
+ BinaryField("u16", 7)
4130
+ ], YGOProMsgSelectCounter_CardInfo.prototype, "counterCount", 2);
4131
+ var YGOProMsgSelectCounter = class extends YGOProMsgResponseBase {
4132
+ static {
4133
+ this.identifier = OcgcoreCommonConstants.MSG_SELECT_COUNTER;
4134
+ }
4135
+ responsePlayer() {
4136
+ return this.player;
4137
+ }
4138
+ prepareResponse(counterOptions) {
4139
+ const counterCounts = new Array(this.count).fill(0);
4140
+ for (const option of counterOptions) {
4141
+ let index;
4142
+ if (isIndexResponse(option.card)) {
4143
+ index = option.card.index;
4144
+ if (index < 0 || index >= this.count) {
4145
+ throw new TypeError(`Index out of range: ${index}`);
4146
+ }
4147
+ } else {
4148
+ const card = option.card;
4149
+ index = this.cards.findIndex(
4150
+ (card2) => (card2.code == null || card2.code === card2.code) && (card2.controller == null || card2.controller === card2.controller) && (card2.location == null || card2.location === card2.location) && (card2.sequence == null || card2.sequence === card2.sequence)
4151
+ );
4152
+ if (index === -1) {
4153
+ throw new TypeError("Card not found");
4154
+ }
4155
+ }
4156
+ counterCounts[index] = option.count;
4157
+ }
4158
+ const buffer = new Uint8Array(counterCounts.length * 2);
4159
+ const view = new DataView(buffer.buffer);
4160
+ counterCounts.forEach((count, i) => {
4161
+ view.setUint16(i * 2, count, true);
4162
+ });
4163
+ return buffer;
4164
+ }
4165
+ };
4166
+ __decorateClass([
4167
+ BinaryField("u8", 0)
4168
+ ], YGOProMsgSelectCounter.prototype, "player", 2);
4169
+ __decorateClass([
4170
+ BinaryField("u16", 1)
4171
+ ], YGOProMsgSelectCounter.prototype, "counterType", 2);
4172
+ __decorateClass([
4173
+ BinaryField("u16", 3)
4174
+ ], YGOProMsgSelectCounter.prototype, "counterCount", 2);
4175
+ __decorateClass([
4176
+ BinaryField("u8", 5)
4177
+ ], YGOProMsgSelectCounter.prototype, "count", 2);
4178
+ __decorateClass([
4179
+ BinaryField(() => YGOProMsgSelectCounter_CardInfo, 6, (obj) => obj.count)
4180
+ ], YGOProMsgSelectCounter.prototype, "cards", 2);
4181
+
4022
4182
  // src/protos/msg/proto/select-place-common.ts
4023
4183
  var YGOProMsgSelectPlaceCommon = class extends YGOProMsgResponseBase {
4024
4184
  getSelectablePlaces() {
@@ -4891,6 +5051,25 @@ var YGOProMsgSpSummoning = class extends YGOProMsgBase {
4891
5051
  static {
4892
5052
  this.identifier = OcgcoreCommonConstants.MSG_SPSUMMONING;
4893
5053
  }
5054
+ opponentView() {
5055
+ const view = this.copy();
5056
+ if (view.position & OcgcoreCommonConstants.POS_FACEDOWN) {
5057
+ view.code = 0;
5058
+ }
5059
+ return view;
5060
+ }
5061
+ teammateView() {
5062
+ return this.copy();
5063
+ }
5064
+ playerView(playerId) {
5065
+ if (playerId === 7 /* OBSERVER */) {
5066
+ return this.observerView();
5067
+ }
5068
+ if (playerId === this.controller) {
5069
+ return this.copy();
5070
+ }
5071
+ return this.opponentView();
5072
+ }
4894
5073
  };
4895
5074
  __decorateClass([
4896
5075
  BinaryField("i32", 0)
@@ -5127,6 +5306,9 @@ var YGOProMsgUpdateCard = class extends YGOProMsgBase {
5127
5306
  }
5128
5307
  }
5129
5308
  playerView(playerId) {
5309
+ if (playerId === 7 /* OBSERVER */) {
5310
+ return this.observerView();
5311
+ }
5130
5312
  if (this.controller === playerId) {
5131
5313
  return this.copy();
5132
5314
  }
@@ -5176,6 +5358,9 @@ var YGOProMsgUpdateCard = class extends YGOProMsgBase {
5176
5358
  result.set(cardPayload, 8);
5177
5359
  return result;
5178
5360
  }
5361
+ getSendTargets() {
5362
+ return [];
5363
+ }
5179
5364
  };
5180
5365
 
5181
5366
  // src/protos/msg/proto/update-data.ts
@@ -5281,6 +5466,9 @@ var YGOProMsgUpdateData = class extends YGOProMsgBase {
5281
5466
  }
5282
5467
  return result;
5283
5468
  }
5469
+ getSendTargets() {
5470
+ return [this.player, 1 - this.player, 7 /* OBSERVER */];
5471
+ }
5284
5472
  };
5285
5473
 
5286
5474
  // src/protos/msg/proto/waiting.ts
@@ -5289,6 +5477,9 @@ var YGOProMsgWaiting = class extends YGOProMsgBase {
5289
5477
  this.identifier = 3;
5290
5478
  }
5291
5479
  // MSG_WAITING
5480
+ getSendTargets() {
5481
+ return [];
5482
+ }
5292
5483
  };
5293
5484
 
5294
5485
  // src/protos/msg/proto/win.ts
@@ -5810,80 +6001,6 @@ YGOProStoc.register(YGOProStocHsWatchChange);
5810
6001
  YGOProStoc.register(YGOProStocTeammateSurrender);
5811
6002
  YGOProStoc.register(YGOProStocFieldFinish);
5812
6003
  YGOProStoc.register(YGOProStocSrvproRoomlist);
5813
-
5814
- // src/protos/network-enums.ts
5815
- var HandResult = /* @__PURE__ */ ((HandResult2) => {
5816
- HandResult2[HandResult2["ROCK"] = 1] = "ROCK";
5817
- HandResult2[HandResult2["SCISSORS"] = 2] = "SCISSORS";
5818
- HandResult2[HandResult2["PAPER"] = 3] = "PAPER";
5819
- return HandResult2;
5820
- })(HandResult || {});
5821
- var TurnPlayerResult = /* @__PURE__ */ ((TurnPlayerResult2) => {
5822
- TurnPlayerResult2[TurnPlayerResult2["SECOND"] = 0] = "SECOND";
5823
- TurnPlayerResult2[TurnPlayerResult2["FIRST"] = 1] = "FIRST";
5824
- return TurnPlayerResult2;
5825
- })(TurnPlayerResult || {});
5826
- var NetPlayerType = /* @__PURE__ */ ((NetPlayerType2) => {
5827
- NetPlayerType2[NetPlayerType2["PLAYER1"] = 0] = "PLAYER1";
5828
- NetPlayerType2[NetPlayerType2["PLAYER2"] = 1] = "PLAYER2";
5829
- NetPlayerType2[NetPlayerType2["PLAYER3"] = 2] = "PLAYER3";
5830
- NetPlayerType2[NetPlayerType2["PLAYER4"] = 3] = "PLAYER4";
5831
- NetPlayerType2[NetPlayerType2["PLAYER5"] = 4] = "PLAYER5";
5832
- NetPlayerType2[NetPlayerType2["PLAYER6"] = 5] = "PLAYER6";
5833
- NetPlayerType2[NetPlayerType2["OBSERVER"] = 7] = "OBSERVER";
5834
- return NetPlayerType2;
5835
- })(NetPlayerType || {});
5836
- var ChatColor = /* @__PURE__ */ ((ChatColor2) => {
5837
- ChatColor2[ChatColor2["LIGHTBLUE"] = 8] = "LIGHTBLUE";
5838
- ChatColor2[ChatColor2["RED"] = 11] = "RED";
5839
- ChatColor2[ChatColor2["GREEN"] = 12] = "GREEN";
5840
- ChatColor2[ChatColor2["BLUE"] = 13] = "BLUE";
5841
- ChatColor2[ChatColor2["BABYBLUE"] = 14] = "BABYBLUE";
5842
- ChatColor2[ChatColor2["PINK"] = 15] = "PINK";
5843
- ChatColor2[ChatColor2["YELLOW"] = 16] = "YELLOW";
5844
- ChatColor2[ChatColor2["WHITE"] = 17] = "WHITE";
5845
- ChatColor2[ChatColor2["GRAY"] = 18] = "GRAY";
5846
- ChatColor2[ChatColor2["DARKGRAY"] = 19] = "DARKGRAY";
5847
- return ChatColor2;
5848
- })(ChatColor || {});
5849
- var GameMode = /* @__PURE__ */ ((GameMode2) => {
5850
- GameMode2[GameMode2["SINGLE"] = 0] = "SINGLE";
5851
- GameMode2[GameMode2["MATCH"] = 1] = "MATCH";
5852
- GameMode2[GameMode2["TAG"] = 2] = "TAG";
5853
- return GameMode2;
5854
- })(GameMode || {});
5855
- var ErrorMessageType = /* @__PURE__ */ ((ErrorMessageType2) => {
5856
- ErrorMessageType2[ErrorMessageType2["JOINERROR"] = 1] = "JOINERROR";
5857
- ErrorMessageType2[ErrorMessageType2["DECKERROR"] = 2] = "DECKERROR";
5858
- ErrorMessageType2[ErrorMessageType2["SIDEERROR"] = 3] = "SIDEERROR";
5859
- ErrorMessageType2[ErrorMessageType2["VERERROR"] = 4] = "VERERROR";
5860
- return ErrorMessageType2;
5861
- })(ErrorMessageType || {});
5862
- var DeckErrorType = /* @__PURE__ */ ((DeckErrorType2) => {
5863
- DeckErrorType2[DeckErrorType2["LFLIST"] = 1] = "LFLIST";
5864
- DeckErrorType2[DeckErrorType2["OCGONLY"] = 2] = "OCGONLY";
5865
- DeckErrorType2[DeckErrorType2["TCGONLY"] = 3] = "TCGONLY";
5866
- DeckErrorType2[DeckErrorType2["UNKNOWNCARD"] = 4] = "UNKNOWNCARD";
5867
- DeckErrorType2[DeckErrorType2["CARDCOUNT"] = 5] = "CARDCOUNT";
5868
- DeckErrorType2[DeckErrorType2["MAINCOUNT"] = 6] = "MAINCOUNT";
5869
- DeckErrorType2[DeckErrorType2["EXTRACOUNT"] = 7] = "EXTRACOUNT";
5870
- DeckErrorType2[DeckErrorType2["SIDECOUNT"] = 8] = "SIDECOUNT";
5871
- DeckErrorType2[DeckErrorType2["NOTAVAIL"] = 9] = "NOTAVAIL";
5872
- return DeckErrorType2;
5873
- })(DeckErrorType || {});
5874
- var PlayerChangeState = /* @__PURE__ */ ((PlayerChangeState2) => {
5875
- PlayerChangeState2[PlayerChangeState2["OBSERVE"] = 8] = "OBSERVE";
5876
- PlayerChangeState2[PlayerChangeState2["READY"] = 9] = "READY";
5877
- PlayerChangeState2[PlayerChangeState2["NOTREADY"] = 10] = "NOTREADY";
5878
- PlayerChangeState2[PlayerChangeState2["LEAVE"] = 11] = "LEAVE";
5879
- return PlayerChangeState2;
5880
- })(PlayerChangeState || {});
5881
- var RoomStatus = /* @__PURE__ */ ((RoomStatus2) => {
5882
- RoomStatus2[RoomStatus2["WAITING"] = 0] = "WAITING";
5883
- RoomStatus2[RoomStatus2["DUELING"] = 1] = "DUELING";
5884
- RoomStatus2[RoomStatus2["SIDING"] = 2] = "SIDING";
5885
- return RoomStatus2;
5886
- })(RoomStatus || {});
5887
6004
  export {
5888
6005
  BattleCmdType,
5889
6006
  BinaryField,
@@ -5904,6 +6021,8 @@ export {
5904
6021
  OcgcoreScriptConstants,
5905
6022
  PlayerChangeState,
5906
6023
  RoomStatus,
6024
+ SEND_TO_ALL,
6025
+ SEND_TO_PLAYERS,
5907
6026
  SrvproRoomInfo,
5908
6027
  TurnPlayerResult,
5909
6028
  YGOProCtos,