ygopro-msg-encode 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -56,6 +56,8 @@ __export(index_exports, {
56
56
  OcgcoreScriptConstants: () => OcgcoreScriptConstants,
57
57
  PlayerChangeState: () => PlayerChangeState,
58
58
  RoomStatus: () => RoomStatus,
59
+ SEND_TO_ALL: () => SEND_TO_ALL,
60
+ SEND_TO_PLAYERS: () => SEND_TO_PLAYERS,
59
61
  SrvproRoomInfo: () => SrvproRoomInfo,
60
62
  TurnPlayerResult: () => TurnPlayerResult,
61
63
  YGOProCtos: () => YGOProCtos,
@@ -1145,1021 +1147,1103 @@ __decorateClass([
1145
1147
  BinaryField("u32", 72)
1146
1148
  ], CardData.prototype, "linkMarker", 2);
1147
1149
 
1148
- // src/protos/ctos/base.ts
1149
- var YGOProCtosBase = class extends PayloadBase {
1150
- /**
1151
- * Serialize to full payload including header (length + identifier + body)
1152
- * Format: [length 2 bytes LE][identifier 1 byte][body]
1153
- * Length = 1 (identifier) + body.length
1154
- */
1155
- toFullPayload() {
1156
- const body = this.toPayload();
1157
- const length = 1 + body.length;
1158
- const fullPayload = new Uint8Array(3 + body.length);
1159
- fullPayload[0] = length & 255;
1160
- fullPayload[1] = length >> 8 & 255;
1161
- fullPayload[2] = this.identifier;
1162
- fullPayload.set(body, 3);
1163
- return fullPayload;
1164
- }
1165
- /**
1166
- * Deserialize from full payload including header (length + identifier + body)
1167
- * Format: [length 2 bytes LE][identifier 1 byte][body]
1168
- * @param data - Full payload data
1169
- * @returns this instance
1170
- * @throws Error if data is too short or identifier mismatch
1171
- */
1172
- fromFullPayload(data) {
1173
- if (data.length < 3) {
1174
- throw new Error(
1175
- `CTOS payload too short: expected at least 3 bytes, got ${data.length}`
1176
- );
1177
- }
1178
- const declaredLength = data[0] | data[1] << 8;
1179
- const identifier = data[2];
1180
- if (identifier !== this.identifier) {
1181
- throw new Error(
1182
- `CTOS identifier mismatch: expected 0x${this.identifier.toString(16)}, got 0x${identifier.toString(16)}`
1183
- );
1184
- }
1185
- const expectedTotalLength = 3 + declaredLength - 1;
1186
- if (data.length < expectedTotalLength) {
1187
- throw new Error(
1188
- `CTOS payload too short: declared length ${declaredLength} requires ${expectedTotalLength} bytes total, got ${data.length}`
1189
- );
1190
- }
1191
- const bodyData = data.length > expectedTotalLength ? data.slice(3, expectedTotalLength) : data.slice(3);
1192
- return this.fromPayload(bodyData);
1193
- }
1194
- };
1195
-
1196
- // src/proto-base/registry-base.ts
1197
- var RegistryBase = class {
1198
- constructor(payloadClass, options = {}) {
1199
- this.payloadClass = payloadClass;
1200
- this.options = options;
1201
- this.protos = /* @__PURE__ */ new Map();
1202
- }
1203
- register(proto) {
1204
- const identifier = proto.identifier;
1205
- this.protos.set(identifier, proto);
1206
- }
1207
- get(identifier) {
1208
- return this.protos.get(identifier);
1209
- }
1210
- getInstanceFromPayload(data) {
1211
- const identifier = data[this.options.identifierOffset ?? 0];
1212
- const proto = this.get(identifier);
1213
- if (!proto) {
1214
- return void 0;
1215
- }
1216
- return new proto().fromPayload(
1217
- data.slice(this.options.dataOffset ?? 0)
1218
- );
1219
- }
1150
+ // src/protos/common/card-query.ts
1151
+ var CardQuery_CardLocation = class {
1220
1152
  };
1221
-
1222
- // src/protos/ctos/proto/response.ts
1223
- var YGOProCtosResponse = class extends YGOProCtosBase {
1224
- fromPayload(data) {
1225
- this.response = data;
1226
- return this;
1227
- }
1228
- toPayload() {
1229
- return this.response || new Uint8Array(0);
1230
- }
1153
+ var CardQuery_Counter = class {
1231
1154
  };
1232
- YGOProCtosResponse.identifier = 1;
1233
-
1234
- // src/protos/ctos/proto/update-deck.ts
1235
- var import_ygopro_deck_encode = __toESM(require("ygopro-deck-encode"));
1236
- var YGOProCtosUpdateDeck = class extends YGOProCtosBase {
1155
+ var CardQuery = class {
1237
1156
  constructor() {
1238
- super();
1239
- this.deck = new import_ygopro_deck_encode.default();
1157
+ this.flags = 0;
1240
1158
  }
1241
1159
  fromPayload(data) {
1242
- this.deck = import_ygopro_deck_encode.default.fromUpdateDeckPayload(data);
1243
- return this;
1244
- }
1245
- toPayload() {
1246
- return this.deck.toUpdateDeckPayload();
1247
- }
1248
- fromPartial(data) {
1249
- if (data.deck) {
1250
- this.deck = new import_ygopro_deck_encode.default(data.deck);
1160
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
1161
+ let offset = 0;
1162
+ this.flags = view.getInt32(offset, true) >>> 0;
1163
+ offset += 4;
1164
+ if (this.flags === 0) {
1165
+ this.empty = true;
1166
+ return this;
1251
1167
  }
1252
- return this;
1253
- }
1254
- copy() {
1255
- const copied = new this.constructor();
1256
- copied.deck = new import_ygopro_deck_encode.default(this.deck);
1257
- return copied;
1258
- }
1259
- };
1260
- YGOProCtosUpdateDeck.identifier = 2;
1261
-
1262
- // src/protos/ctos/proto/hand-result.ts
1263
- var YGOProCtosHandResult = class extends YGOProCtosBase {
1264
- };
1265
- YGOProCtosHandResult.identifier = 3;
1266
- __decorateClass([
1267
- BinaryField("u8", 0)
1268
- ], YGOProCtosHandResult.prototype, "res", 2);
1269
-
1270
- // src/protos/ctos/proto/tp-result.ts
1271
- var YGOProCtosTpResult = class extends YGOProCtosBase {
1272
- };
1273
- YGOProCtosTpResult.identifier = 4;
1274
- __decorateClass([
1275
- BinaryField("u8", 0)
1276
- ], YGOProCtosTpResult.prototype, "res", 2);
1277
-
1278
- // src/protos/ctos/proto/player-info.ts
1279
- var YGOProCtosPlayerInfo = class extends YGOProCtosBase {
1280
- };
1281
- YGOProCtosPlayerInfo.identifier = 16;
1282
- __decorateClass([
1283
- BinaryField("utf16", 0, 20)
1284
- ], YGOProCtosPlayerInfo.prototype, "name", 2);
1285
-
1286
- // src/protos/ctos/proto/create-game.ts
1287
- var YGOProCtosCreateGame = class extends YGOProCtosBase {
1288
- };
1289
- YGOProCtosCreateGame.identifier = 17;
1290
- __decorateClass([
1291
- BinaryField(() => HostInfo, 0)
1292
- ], YGOProCtosCreateGame.prototype, "info", 2);
1293
- __decorateClass([
1294
- BinaryField("utf16", 20, 20)
1295
- ], YGOProCtosCreateGame.prototype, "name", 2);
1296
- __decorateClass([
1297
- BinaryField("utf16", 60, 20)
1298
- ], YGOProCtosCreateGame.prototype, "pass", 2);
1299
-
1300
- // src/protos/ctos/proto/join-game.ts
1301
- var YGOProCtosJoinGame = class extends YGOProCtosBase {
1302
- };
1303
- YGOProCtosJoinGame.identifier = 18;
1304
- __decorateClass([
1305
- BinaryField("u16", 0)
1306
- ], YGOProCtosJoinGame.prototype, "version", 2);
1307
- __decorateClass([
1308
- BinaryField("u32", 4)
1309
- ], YGOProCtosJoinGame.prototype, "gameid", 2);
1310
- __decorateClass([
1311
- BinaryField("utf16", 8, 20)
1312
- ], YGOProCtosJoinGame.prototype, "pass", 2);
1313
-
1314
- // src/protos/ctos/proto/leave-game.ts
1315
- var YGOProCtosLeaveGame = class extends YGOProCtosBase {
1316
- };
1317
- YGOProCtosLeaveGame.identifier = 19;
1318
-
1319
- // src/protos/ctos/proto/surrender.ts
1320
- var YGOProCtosSurrender = class extends YGOProCtosBase {
1321
- };
1322
- YGOProCtosSurrender.identifier = 20;
1323
-
1324
- // src/protos/ctos/proto/time-confirm.ts
1325
- var YGOProCtosTimeConfirm = class extends YGOProCtosBase {
1326
- };
1327
- YGOProCtosTimeConfirm.identifier = 21;
1328
-
1329
- // src/protos/ctos/proto/chat.ts
1330
- var YGOProCtosChat = class extends YGOProCtosBase {
1331
- constructor() {
1332
- super();
1333
- this.msg = "";
1334
- }
1335
- fromPayload(data) {
1336
- const decoder = new TextDecoder("utf-16le");
1337
- this.msg = decoder.decode(data).replace(/\0+$/, "");
1338
- return this;
1339
- }
1340
- toPayload() {
1341
- const encoder = new TextEncoder();
1342
- const utf8 = encoder.encode(this.msg);
1343
- const decoder = new TextDecoder("utf-8");
1344
- const text = decoder.decode(utf8);
1345
- const utf16 = new Uint16Array(text.length + 1);
1346
- for (let i = 0; i < text.length; i++) {
1347
- utf16[i] = text.charCodeAt(i);
1168
+ this.empty = false;
1169
+ if (this.flags & OcgcoreCommonConstants.QUERY_CODE) {
1170
+ this.code = view.getInt32(offset, true);
1171
+ offset += 4;
1348
1172
  }
1349
- utf16[text.length] = 0;
1350
- const result = new Uint8Array(utf16.buffer);
1351
- return result;
1352
- }
1353
- fromPartial(data) {
1354
- if (data.msg !== void 0) {
1355
- this.msg = data.msg;
1173
+ if (this.flags & OcgcoreCommonConstants.QUERY_POSITION) {
1174
+ const pdata = view.getInt32(offset, true);
1175
+ this.position = (pdata >>> 24 & 255) >>> 0;
1176
+ offset += 4;
1356
1177
  }
1357
- return this;
1358
- }
1359
- };
1360
- YGOProCtosChat.identifier = 22;
1361
-
1362
- // src/protos/ctos/proto/external-address.ts
1363
- var YGOProCtosExternalAddress = class extends YGOProCtosBase {
1364
- constructor() {
1365
- super();
1366
- this.real_ip = "0.0.0.0";
1367
- this.hostname = "";
1368
- }
1369
- // Convert IPv4 string to uint32 (network byte order / big endian)
1370
- ipToUint32(ip) {
1371
- let ipv4 = ip;
1372
- if (ip.startsWith("::ffff:")) {
1373
- ipv4 = ip.substring(7);
1178
+ if (this.flags & OcgcoreCommonConstants.QUERY_ALIAS) {
1179
+ this.alias = view.getInt32(offset, true);
1180
+ offset += 4;
1374
1181
  }
1375
- const parts = ipv4.split(".");
1376
- if (parts.length !== 4) {
1377
- return 0;
1182
+ if (this.flags & OcgcoreCommonConstants.QUERY_TYPE) {
1183
+ this.type = view.getInt32(offset, true);
1184
+ offset += 4;
1378
1185
  }
1379
- const bytes = parts.map((p) => parseInt(p, 10));
1380
- if (bytes.some((b) => isNaN(b) || b < 0 || b > 255)) {
1381
- return 0;
1186
+ if (this.flags & OcgcoreCommonConstants.QUERY_LEVEL) {
1187
+ this.level = view.getInt32(offset, true);
1188
+ offset += 4;
1382
1189
  }
1383
- return bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3];
1384
- }
1385
- // Convert uint32 (network byte order / big endian) to IPv4 string
1386
- uint32ToIp(value) {
1387
- const byte1 = value >>> 24 & 255;
1388
- const byte2 = value >>> 16 & 255;
1389
- const byte3 = value >>> 8 & 255;
1390
- const byte4 = value & 255;
1391
- return `${byte1}.${byte2}.${byte3}.${byte4}`;
1392
- }
1393
- fromPayload(data) {
1394
- if (data.length < 4) {
1395
- throw new Error("CTOS_EXTERNAL_ADDRESS data too short");
1190
+ if (this.flags & OcgcoreCommonConstants.QUERY_RANK) {
1191
+ this.rank = view.getInt32(offset, true);
1192
+ offset += 4;
1396
1193
  }
1397
- const ipUint32 = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
1398
- this.real_ip = this.uint32ToIp(ipUint32);
1399
- if (data.length > 4) {
1400
- const decoder = new TextDecoder("utf-16le");
1401
- this.hostname = decoder.decode(data.slice(4)).replace(/\0+$/, "");
1402
- } else {
1403
- this.hostname = "";
1194
+ if (this.flags & OcgcoreCommonConstants.QUERY_ATTRIBUTE) {
1195
+ this.attribute = view.getInt32(offset, true);
1196
+ offset += 4;
1404
1197
  }
1405
- return this;
1406
- }
1407
- toPayload() {
1408
- const encoder = new TextEncoder();
1409
- const utf8 = encoder.encode(this.hostname);
1410
- const decoder = new TextDecoder("utf-8");
1411
- const text = decoder.decode(utf8);
1412
- const utf16 = new Uint16Array(text.length + 1);
1413
- for (let i = 0; i < text.length; i++) {
1414
- utf16[i] = text.charCodeAt(i);
1198
+ if (this.flags & OcgcoreCommonConstants.QUERY_RACE) {
1199
+ this.race = view.getInt32(offset, true);
1200
+ offset += 4;
1415
1201
  }
1416
- utf16[text.length] = 0;
1417
- const result = new Uint8Array(4 + utf16.byteLength);
1418
- const ipUint32 = this.ipToUint32(this.real_ip);
1419
- result[0] = ipUint32 >>> 24 & 255;
1420
- result[1] = ipUint32 >>> 16 & 255;
1421
- result[2] = ipUint32 >>> 8 & 255;
1422
- result[3] = ipUint32 & 255;
1423
- result.set(new Uint8Array(utf16.buffer), 4);
1424
- return result;
1425
- }
1426
- fromPartial(data) {
1427
- if (data.real_ip !== void 0) {
1428
- this.real_ip = data.real_ip;
1202
+ if (this.flags & OcgcoreCommonConstants.QUERY_ATTACK) {
1203
+ this.attack = view.getInt32(offset, true);
1204
+ offset += 4;
1429
1205
  }
1430
- if (data.hostname !== void 0) {
1431
- this.hostname = data.hostname;
1206
+ if (this.flags & OcgcoreCommonConstants.QUERY_DEFENSE) {
1207
+ this.defense = view.getInt32(offset, true);
1208
+ offset += 4;
1432
1209
  }
1433
- return this;
1434
- }
1435
- };
1436
- YGOProCtosExternalAddress.identifier = 23;
1437
-
1438
- // src/protos/ctos/proto/hs-toduelist.ts
1439
- var YGOProCtosHsToDuelist = class extends YGOProCtosBase {
1440
- };
1441
- YGOProCtosHsToDuelist.identifier = 32;
1442
-
1443
- // src/protos/ctos/proto/hs-toobserver.ts
1444
- var YGOProCtosHsToObserver = class extends YGOProCtosBase {
1445
- };
1446
- YGOProCtosHsToObserver.identifier = 33;
1447
-
1448
- // src/protos/ctos/proto/hs-ready.ts
1449
- var YGOProCtosHsReady = class extends YGOProCtosBase {
1450
- };
1451
- YGOProCtosHsReady.identifier = 34;
1452
-
1453
- // src/protos/ctos/proto/hs-notready.ts
1454
- var YGOProCtosHsNotReady = class extends YGOProCtosBase {
1455
- };
1456
- YGOProCtosHsNotReady.identifier = 35;
1457
-
1458
- // src/protos/ctos/proto/kick.ts
1459
- var YGOProCtosKick = class extends YGOProCtosBase {
1460
- };
1461
- YGOProCtosKick.identifier = 36;
1462
- __decorateClass([
1463
- BinaryField("u8", 0)
1464
- ], YGOProCtosKick.prototype, "pos", 2);
1465
-
1466
- // src/protos/ctos/proto/hs-start.ts
1467
- var YGOProCtosHsStart = class extends YGOProCtosBase {
1468
- };
1469
- YGOProCtosHsStart.identifier = 37;
1470
-
1471
- // src/protos/ctos/proto/request-field.ts
1472
- var YGOProCtosRequestField = class extends YGOProCtosBase {
1473
- };
1474
- YGOProCtosRequestField.identifier = 48;
1475
-
1476
- // src/protos/ctos/registry.ts
1477
- var YGOProCtos = new RegistryBase(YGOProCtosBase, {
1478
- identifierOffset: 2,
1479
- dataOffset: 3
1480
- });
1481
- YGOProCtos.register(YGOProCtosResponse);
1482
- YGOProCtos.register(YGOProCtosUpdateDeck);
1483
- YGOProCtos.register(YGOProCtosHandResult);
1484
- YGOProCtos.register(YGOProCtosTpResult);
1485
- YGOProCtos.register(YGOProCtosPlayerInfo);
1486
- YGOProCtos.register(YGOProCtosCreateGame);
1487
- YGOProCtos.register(YGOProCtosJoinGame);
1488
- YGOProCtos.register(YGOProCtosLeaveGame);
1489
- YGOProCtos.register(YGOProCtosSurrender);
1490
- YGOProCtos.register(YGOProCtosTimeConfirm);
1491
- YGOProCtos.register(YGOProCtosChat);
1492
- YGOProCtos.register(YGOProCtosExternalAddress);
1493
- YGOProCtos.register(YGOProCtosHsToDuelist);
1494
- YGOProCtos.register(YGOProCtosHsToObserver);
1495
- YGOProCtos.register(YGOProCtosHsReady);
1496
- YGOProCtos.register(YGOProCtosHsNotReady);
1497
- YGOProCtos.register(YGOProCtosKick);
1498
- YGOProCtos.register(YGOProCtosHsStart);
1499
- YGOProCtos.register(YGOProCtosRequestField);
1500
-
1501
- // src/protos/stoc/base.ts
1502
- var YGOProStocBase = class extends PayloadBase {
1503
- /**
1504
- * Serialize to full payload including header (length + identifier + body)
1505
- * Format: [length 2 bytes LE][identifier 1 byte][body]
1506
- * Length = 1 (identifier) + body.length
1507
- */
1508
- toFullPayload() {
1509
- const body = this.toPayload();
1510
- const length = 1 + body.length;
1511
- const fullPayload = new Uint8Array(3 + body.length);
1512
- fullPayload[0] = length & 255;
1513
- fullPayload[1] = length >> 8 & 255;
1514
- fullPayload[2] = this.identifier;
1515
- fullPayload.set(body, 3);
1516
- return fullPayload;
1517
- }
1518
- /**
1519
- * Deserialize from full payload including header (length + identifier + body)
1520
- * Format: [length 2 bytes LE][identifier 1 byte][body]
1521
- * @param data - Full payload data
1522
- * @returns this instance
1523
- * @throws Error if data is too short or identifier mismatch
1524
- */
1525
- fromFullPayload(data) {
1526
- if (data.length < 3) {
1527
- throw new Error(
1528
- `STOC payload too short: expected at least 3 bytes, got ${data.length}`
1529
- );
1210
+ if (this.flags & OcgcoreCommonConstants.QUERY_BASE_ATTACK) {
1211
+ this.baseAttack = view.getInt32(offset, true);
1212
+ offset += 4;
1530
1213
  }
1531
- const declaredLength = data[0] | data[1] << 8;
1532
- const identifier = data[2];
1533
- if (identifier !== this.identifier) {
1534
- throw new Error(
1535
- `STOC identifier mismatch: expected 0x${this.identifier.toString(16)}, got 0x${identifier.toString(16)}`
1536
- );
1214
+ if (this.flags & OcgcoreCommonConstants.QUERY_BASE_DEFENSE) {
1215
+ this.baseDefense = view.getInt32(offset, true);
1216
+ offset += 4;
1537
1217
  }
1538
- const expectedTotalLength = 3 + declaredLength - 1;
1539
- if (data.length < expectedTotalLength) {
1540
- throw new Error(
1541
- `STOC payload too short: declared length ${declaredLength} requires ${expectedTotalLength} bytes total, got ${data.length}`
1542
- );
1218
+ if (this.flags & OcgcoreCommonConstants.QUERY_REASON) {
1219
+ this.reason = view.getInt32(offset, true);
1220
+ offset += 4;
1543
1221
  }
1544
- const bodyData = data.length > expectedTotalLength ? data.slice(3, expectedTotalLength) : data.slice(3);
1545
- return this.fromPayload(bodyData);
1546
- }
1547
- };
1548
-
1549
- // src/protos/msg/base.ts
1550
- var YGOProMsgBase = class extends PayloadBase {
1551
- fromPayload(data) {
1552
- if (data.length < 1) {
1553
- throw new Error("MSG data too short");
1222
+ if (this.flags & OcgcoreCommonConstants.QUERY_REASON_CARD) {
1223
+ offset += 4;
1554
1224
  }
1555
- const msgType = data[0];
1556
- if (msgType !== this.identifier) {
1557
- throw new Error(
1558
- `MSG type mismatch: expected ${this.identifier}, got ${msgType}`
1559
- );
1225
+ if (this.flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) {
1226
+ this.equipCard = {
1227
+ controller: view.getUint8(offset),
1228
+ location: view.getUint8(offset + 1),
1229
+ sequence: view.getUint8(offset + 2)
1230
+ };
1231
+ offset += 4;
1560
1232
  }
1561
- return super.fromPayload(data.slice(1));
1562
- }
1563
- toPayload() {
1564
- const payload = super.toPayload();
1565
- const result = new Uint8Array(1 + payload.length);
1566
- result[0] = this.identifier;
1567
- result.set(payload, 1);
1568
- return result;
1569
- }
1570
- opponentView() {
1571
- return this.copy();
1572
- }
1573
- teammateView() {
1574
- return this.copy();
1575
- }
1576
- observerView() {
1577
- return this.opponentView();
1578
- }
1579
- playerView(playerId) {
1580
- if (typeof this["player"] === "number") {
1581
- const selfPlayerId = this["player"];
1582
- if (selfPlayerId === playerId) {
1583
- return this.copy();
1233
+ if (this.flags & OcgcoreCommonConstants.QUERY_TARGET_CARD) {
1234
+ const count = view.getInt32(offset, true);
1235
+ offset += 4;
1236
+ this.targetCards = [];
1237
+ for (let i = 0; i < count; i++) {
1238
+ this.targetCards.push({
1239
+ controller: view.getUint8(offset),
1240
+ location: view.getUint8(offset + 1),
1241
+ sequence: view.getUint8(offset + 2)
1242
+ });
1243
+ offset += 4;
1584
1244
  }
1585
- return this.opponentView();
1586
1245
  }
1587
- return this.copy();
1588
- }
1589
- };
1590
-
1591
- // src/protos/msg/proto/add-counter.ts
1592
- var YGOProMsgAddCounter = class extends YGOProMsgBase {
1593
- };
1594
- YGOProMsgAddCounter.identifier = OcgcoreCommonConstants.MSG_ADD_COUNTER;
1595
- __decorateClass([
1596
- BinaryField("u16", 0)
1597
- ], YGOProMsgAddCounter.prototype, "counterType", 2);
1598
- __decorateClass([
1599
- BinaryField("u8", 2)
1600
- ], YGOProMsgAddCounter.prototype, "controller", 2);
1601
- __decorateClass([
1602
- BinaryField("u8", 3)
1603
- ], YGOProMsgAddCounter.prototype, "location", 2);
1604
- __decorateClass([
1605
- BinaryField("u8", 4)
1606
- ], YGOProMsgAddCounter.prototype, "sequence", 2);
1607
- __decorateClass([
1608
- BinaryField("u16", 5)
1609
- ], YGOProMsgAddCounter.prototype, "count", 2);
1610
-
1611
- // src/protos/msg/with-response-base.ts
1612
- var YGOProMsgResponseBase = class extends YGOProMsgBase {
1613
- defaultResponse() {
1614
- return void 0;
1615
- }
1616
- };
1617
-
1618
- // src/protos/msg/proto/announce-attrib.ts
1619
- var YGOProMsgAnnounceAttrib = class extends YGOProMsgResponseBase {
1620
- responsePlayer() {
1621
- return this.player;
1622
- }
1623
- prepareResponse(attributes) {
1624
- const buffer = new Uint8Array(4);
1625
- const view = new DataView(buffer.buffer);
1626
- view.setInt32(0, attributes, true);
1627
- return buffer;
1628
- }
1629
- };
1630
- YGOProMsgAnnounceAttrib.identifier = OcgcoreCommonConstants.MSG_ANNOUNCE_ATTRIB;
1631
- __decorateClass([
1632
- BinaryField("u8", 0)
1633
- ], YGOProMsgAnnounceAttrib.prototype, "player", 2);
1634
- __decorateClass([
1635
- BinaryField("u8", 1)
1636
- ], YGOProMsgAnnounceAttrib.prototype, "count", 2);
1637
- __decorateClass([
1638
- BinaryField("u32", 2)
1639
- ], YGOProMsgAnnounceAttrib.prototype, "availableAttributes", 2);
1640
-
1641
- // src/protos/msg/proto/announce-card.ts
1642
- var YGOProMsgAnnounceCard = class extends YGOProMsgResponseBase {
1643
- responsePlayer() {
1644
- return this.player;
1645
- }
1646
- prepareResponse(cardCode) {
1647
- const buffer = new Uint8Array(4);
1648
- const view = new DataView(buffer.buffer);
1649
- view.setInt32(0, cardCode, true);
1650
- return buffer;
1651
- }
1652
- };
1653
- YGOProMsgAnnounceCard.identifier = OcgcoreCommonConstants.MSG_ANNOUNCE_CARD;
1654
- __decorateClass([
1655
- BinaryField("u8", 0)
1656
- ], YGOProMsgAnnounceCard.prototype, "player", 2);
1657
- __decorateClass([
1658
- BinaryField("u8", 1)
1659
- ], YGOProMsgAnnounceCard.prototype, "count", 2);
1660
- __decorateClass([
1661
- BinaryField("i32", 2, (obj) => obj.count)
1662
- ], YGOProMsgAnnounceCard.prototype, "opcodes", 2);
1663
-
1664
- // src/protos/msg/index-response.ts
1665
- var INDEX_RESPONSE_SYMBOL = /* @__PURE__ */ Symbol("IndexResponse");
1666
- var IndexResponse = (index) => ({
1667
- [INDEX_RESPONSE_SYMBOL]: true,
1668
- index
1669
- });
1670
- var isIndexResponse = (obj) => {
1671
- return obj != null && obj[INDEX_RESPONSE_SYMBOL] === true;
1672
- };
1673
-
1674
- // src/protos/msg/proto/announce-number.ts
1675
- var YGOProMsgAnnounceNumber = class extends YGOProMsgResponseBase {
1676
- responsePlayer() {
1677
- return this.player;
1678
- }
1679
- prepareResponse(option) {
1680
- let index;
1681
- if (isIndexResponse(option)) {
1682
- index = option.index;
1683
- if (index < 0 || index >= this.count) {
1684
- throw new TypeError(`Index out of range: ${index}`);
1246
+ if (this.flags & OcgcoreCommonConstants.QUERY_OVERLAY_CARD) {
1247
+ const count = view.getInt32(offset, true);
1248
+ offset += 4;
1249
+ this.overlayCards = [];
1250
+ for (let i = 0; i < count; i++) {
1251
+ this.overlayCards.push(view.getInt32(offset, true));
1252
+ offset += 4;
1685
1253
  }
1686
- } else {
1687
- index = this.numbers.indexOf(option);
1688
- if (index === -1) {
1689
- throw new TypeError(`Number not found: ${option}`);
1254
+ }
1255
+ if (this.flags & OcgcoreCommonConstants.QUERY_COUNTERS) {
1256
+ const count = view.getInt32(offset, true);
1257
+ offset += 4;
1258
+ this.counters = [];
1259
+ for (let i = 0; i < count; i++) {
1260
+ this.counters.push({
1261
+ type: view.getUint16(offset, true),
1262
+ count: view.getUint16(offset + 2, true)
1263
+ });
1264
+ offset += 4;
1690
1265
  }
1691
1266
  }
1692
- const buffer = new Uint8Array(4);
1693
- const view = new DataView(buffer.buffer);
1694
- view.setInt32(0, index, true);
1695
- return buffer;
1696
- }
1697
- };
1698
- YGOProMsgAnnounceNumber.identifier = OcgcoreCommonConstants.MSG_ANNOUNCE_NUMBER;
1699
- __decorateClass([
1700
- BinaryField("u8", 0)
1701
- ], YGOProMsgAnnounceNumber.prototype, "player", 2);
1702
- __decorateClass([
1703
- BinaryField("u8", 1)
1704
- ], YGOProMsgAnnounceNumber.prototype, "count", 2);
1705
- __decorateClass([
1706
- BinaryField("i32", 2, (obj) => obj.count)
1707
- ], YGOProMsgAnnounceNumber.prototype, "numbers", 2);
1708
-
1709
- // src/protos/msg/proto/announce-race.ts
1710
- var YGOProMsgAnnounceRace = class extends YGOProMsgResponseBase {
1711
- responsePlayer() {
1712
- return this.player;
1713
- }
1714
- prepareResponse(races) {
1715
- const buffer = new Uint8Array(4);
1716
- const view = new DataView(buffer.buffer);
1717
- view.setInt32(0, races, true);
1718
- return buffer;
1719
- }
1720
- };
1721
- YGOProMsgAnnounceRace.identifier = OcgcoreCommonConstants.MSG_ANNOUNCE_RACE;
1722
- __decorateClass([
1723
- BinaryField("u8", 0)
1724
- ], YGOProMsgAnnounceRace.prototype, "player", 2);
1725
- __decorateClass([
1726
- BinaryField("u8", 1)
1727
- ], YGOProMsgAnnounceRace.prototype, "count", 2);
1728
- __decorateClass([
1729
- BinaryField("u32", 2)
1730
- ], YGOProMsgAnnounceRace.prototype, "availableRaces", 2);
1731
-
1732
- // src/protos/msg/proto/attack.ts
1733
- var YGOProMsgAttack_CardLocation = class {
1734
- };
1735
- __decorateClass([
1736
- BinaryField("u8", 0)
1737
- ], YGOProMsgAttack_CardLocation.prototype, "controller", 2);
1738
- __decorateClass([
1739
- BinaryField("u8", 1)
1740
- ], YGOProMsgAttack_CardLocation.prototype, "location", 2);
1741
- __decorateClass([
1742
- BinaryField("u8", 2)
1743
- ], YGOProMsgAttack_CardLocation.prototype, "sequence", 2);
1744
- __decorateClass([
1745
- BinaryField("u8", 3)
1746
- ], YGOProMsgAttack_CardLocation.prototype, "position", 2);
1747
- var YGOProMsgAttack = class extends YGOProMsgBase {
1748
- };
1749
- YGOProMsgAttack.identifier = OcgcoreCommonConstants.MSG_ATTACK;
1750
- __decorateClass([
1751
- BinaryField(() => YGOProMsgAttack_CardLocation, 0)
1752
- ], YGOProMsgAttack.prototype, "attacker", 2);
1753
- __decorateClass([
1754
- BinaryField(() => YGOProMsgAttack_CardLocation, 4)
1755
- ], YGOProMsgAttack.prototype, "defender", 2);
1756
-
1757
- // src/protos/msg/proto/attack-disabled.ts
1758
- var YGOProMsgAttackDisabled = class extends YGOProMsgBase {
1759
- };
1760
- YGOProMsgAttackDisabled.identifier = OcgcoreCommonConstants.MSG_ATTACK_DISABLED;
1761
-
1762
- // src/protos/msg/proto/battle.ts
1763
- var YGOProMsgBattle_CardLocation = class {
1764
- };
1765
- __decorateClass([
1766
- BinaryField("u8", 0)
1767
- ], YGOProMsgBattle_CardLocation.prototype, "controller", 2);
1768
- __decorateClass([
1769
- BinaryField("u8", 1)
1770
- ], YGOProMsgBattle_CardLocation.prototype, "location", 2);
1771
- __decorateClass([
1772
- BinaryField("u8", 2)
1773
- ], YGOProMsgBattle_CardLocation.prototype, "sequence", 2);
1774
- __decorateClass([
1775
- BinaryField("u8", 3)
1776
- ], YGOProMsgBattle_CardLocation.prototype, "position", 2);
1777
- var YGOProMsgBattle_CardStats = class {
1778
- };
1779
- __decorateClass([
1780
- BinaryField(() => YGOProMsgBattle_CardLocation, 0)
1781
- ], YGOProMsgBattle_CardStats.prototype, "location", 2);
1782
- __decorateClass([
1783
- BinaryField("i32", 4)
1784
- ], YGOProMsgBattle_CardStats.prototype, "atk", 2);
1785
- __decorateClass([
1786
- BinaryField("i32", 8)
1787
- ], YGOProMsgBattle_CardStats.prototype, "def", 2);
1788
- var YGOProMsgBattle = class extends YGOProMsgBase {
1789
- };
1790
- YGOProMsgBattle.identifier = OcgcoreCommonConstants.MSG_BATTLE;
1791
- __decorateClass([
1792
- BinaryField(() => YGOProMsgBattle_CardStats, 0)
1793
- ], YGOProMsgBattle.prototype, "attacker", 2);
1794
- __decorateClass([
1795
- BinaryField(() => YGOProMsgBattle_CardStats, 12)
1796
- ], YGOProMsgBattle.prototype, "defender", 2);
1797
- __decorateClass([
1798
- BinaryField("u8", 24)
1799
- ], YGOProMsgBattle.prototype, "battleDamageCalc", 2);
1800
-
1801
- // src/protos/msg/proto/become-target.ts
1802
- var YGOProMsgBecomeTarget = class extends YGOProMsgBase {
1803
- };
1804
- YGOProMsgBecomeTarget.identifier = OcgcoreCommonConstants.MSG_BECOME_TARGET;
1805
- __decorateClass([
1806
- BinaryField("u8", 0)
1807
- ], YGOProMsgBecomeTarget.prototype, "count", 2);
1808
- __decorateClass([
1809
- BinaryField("i32", 1, (obj) => obj.count)
1810
- ], YGOProMsgBecomeTarget.prototype, "targets", 2);
1811
-
1812
- // src/protos/msg/proto/cancel-target.ts
1813
- var YGOProMsgCancelTarget_CardLocation = class {
1814
- };
1815
- __decorateClass([
1816
- BinaryField("u8", 0)
1817
- ], YGOProMsgCancelTarget_CardLocation.prototype, "controller", 2);
1818
- __decorateClass([
1819
- BinaryField("u8", 1)
1820
- ], YGOProMsgCancelTarget_CardLocation.prototype, "location", 2);
1821
- __decorateClass([
1822
- BinaryField("u8", 2)
1823
- ], YGOProMsgCancelTarget_CardLocation.prototype, "sequence", 2);
1824
- var YGOProMsgCancelTarget = class extends YGOProMsgBase {
1825
- };
1826
- YGOProMsgCancelTarget.identifier = OcgcoreCommonConstants.MSG_CANCEL_TARGET;
1827
- __decorateClass([
1828
- BinaryField(() => YGOProMsgCancelTarget_CardLocation, 0)
1829
- ], YGOProMsgCancelTarget.prototype, "card1", 2);
1830
- __decorateClass([
1831
- BinaryField(() => YGOProMsgCancelTarget_CardLocation, 3)
1832
- ], YGOProMsgCancelTarget.prototype, "card2", 2);
1833
-
1834
- // src/protos/msg/proto/card-hint.ts
1835
- var YGOProMsgCardHint = class extends YGOProMsgBase {
1836
- };
1837
- YGOProMsgCardHint.identifier = OcgcoreCommonConstants.MSG_CARD_HINT;
1838
- __decorateClass([
1839
- BinaryField("u8", 0)
1840
- ], YGOProMsgCardHint.prototype, "controller", 2);
1841
- __decorateClass([
1842
- BinaryField("u8", 1)
1843
- ], YGOProMsgCardHint.prototype, "location", 2);
1844
- __decorateClass([
1845
- BinaryField("u8", 2)
1846
- ], YGOProMsgCardHint.prototype, "sequence", 2);
1847
- __decorateClass([
1848
- BinaryField("u8", 3)
1849
- ], YGOProMsgCardHint.prototype, "subsequence", 2);
1850
- __decorateClass([
1851
- BinaryField("u8", 4)
1852
- ], YGOProMsgCardHint.prototype, "type", 2);
1853
- __decorateClass([
1854
- BinaryField("i32", 5)
1855
- ], YGOProMsgCardHint.prototype, "value", 2);
1856
-
1857
- // src/protos/msg/proto/card-query.ts
1858
- var CardQuery_CardLocation = class {
1859
- };
1860
- var CardQuery_Counter = class {
1861
- };
1862
- var CardQuery = class {
1863
- constructor() {
1864
- this.flags = 0;
1267
+ if (this.flags & OcgcoreCommonConstants.QUERY_OWNER) {
1268
+ this.owner = view.getInt32(offset, true);
1269
+ offset += 4;
1270
+ }
1271
+ if (this.flags & OcgcoreCommonConstants.QUERY_STATUS) {
1272
+ this.status = view.getInt32(offset, true);
1273
+ offset += 4;
1274
+ }
1275
+ if (this.flags & OcgcoreCommonConstants.QUERY_LSCALE) {
1276
+ this.lscale = view.getInt32(offset, true);
1277
+ offset += 4;
1278
+ }
1279
+ if (this.flags & OcgcoreCommonConstants.QUERY_RSCALE) {
1280
+ this.rscale = view.getInt32(offset, true);
1281
+ offset += 4;
1282
+ }
1283
+ if (this.flags & OcgcoreCommonConstants.QUERY_LINK) {
1284
+ this.link = view.getInt32(offset, true);
1285
+ offset += 4;
1286
+ this.linkMarker = view.getInt32(offset, true);
1287
+ offset += 4;
1288
+ }
1289
+ return this;
1865
1290
  }
1866
- fromPayload(data) {
1867
- const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
1291
+ toPayload() {
1292
+ let size = 4;
1293
+ const flags = this.flags;
1294
+ if (flags & OcgcoreCommonConstants.QUERY_CODE) size += 4;
1295
+ if (flags & OcgcoreCommonConstants.QUERY_POSITION) size += 4;
1296
+ if (flags & OcgcoreCommonConstants.QUERY_ALIAS) size += 4;
1297
+ if (flags & OcgcoreCommonConstants.QUERY_TYPE) size += 4;
1298
+ if (flags & OcgcoreCommonConstants.QUERY_LEVEL) size += 4;
1299
+ if (flags & OcgcoreCommonConstants.QUERY_RANK) size += 4;
1300
+ if (flags & OcgcoreCommonConstants.QUERY_ATTRIBUTE) size += 4;
1301
+ if (flags & OcgcoreCommonConstants.QUERY_RACE) size += 4;
1302
+ if (flags & OcgcoreCommonConstants.QUERY_ATTACK) size += 4;
1303
+ if (flags & OcgcoreCommonConstants.QUERY_DEFENSE) size += 4;
1304
+ if (flags & OcgcoreCommonConstants.QUERY_BASE_ATTACK) size += 4;
1305
+ if (flags & OcgcoreCommonConstants.QUERY_BASE_DEFENSE) size += 4;
1306
+ if (flags & OcgcoreCommonConstants.QUERY_REASON) size += 4;
1307
+ if (flags & OcgcoreCommonConstants.QUERY_REASON_CARD) size += 4;
1308
+ if (flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) size += 4;
1309
+ if (flags & OcgcoreCommonConstants.QUERY_TARGET_CARD) {
1310
+ size += 4 + (this.targetCards?.length || 0) * 4;
1311
+ }
1312
+ if (flags & OcgcoreCommonConstants.QUERY_OVERLAY_CARD) {
1313
+ size += 4 + (this.overlayCards?.length || 0) * 4;
1314
+ }
1315
+ if (flags & OcgcoreCommonConstants.QUERY_COUNTERS) {
1316
+ size += 4 + (this.counters?.length || 0) * 4;
1317
+ }
1318
+ if (flags & OcgcoreCommonConstants.QUERY_OWNER) size += 4;
1319
+ if (flags & OcgcoreCommonConstants.QUERY_STATUS) size += 4;
1320
+ if (flags & OcgcoreCommonConstants.QUERY_LSCALE) size += 4;
1321
+ if (flags & OcgcoreCommonConstants.QUERY_RSCALE) size += 4;
1322
+ if (flags & OcgcoreCommonConstants.QUERY_LINK) size += 8;
1323
+ const result = new Uint8Array(size);
1324
+ const view = new DataView(result.buffer);
1868
1325
  let offset = 0;
1869
- this.flags = view.getInt32(offset, true) >>> 0;
1326
+ view.setInt32(offset, this.flags, true);
1870
1327
  offset += 4;
1871
- if (this.flags === 0) {
1872
- this.empty = true;
1873
- return this;
1328
+ if (this.empty || this.flags === 0) {
1329
+ return result;
1874
1330
  }
1875
- this.empty = false;
1876
- if (this.flags & OcgcoreCommonConstants.QUERY_CODE) {
1877
- this.code = view.getInt32(offset, true);
1331
+ if (flags & OcgcoreCommonConstants.QUERY_CODE) {
1332
+ view.setInt32(offset, this.code || 0, true);
1878
1333
  offset += 4;
1879
1334
  }
1880
- if (this.flags & OcgcoreCommonConstants.QUERY_POSITION) {
1881
- const pdata = view.getInt32(offset, true);
1882
- this.position = (pdata >>> 24 & 255) >>> 0;
1335
+ if (flags & OcgcoreCommonConstants.QUERY_POSITION) {
1336
+ const pdata = (this.position || 0) << 24 >>> 0;
1337
+ view.setInt32(offset, pdata, true);
1883
1338
  offset += 4;
1884
1339
  }
1885
- if (this.flags & OcgcoreCommonConstants.QUERY_ALIAS) {
1886
- this.alias = view.getInt32(offset, true);
1340
+ if (flags & OcgcoreCommonConstants.QUERY_ALIAS) {
1341
+ view.setInt32(offset, this.alias || 0, true);
1887
1342
  offset += 4;
1888
1343
  }
1889
- if (this.flags & OcgcoreCommonConstants.QUERY_TYPE) {
1890
- this.type = view.getInt32(offset, true);
1344
+ if (flags & OcgcoreCommonConstants.QUERY_TYPE) {
1345
+ view.setInt32(offset, this.type || 0, true);
1891
1346
  offset += 4;
1892
1347
  }
1893
- if (this.flags & OcgcoreCommonConstants.QUERY_LEVEL) {
1894
- this.level = view.getInt32(offset, true);
1348
+ if (flags & OcgcoreCommonConstants.QUERY_LEVEL) {
1349
+ view.setInt32(offset, this.level || 0, true);
1895
1350
  offset += 4;
1896
1351
  }
1897
- if (this.flags & OcgcoreCommonConstants.QUERY_RANK) {
1898
- this.rank = view.getInt32(offset, true);
1352
+ if (flags & OcgcoreCommonConstants.QUERY_RANK) {
1353
+ view.setInt32(offset, this.rank || 0, true);
1899
1354
  offset += 4;
1900
1355
  }
1901
- if (this.flags & OcgcoreCommonConstants.QUERY_ATTRIBUTE) {
1902
- this.attribute = view.getInt32(offset, true);
1356
+ if (flags & OcgcoreCommonConstants.QUERY_ATTRIBUTE) {
1357
+ view.setInt32(offset, this.attribute || 0, true);
1903
1358
  offset += 4;
1904
1359
  }
1905
- if (this.flags & OcgcoreCommonConstants.QUERY_RACE) {
1906
- this.race = view.getInt32(offset, true);
1360
+ if (flags & OcgcoreCommonConstants.QUERY_RACE) {
1361
+ view.setInt32(offset, this.race || 0, true);
1907
1362
  offset += 4;
1908
1363
  }
1909
- if (this.flags & OcgcoreCommonConstants.QUERY_ATTACK) {
1910
- this.attack = view.getInt32(offset, true);
1364
+ if (flags & OcgcoreCommonConstants.QUERY_ATTACK) {
1365
+ view.setInt32(offset, this.attack || 0, true);
1911
1366
  offset += 4;
1912
1367
  }
1913
- if (this.flags & OcgcoreCommonConstants.QUERY_DEFENSE) {
1914
- this.defense = view.getInt32(offset, true);
1368
+ if (flags & OcgcoreCommonConstants.QUERY_DEFENSE) {
1369
+ view.setInt32(offset, this.defense || 0, true);
1915
1370
  offset += 4;
1916
1371
  }
1917
- if (this.flags & OcgcoreCommonConstants.QUERY_BASE_ATTACK) {
1918
- this.baseAttack = view.getInt32(offset, true);
1372
+ if (flags & OcgcoreCommonConstants.QUERY_BASE_ATTACK) {
1373
+ view.setInt32(offset, this.baseAttack || 0, true);
1919
1374
  offset += 4;
1920
1375
  }
1921
- if (this.flags & OcgcoreCommonConstants.QUERY_BASE_DEFENSE) {
1922
- this.baseDefense = view.getInt32(offset, true);
1376
+ if (flags & OcgcoreCommonConstants.QUERY_BASE_DEFENSE) {
1377
+ view.setInt32(offset, this.baseDefense || 0, true);
1923
1378
  offset += 4;
1924
1379
  }
1925
- if (this.flags & OcgcoreCommonConstants.QUERY_REASON) {
1926
- this.reason = view.getInt32(offset, true);
1380
+ if (flags & OcgcoreCommonConstants.QUERY_REASON) {
1381
+ view.setInt32(offset, this.reason || 0, true);
1927
1382
  offset += 4;
1928
1383
  }
1929
- if (this.flags & OcgcoreCommonConstants.QUERY_REASON_CARD) {
1384
+ if (flags & OcgcoreCommonConstants.QUERY_REASON_CARD) {
1385
+ view.setInt32(offset, 0, true);
1930
1386
  offset += 4;
1931
1387
  }
1932
- if (this.flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) {
1933
- this.equipCard = {
1934
- controller: view.getUint8(offset),
1935
- location: view.getUint8(offset + 1),
1936
- sequence: view.getUint8(offset + 2)
1388
+ if (flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) {
1389
+ const card = this.equipCard || {
1390
+ controller: 0,
1391
+ location: 0,
1392
+ sequence: 0
1937
1393
  };
1394
+ view.setUint8(offset, card.controller);
1395
+ view.setUint8(offset + 1, card.location);
1396
+ view.setUint8(offset + 2, card.sequence);
1397
+ view.setUint8(offset + 3, 0);
1938
1398
  offset += 4;
1939
1399
  }
1940
- if (this.flags & OcgcoreCommonConstants.QUERY_TARGET_CARD) {
1941
- const count = view.getInt32(offset, true);
1400
+ if (flags & OcgcoreCommonConstants.QUERY_TARGET_CARD) {
1401
+ const targets = this.targetCards || [];
1402
+ view.setInt32(offset, targets.length, true);
1942
1403
  offset += 4;
1943
- this.targetCards = [];
1944
- for (let i = 0; i < count; i++) {
1945
- this.targetCards.push({
1946
- controller: view.getUint8(offset),
1947
- location: view.getUint8(offset + 1),
1948
- sequence: view.getUint8(offset + 2)
1949
- });
1404
+ for (const target of targets) {
1405
+ view.setUint8(offset, target.controller);
1406
+ view.setUint8(offset + 1, target.location);
1407
+ view.setUint8(offset + 2, target.sequence);
1408
+ view.setUint8(offset + 3, 0);
1950
1409
  offset += 4;
1951
1410
  }
1952
1411
  }
1953
- if (this.flags & OcgcoreCommonConstants.QUERY_OVERLAY_CARD) {
1954
- const count = view.getInt32(offset, true);
1412
+ if (flags & OcgcoreCommonConstants.QUERY_OVERLAY_CARD) {
1413
+ const overlays = this.overlayCards || [];
1414
+ view.setInt32(offset, overlays.length, true);
1955
1415
  offset += 4;
1956
- this.overlayCards = [];
1957
- for (let i = 0; i < count; i++) {
1958
- this.overlayCards.push(view.getInt32(offset, true));
1416
+ for (const card of overlays) {
1417
+ view.setInt32(offset, card, true);
1959
1418
  offset += 4;
1960
1419
  }
1961
1420
  }
1962
- if (this.flags & OcgcoreCommonConstants.QUERY_COUNTERS) {
1963
- const count = view.getInt32(offset, true);
1964
- offset += 4;
1965
- this.counters = [];
1966
- for (let i = 0; i < count; i++) {
1967
- this.counters.push({
1968
- type: view.getUint16(offset, true),
1969
- count: view.getUint16(offset + 2, true)
1970
- });
1421
+ if (flags & OcgcoreCommonConstants.QUERY_COUNTERS) {
1422
+ const counters = this.counters || [];
1423
+ view.setInt32(offset, counters.length, true);
1424
+ offset += 4;
1425
+ for (const counter of counters) {
1426
+ view.setUint16(offset, counter.type, true);
1427
+ view.setUint16(offset + 2, counter.count, true);
1971
1428
  offset += 4;
1972
1429
  }
1973
1430
  }
1974
- if (this.flags & OcgcoreCommonConstants.QUERY_OWNER) {
1975
- this.owner = view.getInt32(offset, true);
1431
+ if (flags & OcgcoreCommonConstants.QUERY_OWNER) {
1432
+ view.setInt32(offset, this.owner || 0, true);
1976
1433
  offset += 4;
1977
1434
  }
1978
- if (this.flags & OcgcoreCommonConstants.QUERY_STATUS) {
1979
- this.status = view.getInt32(offset, true);
1435
+ if (flags & OcgcoreCommonConstants.QUERY_STATUS) {
1436
+ view.setInt32(offset, this.status || 0, true);
1980
1437
  offset += 4;
1981
1438
  }
1982
- if (this.flags & OcgcoreCommonConstants.QUERY_LSCALE) {
1983
- this.lscale = view.getInt32(offset, true);
1439
+ if (flags & OcgcoreCommonConstants.QUERY_LSCALE) {
1440
+ view.setInt32(offset, this.lscale || 0, true);
1984
1441
  offset += 4;
1985
1442
  }
1986
- if (this.flags & OcgcoreCommonConstants.QUERY_RSCALE) {
1987
- this.rscale = view.getInt32(offset, true);
1443
+ if (flags & OcgcoreCommonConstants.QUERY_RSCALE) {
1444
+ view.setInt32(offset, this.rscale || 0, true);
1988
1445
  offset += 4;
1989
1446
  }
1990
- if (this.flags & OcgcoreCommonConstants.QUERY_LINK) {
1991
- this.link = view.getInt32(offset, true);
1447
+ if (flags & OcgcoreCommonConstants.QUERY_LINK) {
1448
+ view.setInt32(offset, this.link || 0, true);
1992
1449
  offset += 4;
1993
- this.linkMarker = view.getInt32(offset, true);
1450
+ view.setInt32(offset, this.linkMarker || 0, true);
1994
1451
  offset += 4;
1995
1452
  }
1996
- return this;
1453
+ return new Uint8Array(view.buffer, view.byteOffset, offset);
1997
1454
  }
1998
- toPayload() {
1999
- let size = 4;
2000
- const flags = this.flags;
2001
- if (flags & OcgcoreCommonConstants.QUERY_CODE) size += 4;
2002
- if (flags & OcgcoreCommonConstants.QUERY_POSITION) size += 4;
2003
- if (flags & OcgcoreCommonConstants.QUERY_ALIAS) size += 4;
2004
- if (flags & OcgcoreCommonConstants.QUERY_TYPE) size += 4;
2005
- if (flags & OcgcoreCommonConstants.QUERY_LEVEL) size += 4;
2006
- if (flags & OcgcoreCommonConstants.QUERY_RANK) size += 4;
2007
- if (flags & OcgcoreCommonConstants.QUERY_ATTRIBUTE) size += 4;
2008
- if (flags & OcgcoreCommonConstants.QUERY_RACE) size += 4;
2009
- if (flags & OcgcoreCommonConstants.QUERY_ATTACK) size += 4;
2010
- if (flags & OcgcoreCommonConstants.QUERY_DEFENSE) size += 4;
2011
- if (flags & OcgcoreCommonConstants.QUERY_BASE_ATTACK) size += 4;
2012
- if (flags & OcgcoreCommonConstants.QUERY_BASE_DEFENSE) size += 4;
2013
- if (flags & OcgcoreCommonConstants.QUERY_REASON) size += 4;
2014
- if (flags & OcgcoreCommonConstants.QUERY_REASON_CARD) size += 4;
2015
- if (flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) size += 4;
2016
- if (flags & OcgcoreCommonConstants.QUERY_TARGET_CARD) {
2017
- size += 4 + (this.targetCards?.length || 0) * 4;
2018
- }
2019
- if (flags & OcgcoreCommonConstants.QUERY_OVERLAY_CARD) {
2020
- size += 4 + (this.overlayCards?.length || 0) * 4;
2021
- }
2022
- if (flags & OcgcoreCommonConstants.QUERY_COUNTERS) {
2023
- size += 4 + (this.counters?.length || 0) * 4;
2024
- }
2025
- if (flags & OcgcoreCommonConstants.QUERY_OWNER) size += 4;
2026
- if (flags & OcgcoreCommonConstants.QUERY_STATUS) size += 4;
2027
- if (flags & OcgcoreCommonConstants.QUERY_LSCALE) size += 4;
2028
- if (flags & OcgcoreCommonConstants.QUERY_RSCALE) size += 4;
2029
- if (flags & OcgcoreCommonConstants.QUERY_LINK) size += 8;
2030
- const result = new Uint8Array(size);
2031
- const view = new DataView(result.buffer);
2032
- let offset = 0;
2033
- view.setInt32(offset, this.flags, true);
2034
- offset += 4;
2035
- if (this.empty || this.flags === 0) {
2036
- return result;
2037
- }
2038
- if (flags & OcgcoreCommonConstants.QUERY_CODE) {
2039
- view.setInt32(offset, this.code || 0, true);
2040
- offset += 4;
2041
- }
2042
- if (flags & OcgcoreCommonConstants.QUERY_POSITION) {
2043
- const pdata = (this.position || 0) << 24 >>> 0;
2044
- view.setInt32(offset, pdata, true);
2045
- offset += 4;
1455
+ };
1456
+
1457
+ // src/protos/ctos/base.ts
1458
+ var YGOProCtosBase = class extends PayloadBase {
1459
+ /**
1460
+ * Serialize to full payload including header (length + identifier + body)
1461
+ * Format: [length 2 bytes LE][identifier 1 byte][body]
1462
+ * Length = 1 (identifier) + body.length
1463
+ */
1464
+ toFullPayload() {
1465
+ const body = this.toPayload();
1466
+ const length = 1 + body.length;
1467
+ const fullPayload = new Uint8Array(3 + body.length);
1468
+ fullPayload[0] = length & 255;
1469
+ fullPayload[1] = length >> 8 & 255;
1470
+ fullPayload[2] = this.identifier;
1471
+ fullPayload.set(body, 3);
1472
+ return fullPayload;
1473
+ }
1474
+ /**
1475
+ * Deserialize from full payload including header (length + identifier + body)
1476
+ * Format: [length 2 bytes LE][identifier 1 byte][body]
1477
+ * @param data - Full payload data
1478
+ * @returns this instance
1479
+ * @throws Error if data is too short or identifier mismatch
1480
+ */
1481
+ fromFullPayload(data) {
1482
+ if (data.length < 3) {
1483
+ throw new Error(
1484
+ `CTOS payload too short: expected at least 3 bytes, got ${data.length}`
1485
+ );
2046
1486
  }
2047
- if (flags & OcgcoreCommonConstants.QUERY_ALIAS) {
2048
- view.setInt32(offset, this.alias || 0, true);
2049
- offset += 4;
1487
+ const declaredLength = data[0] | data[1] << 8;
1488
+ const identifier = data[2];
1489
+ if (identifier !== this.identifier) {
1490
+ throw new Error(
1491
+ `CTOS identifier mismatch: expected 0x${this.identifier.toString(16)}, got 0x${identifier.toString(16)}`
1492
+ );
2050
1493
  }
2051
- if (flags & OcgcoreCommonConstants.QUERY_TYPE) {
2052
- view.setInt32(offset, this.type || 0, true);
2053
- offset += 4;
1494
+ const expectedTotalLength = 3 + declaredLength - 1;
1495
+ if (data.length < expectedTotalLength) {
1496
+ throw new Error(
1497
+ `CTOS payload too short: declared length ${declaredLength} requires ${expectedTotalLength} bytes total, got ${data.length}`
1498
+ );
2054
1499
  }
2055
- if (flags & OcgcoreCommonConstants.QUERY_LEVEL) {
2056
- view.setInt32(offset, this.level || 0, true);
2057
- offset += 4;
1500
+ const bodyData = data.length > expectedTotalLength ? data.slice(3, expectedTotalLength) : data.slice(3);
1501
+ return this.fromPayload(bodyData);
1502
+ }
1503
+ };
1504
+
1505
+ // src/proto-base/registry-base.ts
1506
+ var RegistryBase = class {
1507
+ constructor(payloadClass, options = {}) {
1508
+ this.payloadClass = payloadClass;
1509
+ this.options = options;
1510
+ this.protos = /* @__PURE__ */ new Map();
1511
+ }
1512
+ register(proto) {
1513
+ const identifier = proto.identifier;
1514
+ this.protos.set(identifier, proto);
1515
+ }
1516
+ get(identifier) {
1517
+ return this.protos.get(identifier);
1518
+ }
1519
+ getInstanceFromPayload(data) {
1520
+ const identifier = data[this.options.identifierOffset ?? 0];
1521
+ const proto = this.get(identifier);
1522
+ if (!proto) {
1523
+ return void 0;
2058
1524
  }
2059
- if (flags & OcgcoreCommonConstants.QUERY_RANK) {
2060
- view.setInt32(offset, this.rank || 0, true);
2061
- offset += 4;
1525
+ return new proto().fromPayload(
1526
+ data.slice(this.options.dataOffset ?? 0)
1527
+ );
1528
+ }
1529
+ };
1530
+
1531
+ // src/protos/ctos/proto/response.ts
1532
+ var YGOProCtosResponse = class extends YGOProCtosBase {
1533
+ fromPayload(data) {
1534
+ this.response = data;
1535
+ return this;
1536
+ }
1537
+ toPayload() {
1538
+ return this.response || new Uint8Array(0);
1539
+ }
1540
+ };
1541
+ YGOProCtosResponse.identifier = 1;
1542
+
1543
+ // src/protos/ctos/proto/update-deck.ts
1544
+ var import_ygopro_deck_encode = __toESM(require("ygopro-deck-encode"));
1545
+ var YGOProCtosUpdateDeck = class extends YGOProCtosBase {
1546
+ constructor() {
1547
+ super();
1548
+ this.deck = new import_ygopro_deck_encode.default();
1549
+ }
1550
+ fromPayload(data) {
1551
+ this.deck = import_ygopro_deck_encode.default.fromUpdateDeckPayload(data);
1552
+ return this;
1553
+ }
1554
+ toPayload() {
1555
+ return this.deck.toUpdateDeckPayload();
1556
+ }
1557
+ fromPartial(data) {
1558
+ if (data.deck) {
1559
+ this.deck = new import_ygopro_deck_encode.default(data.deck);
2062
1560
  }
2063
- if (flags & OcgcoreCommonConstants.QUERY_ATTRIBUTE) {
2064
- view.setInt32(offset, this.attribute || 0, true);
2065
- offset += 4;
1561
+ return this;
1562
+ }
1563
+ copy() {
1564
+ const copied = new this.constructor();
1565
+ copied.deck = new import_ygopro_deck_encode.default(this.deck);
1566
+ return copied;
1567
+ }
1568
+ };
1569
+ YGOProCtosUpdateDeck.identifier = 2;
1570
+
1571
+ // src/protos/ctos/proto/hand-result.ts
1572
+ var YGOProCtosHandResult = class extends YGOProCtosBase {
1573
+ };
1574
+ YGOProCtosHandResult.identifier = 3;
1575
+ __decorateClass([
1576
+ BinaryField("u8", 0)
1577
+ ], YGOProCtosHandResult.prototype, "res", 2);
1578
+
1579
+ // src/protos/ctos/proto/tp-result.ts
1580
+ var YGOProCtosTpResult = class extends YGOProCtosBase {
1581
+ };
1582
+ YGOProCtosTpResult.identifier = 4;
1583
+ __decorateClass([
1584
+ BinaryField("u8", 0)
1585
+ ], YGOProCtosTpResult.prototype, "res", 2);
1586
+
1587
+ // src/protos/ctos/proto/player-info.ts
1588
+ var YGOProCtosPlayerInfo = class extends YGOProCtosBase {
1589
+ };
1590
+ YGOProCtosPlayerInfo.identifier = 16;
1591
+ __decorateClass([
1592
+ BinaryField("utf16", 0, 20)
1593
+ ], YGOProCtosPlayerInfo.prototype, "name", 2);
1594
+
1595
+ // src/protos/ctos/proto/create-game.ts
1596
+ var YGOProCtosCreateGame = class extends YGOProCtosBase {
1597
+ };
1598
+ YGOProCtosCreateGame.identifier = 17;
1599
+ __decorateClass([
1600
+ BinaryField(() => HostInfo, 0)
1601
+ ], YGOProCtosCreateGame.prototype, "info", 2);
1602
+ __decorateClass([
1603
+ BinaryField("utf16", 20, 20)
1604
+ ], YGOProCtosCreateGame.prototype, "name", 2);
1605
+ __decorateClass([
1606
+ BinaryField("utf16", 60, 20)
1607
+ ], YGOProCtosCreateGame.prototype, "pass", 2);
1608
+
1609
+ // src/protos/ctos/proto/join-game.ts
1610
+ var YGOProCtosJoinGame = class extends YGOProCtosBase {
1611
+ };
1612
+ YGOProCtosJoinGame.identifier = 18;
1613
+ __decorateClass([
1614
+ BinaryField("u16", 0)
1615
+ ], YGOProCtosJoinGame.prototype, "version", 2);
1616
+ __decorateClass([
1617
+ BinaryField("u32", 4)
1618
+ ], YGOProCtosJoinGame.prototype, "gameid", 2);
1619
+ __decorateClass([
1620
+ BinaryField("utf16", 8, 20)
1621
+ ], YGOProCtosJoinGame.prototype, "pass", 2);
1622
+
1623
+ // src/protos/ctos/proto/leave-game.ts
1624
+ var YGOProCtosLeaveGame = class extends YGOProCtosBase {
1625
+ };
1626
+ YGOProCtosLeaveGame.identifier = 19;
1627
+
1628
+ // src/protos/ctos/proto/surrender.ts
1629
+ var YGOProCtosSurrender = class extends YGOProCtosBase {
1630
+ };
1631
+ YGOProCtosSurrender.identifier = 20;
1632
+
1633
+ // src/protos/ctos/proto/time-confirm.ts
1634
+ var YGOProCtosTimeConfirm = class extends YGOProCtosBase {
1635
+ };
1636
+ YGOProCtosTimeConfirm.identifier = 21;
1637
+
1638
+ // src/protos/ctos/proto/chat.ts
1639
+ var YGOProCtosChat = class extends YGOProCtosBase {
1640
+ constructor() {
1641
+ super();
1642
+ this.msg = "";
1643
+ }
1644
+ fromPayload(data) {
1645
+ const decoder = new TextDecoder("utf-16le");
1646
+ this.msg = decoder.decode(data).replace(/\0+$/, "");
1647
+ return this;
1648
+ }
1649
+ toPayload() {
1650
+ const encoder = new TextEncoder();
1651
+ const utf8 = encoder.encode(this.msg);
1652
+ const decoder = new TextDecoder("utf-8");
1653
+ const text = decoder.decode(utf8);
1654
+ const utf16 = new Uint16Array(text.length + 1);
1655
+ for (let i = 0; i < text.length; i++) {
1656
+ utf16[i] = text.charCodeAt(i);
2066
1657
  }
2067
- if (flags & OcgcoreCommonConstants.QUERY_RACE) {
2068
- view.setInt32(offset, this.race || 0, true);
2069
- offset += 4;
1658
+ utf16[text.length] = 0;
1659
+ const result = new Uint8Array(utf16.buffer);
1660
+ return result;
1661
+ }
1662
+ fromPartial(data) {
1663
+ if (data.msg !== void 0) {
1664
+ this.msg = data.msg;
2070
1665
  }
2071
- if (flags & OcgcoreCommonConstants.QUERY_ATTACK) {
2072
- view.setInt32(offset, this.attack || 0, true);
2073
- offset += 4;
1666
+ return this;
1667
+ }
1668
+ };
1669
+ YGOProCtosChat.identifier = 22;
1670
+
1671
+ // src/protos/ctos/proto/external-address.ts
1672
+ var YGOProCtosExternalAddress = class extends YGOProCtosBase {
1673
+ constructor() {
1674
+ super();
1675
+ this.real_ip = "0.0.0.0";
1676
+ this.hostname = "";
1677
+ }
1678
+ // Convert IPv4 string to uint32 (network byte order / big endian)
1679
+ ipToUint32(ip) {
1680
+ let ipv4 = ip;
1681
+ if (ip.startsWith("::ffff:")) {
1682
+ ipv4 = ip.substring(7);
2074
1683
  }
2075
- if (flags & OcgcoreCommonConstants.QUERY_DEFENSE) {
2076
- view.setInt32(offset, this.defense || 0, true);
2077
- offset += 4;
1684
+ const parts = ipv4.split(".");
1685
+ if (parts.length !== 4) {
1686
+ return 0;
2078
1687
  }
2079
- if (flags & OcgcoreCommonConstants.QUERY_BASE_ATTACK) {
2080
- view.setInt32(offset, this.baseAttack || 0, true);
2081
- offset += 4;
1688
+ const bytes = parts.map((p) => parseInt(p, 10));
1689
+ if (bytes.some((b) => isNaN(b) || b < 0 || b > 255)) {
1690
+ return 0;
2082
1691
  }
2083
- if (flags & OcgcoreCommonConstants.QUERY_BASE_DEFENSE) {
2084
- view.setInt32(offset, this.baseDefense || 0, true);
2085
- offset += 4;
1692
+ return bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3];
1693
+ }
1694
+ // Convert uint32 (network byte order / big endian) to IPv4 string
1695
+ uint32ToIp(value) {
1696
+ const byte1 = value >>> 24 & 255;
1697
+ const byte2 = value >>> 16 & 255;
1698
+ const byte3 = value >>> 8 & 255;
1699
+ const byte4 = value & 255;
1700
+ return `${byte1}.${byte2}.${byte3}.${byte4}`;
1701
+ }
1702
+ fromPayload(data) {
1703
+ if (data.length < 4) {
1704
+ throw new Error("CTOS_EXTERNAL_ADDRESS data too short");
2086
1705
  }
2087
- if (flags & OcgcoreCommonConstants.QUERY_REASON) {
2088
- view.setInt32(offset, this.reason || 0, true);
2089
- offset += 4;
1706
+ const ipUint32 = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
1707
+ this.real_ip = this.uint32ToIp(ipUint32);
1708
+ if (data.length > 4) {
1709
+ const decoder = new TextDecoder("utf-16le");
1710
+ this.hostname = decoder.decode(data.slice(4)).replace(/\0+$/, "");
1711
+ } else {
1712
+ this.hostname = "";
2090
1713
  }
2091
- if (flags & OcgcoreCommonConstants.QUERY_REASON_CARD) {
2092
- view.setInt32(offset, 0, true);
2093
- offset += 4;
1714
+ return this;
1715
+ }
1716
+ toPayload() {
1717
+ const encoder = new TextEncoder();
1718
+ const utf8 = encoder.encode(this.hostname);
1719
+ const decoder = new TextDecoder("utf-8");
1720
+ const text = decoder.decode(utf8);
1721
+ const utf16 = new Uint16Array(text.length + 1);
1722
+ for (let i = 0; i < text.length; i++) {
1723
+ utf16[i] = text.charCodeAt(i);
2094
1724
  }
2095
- if (flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) {
2096
- const card = this.equipCard || {
2097
- controller: 0,
2098
- location: 0,
2099
- sequence: 0
2100
- };
2101
- view.setUint8(offset, card.controller);
2102
- view.setUint8(offset + 1, card.location);
2103
- view.setUint8(offset + 2, card.sequence);
2104
- view.setUint8(offset + 3, 0);
2105
- offset += 4;
1725
+ utf16[text.length] = 0;
1726
+ const result = new Uint8Array(4 + utf16.byteLength);
1727
+ const ipUint32 = this.ipToUint32(this.real_ip);
1728
+ result[0] = ipUint32 >>> 24 & 255;
1729
+ result[1] = ipUint32 >>> 16 & 255;
1730
+ result[2] = ipUint32 >>> 8 & 255;
1731
+ result[3] = ipUint32 & 255;
1732
+ result.set(new Uint8Array(utf16.buffer), 4);
1733
+ return result;
1734
+ }
1735
+ fromPartial(data) {
1736
+ if (data.real_ip !== void 0) {
1737
+ this.real_ip = data.real_ip;
2106
1738
  }
2107
- if (flags & OcgcoreCommonConstants.QUERY_TARGET_CARD) {
2108
- const targets = this.targetCards || [];
2109
- view.setInt32(offset, targets.length, true);
2110
- offset += 4;
2111
- for (const target of targets) {
2112
- view.setUint8(offset, target.controller);
2113
- view.setUint8(offset + 1, target.location);
2114
- view.setUint8(offset + 2, target.sequence);
2115
- view.setUint8(offset + 3, 0);
2116
- offset += 4;
2117
- }
1739
+ if (data.hostname !== void 0) {
1740
+ this.hostname = data.hostname;
2118
1741
  }
2119
- if (flags & OcgcoreCommonConstants.QUERY_OVERLAY_CARD) {
2120
- const overlays = this.overlayCards || [];
2121
- view.setInt32(offset, overlays.length, true);
2122
- offset += 4;
2123
- for (const card of overlays) {
2124
- view.setInt32(offset, card, true);
2125
- offset += 4;
2126
- }
1742
+ return this;
1743
+ }
1744
+ };
1745
+ YGOProCtosExternalAddress.identifier = 23;
1746
+
1747
+ // src/protos/ctos/proto/hs-toduelist.ts
1748
+ var YGOProCtosHsToDuelist = class extends YGOProCtosBase {
1749
+ };
1750
+ YGOProCtosHsToDuelist.identifier = 32;
1751
+
1752
+ // src/protos/ctos/proto/hs-toobserver.ts
1753
+ var YGOProCtosHsToObserver = class extends YGOProCtosBase {
1754
+ };
1755
+ YGOProCtosHsToObserver.identifier = 33;
1756
+
1757
+ // src/protos/ctos/proto/hs-ready.ts
1758
+ var YGOProCtosHsReady = class extends YGOProCtosBase {
1759
+ };
1760
+ YGOProCtosHsReady.identifier = 34;
1761
+
1762
+ // src/protos/ctos/proto/hs-notready.ts
1763
+ var YGOProCtosHsNotReady = class extends YGOProCtosBase {
1764
+ };
1765
+ YGOProCtosHsNotReady.identifier = 35;
1766
+
1767
+ // src/protos/ctos/proto/kick.ts
1768
+ var YGOProCtosKick = class extends YGOProCtosBase {
1769
+ };
1770
+ YGOProCtosKick.identifier = 36;
1771
+ __decorateClass([
1772
+ BinaryField("u8", 0)
1773
+ ], YGOProCtosKick.prototype, "pos", 2);
1774
+
1775
+ // src/protos/ctos/proto/hs-start.ts
1776
+ var YGOProCtosHsStart = class extends YGOProCtosBase {
1777
+ };
1778
+ YGOProCtosHsStart.identifier = 37;
1779
+
1780
+ // src/protos/ctos/proto/request-field.ts
1781
+ var YGOProCtosRequestField = class extends YGOProCtosBase {
1782
+ };
1783
+ YGOProCtosRequestField.identifier = 48;
1784
+
1785
+ // src/protos/ctos/registry.ts
1786
+ var YGOProCtos = new RegistryBase(YGOProCtosBase, {
1787
+ identifierOffset: 2,
1788
+ dataOffset: 3
1789
+ });
1790
+ YGOProCtos.register(YGOProCtosResponse);
1791
+ YGOProCtos.register(YGOProCtosUpdateDeck);
1792
+ YGOProCtos.register(YGOProCtosHandResult);
1793
+ YGOProCtos.register(YGOProCtosTpResult);
1794
+ YGOProCtos.register(YGOProCtosPlayerInfo);
1795
+ YGOProCtos.register(YGOProCtosCreateGame);
1796
+ YGOProCtos.register(YGOProCtosJoinGame);
1797
+ YGOProCtos.register(YGOProCtosLeaveGame);
1798
+ YGOProCtos.register(YGOProCtosSurrender);
1799
+ YGOProCtos.register(YGOProCtosTimeConfirm);
1800
+ YGOProCtos.register(YGOProCtosChat);
1801
+ YGOProCtos.register(YGOProCtosExternalAddress);
1802
+ YGOProCtos.register(YGOProCtosHsToDuelist);
1803
+ YGOProCtos.register(YGOProCtosHsToObserver);
1804
+ YGOProCtos.register(YGOProCtosHsReady);
1805
+ YGOProCtos.register(YGOProCtosHsNotReady);
1806
+ YGOProCtos.register(YGOProCtosKick);
1807
+ YGOProCtos.register(YGOProCtosHsStart);
1808
+ YGOProCtos.register(YGOProCtosRequestField);
1809
+
1810
+ // src/protos/stoc/base.ts
1811
+ var YGOProStocBase = class extends PayloadBase {
1812
+ /**
1813
+ * Serialize to full payload including header (length + identifier + body)
1814
+ * Format: [length 2 bytes LE][identifier 1 byte][body]
1815
+ * Length = 1 (identifier) + body.length
1816
+ */
1817
+ toFullPayload() {
1818
+ const body = this.toPayload();
1819
+ const length = 1 + body.length;
1820
+ const fullPayload = new Uint8Array(3 + body.length);
1821
+ fullPayload[0] = length & 255;
1822
+ fullPayload[1] = length >> 8 & 255;
1823
+ fullPayload[2] = this.identifier;
1824
+ fullPayload.set(body, 3);
1825
+ return fullPayload;
1826
+ }
1827
+ /**
1828
+ * Deserialize from full payload including header (length + identifier + body)
1829
+ * Format: [length 2 bytes LE][identifier 1 byte][body]
1830
+ * @param data - Full payload data
1831
+ * @returns this instance
1832
+ * @throws Error if data is too short or identifier mismatch
1833
+ */
1834
+ fromFullPayload(data) {
1835
+ if (data.length < 3) {
1836
+ throw new Error(
1837
+ `STOC payload too short: expected at least 3 bytes, got ${data.length}`
1838
+ );
2127
1839
  }
2128
- if (flags & OcgcoreCommonConstants.QUERY_COUNTERS) {
2129
- const counters = this.counters || [];
2130
- view.setInt32(offset, counters.length, true);
2131
- offset += 4;
2132
- for (const counter of counters) {
2133
- view.setUint16(offset, counter.type, true);
2134
- view.setUint16(offset + 2, counter.count, true);
2135
- offset += 4;
2136
- }
1840
+ const declaredLength = data[0] | data[1] << 8;
1841
+ const identifier = data[2];
1842
+ if (identifier !== this.identifier) {
1843
+ throw new Error(
1844
+ `STOC identifier mismatch: expected 0x${this.identifier.toString(16)}, got 0x${identifier.toString(16)}`
1845
+ );
2137
1846
  }
2138
- if (flags & OcgcoreCommonConstants.QUERY_OWNER) {
2139
- view.setInt32(offset, this.owner || 0, true);
2140
- offset += 4;
1847
+ const expectedTotalLength = 3 + declaredLength - 1;
1848
+ if (data.length < expectedTotalLength) {
1849
+ throw new Error(
1850
+ `STOC payload too short: declared length ${declaredLength} requires ${expectedTotalLength} bytes total, got ${data.length}`
1851
+ );
2141
1852
  }
2142
- if (flags & OcgcoreCommonConstants.QUERY_STATUS) {
2143
- view.setInt32(offset, this.status || 0, true);
2144
- offset += 4;
1853
+ const bodyData = data.length > expectedTotalLength ? data.slice(3, expectedTotalLength) : data.slice(3);
1854
+ return this.fromPayload(bodyData);
1855
+ }
1856
+ };
1857
+
1858
+ // src/protos/network-enums.ts
1859
+ var HandResult = /* @__PURE__ */ ((HandResult2) => {
1860
+ HandResult2[HandResult2["ROCK"] = 1] = "ROCK";
1861
+ HandResult2[HandResult2["SCISSORS"] = 2] = "SCISSORS";
1862
+ HandResult2[HandResult2["PAPER"] = 3] = "PAPER";
1863
+ return HandResult2;
1864
+ })(HandResult || {});
1865
+ var TurnPlayerResult = /* @__PURE__ */ ((TurnPlayerResult2) => {
1866
+ TurnPlayerResult2[TurnPlayerResult2["SECOND"] = 0] = "SECOND";
1867
+ TurnPlayerResult2[TurnPlayerResult2["FIRST"] = 1] = "FIRST";
1868
+ return TurnPlayerResult2;
1869
+ })(TurnPlayerResult || {});
1870
+ var NetPlayerType = /* @__PURE__ */ ((NetPlayerType2) => {
1871
+ NetPlayerType2[NetPlayerType2["PLAYER1"] = 0] = "PLAYER1";
1872
+ NetPlayerType2[NetPlayerType2["PLAYER2"] = 1] = "PLAYER2";
1873
+ NetPlayerType2[NetPlayerType2["PLAYER3"] = 2] = "PLAYER3";
1874
+ NetPlayerType2[NetPlayerType2["PLAYER4"] = 3] = "PLAYER4";
1875
+ NetPlayerType2[NetPlayerType2["PLAYER5"] = 4] = "PLAYER5";
1876
+ NetPlayerType2[NetPlayerType2["PLAYER6"] = 5] = "PLAYER6";
1877
+ NetPlayerType2[NetPlayerType2["OBSERVER"] = 7] = "OBSERVER";
1878
+ return NetPlayerType2;
1879
+ })(NetPlayerType || {});
1880
+ var ChatColor = /* @__PURE__ */ ((ChatColor2) => {
1881
+ ChatColor2[ChatColor2["LIGHTBLUE"] = 8] = "LIGHTBLUE";
1882
+ ChatColor2[ChatColor2["RED"] = 11] = "RED";
1883
+ ChatColor2[ChatColor2["GREEN"] = 12] = "GREEN";
1884
+ ChatColor2[ChatColor2["BLUE"] = 13] = "BLUE";
1885
+ ChatColor2[ChatColor2["BABYBLUE"] = 14] = "BABYBLUE";
1886
+ ChatColor2[ChatColor2["PINK"] = 15] = "PINK";
1887
+ ChatColor2[ChatColor2["YELLOW"] = 16] = "YELLOW";
1888
+ ChatColor2[ChatColor2["WHITE"] = 17] = "WHITE";
1889
+ ChatColor2[ChatColor2["GRAY"] = 18] = "GRAY";
1890
+ ChatColor2[ChatColor2["DARKGRAY"] = 19] = "DARKGRAY";
1891
+ return ChatColor2;
1892
+ })(ChatColor || {});
1893
+ var GameMode = /* @__PURE__ */ ((GameMode2) => {
1894
+ GameMode2[GameMode2["SINGLE"] = 0] = "SINGLE";
1895
+ GameMode2[GameMode2["MATCH"] = 1] = "MATCH";
1896
+ GameMode2[GameMode2["TAG"] = 2] = "TAG";
1897
+ return GameMode2;
1898
+ })(GameMode || {});
1899
+ var ErrorMessageType = /* @__PURE__ */ ((ErrorMessageType2) => {
1900
+ ErrorMessageType2[ErrorMessageType2["JOINERROR"] = 1] = "JOINERROR";
1901
+ ErrorMessageType2[ErrorMessageType2["DECKERROR"] = 2] = "DECKERROR";
1902
+ ErrorMessageType2[ErrorMessageType2["SIDEERROR"] = 3] = "SIDEERROR";
1903
+ ErrorMessageType2[ErrorMessageType2["VERERROR"] = 4] = "VERERROR";
1904
+ return ErrorMessageType2;
1905
+ })(ErrorMessageType || {});
1906
+ var DeckErrorType = /* @__PURE__ */ ((DeckErrorType2) => {
1907
+ DeckErrorType2[DeckErrorType2["LFLIST"] = 1] = "LFLIST";
1908
+ DeckErrorType2[DeckErrorType2["OCGONLY"] = 2] = "OCGONLY";
1909
+ DeckErrorType2[DeckErrorType2["TCGONLY"] = 3] = "TCGONLY";
1910
+ DeckErrorType2[DeckErrorType2["UNKNOWNCARD"] = 4] = "UNKNOWNCARD";
1911
+ DeckErrorType2[DeckErrorType2["CARDCOUNT"] = 5] = "CARDCOUNT";
1912
+ DeckErrorType2[DeckErrorType2["MAINCOUNT"] = 6] = "MAINCOUNT";
1913
+ DeckErrorType2[DeckErrorType2["EXTRACOUNT"] = 7] = "EXTRACOUNT";
1914
+ DeckErrorType2[DeckErrorType2["SIDECOUNT"] = 8] = "SIDECOUNT";
1915
+ DeckErrorType2[DeckErrorType2["NOTAVAIL"] = 9] = "NOTAVAIL";
1916
+ return DeckErrorType2;
1917
+ })(DeckErrorType || {});
1918
+ var PlayerChangeState = /* @__PURE__ */ ((PlayerChangeState2) => {
1919
+ PlayerChangeState2[PlayerChangeState2["OBSERVE"] = 8] = "OBSERVE";
1920
+ PlayerChangeState2[PlayerChangeState2["READY"] = 9] = "READY";
1921
+ PlayerChangeState2[PlayerChangeState2["NOTREADY"] = 10] = "NOTREADY";
1922
+ PlayerChangeState2[PlayerChangeState2["LEAVE"] = 11] = "LEAVE";
1923
+ return PlayerChangeState2;
1924
+ })(PlayerChangeState || {});
1925
+ var RoomStatus = /* @__PURE__ */ ((RoomStatus2) => {
1926
+ RoomStatus2[RoomStatus2["WAITING"] = 0] = "WAITING";
1927
+ RoomStatus2[RoomStatus2["DUELING"] = 1] = "DUELING";
1928
+ RoomStatus2[RoomStatus2["SIDING"] = 2] = "SIDING";
1929
+ return RoomStatus2;
1930
+ })(RoomStatus || {});
1931
+
1932
+ // src/protos/msg/base.ts
1933
+ var SEND_TO_PLAYERS = [0, 1];
1934
+ var SEND_TO_ALL = [0, 1, 7 /* OBSERVER */];
1935
+ var YGOProMsgBase = class extends PayloadBase {
1936
+ fromPayload(data) {
1937
+ if (data.length < 1) {
1938
+ throw new Error("MSG data too short");
2145
1939
  }
2146
- if (flags & OcgcoreCommonConstants.QUERY_LSCALE) {
2147
- view.setInt32(offset, this.lscale || 0, true);
2148
- offset += 4;
1940
+ const msgType = data[0];
1941
+ if (msgType !== this.identifier) {
1942
+ throw new Error(
1943
+ `MSG type mismatch: expected ${this.identifier}, got ${msgType}`
1944
+ );
2149
1945
  }
2150
- if (flags & OcgcoreCommonConstants.QUERY_RSCALE) {
2151
- view.setInt32(offset, this.rscale || 0, true);
2152
- offset += 4;
1946
+ return super.fromPayload(data.slice(1));
1947
+ }
1948
+ toPayload() {
1949
+ const payload = super.toPayload();
1950
+ const result = new Uint8Array(1 + payload.length);
1951
+ result[0] = this.identifier;
1952
+ result.set(payload, 1);
1953
+ return result;
1954
+ }
1955
+ opponentView() {
1956
+ return this.copy();
1957
+ }
1958
+ teammateView() {
1959
+ return this.copy();
1960
+ }
1961
+ observerView() {
1962
+ return this.opponentView();
1963
+ }
1964
+ playerView(playerId) {
1965
+ if (typeof this["player"] === "number") {
1966
+ const selfPlayerId = this["player"];
1967
+ if (selfPlayerId === playerId) {
1968
+ return this.copy();
1969
+ }
1970
+ return this.opponentView();
2153
1971
  }
2154
- if (flags & OcgcoreCommonConstants.QUERY_LINK) {
2155
- view.setInt32(offset, this.link || 0, true);
2156
- offset += 4;
2157
- view.setInt32(offset, this.linkMarker || 0, true);
2158
- offset += 4;
1972
+ return this.copy();
1973
+ }
1974
+ getSendTargets() {
1975
+ return SEND_TO_ALL;
1976
+ }
1977
+ };
1978
+
1979
+ // src/protos/msg/proto/add-counter.ts
1980
+ var YGOProMsgAddCounter = class extends YGOProMsgBase {
1981
+ };
1982
+ YGOProMsgAddCounter.identifier = OcgcoreCommonConstants.MSG_ADD_COUNTER;
1983
+ __decorateClass([
1984
+ BinaryField("u16", 0)
1985
+ ], YGOProMsgAddCounter.prototype, "counterType", 2);
1986
+ __decorateClass([
1987
+ BinaryField("u8", 2)
1988
+ ], YGOProMsgAddCounter.prototype, "controller", 2);
1989
+ __decorateClass([
1990
+ BinaryField("u8", 3)
1991
+ ], YGOProMsgAddCounter.prototype, "location", 2);
1992
+ __decorateClass([
1993
+ BinaryField("u8", 4)
1994
+ ], YGOProMsgAddCounter.prototype, "sequence", 2);
1995
+ __decorateClass([
1996
+ BinaryField("u16", 5)
1997
+ ], YGOProMsgAddCounter.prototype, "count", 2);
1998
+
1999
+ // src/protos/msg/with-response-base.ts
2000
+ var YGOProMsgResponseBase = class extends YGOProMsgBase {
2001
+ defaultResponse() {
2002
+ return void 0;
2003
+ }
2004
+ getSendTargets() {
2005
+ return [this.responsePlayer()];
2006
+ }
2007
+ };
2008
+
2009
+ // src/protos/msg/proto/announce-attrib.ts
2010
+ var YGOProMsgAnnounceAttrib = class extends YGOProMsgResponseBase {
2011
+ responsePlayer() {
2012
+ return this.player;
2013
+ }
2014
+ prepareResponse(attributes) {
2015
+ const buffer = new Uint8Array(4);
2016
+ const view = new DataView(buffer.buffer);
2017
+ view.setInt32(0, attributes, true);
2018
+ return buffer;
2019
+ }
2020
+ };
2021
+ YGOProMsgAnnounceAttrib.identifier = OcgcoreCommonConstants.MSG_ANNOUNCE_ATTRIB;
2022
+ __decorateClass([
2023
+ BinaryField("u8", 0)
2024
+ ], YGOProMsgAnnounceAttrib.prototype, "player", 2);
2025
+ __decorateClass([
2026
+ BinaryField("u8", 1)
2027
+ ], YGOProMsgAnnounceAttrib.prototype, "count", 2);
2028
+ __decorateClass([
2029
+ BinaryField("u32", 2)
2030
+ ], YGOProMsgAnnounceAttrib.prototype, "availableAttributes", 2);
2031
+
2032
+ // src/protos/msg/proto/announce-card.ts
2033
+ var YGOProMsgAnnounceCard = class extends YGOProMsgResponseBase {
2034
+ responsePlayer() {
2035
+ return this.player;
2036
+ }
2037
+ prepareResponse(cardCode) {
2038
+ const buffer = new Uint8Array(4);
2039
+ const view = new DataView(buffer.buffer);
2040
+ view.setInt32(0, cardCode, true);
2041
+ return buffer;
2042
+ }
2043
+ };
2044
+ YGOProMsgAnnounceCard.identifier = OcgcoreCommonConstants.MSG_ANNOUNCE_CARD;
2045
+ __decorateClass([
2046
+ BinaryField("u8", 0)
2047
+ ], YGOProMsgAnnounceCard.prototype, "player", 2);
2048
+ __decorateClass([
2049
+ BinaryField("u8", 1)
2050
+ ], YGOProMsgAnnounceCard.prototype, "count", 2);
2051
+ __decorateClass([
2052
+ BinaryField("i32", 2, (obj) => obj.count)
2053
+ ], YGOProMsgAnnounceCard.prototype, "opcodes", 2);
2054
+
2055
+ // src/protos/msg/index-response.ts
2056
+ var INDEX_RESPONSE_SYMBOL = /* @__PURE__ */ Symbol("IndexResponse");
2057
+ var IndexResponse = (index) => ({
2058
+ [INDEX_RESPONSE_SYMBOL]: true,
2059
+ index
2060
+ });
2061
+ var isIndexResponse = (obj) => {
2062
+ return obj != null && obj[INDEX_RESPONSE_SYMBOL] === true;
2063
+ };
2064
+
2065
+ // src/protos/msg/proto/announce-number.ts
2066
+ var YGOProMsgAnnounceNumber = class extends YGOProMsgResponseBase {
2067
+ responsePlayer() {
2068
+ return this.player;
2069
+ }
2070
+ prepareResponse(option) {
2071
+ let index;
2072
+ if (isIndexResponse(option)) {
2073
+ index = option.index;
2074
+ if (index < 0 || index >= this.count) {
2075
+ throw new TypeError(`Index out of range: ${index}`);
2076
+ }
2077
+ } else {
2078
+ index = this.numbers.indexOf(option);
2079
+ if (index === -1) {
2080
+ throw new TypeError(`Number not found: ${option}`);
2081
+ }
2159
2082
  }
2160
- return new Uint8Array(view.buffer, view.byteOffset, offset);
2083
+ const buffer = new Uint8Array(4);
2084
+ const view = new DataView(buffer.buffer);
2085
+ view.setInt32(0, index, true);
2086
+ return buffer;
2087
+ }
2088
+ };
2089
+ YGOProMsgAnnounceNumber.identifier = OcgcoreCommonConstants.MSG_ANNOUNCE_NUMBER;
2090
+ __decorateClass([
2091
+ BinaryField("u8", 0)
2092
+ ], YGOProMsgAnnounceNumber.prototype, "player", 2);
2093
+ __decorateClass([
2094
+ BinaryField("u8", 1)
2095
+ ], YGOProMsgAnnounceNumber.prototype, "count", 2);
2096
+ __decorateClass([
2097
+ BinaryField("i32", 2, (obj) => obj.count)
2098
+ ], YGOProMsgAnnounceNumber.prototype, "numbers", 2);
2099
+
2100
+ // src/protos/msg/proto/announce-race.ts
2101
+ var YGOProMsgAnnounceRace = class extends YGOProMsgResponseBase {
2102
+ responsePlayer() {
2103
+ return this.player;
2161
2104
  }
2105
+ prepareResponse(races) {
2106
+ const buffer = new Uint8Array(4);
2107
+ const view = new DataView(buffer.buffer);
2108
+ view.setInt32(0, races, true);
2109
+ return buffer;
2110
+ }
2111
+ };
2112
+ YGOProMsgAnnounceRace.identifier = OcgcoreCommonConstants.MSG_ANNOUNCE_RACE;
2113
+ __decorateClass([
2114
+ BinaryField("u8", 0)
2115
+ ], YGOProMsgAnnounceRace.prototype, "player", 2);
2116
+ __decorateClass([
2117
+ BinaryField("u8", 1)
2118
+ ], YGOProMsgAnnounceRace.prototype, "count", 2);
2119
+ __decorateClass([
2120
+ BinaryField("u32", 2)
2121
+ ], YGOProMsgAnnounceRace.prototype, "availableRaces", 2);
2122
+
2123
+ // src/protos/msg/proto/attack.ts
2124
+ var YGOProMsgAttack_CardLocation = class {
2125
+ };
2126
+ __decorateClass([
2127
+ BinaryField("u8", 0)
2128
+ ], YGOProMsgAttack_CardLocation.prototype, "controller", 2);
2129
+ __decorateClass([
2130
+ BinaryField("u8", 1)
2131
+ ], YGOProMsgAttack_CardLocation.prototype, "location", 2);
2132
+ __decorateClass([
2133
+ BinaryField("u8", 2)
2134
+ ], YGOProMsgAttack_CardLocation.prototype, "sequence", 2);
2135
+ __decorateClass([
2136
+ BinaryField("u8", 3)
2137
+ ], YGOProMsgAttack_CardLocation.prototype, "position", 2);
2138
+ var YGOProMsgAttack = class extends YGOProMsgBase {
2139
+ };
2140
+ YGOProMsgAttack.identifier = OcgcoreCommonConstants.MSG_ATTACK;
2141
+ __decorateClass([
2142
+ BinaryField(() => YGOProMsgAttack_CardLocation, 0)
2143
+ ], YGOProMsgAttack.prototype, "attacker", 2);
2144
+ __decorateClass([
2145
+ BinaryField(() => YGOProMsgAttack_CardLocation, 4)
2146
+ ], YGOProMsgAttack.prototype, "defender", 2);
2147
+
2148
+ // src/protos/msg/proto/attack-disabled.ts
2149
+ var YGOProMsgAttackDisabled = class extends YGOProMsgBase {
2150
+ };
2151
+ YGOProMsgAttackDisabled.identifier = OcgcoreCommonConstants.MSG_ATTACK_DISABLED;
2152
+
2153
+ // src/protos/msg/proto/battle.ts
2154
+ var YGOProMsgBattle_CardLocation = class {
2155
+ };
2156
+ __decorateClass([
2157
+ BinaryField("u8", 0)
2158
+ ], YGOProMsgBattle_CardLocation.prototype, "controller", 2);
2159
+ __decorateClass([
2160
+ BinaryField("u8", 1)
2161
+ ], YGOProMsgBattle_CardLocation.prototype, "location", 2);
2162
+ __decorateClass([
2163
+ BinaryField("u8", 2)
2164
+ ], YGOProMsgBattle_CardLocation.prototype, "sequence", 2);
2165
+ __decorateClass([
2166
+ BinaryField("u8", 3)
2167
+ ], YGOProMsgBattle_CardLocation.prototype, "position", 2);
2168
+ var YGOProMsgBattle_CardStats = class {
2169
+ };
2170
+ __decorateClass([
2171
+ BinaryField(() => YGOProMsgBattle_CardLocation, 0)
2172
+ ], YGOProMsgBattle_CardStats.prototype, "location", 2);
2173
+ __decorateClass([
2174
+ BinaryField("i32", 4)
2175
+ ], YGOProMsgBattle_CardStats.prototype, "atk", 2);
2176
+ __decorateClass([
2177
+ BinaryField("i32", 8)
2178
+ ], YGOProMsgBattle_CardStats.prototype, "def", 2);
2179
+ var YGOProMsgBattle = class extends YGOProMsgBase {
2180
+ };
2181
+ YGOProMsgBattle.identifier = OcgcoreCommonConstants.MSG_BATTLE;
2182
+ __decorateClass([
2183
+ BinaryField(() => YGOProMsgBattle_CardStats, 0)
2184
+ ], YGOProMsgBattle.prototype, "attacker", 2);
2185
+ __decorateClass([
2186
+ BinaryField(() => YGOProMsgBattle_CardStats, 12)
2187
+ ], YGOProMsgBattle.prototype, "defender", 2);
2188
+ __decorateClass([
2189
+ BinaryField("u8", 24)
2190
+ ], YGOProMsgBattle.prototype, "battleDamageCalc", 2);
2191
+
2192
+ // src/protos/msg/proto/become-target.ts
2193
+ var YGOProMsgBecomeTarget = class extends YGOProMsgBase {
2194
+ };
2195
+ YGOProMsgBecomeTarget.identifier = OcgcoreCommonConstants.MSG_BECOME_TARGET;
2196
+ __decorateClass([
2197
+ BinaryField("u8", 0)
2198
+ ], YGOProMsgBecomeTarget.prototype, "count", 2);
2199
+ __decorateClass([
2200
+ BinaryField("i32", 1, (obj) => obj.count)
2201
+ ], YGOProMsgBecomeTarget.prototype, "targets", 2);
2202
+
2203
+ // src/protos/msg/proto/cancel-target.ts
2204
+ var YGOProMsgCancelTarget_CardLocation = class {
2205
+ };
2206
+ __decorateClass([
2207
+ BinaryField("u8", 0)
2208
+ ], YGOProMsgCancelTarget_CardLocation.prototype, "controller", 2);
2209
+ __decorateClass([
2210
+ BinaryField("u8", 1)
2211
+ ], YGOProMsgCancelTarget_CardLocation.prototype, "location", 2);
2212
+ __decorateClass([
2213
+ BinaryField("u8", 2)
2214
+ ], YGOProMsgCancelTarget_CardLocation.prototype, "sequence", 2);
2215
+ var YGOProMsgCancelTarget = class extends YGOProMsgBase {
2216
+ };
2217
+ YGOProMsgCancelTarget.identifier = OcgcoreCommonConstants.MSG_CANCEL_TARGET;
2218
+ __decorateClass([
2219
+ BinaryField(() => YGOProMsgCancelTarget_CardLocation, 0)
2220
+ ], YGOProMsgCancelTarget.prototype, "card1", 2);
2221
+ __decorateClass([
2222
+ BinaryField(() => YGOProMsgCancelTarget_CardLocation, 3)
2223
+ ], YGOProMsgCancelTarget.prototype, "card2", 2);
2224
+
2225
+ // src/protos/msg/proto/card-hint.ts
2226
+ var YGOProMsgCardHint = class extends YGOProMsgBase {
2162
2227
  };
2228
+ YGOProMsgCardHint.identifier = OcgcoreCommonConstants.MSG_CARD_HINT;
2229
+ __decorateClass([
2230
+ BinaryField("u8", 0)
2231
+ ], YGOProMsgCardHint.prototype, "controller", 2);
2232
+ __decorateClass([
2233
+ BinaryField("u8", 1)
2234
+ ], YGOProMsgCardHint.prototype, "location", 2);
2235
+ __decorateClass([
2236
+ BinaryField("u8", 2)
2237
+ ], YGOProMsgCardHint.prototype, "sequence", 2);
2238
+ __decorateClass([
2239
+ BinaryField("u8", 3)
2240
+ ], YGOProMsgCardHint.prototype, "subsequence", 2);
2241
+ __decorateClass([
2242
+ BinaryField("u8", 4)
2243
+ ], YGOProMsgCardHint.prototype, "type", 2);
2244
+ __decorateClass([
2245
+ BinaryField("i32", 5)
2246
+ ], YGOProMsgCardHint.prototype, "value", 2);
2163
2247
 
2164
2248
  // src/protos/msg/proto/card-target.ts
2165
2249
  var YGOProMsgCardTarget_CardLocation = class {
@@ -2288,6 +2372,12 @@ var YGOProMsgConfirmCards = class extends YGOProMsgBase {
2288
2372
  });
2289
2373
  return view;
2290
2374
  }
2375
+ getSendTargets() {
2376
+ if (this.cards.length > 0 && this.cards[0].location === 1) {
2377
+ return [this.player];
2378
+ }
2379
+ return SEND_TO_ALL;
2380
+ }
2291
2381
  };
2292
2382
  YGOProMsgConfirmCards.identifier = OcgcoreCommonConstants.MSG_CONFIRM_CARDS;
2293
2383
  __decorateClass([
@@ -2518,7 +2608,18 @@ __decorateClass([
2518
2608
  ], YGOProMsgHandRes.prototype, "result", 2);
2519
2609
 
2520
2610
  // src/protos/msg/proto/hint.ts
2611
+ var HINT_TYPES_SEND_TO_SELF = /* @__PURE__ */ new Set([1, 2, 3, 5]);
2612
+ var HINT_TYPES_SEND_TO_OPPONENT = /* @__PURE__ */ new Set([4, 6, 7, 8, 9, 11]);
2521
2613
  var YGOProMsgHint = class extends YGOProMsgBase {
2614
+ getSendTargets() {
2615
+ if (HINT_TYPES_SEND_TO_SELF.has(this.type)) {
2616
+ return [this.player];
2617
+ }
2618
+ if (HINT_TYPES_SEND_TO_OPPONENT.has(this.type)) {
2619
+ return [1 - this.player, 7 /* OBSERVER */];
2620
+ }
2621
+ return SEND_TO_ALL;
2622
+ }
2522
2623
  };
2523
2624
  YGOProMsgHint.identifier = OcgcoreCommonConstants.MSG_HINT;
2524
2625
  __decorateClass([
@@ -2552,6 +2653,9 @@ __decorateClass([
2552
2653
 
2553
2654
  // src/protos/msg/proto/missed-effect.ts
2554
2655
  var YGOProMsgMissedEffect = class extends YGOProMsgBase {
2656
+ getSendTargets() {
2657
+ return [this.player];
2658
+ }
2555
2659
  };
2556
2660
  YGOProMsgMissedEffect.identifier = OcgcoreCommonConstants.MSG_MISSED_EFFECT;
2557
2661
  __decorateClass([
@@ -2853,6 +2957,9 @@ __decorateClass([
2853
2957
 
2854
2958
  // src/protos/msg/proto/reset-time.ts
2855
2959
  var YGOProMsgResetTime = class extends YGOProMsgBase {
2960
+ getSendTargets() {
2961
+ return [];
2962
+ }
2856
2963
  };
2857
2964
  YGOProMsgResetTime.identifier = OcgcoreCommonConstants.MSG_RESET_TIME;
2858
2965
  __decorateClass([
@@ -2864,6 +2971,9 @@ __decorateClass([
2864
2971
 
2865
2972
  // src/protos/msg/proto/retry.ts
2866
2973
  var YGOProMsgRetry = class extends YGOProMsgBase {
2974
+ getSendTargets() {
2975
+ return [];
2976
+ }
2867
2977
  };
2868
2978
  YGOProMsgRetry.identifier = OcgcoreCommonConstants.MSG_RETRY;
2869
2979
 
@@ -2873,7 +2983,18 @@ var YGOProMsgReverseDeck = class extends YGOProMsgBase {
2873
2983
  YGOProMsgReverseDeck.identifier = OcgcoreCommonConstants.MSG_REVERSE_DECK;
2874
2984
 
2875
2985
  // src/protos/msg/proto/rock-paper-scissors.ts
2876
- var YGOProMsgRockPaperScissors = class extends YGOProMsgBase {
2986
+ var YGOProMsgRockPaperScissors = class extends YGOProMsgResponseBase {
2987
+ responsePlayer() {
2988
+ return this.player;
2989
+ }
2990
+ prepareResponse(choice) {
2991
+ if (choice < 1 /* ROCK */ || choice > 3 /* PAPER */) {
2992
+ throw new TypeError(`Invalid choice: ${choice}. Must be 1 (ROCK), 2 (SCISSORS), or 3 (PAPER)`);
2993
+ }
2994
+ const buffer = new Uint8Array(1);
2995
+ buffer[0] = choice;
2996
+ return buffer;
2997
+ }
2877
2998
  };
2878
2999
  YGOProMsgRockPaperScissors.identifier = OcgcoreCommonConstants.MSG_ROCK_PAPER_SCISSORS;
2879
3000
  __decorateClass([
@@ -5193,6 +5314,9 @@ var YGOProMsgUpdateCard = class extends YGOProMsgBase {
5193
5314
  result.set(cardPayload, 8);
5194
5315
  return result;
5195
5316
  }
5317
+ getSendTargets() {
5318
+ return [this.controller, 1 - this.controller, 7 /* OBSERVER */];
5319
+ }
5196
5320
  };
5197
5321
  YGOProMsgUpdateCard.identifier = OcgcoreCommonConstants.MSG_UPDATE_CARD;
5198
5322
 
@@ -5296,12 +5420,18 @@ var YGOProMsgUpdateData = class extends YGOProMsgBase {
5296
5420
  }
5297
5421
  return result;
5298
5422
  }
5423
+ getSendTargets() {
5424
+ return [this.player, 1 - this.player, 7 /* OBSERVER */];
5425
+ }
5299
5426
  };
5300
5427
  YGOProMsgUpdateData.identifier = 6;
5301
5428
 
5302
5429
  // src/protos/msg/proto/waiting.ts
5303
5430
  var YGOProMsgWaiting = class extends YGOProMsgBase {
5304
5431
  // MSG_WAITING
5432
+ getSendTargets() {
5433
+ return [];
5434
+ }
5305
5435
  };
5306
5436
  YGOProMsgWaiting.identifier = 3;
5307
5437
 
@@ -5774,80 +5904,6 @@ YGOProStoc.register(YGOProStocHsWatchChange);
5774
5904
  YGOProStoc.register(YGOProStocTeammateSurrender);
5775
5905
  YGOProStoc.register(YGOProStocFieldFinish);
5776
5906
  YGOProStoc.register(YGOProStocSrvproRoomlist);
5777
-
5778
- // src/protos/network-enums.ts
5779
- var HandResult = /* @__PURE__ */ ((HandResult2) => {
5780
- HandResult2[HandResult2["ROCK"] = 1] = "ROCK";
5781
- HandResult2[HandResult2["SCISSORS"] = 2] = "SCISSORS";
5782
- HandResult2[HandResult2["PAPER"] = 3] = "PAPER";
5783
- return HandResult2;
5784
- })(HandResult || {});
5785
- var TurnPlayerResult = /* @__PURE__ */ ((TurnPlayerResult2) => {
5786
- TurnPlayerResult2[TurnPlayerResult2["SECOND"] = 0] = "SECOND";
5787
- TurnPlayerResult2[TurnPlayerResult2["FIRST"] = 1] = "FIRST";
5788
- return TurnPlayerResult2;
5789
- })(TurnPlayerResult || {});
5790
- var NetPlayerType = /* @__PURE__ */ ((NetPlayerType2) => {
5791
- NetPlayerType2[NetPlayerType2["PLAYER1"] = 0] = "PLAYER1";
5792
- NetPlayerType2[NetPlayerType2["PLAYER2"] = 1] = "PLAYER2";
5793
- NetPlayerType2[NetPlayerType2["PLAYER3"] = 2] = "PLAYER3";
5794
- NetPlayerType2[NetPlayerType2["PLAYER4"] = 3] = "PLAYER4";
5795
- NetPlayerType2[NetPlayerType2["PLAYER5"] = 4] = "PLAYER5";
5796
- NetPlayerType2[NetPlayerType2["PLAYER6"] = 5] = "PLAYER6";
5797
- NetPlayerType2[NetPlayerType2["OBSERVER"] = 7] = "OBSERVER";
5798
- return NetPlayerType2;
5799
- })(NetPlayerType || {});
5800
- var ChatColor = /* @__PURE__ */ ((ChatColor2) => {
5801
- ChatColor2[ChatColor2["LIGHTBLUE"] = 8] = "LIGHTBLUE";
5802
- ChatColor2[ChatColor2["RED"] = 11] = "RED";
5803
- ChatColor2[ChatColor2["GREEN"] = 12] = "GREEN";
5804
- ChatColor2[ChatColor2["BLUE"] = 13] = "BLUE";
5805
- ChatColor2[ChatColor2["BABYBLUE"] = 14] = "BABYBLUE";
5806
- ChatColor2[ChatColor2["PINK"] = 15] = "PINK";
5807
- ChatColor2[ChatColor2["YELLOW"] = 16] = "YELLOW";
5808
- ChatColor2[ChatColor2["WHITE"] = 17] = "WHITE";
5809
- ChatColor2[ChatColor2["GRAY"] = 18] = "GRAY";
5810
- ChatColor2[ChatColor2["DARKGRAY"] = 19] = "DARKGRAY";
5811
- return ChatColor2;
5812
- })(ChatColor || {});
5813
- var GameMode = /* @__PURE__ */ ((GameMode2) => {
5814
- GameMode2[GameMode2["SINGLE"] = 0] = "SINGLE";
5815
- GameMode2[GameMode2["MATCH"] = 1] = "MATCH";
5816
- GameMode2[GameMode2["TAG"] = 2] = "TAG";
5817
- return GameMode2;
5818
- })(GameMode || {});
5819
- var ErrorMessageType = /* @__PURE__ */ ((ErrorMessageType2) => {
5820
- ErrorMessageType2[ErrorMessageType2["JOINERROR"] = 1] = "JOINERROR";
5821
- ErrorMessageType2[ErrorMessageType2["DECKERROR"] = 2] = "DECKERROR";
5822
- ErrorMessageType2[ErrorMessageType2["SIDEERROR"] = 3] = "SIDEERROR";
5823
- ErrorMessageType2[ErrorMessageType2["VERERROR"] = 4] = "VERERROR";
5824
- return ErrorMessageType2;
5825
- })(ErrorMessageType || {});
5826
- var DeckErrorType = /* @__PURE__ */ ((DeckErrorType2) => {
5827
- DeckErrorType2[DeckErrorType2["LFLIST"] = 1] = "LFLIST";
5828
- DeckErrorType2[DeckErrorType2["OCGONLY"] = 2] = "OCGONLY";
5829
- DeckErrorType2[DeckErrorType2["TCGONLY"] = 3] = "TCGONLY";
5830
- DeckErrorType2[DeckErrorType2["UNKNOWNCARD"] = 4] = "UNKNOWNCARD";
5831
- DeckErrorType2[DeckErrorType2["CARDCOUNT"] = 5] = "CARDCOUNT";
5832
- DeckErrorType2[DeckErrorType2["MAINCOUNT"] = 6] = "MAINCOUNT";
5833
- DeckErrorType2[DeckErrorType2["EXTRACOUNT"] = 7] = "EXTRACOUNT";
5834
- DeckErrorType2[DeckErrorType2["SIDECOUNT"] = 8] = "SIDECOUNT";
5835
- DeckErrorType2[DeckErrorType2["NOTAVAIL"] = 9] = "NOTAVAIL";
5836
- return DeckErrorType2;
5837
- })(DeckErrorType || {});
5838
- var PlayerChangeState = /* @__PURE__ */ ((PlayerChangeState2) => {
5839
- PlayerChangeState2[PlayerChangeState2["OBSERVE"] = 8] = "OBSERVE";
5840
- PlayerChangeState2[PlayerChangeState2["READY"] = 9] = "READY";
5841
- PlayerChangeState2[PlayerChangeState2["NOTREADY"] = 10] = "NOTREADY";
5842
- PlayerChangeState2[PlayerChangeState2["LEAVE"] = 11] = "LEAVE";
5843
- return PlayerChangeState2;
5844
- })(PlayerChangeState || {});
5845
- var RoomStatus = /* @__PURE__ */ ((RoomStatus2) => {
5846
- RoomStatus2[RoomStatus2["WAITING"] = 0] = "WAITING";
5847
- RoomStatus2[RoomStatus2["DUELING"] = 1] = "DUELING";
5848
- RoomStatus2[RoomStatus2["SIDING"] = 2] = "SIDING";
5849
- return RoomStatus2;
5850
- })(RoomStatus || {});
5851
5907
  // Annotate the CommonJS export names for ESM import in node:
5852
5908
  0 && (module.exports = {
5853
5909
  BattleCmdType,
@@ -5869,6 +5925,8 @@ var RoomStatus = /* @__PURE__ */ ((RoomStatus2) => {
5869
5925
  OcgcoreScriptConstants,
5870
5926
  PlayerChangeState,
5871
5927
  RoomStatus,
5928
+ SEND_TO_ALL,
5929
+ SEND_TO_PLAYERS,
5872
5930
  SrvproRoomInfo,
5873
5931
  TurnPlayerResult,
5874
5932
  YGOProCtos,