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.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,2113 +1147,1532 @@ __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;
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;
1253
+ }
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;
1265
+ }
1266
+ }
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;
1622
1290
  }
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;
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);
1325
+ let offset = 0;
1326
+ view.setInt32(offset, this.flags, true);
1327
+ offset += 4;
1328
+ if (this.empty || this.flags === 0) {
1329
+ return result;
1330
+ }
1331
+ if (flags & OcgcoreCommonConstants.QUERY_CODE) {
1332
+ view.setInt32(offset, this.code || 0, true);
1333
+ offset += 4;
1334
+ }
1335
+ if (flags & OcgcoreCommonConstants.QUERY_POSITION) {
1336
+ const pdata = (this.position || 0) << 24 >>> 0;
1337
+ view.setInt32(offset, pdata, true);
1338
+ offset += 4;
1339
+ }
1340
+ if (flags & OcgcoreCommonConstants.QUERY_ALIAS) {
1341
+ view.setInt32(offset, this.alias || 0, true);
1342
+ offset += 4;
1343
+ }
1344
+ if (flags & OcgcoreCommonConstants.QUERY_TYPE) {
1345
+ view.setInt32(offset, this.type || 0, true);
1346
+ offset += 4;
1347
+ }
1348
+ if (flags & OcgcoreCommonConstants.QUERY_LEVEL) {
1349
+ view.setInt32(offset, this.level || 0, true);
1350
+ offset += 4;
1351
+ }
1352
+ if (flags & OcgcoreCommonConstants.QUERY_RANK) {
1353
+ view.setInt32(offset, this.rank || 0, true);
1354
+ offset += 4;
1355
+ }
1356
+ if (flags & OcgcoreCommonConstants.QUERY_ATTRIBUTE) {
1357
+ view.setInt32(offset, this.attribute || 0, true);
1358
+ offset += 4;
1359
+ }
1360
+ if (flags & OcgcoreCommonConstants.QUERY_RACE) {
1361
+ view.setInt32(offset, this.race || 0, true);
1362
+ offset += 4;
1363
+ }
1364
+ if (flags & OcgcoreCommonConstants.QUERY_ATTACK) {
1365
+ view.setInt32(offset, this.attack || 0, true);
1366
+ offset += 4;
1367
+ }
1368
+ if (flags & OcgcoreCommonConstants.QUERY_DEFENSE) {
1369
+ view.setInt32(offset, this.defense || 0, true);
1370
+ offset += 4;
1371
+ }
1372
+ if (flags & OcgcoreCommonConstants.QUERY_BASE_ATTACK) {
1373
+ view.setInt32(offset, this.baseAttack || 0, true);
1374
+ offset += 4;
1375
+ }
1376
+ if (flags & OcgcoreCommonConstants.QUERY_BASE_DEFENSE) {
1377
+ view.setInt32(offset, this.baseDefense || 0, true);
1378
+ offset += 4;
1379
+ }
1380
+ if (flags & OcgcoreCommonConstants.QUERY_REASON) {
1381
+ view.setInt32(offset, this.reason || 0, true);
1382
+ offset += 4;
1383
+ }
1384
+ if (flags & OcgcoreCommonConstants.QUERY_REASON_CARD) {
1385
+ view.setInt32(offset, 0, true);
1386
+ offset += 4;
1387
+ }
1388
+ if (flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) {
1389
+ const card = this.equipCard || {
1390
+ controller: 0,
1391
+ location: 0,
1392
+ sequence: 0
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);
1398
+ offset += 4;
1399
+ }
1400
+ if (flags & OcgcoreCommonConstants.QUERY_TARGET_CARD) {
1401
+ const targets = this.targetCards || [];
1402
+ view.setInt32(offset, targets.length, true);
1403
+ offset += 4;
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);
1409
+ offset += 4;
1410
+ }
1411
+ }
1412
+ if (flags & OcgcoreCommonConstants.QUERY_OVERLAY_CARD) {
1413
+ const overlays = this.overlayCards || [];
1414
+ view.setInt32(offset, overlays.length, true);
1415
+ offset += 4;
1416
+ for (const card of overlays) {
1417
+ view.setInt32(offset, card, true);
1418
+ offset += 4;
1419
+ }
1420
+ }
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);
1428
+ offset += 4;
1429
+ }
1430
+ }
1431
+ if (flags & OcgcoreCommonConstants.QUERY_OWNER) {
1432
+ view.setInt32(offset, this.owner || 0, true);
1433
+ offset += 4;
1434
+ }
1435
+ if (flags & OcgcoreCommonConstants.QUERY_STATUS) {
1436
+ view.setInt32(offset, this.status || 0, true);
1437
+ offset += 4;
1438
+ }
1439
+ if (flags & OcgcoreCommonConstants.QUERY_LSCALE) {
1440
+ view.setInt32(offset, this.lscale || 0, true);
1441
+ offset += 4;
1442
+ }
1443
+ if (flags & OcgcoreCommonConstants.QUERY_RSCALE) {
1444
+ view.setInt32(offset, this.rscale || 0, true);
1445
+ offset += 4;
1446
+ }
1447
+ if (flags & OcgcoreCommonConstants.QUERY_LINK) {
1448
+ view.setInt32(offset, this.link || 0, true);
1449
+ offset += 4;
1450
+ view.setInt32(offset, this.linkMarker || 0, true);
1451
+ offset += 4;
1452
+ }
1453
+ return new Uint8Array(view.buffer, view.byteOffset, offset);
1628
1454
  }
1629
1455
  };
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
1456
 
1641
- // src/protos/msg/proto/announce-card.ts
1642
- var YGOProMsgAnnounceCard = class extends YGOProMsgResponseBase {
1643
- responsePlayer() {
1644
- return this.player;
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;
1645
1473
  }
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;
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
+ );
1486
+ }
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
+ );
1493
+ }
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
+ );
1499
+ }
1500
+ const bodyData = data.length > expectedTotalLength ? data.slice(3, expectedTotalLength) : data.slice(3);
1501
+ return this.fromPayload(bodyData);
1651
1502
  }
1652
1503
  };
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
1504
 
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;
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;
1524
+ }
1525
+ return new proto().fromPayload(
1526
+ data.slice(this.options.dataOffset ?? 0)
1527
+ );
1528
+ }
1672
1529
  };
1673
1530
 
1674
- // src/protos/msg/proto/announce-number.ts
1675
- var YGOProMsgAnnounceNumber = class extends YGOProMsgResponseBase {
1676
- responsePlayer() {
1677
- return this.player;
1531
+ // src/protos/ctos/proto/response.ts
1532
+ var YGOProCtosResponse = class extends YGOProCtosBase {
1533
+ fromPayload(data) {
1534
+ this.response = data;
1535
+ return this;
1678
1536
  }
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}`);
1685
- }
1686
- } else {
1687
- index = this.numbers.indexOf(option);
1688
- if (index === -1) {
1689
- throw new TypeError(`Number not found: ${option}`);
1690
- }
1691
- }
1692
- const buffer = new Uint8Array(4);
1693
- const view = new DataView(buffer.buffer);
1694
- view.setInt32(0, index, true);
1695
- return buffer;
1537
+ toPayload() {
1538
+ return this.response || new Uint8Array(0);
1696
1539
  }
1697
1540
  };
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);
1541
+ YGOProCtosResponse.identifier = 1;
1708
1542
 
1709
- // src/protos/msg/proto/announce-race.ts
1710
- var YGOProMsgAnnounceRace = class extends YGOProMsgResponseBase {
1711
- responsePlayer() {
1712
- return this.player;
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();
1713
1549
  }
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;
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);
1560
+ }
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;
1719
1567
  }
1720
1568
  };
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);
1569
+ YGOProCtosUpdateDeck.identifier = 2;
1731
1570
 
1732
- // src/protos/msg/proto/attack.ts
1733
- var YGOProMsgAttack_CardLocation = class {
1571
+ // src/protos/ctos/proto/hand-result.ts
1572
+ var YGOProCtosHandResult = class extends YGOProCtosBase {
1734
1573
  };
1574
+ YGOProCtosHandResult.identifier = 3;
1735
1575
  __decorateClass([
1736
1576
  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 {
1577
+ ], YGOProCtosHandResult.prototype, "res", 2);
1578
+
1579
+ // src/protos/ctos/proto/tp-result.ts
1580
+ var YGOProCtosTpResult = class extends YGOProCtosBase {
1748
1581
  };
1749
- YGOProMsgAttack.identifier = OcgcoreCommonConstants.MSG_ATTACK;
1750
- __decorateClass([
1751
- BinaryField(() => YGOProMsgAttack_CardLocation, 0)
1752
- ], YGOProMsgAttack.prototype, "attacker", 2);
1582
+ YGOProCtosTpResult.identifier = 4;
1753
1583
  __decorateClass([
1754
- BinaryField(() => YGOProMsgAttack_CardLocation, 4)
1755
- ], YGOProMsgAttack.prototype, "defender", 2);
1584
+ BinaryField("u8", 0)
1585
+ ], YGOProCtosTpResult.prototype, "res", 2);
1756
1586
 
1757
- // src/protos/msg/proto/attack-disabled.ts
1758
- var YGOProMsgAttackDisabled = class extends YGOProMsgBase {
1587
+ // src/protos/ctos/proto/player-info.ts
1588
+ var YGOProCtosPlayerInfo = class extends YGOProCtosBase {
1759
1589
  };
1760
- YGOProMsgAttackDisabled.identifier = OcgcoreCommonConstants.MSG_ATTACK_DISABLED;
1590
+ YGOProCtosPlayerInfo.identifier = 16;
1591
+ __decorateClass([
1592
+ BinaryField("utf16", 0, 20)
1593
+ ], YGOProCtosPlayerInfo.prototype, "name", 2);
1761
1594
 
1762
- // src/protos/msg/proto/battle.ts
1763
- var YGOProMsgBattle_CardLocation = class {
1595
+ // src/protos/ctos/proto/create-game.ts
1596
+ var YGOProCtosCreateGame = class extends YGOProCtosBase {
1764
1597
  };
1598
+ YGOProCtosCreateGame.identifier = 17;
1765
1599
  __decorateClass([
1766
- BinaryField("u8", 0)
1767
- ], YGOProMsgBattle_CardLocation.prototype, "controller", 2);
1768
- __decorateClass([
1769
- BinaryField("u8", 1)
1770
- ], YGOProMsgBattle_CardLocation.prototype, "location", 2);
1600
+ BinaryField(() => HostInfo, 0)
1601
+ ], YGOProCtosCreateGame.prototype, "info", 2);
1771
1602
  __decorateClass([
1772
- BinaryField("u8", 2)
1773
- ], YGOProMsgBattle_CardLocation.prototype, "sequence", 2);
1603
+ BinaryField("utf16", 20, 20)
1604
+ ], YGOProCtosCreateGame.prototype, "name", 2);
1774
1605
  __decorateClass([
1775
- BinaryField("u8", 3)
1776
- ], YGOProMsgBattle_CardLocation.prototype, "position", 2);
1777
- var YGOProMsgBattle_CardStats = class {
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 {
1778
1611
  };
1612
+ YGOProCtosJoinGame.identifier = 18;
1779
1613
  __decorateClass([
1780
- BinaryField(() => YGOProMsgBattle_CardLocation, 0)
1781
- ], YGOProMsgBattle_CardStats.prototype, "location", 2);
1614
+ BinaryField("u16", 0)
1615
+ ], YGOProCtosJoinGame.prototype, "version", 2);
1782
1616
  __decorateClass([
1783
- BinaryField("i32", 4)
1784
- ], YGOProMsgBattle_CardStats.prototype, "atk", 2);
1617
+ BinaryField("u32", 4)
1618
+ ], YGOProCtosJoinGame.prototype, "gameid", 2);
1785
1619
  __decorateClass([
1786
- BinaryField("i32", 8)
1787
- ], YGOProMsgBattle_CardStats.prototype, "def", 2);
1788
- var YGOProMsgBattle = class extends YGOProMsgBase {
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 {
1789
1625
  };
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);
1626
+ YGOProCtosLeaveGame.identifier = 19;
1800
1627
 
1801
- // src/protos/msg/proto/become-target.ts
1802
- var YGOProMsgBecomeTarget = class extends YGOProMsgBase {
1628
+ // src/protos/ctos/proto/surrender.ts
1629
+ var YGOProCtosSurrender = class extends YGOProCtosBase {
1803
1630
  };
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);
1631
+ YGOProCtosSurrender.identifier = 20;
1811
1632
 
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 {
1633
+ // src/protos/ctos/proto/time-confirm.ts
1634
+ var YGOProCtosTimeConfirm = class extends YGOProCtosBase {
1836
1635
  };
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);
1636
+ YGOProCtosTimeConfirm.identifier = 21;
1856
1637
 
1857
- // src/protos/msg/proto/card-query.ts
1858
- var CardQuery_CardLocation = class {
1859
- };
1860
- var CardQuery_Counter = class {
1861
- };
1862
- var CardQuery = class {
1638
+ // src/protos/ctos/proto/chat.ts
1639
+ var YGOProCtosChat = class extends YGOProCtosBase {
1863
1640
  constructor() {
1864
- this.flags = 0;
1641
+ super();
1642
+ this.msg = "";
1865
1643
  }
1866
1644
  fromPayload(data) {
1867
- const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
1868
- let offset = 0;
1869
- this.flags = view.getInt32(offset, true) >>> 0;
1870
- offset += 4;
1871
- if (this.flags === 0) {
1872
- this.empty = true;
1873
- return this;
1874
- }
1875
- this.empty = false;
1876
- if (this.flags & OcgcoreCommonConstants.QUERY_CODE) {
1877
- this.code = view.getInt32(offset, true);
1878
- offset += 4;
1879
- }
1880
- if (this.flags & OcgcoreCommonConstants.QUERY_POSITION) {
1881
- const pdata = view.getInt32(offset, true);
1882
- this.position = (pdata >>> 24 & 255) >>> 0;
1883
- offset += 4;
1884
- }
1885
- if (this.flags & OcgcoreCommonConstants.QUERY_ALIAS) {
1886
- this.alias = view.getInt32(offset, true);
1887
- offset += 4;
1888
- }
1889
- if (this.flags & OcgcoreCommonConstants.QUERY_TYPE) {
1890
- this.type = view.getInt32(offset, true);
1891
- offset += 4;
1892
- }
1893
- if (this.flags & OcgcoreCommonConstants.QUERY_LEVEL) {
1894
- this.level = view.getInt32(offset, true);
1895
- offset += 4;
1896
- }
1897
- if (this.flags & OcgcoreCommonConstants.QUERY_RANK) {
1898
- this.rank = view.getInt32(offset, true);
1899
- offset += 4;
1900
- }
1901
- if (this.flags & OcgcoreCommonConstants.QUERY_ATTRIBUTE) {
1902
- this.attribute = view.getInt32(offset, true);
1903
- offset += 4;
1904
- }
1905
- if (this.flags & OcgcoreCommonConstants.QUERY_RACE) {
1906
- this.race = view.getInt32(offset, true);
1907
- offset += 4;
1908
- }
1909
- if (this.flags & OcgcoreCommonConstants.QUERY_ATTACK) {
1910
- this.attack = view.getInt32(offset, true);
1911
- offset += 4;
1912
- }
1913
- if (this.flags & OcgcoreCommonConstants.QUERY_DEFENSE) {
1914
- this.defense = view.getInt32(offset, true);
1915
- offset += 4;
1916
- }
1917
- if (this.flags & OcgcoreCommonConstants.QUERY_BASE_ATTACK) {
1918
- this.baseAttack = view.getInt32(offset, true);
1919
- offset += 4;
1920
- }
1921
- if (this.flags & OcgcoreCommonConstants.QUERY_BASE_DEFENSE) {
1922
- this.baseDefense = view.getInt32(offset, true);
1923
- offset += 4;
1924
- }
1925
- if (this.flags & OcgcoreCommonConstants.QUERY_REASON) {
1926
- this.reason = view.getInt32(offset, true);
1927
- offset += 4;
1928
- }
1929
- if (this.flags & OcgcoreCommonConstants.QUERY_REASON_CARD) {
1930
- offset += 4;
1931
- }
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)
1937
- };
1938
- offset += 4;
1939
- }
1940
- if (this.flags & OcgcoreCommonConstants.QUERY_TARGET_CARD) {
1941
- const count = view.getInt32(offset, true);
1942
- 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
- });
1950
- offset += 4;
1951
- }
1952
- }
1953
- if (this.flags & OcgcoreCommonConstants.QUERY_OVERLAY_CARD) {
1954
- const count = view.getInt32(offset, true);
1955
- offset += 4;
1956
- this.overlayCards = [];
1957
- for (let i = 0; i < count; i++) {
1958
- this.overlayCards.push(view.getInt32(offset, true));
1959
- offset += 4;
1960
- }
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);
1961
1657
  }
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
- });
1971
- offset += 4;
1972
- }
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;
1973
1665
  }
1974
- if (this.flags & OcgcoreCommonConstants.QUERY_OWNER) {
1975
- this.owner = view.getInt32(offset, true);
1976
- 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);
1977
1683
  }
1978
- if (this.flags & OcgcoreCommonConstants.QUERY_STATUS) {
1979
- this.status = view.getInt32(offset, true);
1980
- offset += 4;
1684
+ const parts = ipv4.split(".");
1685
+ if (parts.length !== 4) {
1686
+ return 0;
1981
1687
  }
1982
- if (this.flags & OcgcoreCommonConstants.QUERY_LSCALE) {
1983
- this.lscale = view.getInt32(offset, true);
1984
- 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;
1985
1691
  }
1986
- if (this.flags & OcgcoreCommonConstants.QUERY_RSCALE) {
1987
- this.rscale = view.getInt32(offset, true);
1988
- 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");
1989
1705
  }
1990
- if (this.flags & OcgcoreCommonConstants.QUERY_LINK) {
1991
- this.link = view.getInt32(offset, true);
1992
- offset += 4;
1993
- this.linkMarker = view.getInt32(offset, true);
1994
- 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 = "";
1995
1713
  }
1996
1714
  return this;
1997
1715
  }
1998
1716
  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;
2046
- }
2047
- if (flags & OcgcoreCommonConstants.QUERY_ALIAS) {
2048
- view.setInt32(offset, this.alias || 0, true);
2049
- offset += 4;
2050
- }
2051
- if (flags & OcgcoreCommonConstants.QUERY_TYPE) {
2052
- view.setInt32(offset, this.type || 0, true);
2053
- offset += 4;
2054
- }
2055
- if (flags & OcgcoreCommonConstants.QUERY_LEVEL) {
2056
- view.setInt32(offset, this.level || 0, true);
2057
- offset += 4;
2058
- }
2059
- if (flags & OcgcoreCommonConstants.QUERY_RANK) {
2060
- view.setInt32(offset, this.rank || 0, true);
2061
- offset += 4;
2062
- }
2063
- if (flags & OcgcoreCommonConstants.QUERY_ATTRIBUTE) {
2064
- view.setInt32(offset, this.attribute || 0, true);
2065
- offset += 4;
2066
- }
2067
- if (flags & OcgcoreCommonConstants.QUERY_RACE) {
2068
- view.setInt32(offset, this.race || 0, true);
2069
- offset += 4;
2070
- }
2071
- if (flags & OcgcoreCommonConstants.QUERY_ATTACK) {
2072
- view.setInt32(offset, this.attack || 0, true);
2073
- offset += 4;
2074
- }
2075
- if (flags & OcgcoreCommonConstants.QUERY_DEFENSE) {
2076
- view.setInt32(offset, this.defense || 0, true);
2077
- offset += 4;
2078
- }
2079
- if (flags & OcgcoreCommonConstants.QUERY_BASE_ATTACK) {
2080
- view.setInt32(offset, this.baseAttack || 0, true);
2081
- offset += 4;
2082
- }
2083
- if (flags & OcgcoreCommonConstants.QUERY_BASE_DEFENSE) {
2084
- view.setInt32(offset, this.baseDefense || 0, true);
2085
- offset += 4;
2086
- }
2087
- if (flags & OcgcoreCommonConstants.QUERY_REASON) {
2088
- view.setInt32(offset, this.reason || 0, true);
2089
- offset += 4;
2090
- }
2091
- if (flags & OcgcoreCommonConstants.QUERY_REASON_CARD) {
2092
- view.setInt32(offset, 0, true);
2093
- offset += 4;
2094
- }
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;
2106
- }
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
- }
2118
- }
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
- }
2127
- }
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
- }
2137
- }
2138
- if (flags & OcgcoreCommonConstants.QUERY_OWNER) {
2139
- view.setInt32(offset, this.owner || 0, true);
2140
- offset += 4;
2141
- }
2142
- if (flags & OcgcoreCommonConstants.QUERY_STATUS) {
2143
- view.setInt32(offset, this.status || 0, true);
2144
- offset += 4;
2145
- }
2146
- if (flags & OcgcoreCommonConstants.QUERY_LSCALE) {
2147
- view.setInt32(offset, this.lscale || 0, true);
2148
- offset += 4;
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);
2149
1724
  }
2150
- if (flags & OcgcoreCommonConstants.QUERY_RSCALE) {
2151
- view.setInt32(offset, this.rscale || 0, true);
2152
- 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;
2153
1738
  }
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;
1739
+ if (data.hostname !== void 0) {
1740
+ this.hostname = data.hostname;
2159
1741
  }
2160
- return new Uint8Array(view.buffer, view.byteOffset, offset);
1742
+ return this;
2161
1743
  }
2162
1744
  };
1745
+ YGOProCtosExternalAddress.identifier = 23;
2163
1746
 
2164
- // src/protos/msg/proto/card-target.ts
2165
- var YGOProMsgCardTarget_CardLocation = class {
2166
- };
2167
- __decorateClass([
2168
- BinaryField("u8", 0)
2169
- ], YGOProMsgCardTarget_CardLocation.prototype, "controller", 2);
2170
- __decorateClass([
2171
- BinaryField("u8", 1)
2172
- ], YGOProMsgCardTarget_CardLocation.prototype, "location", 2);
2173
- __decorateClass([
2174
- BinaryField("u8", 2)
2175
- ], YGOProMsgCardTarget_CardLocation.prototype, "sequence", 2);
2176
- var YGOProMsgCardTarget = class extends YGOProMsgBase {
1747
+ // src/protos/ctos/proto/hs-toduelist.ts
1748
+ var YGOProCtosHsToDuelist = class extends YGOProCtosBase {
2177
1749
  };
2178
- YGOProMsgCardTarget.identifier = OcgcoreCommonConstants.MSG_CARD_TARGET;
2179
- __decorateClass([
2180
- BinaryField(() => YGOProMsgCardTarget_CardLocation, 0)
2181
- ], YGOProMsgCardTarget.prototype, "card1", 2);
2182
- __decorateClass([
2183
- BinaryField(() => YGOProMsgCardTarget_CardLocation, 3)
2184
- ], YGOProMsgCardTarget.prototype, "card2", 2);
1750
+ YGOProCtosHsToDuelist.identifier = 32;
2185
1751
 
2186
- // src/protos/msg/proto/chain-disabled.ts
2187
- var YGOProMsgChainDisabled = class extends YGOProMsgBase {
1752
+ // src/protos/ctos/proto/hs-toobserver.ts
1753
+ var YGOProCtosHsToObserver = class extends YGOProCtosBase {
2188
1754
  };
2189
- YGOProMsgChainDisabled.identifier = OcgcoreCommonConstants.MSG_CHAIN_DISABLED;
2190
- __decorateClass([
2191
- BinaryField("u8", 0)
2192
- ], YGOProMsgChainDisabled.prototype, "chainCount", 2);
1755
+ YGOProCtosHsToObserver.identifier = 33;
2193
1756
 
2194
- // src/protos/msg/proto/chain-end.ts
2195
- var YGOProMsgChainEnd = class extends YGOProMsgBase {
1757
+ // src/protos/ctos/proto/hs-ready.ts
1758
+ var YGOProCtosHsReady = class extends YGOProCtosBase {
2196
1759
  };
2197
- YGOProMsgChainEnd.identifier = OcgcoreCommonConstants.MSG_CHAIN_END;
1760
+ YGOProCtosHsReady.identifier = 34;
2198
1761
 
2199
- // src/protos/msg/proto/chain-negated.ts
2200
- var YGOProMsgChainNegated = class extends YGOProMsgBase {
1762
+ // src/protos/ctos/proto/hs-notready.ts
1763
+ var YGOProCtosHsNotReady = class extends YGOProCtosBase {
2201
1764
  };
2202
- YGOProMsgChainNegated.identifier = OcgcoreCommonConstants.MSG_CHAIN_NEGATED;
2203
- __decorateClass([
2204
- BinaryField("u8", 0)
2205
- ], YGOProMsgChainNegated.prototype, "chainCount", 2);
1765
+ YGOProCtosHsNotReady.identifier = 35;
2206
1766
 
2207
- // src/protos/msg/proto/chain-solved.ts
2208
- var YGOProMsgChainSolved = class extends YGOProMsgBase {
1767
+ // src/protos/ctos/proto/kick.ts
1768
+ var YGOProCtosKick = class extends YGOProCtosBase {
2209
1769
  };
2210
- YGOProMsgChainSolved.identifier = OcgcoreCommonConstants.MSG_CHAIN_SOLVED;
1770
+ YGOProCtosKick.identifier = 36;
2211
1771
  __decorateClass([
2212
1772
  BinaryField("u8", 0)
2213
- ], YGOProMsgChainSolved.prototype, "chainCount", 2);
1773
+ ], YGOProCtosKick.prototype, "pos", 2);
2214
1774
 
2215
- // src/protos/msg/proto/chain-solving.ts
2216
- var YGOProMsgChainSolving = class extends YGOProMsgBase {
1775
+ // src/protos/ctos/proto/hs-start.ts
1776
+ var YGOProCtosHsStart = class extends YGOProCtosBase {
2217
1777
  };
2218
- YGOProMsgChainSolving.identifier = OcgcoreCommonConstants.MSG_CHAIN_SOLVING;
2219
- __decorateClass([
2220
- BinaryField("u8", 0)
2221
- ], YGOProMsgChainSolving.prototype, "chainCount", 2);
1778
+ YGOProCtosHsStart.identifier = 37;
2222
1779
 
2223
- // src/protos/msg/proto/chained.ts
2224
- var YGOProMsgChained = class extends YGOProMsgBase {
1780
+ // src/protos/ctos/proto/request-field.ts
1781
+ var YGOProCtosRequestField = class extends YGOProCtosBase {
2225
1782
  };
2226
- YGOProMsgChained.identifier = OcgcoreCommonConstants.MSG_CHAINED;
2227
- __decorateClass([
2228
- BinaryField("u8", 0)
2229
- ], YGOProMsgChained.prototype, "chainCount", 2);
1783
+ YGOProCtosRequestField.identifier = 48;
2230
1784
 
2231
- // src/protos/msg/proto/chaining.ts
2232
- var YGOProMsgChaining = class extends YGOProMsgBase {
2233
- };
2234
- YGOProMsgChaining.identifier = OcgcoreCommonConstants.MSG_CHAINING;
2235
- __decorateClass([
2236
- BinaryField("i32", 0)
2237
- ], YGOProMsgChaining.prototype, "code", 2);
2238
- __decorateClass([
2239
- BinaryField("u8", 4)
2240
- ], YGOProMsgChaining.prototype, "controller", 2);
2241
- __decorateClass([
2242
- BinaryField("u8", 5)
2243
- ], YGOProMsgChaining.prototype, "location", 2);
2244
- __decorateClass([
2245
- BinaryField("u8", 6)
2246
- ], YGOProMsgChaining.prototype, "sequence", 2);
2247
- __decorateClass([
2248
- BinaryField("u8", 7)
2249
- ], YGOProMsgChaining.prototype, "subsequence", 2);
2250
- __decorateClass([
2251
- BinaryField("u8", 8)
2252
- ], YGOProMsgChaining.prototype, "chainCount", 2);
2253
- __decorateClass([
2254
- BinaryField("i32", 9)
2255
- ], YGOProMsgChaining.prototype, "desc", 2);
2256
- __decorateClass([
2257
- BinaryField("u8", 13)
2258
- ], YGOProMsgChaining.prototype, "chainPlayer", 2);
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);
2259
1809
 
2260
- // src/protos/msg/proto/confirm-cards.ts
2261
- var YGOProMsgConfirmCards_CardInfo = class {
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
+ );
1839
+ }
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
+ );
1846
+ }
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
+ );
1852
+ }
1853
+ const bodyData = data.length > expectedTotalLength ? data.slice(3, expectedTotalLength) : data.slice(3);
1854
+ return this.fromPayload(bodyData);
1855
+ }
2262
1856
  };
2263
- __decorateClass([
2264
- BinaryField("i32", 0)
2265
- ], YGOProMsgConfirmCards_CardInfo.prototype, "code", 2);
2266
- __decorateClass([
2267
- BinaryField("u8", 4)
2268
- ], YGOProMsgConfirmCards_CardInfo.prototype, "controller", 2);
2269
- __decorateClass([
2270
- BinaryField("u8", 5)
2271
- ], YGOProMsgConfirmCards_CardInfo.prototype, "location", 2);
2272
- __decorateClass([
2273
- BinaryField("u8", 6)
2274
- ], YGOProMsgConfirmCards_CardInfo.prototype, "sequence", 2);
2275
- __decorateClass([
2276
- BinaryField("u8", 7)
2277
- ], YGOProMsgConfirmCards_CardInfo.prototype, "subsequence", 2);
2278
- var YGOProMsgConfirmCards = class extends YGOProMsgBase {
2279
- // 对方视角可能需要隐藏卡片信息
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");
1939
+ }
1940
+ const msgType = data[0];
1941
+ if (msgType !== this.identifier) {
1942
+ throw new Error(
1943
+ `MSG type mismatch: expected ${this.identifier}, got ${msgType}`
1944
+ );
1945
+ }
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
+ }
2280
1955
  opponentView() {
2281
- const view = this.copy();
2282
- view.cards = view.cards.map((card) => {
2283
- const c = { ...card };
2284
- if (!(c.code & 2147483648)) {
2285
- c.code = 0;
1956
+ return this.copy();
1957
+ }
1958
+ teammateView() {
1959
+ return this.copy();
1960
+ }
1961
+ observerView() {
1962
+ return this.opponentView();
1963
+ }
1964
+ playerView(playerId) {
1965
+ if (playerId === 7 /* OBSERVER */) {
1966
+ return this.observerView();
1967
+ }
1968
+ if (typeof this["player"] === "number") {
1969
+ const selfPlayerId = this["player"];
1970
+ if (selfPlayerId === playerId) {
1971
+ return this.copy();
2286
1972
  }
2287
- return c;
2288
- });
2289
- return view;
1973
+ return this.opponentView();
1974
+ }
1975
+ return this.copy();
1976
+ }
1977
+ getSendTargets() {
1978
+ return SEND_TO_ALL;
2290
1979
  }
2291
1980
  };
2292
- YGOProMsgConfirmCards.identifier = OcgcoreCommonConstants.MSG_CONFIRM_CARDS;
2293
- __decorateClass([
2294
- BinaryField("u8", 0)
2295
- ], YGOProMsgConfirmCards.prototype, "player", 2);
1981
+
1982
+ // src/protos/msg/proto/add-counter.ts
1983
+ var YGOProMsgAddCounter = class extends YGOProMsgBase {
1984
+ };
1985
+ YGOProMsgAddCounter.identifier = OcgcoreCommonConstants.MSG_ADD_COUNTER;
2296
1986
  __decorateClass([
2297
- BinaryField("u8", 1)
2298
- ], YGOProMsgConfirmCards.prototype, "unused", 2);
1987
+ BinaryField("u16", 0)
1988
+ ], YGOProMsgAddCounter.prototype, "counterType", 2);
2299
1989
  __decorateClass([
2300
1990
  BinaryField("u8", 2)
2301
- ], YGOProMsgConfirmCards.prototype, "count", 2);
2302
- __decorateClass([
2303
- BinaryField(() => YGOProMsgConfirmCards_CardInfo, 3, (obj) => obj.count)
2304
- ], YGOProMsgConfirmCards.prototype, "cards", 2);
2305
-
2306
- // src/protos/msg/proto/confirm-decktop.ts
2307
- var YGOProMsgConfirmDeckTop_CardInfo = class {
2308
- };
1991
+ ], YGOProMsgAddCounter.prototype, "controller", 2);
2309
1992
  __decorateClass([
2310
- BinaryField("i32", 0)
2311
- ], YGOProMsgConfirmDeckTop_CardInfo.prototype, "code", 2);
1993
+ BinaryField("u8", 3)
1994
+ ], YGOProMsgAddCounter.prototype, "location", 2);
2312
1995
  __decorateClass([
2313
1996
  BinaryField("u8", 4)
2314
- ], YGOProMsgConfirmDeckTop_CardInfo.prototype, "controller", 2);
2315
- __decorateClass([
2316
- BinaryField("u8", 5)
2317
- ], YGOProMsgConfirmDeckTop_CardInfo.prototype, "location", 2);
1997
+ ], YGOProMsgAddCounter.prototype, "sequence", 2);
2318
1998
  __decorateClass([
2319
- BinaryField("u8", 6)
2320
- ], YGOProMsgConfirmDeckTop_CardInfo.prototype, "sequence", 2);
2321
- var YGOProMsgConfirmDeckTop = class extends YGOProMsgBase {
2322
- // 对方视角可能需要隐藏卡片信息
2323
- opponentView() {
2324
- const view = this.copy();
2325
- view.cards = view.cards.map((card) => {
2326
- const c = { ...card };
2327
- if (!(c.code & 2147483648)) {
2328
- c.code = 0;
2329
- }
2330
- return c;
2331
- });
2332
- return view;
1999
+ BinaryField("u16", 5)
2000
+ ], YGOProMsgAddCounter.prototype, "count", 2);
2001
+
2002
+ // src/protos/msg/with-response-base.ts
2003
+ var YGOProMsgResponseBase = class extends YGOProMsgBase {
2004
+ defaultResponse() {
2005
+ return void 0;
2006
+ }
2007
+ getSendTargets() {
2008
+ return [this.responsePlayer()];
2333
2009
  }
2334
2010
  };
2335
- YGOProMsgConfirmDeckTop.identifier = OcgcoreCommonConstants.MSG_CONFIRM_DECKTOP;
2336
- __decorateClass([
2337
- BinaryField("u8", 0)
2338
- ], YGOProMsgConfirmDeckTop.prototype, "player", 2);
2339
- __decorateClass([
2340
- BinaryField("u8", 1)
2341
- ], YGOProMsgConfirmDeckTop.prototype, "count", 2);
2342
- __decorateClass([
2343
- BinaryField(() => YGOProMsgConfirmDeckTop_CardInfo, 2, (obj) => obj.count)
2344
- ], YGOProMsgConfirmDeckTop.prototype, "cards", 2);
2345
2011
 
2346
- // src/protos/msg/proto/confirm-extratop.ts
2347
- var YGOProMsgConfirmExtraTop_CardInfo = class {
2348
- };
2349
- __decorateClass([
2350
- BinaryField("i32", 0)
2351
- ], YGOProMsgConfirmExtraTop_CardInfo.prototype, "code", 2);
2352
- __decorateClass([
2353
- BinaryField("u8", 4)
2354
- ], YGOProMsgConfirmExtraTop_CardInfo.prototype, "controller", 2);
2355
- __decorateClass([
2356
- BinaryField("u8", 5)
2357
- ], YGOProMsgConfirmExtraTop_CardInfo.prototype, "location", 2);
2358
- __decorateClass([
2359
- BinaryField("u8", 6)
2360
- ], YGOProMsgConfirmExtraTop_CardInfo.prototype, "sequence", 2);
2361
- var YGOProMsgConfirmExtraTop = class extends YGOProMsgBase {
2362
- // 对方视角可能需要隐藏卡片信息
2363
- opponentView() {
2364
- const view = this.copy();
2365
- view.cards = view.cards.map((card) => {
2366
- const c = { ...card };
2367
- if (!(c.code & 2147483648)) {
2368
- c.code = 0;
2369
- }
2370
- return c;
2371
- });
2372
- return view;
2012
+ // src/protos/msg/proto/announce-attrib.ts
2013
+ var YGOProMsgAnnounceAttrib = class extends YGOProMsgResponseBase {
2014
+ responsePlayer() {
2015
+ return this.player;
2016
+ }
2017
+ prepareResponse(attributes) {
2018
+ const buffer = new Uint8Array(4);
2019
+ const view = new DataView(buffer.buffer);
2020
+ view.setInt32(0, attributes, true);
2021
+ return buffer;
2373
2022
  }
2374
2023
  };
2375
- YGOProMsgConfirmExtraTop.identifier = OcgcoreCommonConstants.MSG_CONFIRM_EXTRATOP;
2024
+ YGOProMsgAnnounceAttrib.identifier = OcgcoreCommonConstants.MSG_ANNOUNCE_ATTRIB;
2376
2025
  __decorateClass([
2377
2026
  BinaryField("u8", 0)
2378
- ], YGOProMsgConfirmExtraTop.prototype, "player", 2);
2027
+ ], YGOProMsgAnnounceAttrib.prototype, "player", 2);
2379
2028
  __decorateClass([
2380
2029
  BinaryField("u8", 1)
2381
- ], YGOProMsgConfirmExtraTop.prototype, "count", 2);
2030
+ ], YGOProMsgAnnounceAttrib.prototype, "count", 2);
2382
2031
  __decorateClass([
2383
- BinaryField(() => YGOProMsgConfirmExtraTop_CardInfo, 2, (obj) => obj.count)
2384
- ], YGOProMsgConfirmExtraTop.prototype, "cards", 2);
2032
+ BinaryField("u32", 2)
2033
+ ], YGOProMsgAnnounceAttrib.prototype, "availableAttributes", 2);
2385
2034
 
2386
- // src/protos/msg/proto/damage.ts
2387
- var YGOProMsgDamage = class extends YGOProMsgBase {
2035
+ // src/protos/msg/proto/announce-card.ts
2036
+ var YGOProMsgAnnounceCard = class extends YGOProMsgResponseBase {
2037
+ responsePlayer() {
2038
+ return this.player;
2039
+ }
2040
+ prepareResponse(cardCode) {
2041
+ const buffer = new Uint8Array(4);
2042
+ const view = new DataView(buffer.buffer);
2043
+ view.setInt32(0, cardCode, true);
2044
+ return buffer;
2045
+ }
2388
2046
  };
2389
- YGOProMsgDamage.identifier = OcgcoreCommonConstants.MSG_DAMAGE;
2047
+ YGOProMsgAnnounceCard.identifier = OcgcoreCommonConstants.MSG_ANNOUNCE_CARD;
2390
2048
  __decorateClass([
2391
2049
  BinaryField("u8", 0)
2392
- ], YGOProMsgDamage.prototype, "player", 2);
2050
+ ], YGOProMsgAnnounceCard.prototype, "player", 2);
2393
2051
  __decorateClass([
2394
- BinaryField("i32", 1)
2395
- ], YGOProMsgDamage.prototype, "value", 2);
2396
-
2397
- // src/protos/msg/proto/damage-step-end.ts
2398
- var YGOProMsgDamageStepEnd = class extends YGOProMsgBase {
2399
- };
2400
- YGOProMsgDamageStepEnd.identifier = OcgcoreCommonConstants.MSG_DAMAGE_STEP_END;
2052
+ BinaryField("u8", 1)
2053
+ ], YGOProMsgAnnounceCard.prototype, "count", 2);
2054
+ __decorateClass([
2055
+ BinaryField("i32", 2, (obj) => obj.count)
2056
+ ], YGOProMsgAnnounceCard.prototype, "opcodes", 2);
2401
2057
 
2402
- // src/protos/msg/proto/damage-step-start.ts
2403
- var YGOProMsgDamageStepStart = class extends YGOProMsgBase {
2058
+ // src/protos/msg/index-response.ts
2059
+ var INDEX_RESPONSE_SYMBOL = /* @__PURE__ */ Symbol("IndexResponse");
2060
+ var IndexResponse = (index) => ({
2061
+ [INDEX_RESPONSE_SYMBOL]: true,
2062
+ index
2063
+ });
2064
+ var isIndexResponse = (obj) => {
2065
+ return obj != null && obj[INDEX_RESPONSE_SYMBOL] === true;
2404
2066
  };
2405
- YGOProMsgDamageStepStart.identifier = OcgcoreCommonConstants.MSG_DAMAGE_STEP_START;
2406
2067
 
2407
- // src/protos/msg/proto/deck-top.ts
2408
- var YGOProMsgDeckTop = class extends YGOProMsgBase {
2409
- // 对方视角可能需要隐藏卡片信息
2410
- opponentView() {
2411
- const view = this.copy();
2412
- if (!(view.code & 2147483648)) {
2413
- view.code = 0;
2068
+ // src/protos/msg/proto/announce-number.ts
2069
+ var YGOProMsgAnnounceNumber = class extends YGOProMsgResponseBase {
2070
+ responsePlayer() {
2071
+ return this.player;
2072
+ }
2073
+ prepareResponse(option) {
2074
+ let index;
2075
+ if (isIndexResponse(option)) {
2076
+ index = option.index;
2077
+ if (index < 0 || index >= this.count) {
2078
+ throw new TypeError(`Index out of range: ${index}`);
2079
+ }
2080
+ } else {
2081
+ index = this.numbers.indexOf(option);
2082
+ if (index === -1) {
2083
+ throw new TypeError(`Number not found: ${option}`);
2084
+ }
2414
2085
  }
2415
- return view;
2086
+ const buffer = new Uint8Array(4);
2087
+ const view = new DataView(buffer.buffer);
2088
+ view.setInt32(0, index, true);
2089
+ return buffer;
2416
2090
  }
2417
2091
  };
2418
- YGOProMsgDeckTop.identifier = OcgcoreCommonConstants.MSG_DECK_TOP;
2092
+ YGOProMsgAnnounceNumber.identifier = OcgcoreCommonConstants.MSG_ANNOUNCE_NUMBER;
2419
2093
  __decorateClass([
2420
2094
  BinaryField("u8", 0)
2421
- ], YGOProMsgDeckTop.prototype, "player", 2);
2095
+ ], YGOProMsgAnnounceNumber.prototype, "player", 2);
2422
2096
  __decorateClass([
2423
2097
  BinaryField("u8", 1)
2424
- ], YGOProMsgDeckTop.prototype, "sequence", 2);
2098
+ ], YGOProMsgAnnounceNumber.prototype, "count", 2);
2425
2099
  __decorateClass([
2426
- BinaryField("i32", 2)
2427
- ], YGOProMsgDeckTop.prototype, "code", 2);
2100
+ BinaryField("i32", 2, (obj) => obj.count)
2101
+ ], YGOProMsgAnnounceNumber.prototype, "numbers", 2);
2428
2102
 
2429
- // src/protos/msg/proto/draw.ts
2430
- var YGOProMsgDraw = class extends YGOProMsgBase {
2431
- // 对方视角需要隐藏抽到的卡(如果卡片标志位 0x80 未设置)
2432
- opponentView() {
2433
- const view = this.copy();
2434
- view.cards = view.cards.map((card) => {
2435
- if (!(card & 2147483648)) {
2436
- return 0;
2437
- }
2438
- return card;
2439
- });
2440
- return view;
2103
+ // src/protos/msg/proto/announce-race.ts
2104
+ var YGOProMsgAnnounceRace = class extends YGOProMsgResponseBase {
2105
+ responsePlayer() {
2106
+ return this.player;
2107
+ }
2108
+ prepareResponse(races) {
2109
+ const buffer = new Uint8Array(4);
2110
+ const view = new DataView(buffer.buffer);
2111
+ view.setInt32(0, races, true);
2112
+ return buffer;
2441
2113
  }
2442
2114
  };
2443
- YGOProMsgDraw.identifier = OcgcoreCommonConstants.MSG_DRAW;
2115
+ YGOProMsgAnnounceRace.identifier = OcgcoreCommonConstants.MSG_ANNOUNCE_RACE;
2444
2116
  __decorateClass([
2445
2117
  BinaryField("u8", 0)
2446
- ], YGOProMsgDraw.prototype, "player", 2);
2118
+ ], YGOProMsgAnnounceRace.prototype, "player", 2);
2447
2119
  __decorateClass([
2448
2120
  BinaryField("u8", 1)
2449
- ], YGOProMsgDraw.prototype, "count", 2);
2121
+ ], YGOProMsgAnnounceRace.prototype, "count", 2);
2450
2122
  __decorateClass([
2451
- BinaryField("i32", 2, (obj) => obj.count)
2452
- ], YGOProMsgDraw.prototype, "cards", 2);
2123
+ BinaryField("u32", 2)
2124
+ ], YGOProMsgAnnounceRace.prototype, "availableRaces", 2);
2453
2125
 
2454
- // src/protos/msg/proto/equip.ts
2455
- var YGOProMsgEquip_CardLocation = class {
2126
+ // src/protos/msg/proto/attack.ts
2127
+ var YGOProMsgAttack_CardLocation = class {
2456
2128
  };
2457
2129
  __decorateClass([
2458
2130
  BinaryField("u8", 0)
2459
- ], YGOProMsgEquip_CardLocation.prototype, "controller", 2);
2131
+ ], YGOProMsgAttack_CardLocation.prototype, "controller", 2);
2460
2132
  __decorateClass([
2461
2133
  BinaryField("u8", 1)
2462
- ], YGOProMsgEquip_CardLocation.prototype, "location", 2);
2134
+ ], YGOProMsgAttack_CardLocation.prototype, "location", 2);
2463
2135
  __decorateClass([
2464
2136
  BinaryField("u8", 2)
2465
- ], YGOProMsgEquip_CardLocation.prototype, "sequence", 2);
2466
- var YGOProMsgEquip = class extends YGOProMsgBase {
2467
- };
2468
- YGOProMsgEquip.identifier = OcgcoreCommonConstants.MSG_EQUIP;
2469
- __decorateClass([
2470
- BinaryField(() => YGOProMsgEquip_CardLocation, 0)
2471
- ], YGOProMsgEquip.prototype, "equip", 2);
2472
- __decorateClass([
2473
- BinaryField(() => YGOProMsgEquip_CardLocation, 3)
2474
- ], YGOProMsgEquip.prototype, "target", 2);
2137
+ ], YGOProMsgAttack_CardLocation.prototype, "sequence", 2);
2475
2138
  __decorateClass([
2476
- BinaryField("u8", 6)
2477
- ], YGOProMsgEquip.prototype, "position", 2);
2478
-
2479
- // src/protos/msg/proto/field-disabled.ts
2480
- var YGOProMsgFieldDisabled = class extends YGOProMsgBase {
2139
+ BinaryField("u8", 3)
2140
+ ], YGOProMsgAttack_CardLocation.prototype, "position", 2);
2141
+ var YGOProMsgAttack = class extends YGOProMsgBase {
2481
2142
  };
2482
- YGOProMsgFieldDisabled.identifier = OcgcoreCommonConstants.MSG_FIELD_DISABLED;
2143
+ YGOProMsgAttack.identifier = OcgcoreCommonConstants.MSG_ATTACK;
2483
2144
  __decorateClass([
2484
- BinaryField("u32", 0)
2485
- ], YGOProMsgFieldDisabled.prototype, "disabledField", 2);
2145
+ BinaryField(() => YGOProMsgAttack_CardLocation, 0)
2146
+ ], YGOProMsgAttack.prototype, "attacker", 2);
2147
+ __decorateClass([
2148
+ BinaryField(() => YGOProMsgAttack_CardLocation, 4)
2149
+ ], YGOProMsgAttack.prototype, "defender", 2);
2486
2150
 
2487
- // src/protos/msg/proto/flipsummoned.ts
2488
- var YGOProMsgFlipSummoned = class extends YGOProMsgBase {
2151
+ // src/protos/msg/proto/attack-disabled.ts
2152
+ var YGOProMsgAttackDisabled = class extends YGOProMsgBase {
2489
2153
  };
2490
- YGOProMsgFlipSummoned.identifier = OcgcoreCommonConstants.MSG_FLIPSUMMONED;
2154
+ YGOProMsgAttackDisabled.identifier = OcgcoreCommonConstants.MSG_ATTACK_DISABLED;
2491
2155
 
2492
- // src/protos/msg/proto/flipsummoning.ts
2493
- var YGOProMsgFlipSummoning = class extends YGOProMsgBase {
2156
+ // src/protos/msg/proto/battle.ts
2157
+ var YGOProMsgBattle_CardLocation = class {
2494
2158
  };
2495
- YGOProMsgFlipSummoning.identifier = OcgcoreCommonConstants.MSG_FLIPSUMMONING;
2496
2159
  __decorateClass([
2497
- BinaryField("i32", 0)
2498
- ], YGOProMsgFlipSummoning.prototype, "code", 2);
2160
+ BinaryField("u8", 0)
2161
+ ], YGOProMsgBattle_CardLocation.prototype, "controller", 2);
2499
2162
  __decorateClass([
2500
- BinaryField("u8", 4)
2501
- ], YGOProMsgFlipSummoning.prototype, "controller", 2);
2163
+ BinaryField("u8", 1)
2164
+ ], YGOProMsgBattle_CardLocation.prototype, "location", 2);
2502
2165
  __decorateClass([
2503
- BinaryField("u8", 5)
2504
- ], YGOProMsgFlipSummoning.prototype, "location", 2);
2166
+ BinaryField("u8", 2)
2167
+ ], YGOProMsgBattle_CardLocation.prototype, "sequence", 2);
2505
2168
  __decorateClass([
2506
- BinaryField("u8", 6)
2507
- ], YGOProMsgFlipSummoning.prototype, "sequence", 2);
2169
+ BinaryField("u8", 3)
2170
+ ], YGOProMsgBattle_CardLocation.prototype, "position", 2);
2171
+ var YGOProMsgBattle_CardStats = class {
2172
+ };
2508
2173
  __decorateClass([
2509
- BinaryField("u8", 7)
2510
- ], YGOProMsgFlipSummoning.prototype, "position", 2);
2511
-
2512
- // src/protos/msg/proto/hand-res.ts
2513
- var YGOProMsgHandRes = class extends YGOProMsgBase {
2174
+ BinaryField(() => YGOProMsgBattle_CardLocation, 0)
2175
+ ], YGOProMsgBattle_CardStats.prototype, "location", 2);
2176
+ __decorateClass([
2177
+ BinaryField("i32", 4)
2178
+ ], YGOProMsgBattle_CardStats.prototype, "atk", 2);
2179
+ __decorateClass([
2180
+ BinaryField("i32", 8)
2181
+ ], YGOProMsgBattle_CardStats.prototype, "def", 2);
2182
+ var YGOProMsgBattle = class extends YGOProMsgBase {
2514
2183
  };
2515
- YGOProMsgHandRes.identifier = OcgcoreCommonConstants.MSG_HAND_RES;
2184
+ YGOProMsgBattle.identifier = OcgcoreCommonConstants.MSG_BATTLE;
2516
2185
  __decorateClass([
2517
- BinaryField("u8", 0)
2518
- ], YGOProMsgHandRes.prototype, "result", 2);
2186
+ BinaryField(() => YGOProMsgBattle_CardStats, 0)
2187
+ ], YGOProMsgBattle.prototype, "attacker", 2);
2188
+ __decorateClass([
2189
+ BinaryField(() => YGOProMsgBattle_CardStats, 12)
2190
+ ], YGOProMsgBattle.prototype, "defender", 2);
2191
+ __decorateClass([
2192
+ BinaryField("u8", 24)
2193
+ ], YGOProMsgBattle.prototype, "battleDamageCalc", 2);
2519
2194
 
2520
- // src/protos/msg/proto/hint.ts
2521
- var YGOProMsgHint = class extends YGOProMsgBase {
2195
+ // src/protos/msg/proto/become-target.ts
2196
+ var YGOProMsgBecomeTarget = class extends YGOProMsgBase {
2522
2197
  };
2523
- YGOProMsgHint.identifier = OcgcoreCommonConstants.MSG_HINT;
2198
+ YGOProMsgBecomeTarget.identifier = OcgcoreCommonConstants.MSG_BECOME_TARGET;
2524
2199
  __decorateClass([
2525
2200
  BinaryField("u8", 0)
2526
- ], YGOProMsgHint.prototype, "type", 2);
2527
- __decorateClass([
2528
- BinaryField("u8", 1)
2529
- ], YGOProMsgHint.prototype, "player", 2);
2201
+ ], YGOProMsgBecomeTarget.prototype, "count", 2);
2530
2202
  __decorateClass([
2531
- BinaryField("i32", 2)
2532
- ], YGOProMsgHint.prototype, "desc", 2);
2203
+ BinaryField("i32", 1, (obj) => obj.count)
2204
+ ], YGOProMsgBecomeTarget.prototype, "targets", 2);
2533
2205
 
2534
- // src/protos/msg/proto/lpupdate.ts
2535
- var YGOProMsgLpUpdate = class extends YGOProMsgBase {
2206
+ // src/protos/msg/proto/cancel-target.ts
2207
+ var YGOProMsgCancelTarget_CardLocation = class {
2536
2208
  };
2537
- YGOProMsgLpUpdate.identifier = OcgcoreCommonConstants.MSG_LPUPDATE;
2538
2209
  __decorateClass([
2539
2210
  BinaryField("u8", 0)
2540
- ], YGOProMsgLpUpdate.prototype, "player", 2);
2211
+ ], YGOProMsgCancelTarget_CardLocation.prototype, "controller", 2);
2541
2212
  __decorateClass([
2542
- BinaryField("i32", 1)
2543
- ], YGOProMsgLpUpdate.prototype, "lp", 2);
2544
-
2545
- // src/protos/msg/proto/match-kill.ts
2546
- var YGOProMsgMatchKill = class extends YGOProMsgBase {
2213
+ BinaryField("u8", 1)
2214
+ ], YGOProMsgCancelTarget_CardLocation.prototype, "location", 2);
2215
+ __decorateClass([
2216
+ BinaryField("u8", 2)
2217
+ ], YGOProMsgCancelTarget_CardLocation.prototype, "sequence", 2);
2218
+ var YGOProMsgCancelTarget = class extends YGOProMsgBase {
2547
2219
  };
2548
- YGOProMsgMatchKill.identifier = OcgcoreCommonConstants.MSG_MATCH_KILL;
2220
+ YGOProMsgCancelTarget.identifier = OcgcoreCommonConstants.MSG_CANCEL_TARGET;
2549
2221
  __decorateClass([
2550
- BinaryField("i32", 0)
2551
- ], YGOProMsgMatchKill.prototype, "code", 2);
2222
+ BinaryField(() => YGOProMsgCancelTarget_CardLocation, 0)
2223
+ ], YGOProMsgCancelTarget.prototype, "card1", 2);
2224
+ __decorateClass([
2225
+ BinaryField(() => YGOProMsgCancelTarget_CardLocation, 3)
2226
+ ], YGOProMsgCancelTarget.prototype, "card2", 2);
2552
2227
 
2553
- // src/protos/msg/proto/missed-effect.ts
2554
- var YGOProMsgMissedEffect = class extends YGOProMsgBase {
2228
+ // src/protos/msg/proto/card-hint.ts
2229
+ var YGOProMsgCardHint = class extends YGOProMsgBase {
2555
2230
  };
2556
- YGOProMsgMissedEffect.identifier = OcgcoreCommonConstants.MSG_MISSED_EFFECT;
2231
+ YGOProMsgCardHint.identifier = OcgcoreCommonConstants.MSG_CARD_HINT;
2557
2232
  __decorateClass([
2558
2233
  BinaryField("u8", 0)
2559
- ], YGOProMsgMissedEffect.prototype, "player", 2);
2234
+ ], YGOProMsgCardHint.prototype, "controller", 2);
2560
2235
  __decorateClass([
2561
- BinaryField("i32", 1)
2562
- ], YGOProMsgMissedEffect.prototype, "code", 2);
2236
+ BinaryField("u8", 1)
2237
+ ], YGOProMsgCardHint.prototype, "location", 2);
2238
+ __decorateClass([
2239
+ BinaryField("u8", 2)
2240
+ ], YGOProMsgCardHint.prototype, "sequence", 2);
2241
+ __decorateClass([
2242
+ BinaryField("u8", 3)
2243
+ ], YGOProMsgCardHint.prototype, "subsequence", 2);
2244
+ __decorateClass([
2245
+ BinaryField("u8", 4)
2246
+ ], YGOProMsgCardHint.prototype, "type", 2);
2563
2247
  __decorateClass([
2564
2248
  BinaryField("i32", 5)
2565
- ], YGOProMsgMissedEffect.prototype, "desc", 2);
2249
+ ], YGOProMsgCardHint.prototype, "value", 2);
2566
2250
 
2567
- // src/protos/msg/proto/move.ts
2568
- var YGOProMsgMove_CardLocation = class {
2251
+ // src/protos/msg/proto/card-target.ts
2252
+ var YGOProMsgCardTarget_CardLocation = class {
2569
2253
  };
2570
2254
  __decorateClass([
2571
2255
  BinaryField("u8", 0)
2572
- ], YGOProMsgMove_CardLocation.prototype, "controller", 2);
2256
+ ], YGOProMsgCardTarget_CardLocation.prototype, "controller", 2);
2573
2257
  __decorateClass([
2574
2258
  BinaryField("u8", 1)
2575
- ], YGOProMsgMove_CardLocation.prototype, "location", 2);
2259
+ ], YGOProMsgCardTarget_CardLocation.prototype, "location", 2);
2576
2260
  __decorateClass([
2577
2261
  BinaryField("u8", 2)
2578
- ], YGOProMsgMove_CardLocation.prototype, "sequence", 2);
2579
- __decorateClass([
2580
- BinaryField("u8", 3)
2581
- ], YGOProMsgMove_CardLocation.prototype, "position", 2);
2582
- var YGOProMsgMove = class extends YGOProMsgBase {
2262
+ ], YGOProMsgCardTarget_CardLocation.prototype, "sequence", 2);
2263
+ var YGOProMsgCardTarget = class extends YGOProMsgBase {
2583
2264
  };
2584
- YGOProMsgMove.identifier = OcgcoreCommonConstants.MSG_MOVE;
2585
- __decorateClass([
2586
- BinaryField("i32", 0)
2587
- ], YGOProMsgMove.prototype, "code", 2);
2588
- __decorateClass([
2589
- BinaryField(() => YGOProMsgMove_CardLocation, 4)
2590
- ], YGOProMsgMove.prototype, "previous", 2);
2265
+ YGOProMsgCardTarget.identifier = OcgcoreCommonConstants.MSG_CARD_TARGET;
2591
2266
  __decorateClass([
2592
- BinaryField(() => YGOProMsgMove_CardLocation, 8)
2593
- ], YGOProMsgMove.prototype, "current", 2);
2267
+ BinaryField(() => YGOProMsgCardTarget_CardLocation, 0)
2268
+ ], YGOProMsgCardTarget.prototype, "card1", 2);
2594
2269
  __decorateClass([
2595
- BinaryField("i32", 12)
2596
- ], YGOProMsgMove.prototype, "reason", 2);
2270
+ BinaryField(() => YGOProMsgCardTarget_CardLocation, 3)
2271
+ ], YGOProMsgCardTarget.prototype, "card2", 2);
2597
2272
 
2598
- // src/protos/msg/proto/new-phase.ts
2599
- var YGOProMsgNewPhase = class extends YGOProMsgBase {
2273
+ // src/protos/msg/proto/chain-disabled.ts
2274
+ var YGOProMsgChainDisabled = class extends YGOProMsgBase {
2600
2275
  };
2601
- YGOProMsgNewPhase.identifier = OcgcoreCommonConstants.MSG_NEW_PHASE;
2276
+ YGOProMsgChainDisabled.identifier = OcgcoreCommonConstants.MSG_CHAIN_DISABLED;
2602
2277
  __decorateClass([
2603
- BinaryField("u16", 0)
2604
- ], YGOProMsgNewPhase.prototype, "phase", 2);
2278
+ BinaryField("u8", 0)
2279
+ ], YGOProMsgChainDisabled.prototype, "chainCount", 2);
2605
2280
 
2606
- // src/protos/msg/proto/new-turn.ts
2607
- var YGOProMsgNewTurn = class extends YGOProMsgBase {
2281
+ // src/protos/msg/proto/chain-end.ts
2282
+ var YGOProMsgChainEnd = class extends YGOProMsgBase {
2608
2283
  };
2609
- YGOProMsgNewTurn.identifier = OcgcoreCommonConstants.MSG_NEW_TURN;
2284
+ YGOProMsgChainEnd.identifier = OcgcoreCommonConstants.MSG_CHAIN_END;
2285
+
2286
+ // src/protos/msg/proto/chain-negated.ts
2287
+ var YGOProMsgChainNegated = class extends YGOProMsgBase {
2288
+ };
2289
+ YGOProMsgChainNegated.identifier = OcgcoreCommonConstants.MSG_CHAIN_NEGATED;
2610
2290
  __decorateClass([
2611
2291
  BinaryField("u8", 0)
2612
- ], YGOProMsgNewTurn.prototype, "player", 2);
2292
+ ], YGOProMsgChainNegated.prototype, "chainCount", 2);
2613
2293
 
2614
- // src/protos/msg/proto/pay-lpcost.ts
2615
- var YGOProMsgPayLpCost = class extends YGOProMsgBase {
2294
+ // src/protos/msg/proto/chain-solved.ts
2295
+ var YGOProMsgChainSolved = class extends YGOProMsgBase {
2616
2296
  };
2617
- YGOProMsgPayLpCost.identifier = OcgcoreCommonConstants.MSG_PAY_LPCOST;
2297
+ YGOProMsgChainSolved.identifier = OcgcoreCommonConstants.MSG_CHAIN_SOLVED;
2618
2298
  __decorateClass([
2619
2299
  BinaryField("u8", 0)
2620
- ], YGOProMsgPayLpCost.prototype, "player", 2);
2621
- __decorateClass([
2622
- BinaryField("i32", 1)
2623
- ], YGOProMsgPayLpCost.prototype, "cost", 2);
2300
+ ], YGOProMsgChainSolved.prototype, "chainCount", 2);
2624
2301
 
2625
- // src/protos/msg/proto/player-hint.ts
2626
- var YGOProMsgPlayerHint = class extends YGOProMsgBase {
2302
+ // src/protos/msg/proto/chain-solving.ts
2303
+ var YGOProMsgChainSolving = class extends YGOProMsgBase {
2627
2304
  };
2628
- YGOProMsgPlayerHint.identifier = OcgcoreCommonConstants.MSG_PLAYER_HINT;
2305
+ YGOProMsgChainSolving.identifier = OcgcoreCommonConstants.MSG_CHAIN_SOLVING;
2629
2306
  __decorateClass([
2630
2307
  BinaryField("u8", 0)
2631
- ], YGOProMsgPlayerHint.prototype, "player", 2);
2632
- __decorateClass([
2633
- BinaryField("u8", 1)
2634
- ], YGOProMsgPlayerHint.prototype, "type", 2);
2635
- __decorateClass([
2636
- BinaryField("i32", 2)
2637
- ], YGOProMsgPlayerHint.prototype, "value", 2);
2308
+ ], YGOProMsgChainSolving.prototype, "chainCount", 2);
2638
2309
 
2639
- // src/protos/msg/proto/pos-change.ts
2640
- var YGOProMsgPosChange_CardLocation = class {
2310
+ // src/protos/msg/proto/chained.ts
2311
+ var YGOProMsgChained = class extends YGOProMsgBase {
2641
2312
  };
2313
+ YGOProMsgChained.identifier = OcgcoreCommonConstants.MSG_CHAINED;
2642
2314
  __decorateClass([
2643
2315
  BinaryField("u8", 0)
2644
- ], YGOProMsgPosChange_CardLocation.prototype, "controller", 2);
2316
+ ], YGOProMsgChained.prototype, "chainCount", 2);
2317
+
2318
+ // src/protos/msg/proto/chaining.ts
2319
+ var YGOProMsgChaining = class extends YGOProMsgBase {
2320
+ };
2321
+ YGOProMsgChaining.identifier = OcgcoreCommonConstants.MSG_CHAINING;
2645
2322
  __decorateClass([
2646
- BinaryField("u8", 1)
2647
- ], YGOProMsgPosChange_CardLocation.prototype, "location", 2);
2323
+ BinaryField("i32", 0)
2324
+ ], YGOProMsgChaining.prototype, "code", 2);
2648
2325
  __decorateClass([
2649
- BinaryField("u8", 2)
2650
- ], YGOProMsgPosChange_CardLocation.prototype, "sequence", 2);
2651
- var YGOProMsgPosChange = class extends YGOProMsgBase {
2652
- };
2653
- YGOProMsgPosChange.identifier = OcgcoreCommonConstants.MSG_POS_CHANGE;
2326
+ BinaryField("u8", 4)
2327
+ ], YGOProMsgChaining.prototype, "controller", 2);
2654
2328
  __decorateClass([
2655
- BinaryField(() => YGOProMsgPosChange_CardLocation, 0)
2656
- ], YGOProMsgPosChange.prototype, "card", 2);
2329
+ BinaryField("u8", 5)
2330
+ ], YGOProMsgChaining.prototype, "location", 2);
2657
2331
  __decorateClass([
2658
- BinaryField("u8", 3)
2659
- ], YGOProMsgPosChange.prototype, "previousPosition", 2);
2332
+ BinaryField("u8", 6)
2333
+ ], YGOProMsgChaining.prototype, "sequence", 2);
2660
2334
  __decorateClass([
2661
- BinaryField("u8", 4)
2662
- ], YGOProMsgPosChange.prototype, "currentPosition", 2);
2335
+ BinaryField("u8", 7)
2336
+ ], YGOProMsgChaining.prototype, "subsequence", 2);
2337
+ __decorateClass([
2338
+ BinaryField("u8", 8)
2339
+ ], YGOProMsgChaining.prototype, "chainCount", 2);
2340
+ __decorateClass([
2341
+ BinaryField("i32", 9)
2342
+ ], YGOProMsgChaining.prototype, "desc", 2);
2343
+ __decorateClass([
2344
+ BinaryField("u8", 13)
2345
+ ], YGOProMsgChaining.prototype, "chainPlayer", 2);
2663
2346
 
2664
- // src/protos/msg/proto/random-selected.ts
2665
- var YGOProMsgRandomSelected = class extends YGOProMsgBase {
2347
+ // src/protos/msg/proto/confirm-cards.ts
2348
+ var YGOProMsgConfirmCards_CardInfo = class {
2666
2349
  };
2667
- YGOProMsgRandomSelected.identifier = OcgcoreCommonConstants.MSG_RANDOM_SELECTED;
2668
2350
  __decorateClass([
2669
- BinaryField("u8", 0)
2670
- ], YGOProMsgRandomSelected.prototype, "player", 2);
2351
+ BinaryField("i32", 0)
2352
+ ], YGOProMsgConfirmCards_CardInfo.prototype, "code", 2);
2671
2353
  __decorateClass([
2672
- BinaryField("u8", 1)
2673
- ], YGOProMsgRandomSelected.prototype, "count", 2);
2354
+ BinaryField("u8", 4)
2355
+ ], YGOProMsgConfirmCards_CardInfo.prototype, "controller", 2);
2674
2356
  __decorateClass([
2675
- BinaryField("i32", 2, (obj) => obj.count)
2676
- ], YGOProMsgRandomSelected.prototype, "cards", 2);
2677
-
2678
- // src/protos/msg/proto/recover.ts
2679
- var YGOProMsgRecover = class extends YGOProMsgBase {
2357
+ BinaryField("u8", 5)
2358
+ ], YGOProMsgConfirmCards_CardInfo.prototype, "location", 2);
2359
+ __decorateClass([
2360
+ BinaryField("u8", 6)
2361
+ ], YGOProMsgConfirmCards_CardInfo.prototype, "sequence", 2);
2362
+ __decorateClass([
2363
+ BinaryField("u8", 7)
2364
+ ], YGOProMsgConfirmCards_CardInfo.prototype, "subsequence", 2);
2365
+ var YGOProMsgConfirmCards = class extends YGOProMsgBase {
2366
+ // 对方视角可能需要隐藏卡片信息
2367
+ opponentView() {
2368
+ const view = this.copy();
2369
+ view.cards = view.cards.map((card) => {
2370
+ const c = { ...card };
2371
+ if (!(c.code & 2147483648)) {
2372
+ c.code = 0;
2373
+ }
2374
+ return c;
2375
+ });
2376
+ return view;
2377
+ }
2378
+ getSendTargets() {
2379
+ if (this.cards.length > 0 && this.cards[0].location === 1) {
2380
+ return [this.player];
2381
+ }
2382
+ return SEND_TO_ALL;
2383
+ }
2680
2384
  };
2681
- YGOProMsgRecover.identifier = OcgcoreCommonConstants.MSG_RECOVER;
2385
+ YGOProMsgConfirmCards.identifier = OcgcoreCommonConstants.MSG_CONFIRM_CARDS;
2682
2386
  __decorateClass([
2683
2387
  BinaryField("u8", 0)
2684
- ], YGOProMsgRecover.prototype, "player", 2);
2388
+ ], YGOProMsgConfirmCards.prototype, "player", 2);
2685
2389
  __decorateClass([
2686
- BinaryField("i32", 1)
2687
- ], YGOProMsgRecover.prototype, "value", 2);
2688
-
2689
- // src/protos/msg/proto/reload-field.ts
2690
- var YGOProMsgReloadField_ZoneCard = class {
2691
- };
2692
- var YGOProMsgReloadField_PlayerInfo = class {
2693
- };
2694
- var YGOProMsgReloadField_ChainInfo = class {
2695
- };
2696
- var YGOProMsgReloadField = class extends YGOProMsgBase {
2697
- fromPayload(data) {
2698
- if (data.length < 1) {
2699
- throw new Error("MSG data too short");
2700
- }
2701
- const msgType = data[0];
2702
- if (msgType !== this.identifier) {
2703
- throw new Error(
2704
- `MSG type mismatch: expected ${this.identifier}, got ${msgType}`
2705
- );
2706
- }
2707
- const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
2708
- let offset = 1;
2709
- this.duelRule = view.getUint8(offset++);
2710
- this.players = [];
2711
- for (let i = 0; i < 2; i++) {
2712
- const player = {
2713
- lp: view.getInt32(offset, true),
2714
- mzone: [],
2715
- szone: [],
2716
- deckCount: 0,
2717
- handCount: 0,
2718
- graveCount: 0,
2719
- removedCount: 0,
2720
- extraCount: 0,
2721
- extraPCount: 0
2722
- };
2723
- offset += 4;
2724
- for (let seq = 0; seq < 7; seq++) {
2725
- const occupied = view.getUint8(offset++);
2726
- const card = { occupied };
2727
- if (occupied) {
2728
- card.position = view.getUint8(offset++);
2729
- card.xyzCount = view.getUint8(offset++);
2730
- }
2731
- player.mzone.push(card);
2732
- }
2733
- for (let seq = 0; seq < 8; seq++) {
2734
- const occupied = view.getUint8(offset++);
2735
- const card = { occupied };
2736
- if (occupied) {
2737
- card.position = view.getUint8(offset++);
2738
- }
2739
- player.szone.push(card);
2740
- }
2741
- player.deckCount = view.getUint8(offset++);
2742
- player.handCount = view.getUint8(offset++);
2743
- player.graveCount = view.getUint8(offset++);
2744
- player.removedCount = view.getUint8(offset++);
2745
- player.extraCount = view.getUint8(offset++);
2746
- player.extraPCount = view.getUint8(offset++);
2747
- this.players.push(player);
2748
- }
2749
- const chainCount = view.getUint8(offset++);
2750
- this.chains = [];
2751
- for (let i = 0; i < chainCount; i++) {
2752
- const chain = {
2753
- code: view.getInt32(offset, true),
2754
- chainCardController: view.getUint8(offset + 4),
2755
- chainCardLocation: view.getUint8(offset + 5),
2756
- chainCardSequence: view.getUint8(offset + 6),
2757
- chainCardSubsequence: view.getUint8(offset + 7),
2758
- triggerController: view.getUint8(offset + 8),
2759
- triggerLocation: view.getUint8(offset + 9),
2760
- triggerSequence: view.getUint8(offset + 10),
2761
- desc: view.getInt32(offset + 11, true)
2762
- };
2763
- offset += 15;
2764
- this.chains.push(chain);
2765
- }
2766
- return this;
2767
- }
2768
- toPayload() {
2769
- let size = 1 + 1;
2770
- for (const player of this.players) {
2771
- size += 4;
2772
- for (const card of player.mzone) {
2773
- size += 1;
2774
- if (card.occupied) {
2775
- size += 2;
2776
- }
2777
- }
2778
- for (const card of player.szone) {
2779
- size += 1;
2780
- if (card.occupied) {
2781
- size += 1;
2782
- }
2783
- }
2784
- size += 6;
2785
- }
2786
- size += 1;
2787
- size += this.chains.length * 15;
2788
- const result = new Uint8Array(size);
2789
- const view = new DataView(result.buffer);
2790
- let offset = 0;
2791
- result[offset++] = this.identifier;
2792
- result[offset++] = this.duelRule;
2793
- for (const player of this.players) {
2794
- view.setInt32(offset, player.lp, true);
2795
- offset += 4;
2796
- for (const card of player.mzone) {
2797
- result[offset++] = card.occupied;
2798
- if (card.occupied) {
2799
- result[offset++] = card.position || 0;
2800
- result[offset++] = card.xyzCount || 0;
2801
- }
2802
- }
2803
- for (const card of player.szone) {
2804
- result[offset++] = card.occupied;
2805
- if (card.occupied) {
2806
- result[offset++] = card.position || 0;
2807
- }
2808
- }
2809
- result[offset++] = player.deckCount;
2810
- result[offset++] = player.handCount;
2811
- result[offset++] = player.graveCount;
2812
- result[offset++] = player.removedCount;
2813
- result[offset++] = player.extraCount;
2814
- result[offset++] = player.extraPCount;
2815
- }
2816
- result[offset++] = this.chains.length;
2817
- for (const chain of this.chains) {
2818
- view.setInt32(offset, chain.code, true);
2819
- result[offset + 4] = chain.chainCardController;
2820
- result[offset + 5] = chain.chainCardLocation;
2821
- result[offset + 6] = chain.chainCardSequence;
2822
- result[offset + 7] = chain.chainCardSubsequence;
2823
- result[offset + 8] = chain.triggerController;
2824
- result[offset + 9] = chain.triggerLocation;
2825
- result[offset + 10] = chain.triggerSequence;
2826
- view.setInt32(offset + 11, chain.desc, true);
2827
- offset += 15;
2828
- }
2829
- return result;
2830
- }
2831
- };
2832
- YGOProMsgReloadField.identifier = 162;
2833
-
2834
- // src/protos/msg/proto/remove-counter.ts
2835
- var YGOProMsgRemoveCounter = class extends YGOProMsgBase {
2836
- };
2837
- YGOProMsgRemoveCounter.identifier = OcgcoreCommonConstants.MSG_REMOVE_COUNTER;
2838
- __decorateClass([
2839
- BinaryField("u16", 0)
2840
- ], YGOProMsgRemoveCounter.prototype, "counterType", 2);
2390
+ BinaryField("u8", 1)
2391
+ ], YGOProMsgConfirmCards.prototype, "unused", 2);
2841
2392
  __decorateClass([
2842
2393
  BinaryField("u8", 2)
2843
- ], YGOProMsgRemoveCounter.prototype, "controller", 2);
2844
- __decorateClass([
2845
- BinaryField("u8", 3)
2846
- ], YGOProMsgRemoveCounter.prototype, "location", 2);
2847
- __decorateClass([
2848
- BinaryField("u8", 4)
2849
- ], YGOProMsgRemoveCounter.prototype, "sequence", 2);
2850
- __decorateClass([
2851
- BinaryField("u16", 5)
2852
- ], YGOProMsgRemoveCounter.prototype, "count", 2);
2853
-
2854
- // src/protos/msg/proto/reset-time.ts
2855
- var YGOProMsgResetTime = class extends YGOProMsgBase {
2856
- };
2857
- YGOProMsgResetTime.identifier = OcgcoreCommonConstants.MSG_RESET_TIME;
2858
- __decorateClass([
2859
- BinaryField("i8", 0)
2860
- ], YGOProMsgResetTime.prototype, "player", 2);
2861
- __decorateClass([
2862
- BinaryField("i16", 1)
2863
- ], YGOProMsgResetTime.prototype, "time", 2);
2864
-
2865
- // src/protos/msg/proto/retry.ts
2866
- var YGOProMsgRetry = class extends YGOProMsgBase {
2867
- };
2868
- YGOProMsgRetry.identifier = OcgcoreCommonConstants.MSG_RETRY;
2869
-
2870
- // src/protos/msg/proto/reverse-deck.ts
2871
- var YGOProMsgReverseDeck = class extends YGOProMsgBase {
2872
- };
2873
- YGOProMsgReverseDeck.identifier = OcgcoreCommonConstants.MSG_REVERSE_DECK;
2874
-
2875
- // src/protos/msg/proto/rock-paper-scissors.ts
2876
- var YGOProMsgRockPaperScissors = class extends YGOProMsgBase {
2877
- };
2878
- YGOProMsgRockPaperScissors.identifier = OcgcoreCommonConstants.MSG_ROCK_PAPER_SCISSORS;
2394
+ ], YGOProMsgConfirmCards.prototype, "count", 2);
2879
2395
  __decorateClass([
2880
- BinaryField("u8", 0)
2881
- ], YGOProMsgRockPaperScissors.prototype, "player", 2);
2396
+ BinaryField(() => YGOProMsgConfirmCards_CardInfo, 3, (obj) => obj.count)
2397
+ ], YGOProMsgConfirmCards.prototype, "cards", 2);
2882
2398
 
2883
- // src/protos/msg/proto/select-battlecmd.ts
2884
- var BattleCmdType = /* @__PURE__ */ ((BattleCmdType2) => {
2885
- BattleCmdType2[BattleCmdType2["ACTIVATE"] = 0] = "ACTIVATE";
2886
- BattleCmdType2[BattleCmdType2["ATTACK"] = 1] = "ATTACK";
2887
- BattleCmdType2[BattleCmdType2["TO_M2"] = 2] = "TO_M2";
2888
- BattleCmdType2[BattleCmdType2["TO_EP"] = 3] = "TO_EP";
2889
- return BattleCmdType2;
2890
- })(BattleCmdType || {});
2891
- var YGOProMsgSelectBattleCmd_ActivatableInfo = class {
2399
+ // src/protos/msg/proto/confirm-decktop.ts
2400
+ var YGOProMsgConfirmDeckTop_CardInfo = class {
2892
2401
  };
2893
2402
  __decorateClass([
2894
2403
  BinaryField("i32", 0)
2895
- ], YGOProMsgSelectBattleCmd_ActivatableInfo.prototype, "code", 2);
2404
+ ], YGOProMsgConfirmDeckTop_CardInfo.prototype, "code", 2);
2896
2405
  __decorateClass([
2897
2406
  BinaryField("u8", 4)
2898
- ], YGOProMsgSelectBattleCmd_ActivatableInfo.prototype, "controller", 2);
2407
+ ], YGOProMsgConfirmDeckTop_CardInfo.prototype, "controller", 2);
2899
2408
  __decorateClass([
2900
2409
  BinaryField("u8", 5)
2901
- ], YGOProMsgSelectBattleCmd_ActivatableInfo.prototype, "location", 2);
2410
+ ], YGOProMsgConfirmDeckTop_CardInfo.prototype, "location", 2);
2902
2411
  __decorateClass([
2903
2412
  BinaryField("u8", 6)
2904
- ], YGOProMsgSelectBattleCmd_ActivatableInfo.prototype, "sequence", 2);
2413
+ ], YGOProMsgConfirmDeckTop_CardInfo.prototype, "sequence", 2);
2414
+ var YGOProMsgConfirmDeckTop = class extends YGOProMsgBase {
2415
+ // 对方视角可能需要隐藏卡片信息
2416
+ opponentView() {
2417
+ const view = this.copy();
2418
+ view.cards = view.cards.map((card) => {
2419
+ const c = { ...card };
2420
+ if (!(c.code & 2147483648)) {
2421
+ c.code = 0;
2422
+ }
2423
+ return c;
2424
+ });
2425
+ return view;
2426
+ }
2427
+ // confirm-decktop 使用基类的 playerView (基于 player 字段)
2428
+ };
2429
+ YGOProMsgConfirmDeckTop.identifier = OcgcoreCommonConstants.MSG_CONFIRM_DECKTOP;
2905
2430
  __decorateClass([
2906
- BinaryField("i32", 7)
2907
- ], YGOProMsgSelectBattleCmd_ActivatableInfo.prototype, "desc", 2);
2908
- var YGOProMsgSelectBattleCmd_AttackableInfo = class {
2431
+ BinaryField("u8", 0)
2432
+ ], YGOProMsgConfirmDeckTop.prototype, "player", 2);
2433
+ __decorateClass([
2434
+ BinaryField("u8", 1)
2435
+ ], YGOProMsgConfirmDeckTop.prototype, "count", 2);
2436
+ __decorateClass([
2437
+ BinaryField(() => YGOProMsgConfirmDeckTop_CardInfo, 2, (obj) => obj.count)
2438
+ ], YGOProMsgConfirmDeckTop.prototype, "cards", 2);
2439
+
2440
+ // src/protos/msg/proto/confirm-extratop.ts
2441
+ var YGOProMsgConfirmExtraTop_CardInfo = class {
2909
2442
  };
2910
2443
  __decorateClass([
2911
2444
  BinaryField("i32", 0)
2912
- ], YGOProMsgSelectBattleCmd_AttackableInfo.prototype, "code", 2);
2445
+ ], YGOProMsgConfirmExtraTop_CardInfo.prototype, "code", 2);
2913
2446
  __decorateClass([
2914
2447
  BinaryField("u8", 4)
2915
- ], YGOProMsgSelectBattleCmd_AttackableInfo.prototype, "controller", 2);
2448
+ ], YGOProMsgConfirmExtraTop_CardInfo.prototype, "controller", 2);
2916
2449
  __decorateClass([
2917
2450
  BinaryField("u8", 5)
2918
- ], YGOProMsgSelectBattleCmd_AttackableInfo.prototype, "location", 2);
2451
+ ], YGOProMsgConfirmExtraTop_CardInfo.prototype, "location", 2);
2919
2452
  __decorateClass([
2920
2453
  BinaryField("u8", 6)
2921
- ], YGOProMsgSelectBattleCmd_AttackableInfo.prototype, "sequence", 2);
2922
- __decorateClass([
2923
- BinaryField("u8", 7)
2924
- ], YGOProMsgSelectBattleCmd_AttackableInfo.prototype, "directAttack", 2);
2925
- var YGOProMsgSelectBattleCmd = class extends YGOProMsgResponseBase {
2926
- responsePlayer() {
2927
- return this.player;
2928
- }
2929
- prepareResponse(type, option) {
2930
- let sequence;
2931
- if (type === 0 /* ACTIVATE */) {
2932
- if (option == null) {
2933
- throw new TypeError("Option required for ACTIVATE");
2934
- }
2935
- if (isIndexResponse(option)) {
2936
- sequence = option.index;
2937
- if (sequence < 0 || sequence >= this.activatableCount) {
2938
- throw new TypeError(`Index out of range: ${sequence}`);
2939
- }
2940
- } else {
2941
- const idx = this.activatableCards.findIndex(
2942
- (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)
2943
- );
2944
- if (idx === -1) {
2945
- throw new TypeError("Activatable card not found");
2946
- }
2947
- sequence = idx;
2948
- }
2949
- } else if (type === 1 /* ATTACK */) {
2950
- if (option == null) {
2951
- throw new TypeError("Option required for ATTACK");
2952
- }
2953
- if (isIndexResponse(option)) {
2954
- sequence = option.index;
2955
- if (sequence < 0 || sequence >= this.attackableCount) {
2956
- throw new TypeError(`Index out of range: ${sequence}`);
2957
- }
2958
- } else {
2959
- const idx = this.attackableCards.findIndex(
2960
- (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)
2961
- );
2962
- if (idx === -1) {
2963
- throw new TypeError("Attackable card not found");
2964
- }
2965
- sequence = idx;
2966
- }
2967
- } else if (type === 2 /* TO_M2 */) {
2968
- if (this.canM2 === 0) {
2969
- throw new TypeError("Cannot go to M2");
2970
- }
2971
- sequence = 0;
2972
- } else if (type === 3 /* TO_EP */) {
2973
- if (this.canEp === 0) {
2974
- throw new TypeError("Cannot go to EP");
2454
+ ], YGOProMsgConfirmExtraTop_CardInfo.prototype, "sequence", 2);
2455
+ var YGOProMsgConfirmExtraTop = class extends YGOProMsgBase {
2456
+ // 对方视角可能需要隐藏卡片信息
2457
+ opponentView() {
2458
+ const view = this.copy();
2459
+ view.cards = view.cards.map((card) => {
2460
+ const c = { ...card };
2461
+ if (!(c.code & 2147483648)) {
2462
+ c.code = 0;
2975
2463
  }
2976
- sequence = 0;
2977
- } else {
2978
- throw new TypeError(`Unknown type: ${type}`);
2979
- }
2980
- const buffer = new Uint8Array(4);
2981
- const view = new DataView(buffer.buffer);
2982
- view.setUint32(0, sequence << 16 | type, true);
2983
- return buffer;
2464
+ return c;
2465
+ });
2466
+ return view;
2984
2467
  }
2468
+ // confirm-extratop 使用基类的 playerView (基于 player 字段)
2985
2469
  };
2986
- YGOProMsgSelectBattleCmd.identifier = OcgcoreCommonConstants.MSG_SELECT_BATTLECMD;
2470
+ YGOProMsgConfirmExtraTop.identifier = OcgcoreCommonConstants.MSG_CONFIRM_EXTRATOP;
2987
2471
  __decorateClass([
2988
2472
  BinaryField("u8", 0)
2989
- ], YGOProMsgSelectBattleCmd.prototype, "player", 2);
2473
+ ], YGOProMsgConfirmExtraTop.prototype, "player", 2);
2990
2474
  __decorateClass([
2991
2475
  BinaryField("u8", 1)
2992
- ], YGOProMsgSelectBattleCmd.prototype, "activatableCount", 2);
2993
- __decorateClass([
2994
- BinaryField(
2995
- () => YGOProMsgSelectBattleCmd_ActivatableInfo,
2996
- 2,
2997
- (obj) => obj.activatableCount
2998
- )
2999
- ], YGOProMsgSelectBattleCmd.prototype, "activatableCards", 2);
3000
- __decorateClass([
3001
- BinaryField("u8", (obj) => {
3002
- return 2 + obj.activatableCount * 11;
3003
- })
3004
- ], YGOProMsgSelectBattleCmd.prototype, "attackableCount", 2);
3005
- __decorateClass([
3006
- BinaryField(
3007
- () => YGOProMsgSelectBattleCmd_AttackableInfo,
3008
- (obj) => {
3009
- return 3 + obj.activatableCount * 11;
3010
- },
3011
- (obj) => obj.attackableCount
3012
- )
3013
- ], YGOProMsgSelectBattleCmd.prototype, "attackableCards", 2);
3014
- __decorateClass([
3015
- BinaryField("u8", (obj) => {
3016
- return 3 + obj.activatableCount * 11 + obj.attackableCount * 8;
3017
- })
3018
- ], YGOProMsgSelectBattleCmd.prototype, "canM2", 2);
2476
+ ], YGOProMsgConfirmExtraTop.prototype, "count", 2);
3019
2477
  __decorateClass([
3020
- BinaryField("u8", (obj) => {
3021
- return 4 + obj.activatableCount * 11 + obj.attackableCount * 8;
3022
- })
3023
- ], YGOProMsgSelectBattleCmd.prototype, "canEp", 2);
2478
+ BinaryField(() => YGOProMsgConfirmExtraTop_CardInfo, 2, (obj) => obj.count)
2479
+ ], YGOProMsgConfirmExtraTop.prototype, "cards", 2);
3024
2480
 
3025
- // src/protos/msg/proto/select-card.ts
3026
- var YGOProMsgSelectCard_CardInfo = class {
2481
+ // src/protos/msg/proto/damage.ts
2482
+ var YGOProMsgDamage = class extends YGOProMsgBase {
3027
2483
  };
2484
+ YGOProMsgDamage.identifier = OcgcoreCommonConstants.MSG_DAMAGE;
3028
2485
  __decorateClass([
3029
- BinaryField("i32", 0)
3030
- ], YGOProMsgSelectCard_CardInfo.prototype, "code", 2);
2486
+ BinaryField("u8", 0)
2487
+ ], YGOProMsgDamage.prototype, "player", 2);
3031
2488
  __decorateClass([
3032
- BinaryField("u8", 4)
3033
- ], YGOProMsgSelectCard_CardInfo.prototype, "controller", 2);
2489
+ BinaryField("i32", 1)
2490
+ ], YGOProMsgDamage.prototype, "value", 2);
2491
+
2492
+ // src/protos/msg/proto/damage-step-end.ts
2493
+ var YGOProMsgDamageStepEnd = class extends YGOProMsgBase {
2494
+ };
2495
+ YGOProMsgDamageStepEnd.identifier = OcgcoreCommonConstants.MSG_DAMAGE_STEP_END;
2496
+
2497
+ // src/protos/msg/proto/damage-step-start.ts
2498
+ var YGOProMsgDamageStepStart = class extends YGOProMsgBase {
2499
+ };
2500
+ YGOProMsgDamageStepStart.identifier = OcgcoreCommonConstants.MSG_DAMAGE_STEP_START;
2501
+
2502
+ // src/protos/msg/proto/deck-top.ts
2503
+ var YGOProMsgDeckTop = class extends YGOProMsgBase {
2504
+ // 对方视角可能需要隐藏卡片信息
2505
+ opponentView() {
2506
+ const view = this.copy();
2507
+ if (!(view.code & 2147483648)) {
2508
+ view.code = 0;
2509
+ }
2510
+ return view;
2511
+ }
2512
+ // deck-top 使用基类的 playerView (基于 player 字段)
2513
+ };
2514
+ YGOProMsgDeckTop.identifier = OcgcoreCommonConstants.MSG_DECK_TOP;
3034
2515
  __decorateClass([
3035
- BinaryField("u8", 5)
3036
- ], YGOProMsgSelectCard_CardInfo.prototype, "location", 2);
2516
+ BinaryField("u8", 0)
2517
+ ], YGOProMsgDeckTop.prototype, "player", 2);
3037
2518
  __decorateClass([
3038
- BinaryField("u8", 6)
3039
- ], YGOProMsgSelectCard_CardInfo.prototype, "sequence", 2);
2519
+ BinaryField("u8", 1)
2520
+ ], YGOProMsgDeckTop.prototype, "sequence", 2);
3040
2521
  __decorateClass([
3041
- BinaryField("u8", 7)
3042
- ], YGOProMsgSelectCard_CardInfo.prototype, "subsequence", 2);
3043
- var YGOProMsgSelectCard = class extends YGOProMsgResponseBase {
3044
- responsePlayer() {
3045
- return this.player;
3046
- }
3047
- defaultResponse() {
3048
- if (this.cancelable === 0) {
3049
- return void 0;
3050
- }
3051
- return this.prepareResponse(null);
3052
- }
3053
- prepareResponse(cardOptions) {
3054
- if (cardOptions == null) {
3055
- const buffer2 = new Uint8Array(4);
3056
- const view = new DataView(buffer2.buffer);
3057
- view.setInt32(0, -1, true);
3058
- return buffer2;
3059
- }
3060
- const indices = [];
3061
- const usedIndices = /* @__PURE__ */ new Set();
3062
- for (const option of cardOptions) {
3063
- let index;
3064
- if (isIndexResponse(option)) {
3065
- index = option.index;
3066
- if (index < 0 || index >= this.count) {
3067
- throw new TypeError(`Index out of range: ${index}`);
3068
- }
3069
- } else {
3070
- index = this.cards.findIndex(
3071
- (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)
3072
- );
3073
- if (index === -1) {
3074
- throw new TypeError("Card not found");
3075
- }
2522
+ BinaryField("i32", 2)
2523
+ ], YGOProMsgDeckTop.prototype, "code", 2);
2524
+
2525
+ // src/protos/msg/proto/draw.ts
2526
+ var YGOProMsgDraw = class extends YGOProMsgBase {
2527
+ // 对方视角需要隐藏抽到的卡(如果卡片标志位 0x80 未设置)
2528
+ opponentView() {
2529
+ const view = this.copy();
2530
+ view.cards = view.cards.map((card) => {
2531
+ if (!(card & 2147483648)) {
2532
+ return 0;
3076
2533
  }
3077
- indices.push(index);
3078
- usedIndices.add(index);
3079
- }
3080
- const buffer = new Uint8Array(1 + indices.length);
3081
- buffer[0] = indices.length;
3082
- indices.forEach((idx, i) => {
3083
- buffer[1 + i] = idx;
2534
+ return card;
3084
2535
  });
3085
- return buffer;
2536
+ return view;
3086
2537
  }
3087
2538
  };
3088
- YGOProMsgSelectCard.identifier = OcgcoreCommonConstants.MSG_SELECT_CARD;
2539
+ YGOProMsgDraw.identifier = OcgcoreCommonConstants.MSG_DRAW;
3089
2540
  __decorateClass([
3090
2541
  BinaryField("u8", 0)
3091
- ], YGOProMsgSelectCard.prototype, "player", 2);
2542
+ ], YGOProMsgDraw.prototype, "player", 2);
3092
2543
  __decorateClass([
3093
2544
  BinaryField("u8", 1)
3094
- ], YGOProMsgSelectCard.prototype, "cancelable", 2);
3095
- __decorateClass([
3096
- BinaryField("u8", 2)
3097
- ], YGOProMsgSelectCard.prototype, "min", 2);
3098
- __decorateClass([
3099
- BinaryField("u8", 3)
3100
- ], YGOProMsgSelectCard.prototype, "max", 2);
3101
- __decorateClass([
3102
- BinaryField("u8", 4)
3103
- ], YGOProMsgSelectCard.prototype, "count", 2);
2545
+ ], YGOProMsgDraw.prototype, "count", 2);
3104
2546
  __decorateClass([
3105
- BinaryField(() => YGOProMsgSelectCard_CardInfo, 5, (obj) => obj.count)
3106
- ], YGOProMsgSelectCard.prototype, "cards", 2);
2547
+ BinaryField("i32", 2, (obj) => obj.count)
2548
+ ], YGOProMsgDraw.prototype, "cards", 2);
3107
2549
 
3108
- // src/protos/msg/proto/select-chain.ts
3109
- var YGOProMsgSelectChain_ChainInfo = class {
2550
+ // src/protos/msg/proto/equip.ts
2551
+ var YGOProMsgEquip_CardLocation = class {
3110
2552
  };
3111
2553
  __decorateClass([
3112
2554
  BinaryField("u8", 0)
3113
- ], YGOProMsgSelectChain_ChainInfo.prototype, "edesc", 2);
2555
+ ], YGOProMsgEquip_CardLocation.prototype, "controller", 2);
3114
2556
  __decorateClass([
3115
2557
  BinaryField("u8", 1)
3116
- ], YGOProMsgSelectChain_ChainInfo.prototype, "forced", 2);
3117
- __decorateClass([
3118
- BinaryField("i32", 2)
3119
- ], YGOProMsgSelectChain_ChainInfo.prototype, "code", 2);
3120
- __decorateClass([
3121
- BinaryField("u8", 6)
3122
- ], YGOProMsgSelectChain_ChainInfo.prototype, "controller", 2);
2558
+ ], YGOProMsgEquip_CardLocation.prototype, "location", 2);
3123
2559
  __decorateClass([
3124
- BinaryField("u8", 7)
3125
- ], YGOProMsgSelectChain_ChainInfo.prototype, "location", 2);
2560
+ BinaryField("u8", 2)
2561
+ ], YGOProMsgEquip_CardLocation.prototype, "sequence", 2);
2562
+ var YGOProMsgEquip = class extends YGOProMsgBase {
2563
+ };
2564
+ YGOProMsgEquip.identifier = OcgcoreCommonConstants.MSG_EQUIP;
3126
2565
  __decorateClass([
3127
- BinaryField("u8", 8)
3128
- ], YGOProMsgSelectChain_ChainInfo.prototype, "sequence", 2);
2566
+ BinaryField(() => YGOProMsgEquip_CardLocation, 0)
2567
+ ], YGOProMsgEquip.prototype, "equip", 2);
3129
2568
  __decorateClass([
3130
- BinaryField("u8", 9)
3131
- ], YGOProMsgSelectChain_ChainInfo.prototype, "subsequence", 2);
2569
+ BinaryField(() => YGOProMsgEquip_CardLocation, 3)
2570
+ ], YGOProMsgEquip.prototype, "target", 2);
3132
2571
  __decorateClass([
3133
- BinaryField("i32", 10)
3134
- ], YGOProMsgSelectChain_ChainInfo.prototype, "desc", 2);
3135
- var YGOProMsgSelectChain = class extends YGOProMsgResponseBase {
3136
- responsePlayer() {
3137
- return this.player;
3138
- }
3139
- defaultResponse() {
3140
- const hasForced = this.chains.some((chain) => chain.forced !== 0);
3141
- if (hasForced) {
3142
- return void 0;
3143
- }
3144
- return this.prepareResponse(null);
3145
- }
3146
- prepareResponse(option) {
3147
- let index;
3148
- if (option == null) {
3149
- index = -1;
3150
- } else if (isIndexResponse(option)) {
3151
- index = option.index;
3152
- if (index < -1 || index >= this.count) {
3153
- throw new TypeError(`Index out of range: ${index}`);
3154
- }
3155
- } else {
3156
- index = this.chains.findIndex(
3157
- (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)
3158
- );
3159
- if (index === -1) {
3160
- throw new TypeError("Chain not found");
3161
- }
3162
- }
3163
- const buffer = new Uint8Array(4);
3164
- const view = new DataView(buffer.buffer);
3165
- view.setInt32(0, index, true);
3166
- return buffer;
3167
- }
2572
+ BinaryField("u8", 6)
2573
+ ], YGOProMsgEquip.prototype, "position", 2);
2574
+
2575
+ // src/protos/msg/proto/field-disabled.ts
2576
+ var YGOProMsgFieldDisabled = class extends YGOProMsgBase {
3168
2577
  };
3169
- YGOProMsgSelectChain.identifier = OcgcoreCommonConstants.MSG_SELECT_CHAIN;
3170
- __decorateClass([
3171
- BinaryField("u8", 0)
3172
- ], YGOProMsgSelectChain.prototype, "player", 2);
3173
- __decorateClass([
3174
- BinaryField("u8", 1)
3175
- ], YGOProMsgSelectChain.prototype, "count", 2);
3176
- __decorateClass([
3177
- BinaryField("u8", 2)
3178
- ], YGOProMsgSelectChain.prototype, "specialCount", 2);
3179
- __decorateClass([
3180
- BinaryField("i32", 3)
3181
- ], YGOProMsgSelectChain.prototype, "hint0", 2);
3182
- __decorateClass([
3183
- BinaryField("i32", 7)
3184
- ], YGOProMsgSelectChain.prototype, "hint1", 2);
2578
+ YGOProMsgFieldDisabled.identifier = OcgcoreCommonConstants.MSG_FIELD_DISABLED;
3185
2579
  __decorateClass([
3186
- BinaryField(() => YGOProMsgSelectChain_ChainInfo, 11, (obj) => obj.count)
3187
- ], YGOProMsgSelectChain.prototype, "chains", 2);
2580
+ BinaryField("u32", 0)
2581
+ ], YGOProMsgFieldDisabled.prototype, "disabledField", 2);
3188
2582
 
3189
- // src/protos/msg/proto/select-counter.ts
3190
- var YGOProMsgSelectCounter_CardInfo = class {
2583
+ // src/protos/msg/proto/flipsummoned.ts
2584
+ var YGOProMsgFlipSummoned = class extends YGOProMsgBase {
3191
2585
  };
2586
+ YGOProMsgFlipSummoned.identifier = OcgcoreCommonConstants.MSG_FLIPSUMMONED;
2587
+
2588
+ // src/protos/msg/proto/flipsummoning.ts
2589
+ var YGOProMsgFlipSummoning = class extends YGOProMsgBase {
2590
+ };
2591
+ YGOProMsgFlipSummoning.identifier = OcgcoreCommonConstants.MSG_FLIPSUMMONING;
3192
2592
  __decorateClass([
3193
2593
  BinaryField("i32", 0)
3194
- ], YGOProMsgSelectCounter_CardInfo.prototype, "code", 2);
2594
+ ], YGOProMsgFlipSummoning.prototype, "code", 2);
3195
2595
  __decorateClass([
3196
2596
  BinaryField("u8", 4)
3197
- ], YGOProMsgSelectCounter_CardInfo.prototype, "controller", 2);
2597
+ ], YGOProMsgFlipSummoning.prototype, "controller", 2);
3198
2598
  __decorateClass([
3199
2599
  BinaryField("u8", 5)
3200
- ], YGOProMsgSelectCounter_CardInfo.prototype, "location", 2);
2600
+ ], YGOProMsgFlipSummoning.prototype, "location", 2);
3201
2601
  __decorateClass([
3202
2602
  BinaryField("u8", 6)
3203
- ], YGOProMsgSelectCounter_CardInfo.prototype, "sequence", 2);
2603
+ ], YGOProMsgFlipSummoning.prototype, "sequence", 2);
3204
2604
  __decorateClass([
3205
- BinaryField("u16", 7)
3206
- ], YGOProMsgSelectCounter_CardInfo.prototype, "counterCount", 2);
3207
- var YGOProMsgSelectCounter = class extends YGOProMsgResponseBase {
3208
- responsePlayer() {
3209
- return this.player;
3210
- }
3211
- prepareResponse(counterOptions) {
3212
- const counterCounts = new Array(this.count).fill(0);
3213
- for (const option of counterOptions) {
3214
- let index;
3215
- if (isIndexResponse(option.card)) {
3216
- index = option.card.index;
3217
- if (index < 0 || index >= this.count) {
3218
- throw new TypeError(`Index out of range: ${index}`);
3219
- }
3220
- } else {
3221
- const card = option.card;
3222
- index = this.cards.findIndex(
3223
- (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)
3224
- );
3225
- if (index === -1) {
3226
- throw new TypeError("Card not found");
3227
- }
3228
- }
3229
- counterCounts[index] = option.count;
2605
+ BinaryField("u8", 7)
2606
+ ], YGOProMsgFlipSummoning.prototype, "position", 2);
2607
+
2608
+ // src/protos/msg/proto/hand-res.ts
2609
+ var YGOProMsgHandRes = class extends YGOProMsgBase {
2610
+ };
2611
+ YGOProMsgHandRes.identifier = OcgcoreCommonConstants.MSG_HAND_RES;
2612
+ __decorateClass([
2613
+ BinaryField("u8", 0)
2614
+ ], YGOProMsgHandRes.prototype, "result", 2);
2615
+
2616
+ // src/protos/msg/proto/hint.ts
2617
+ var HINT_TYPES_SEND_TO_SELF = /* @__PURE__ */ new Set([1, 2, 3, 5]);
2618
+ var HINT_TYPES_SEND_TO_OPPONENT = /* @__PURE__ */ new Set([4, 6, 7, 8, 9, 11]);
2619
+ var YGOProMsgHint = class extends YGOProMsgBase {
2620
+ getSendTargets() {
2621
+ if (HINT_TYPES_SEND_TO_SELF.has(this.type)) {
2622
+ return [this.player];
3230
2623
  }
3231
- const buffer = new Uint8Array(counterCounts.length * 2);
3232
- const view = new DataView(buffer.buffer);
3233
- counterCounts.forEach((count, i) => {
3234
- view.setUint16(i * 2, count, true);
3235
- });
3236
- return buffer;
2624
+ if (HINT_TYPES_SEND_TO_OPPONENT.has(this.type)) {
2625
+ return [1 - this.player, 7 /* OBSERVER */];
2626
+ }
2627
+ return SEND_TO_ALL;
3237
2628
  }
3238
2629
  };
3239
- YGOProMsgSelectCounter.identifier = OcgcoreCommonConstants.MSG_SELECT_COUNTER;
2630
+ YGOProMsgHint.identifier = OcgcoreCommonConstants.MSG_HINT;
3240
2631
  __decorateClass([
3241
2632
  BinaryField("u8", 0)
3242
- ], YGOProMsgSelectCounter.prototype, "player", 2);
2633
+ ], YGOProMsgHint.prototype, "type", 2);
3243
2634
  __decorateClass([
3244
- BinaryField("u16", 1)
3245
- ], YGOProMsgSelectCounter.prototype, "counterType", 2);
2635
+ BinaryField("u8", 1)
2636
+ ], YGOProMsgHint.prototype, "player", 2);
3246
2637
  __decorateClass([
3247
- BinaryField("u16", 3)
3248
- ], YGOProMsgSelectCounter.prototype, "counterCount", 2);
2638
+ BinaryField("i32", 2)
2639
+ ], YGOProMsgHint.prototype, "desc", 2);
2640
+
2641
+ // src/protos/msg/proto/lpupdate.ts
2642
+ var YGOProMsgLpUpdate = class extends YGOProMsgBase {
2643
+ };
2644
+ YGOProMsgLpUpdate.identifier = OcgcoreCommonConstants.MSG_LPUPDATE;
3249
2645
  __decorateClass([
3250
- BinaryField("u8", 5)
3251
- ], YGOProMsgSelectCounter.prototype, "count", 2);
2646
+ BinaryField("u8", 0)
2647
+ ], YGOProMsgLpUpdate.prototype, "player", 2);
3252
2648
  __decorateClass([
3253
- BinaryField(() => YGOProMsgSelectCounter_CardInfo, 6, (obj) => obj.count)
3254
- ], YGOProMsgSelectCounter.prototype, "cards", 2);
2649
+ BinaryField("i32", 1)
2650
+ ], YGOProMsgLpUpdate.prototype, "lp", 2);
2651
+
2652
+ // src/protos/msg/proto/match-kill.ts
2653
+ var YGOProMsgMatchKill = class extends YGOProMsgBase {
2654
+ };
2655
+ YGOProMsgMatchKill.identifier = OcgcoreCommonConstants.MSG_MATCH_KILL;
2656
+ __decorateClass([
2657
+ BinaryField("i32", 0)
2658
+ ], YGOProMsgMatchKill.prototype, "code", 2);
2659
+
2660
+ // src/protos/msg/proto/missed-effect.ts
2661
+ var YGOProMsgMissedEffect = class extends YGOProMsgBase {
2662
+ getSendTargets() {
2663
+ return [this.player];
2664
+ }
2665
+ };
2666
+ YGOProMsgMissedEffect.identifier = OcgcoreCommonConstants.MSG_MISSED_EFFECT;
2667
+ __decorateClass([
2668
+ BinaryField("u8", 0)
2669
+ ], YGOProMsgMissedEffect.prototype, "player", 2);
2670
+ __decorateClass([
2671
+ BinaryField("i32", 1)
2672
+ ], YGOProMsgMissedEffect.prototype, "code", 2);
2673
+ __decorateClass([
2674
+ BinaryField("i32", 5)
2675
+ ], YGOProMsgMissedEffect.prototype, "desc", 2);
3255
2676
 
3256
2677
  // src/vendor/script-constants.ts
3257
2678
  var OcgcoreScriptConstants = {
@@ -4091,6 +3512,747 @@ var OcgcoreScriptConstants = {
4091
3512
  TYPE_XYZ: 8388608
4092
3513
  };
4093
3514
 
3515
+ // src/protos/msg/proto/move.ts
3516
+ var YGOProMsgMove_CardLocation = class {
3517
+ };
3518
+ __decorateClass([
3519
+ BinaryField("u8", 0)
3520
+ ], YGOProMsgMove_CardLocation.prototype, "controller", 2);
3521
+ __decorateClass([
3522
+ BinaryField("u8", 1)
3523
+ ], YGOProMsgMove_CardLocation.prototype, "location", 2);
3524
+ __decorateClass([
3525
+ BinaryField("u8", 2)
3526
+ ], YGOProMsgMove_CardLocation.prototype, "sequence", 2);
3527
+ __decorateClass([
3528
+ BinaryField("u8", 3)
3529
+ ], YGOProMsgMove_CardLocation.prototype, "position", 2);
3530
+ var YGOProMsgMove = class extends YGOProMsgBase {
3531
+ opponentView() {
3532
+ const view = this.copy();
3533
+ const cl = view.current.location;
3534
+ const cp = view.current.position;
3535
+ if (cl & (OcgcoreScriptConstants.LOCATION_GRAVE | OcgcoreScriptConstants.LOCATION_OVERLAY)) {
3536
+ return view;
3537
+ }
3538
+ if (cl & (OcgcoreScriptConstants.LOCATION_DECK | OcgcoreScriptConstants.LOCATION_HAND) || cp & OcgcoreCommonConstants.POS_FACEDOWN) {
3539
+ view.code = 0;
3540
+ }
3541
+ return view;
3542
+ }
3543
+ teammateView() {
3544
+ const view = this.copy();
3545
+ const cl = view.current.location;
3546
+ const cp = view.current.position;
3547
+ if (cl & (OcgcoreScriptConstants.LOCATION_GRAVE | OcgcoreScriptConstants.LOCATION_OVERLAY)) {
3548
+ return view;
3549
+ }
3550
+ if (cl & (OcgcoreScriptConstants.LOCATION_DECK | OcgcoreScriptConstants.LOCATION_HAND)) {
3551
+ view.code = 0;
3552
+ }
3553
+ return view;
3554
+ }
3555
+ playerView(playerId) {
3556
+ if (playerId === 7 /* OBSERVER */) {
3557
+ return this.observerView();
3558
+ }
3559
+ if (playerId === this.current.controller) {
3560
+ return this.copy();
3561
+ }
3562
+ return this.opponentView();
3563
+ }
3564
+ };
3565
+ YGOProMsgMove.identifier = OcgcoreCommonConstants.MSG_MOVE;
3566
+ __decorateClass([
3567
+ BinaryField("i32", 0)
3568
+ ], YGOProMsgMove.prototype, "code", 2);
3569
+ __decorateClass([
3570
+ BinaryField(() => YGOProMsgMove_CardLocation, 4)
3571
+ ], YGOProMsgMove.prototype, "previous", 2);
3572
+ __decorateClass([
3573
+ BinaryField(() => YGOProMsgMove_CardLocation, 8)
3574
+ ], YGOProMsgMove.prototype, "current", 2);
3575
+ __decorateClass([
3576
+ BinaryField("i32", 12)
3577
+ ], YGOProMsgMove.prototype, "reason", 2);
3578
+
3579
+ // src/protos/msg/proto/new-phase.ts
3580
+ var YGOProMsgNewPhase = class extends YGOProMsgBase {
3581
+ };
3582
+ YGOProMsgNewPhase.identifier = OcgcoreCommonConstants.MSG_NEW_PHASE;
3583
+ __decorateClass([
3584
+ BinaryField("u16", 0)
3585
+ ], YGOProMsgNewPhase.prototype, "phase", 2);
3586
+
3587
+ // src/protos/msg/proto/new-turn.ts
3588
+ var YGOProMsgNewTurn = class extends YGOProMsgBase {
3589
+ };
3590
+ YGOProMsgNewTurn.identifier = OcgcoreCommonConstants.MSG_NEW_TURN;
3591
+ __decorateClass([
3592
+ BinaryField("u8", 0)
3593
+ ], YGOProMsgNewTurn.prototype, "player", 2);
3594
+
3595
+ // src/protos/msg/proto/pay-lpcost.ts
3596
+ var YGOProMsgPayLpCost = class extends YGOProMsgBase {
3597
+ };
3598
+ YGOProMsgPayLpCost.identifier = OcgcoreCommonConstants.MSG_PAY_LPCOST;
3599
+ __decorateClass([
3600
+ BinaryField("u8", 0)
3601
+ ], YGOProMsgPayLpCost.prototype, "player", 2);
3602
+ __decorateClass([
3603
+ BinaryField("i32", 1)
3604
+ ], YGOProMsgPayLpCost.prototype, "cost", 2);
3605
+
3606
+ // src/protos/msg/proto/player-hint.ts
3607
+ var YGOProMsgPlayerHint = class extends YGOProMsgBase {
3608
+ };
3609
+ YGOProMsgPlayerHint.identifier = OcgcoreCommonConstants.MSG_PLAYER_HINT;
3610
+ __decorateClass([
3611
+ BinaryField("u8", 0)
3612
+ ], YGOProMsgPlayerHint.prototype, "player", 2);
3613
+ __decorateClass([
3614
+ BinaryField("u8", 1)
3615
+ ], YGOProMsgPlayerHint.prototype, "type", 2);
3616
+ __decorateClass([
3617
+ BinaryField("i32", 2)
3618
+ ], YGOProMsgPlayerHint.prototype, "value", 2);
3619
+
3620
+ // src/protos/msg/proto/pos-change.ts
3621
+ var YGOProMsgPosChange_CardLocation = class {
3622
+ };
3623
+ __decorateClass([
3624
+ BinaryField("u8", 0)
3625
+ ], YGOProMsgPosChange_CardLocation.prototype, "controller", 2);
3626
+ __decorateClass([
3627
+ BinaryField("u8", 1)
3628
+ ], YGOProMsgPosChange_CardLocation.prototype, "location", 2);
3629
+ __decorateClass([
3630
+ BinaryField("u8", 2)
3631
+ ], YGOProMsgPosChange_CardLocation.prototype, "sequence", 2);
3632
+ var YGOProMsgPosChange = class extends YGOProMsgBase {
3633
+ };
3634
+ YGOProMsgPosChange.identifier = OcgcoreCommonConstants.MSG_POS_CHANGE;
3635
+ __decorateClass([
3636
+ BinaryField(() => YGOProMsgPosChange_CardLocation, 0)
3637
+ ], YGOProMsgPosChange.prototype, "card", 2);
3638
+ __decorateClass([
3639
+ BinaryField("u8", 3)
3640
+ ], YGOProMsgPosChange.prototype, "previousPosition", 2);
3641
+ __decorateClass([
3642
+ BinaryField("u8", 4)
3643
+ ], YGOProMsgPosChange.prototype, "currentPosition", 2);
3644
+
3645
+ // src/protos/msg/proto/random-selected.ts
3646
+ var YGOProMsgRandomSelected = class extends YGOProMsgBase {
3647
+ };
3648
+ YGOProMsgRandomSelected.identifier = OcgcoreCommonConstants.MSG_RANDOM_SELECTED;
3649
+ __decorateClass([
3650
+ BinaryField("u8", 0)
3651
+ ], YGOProMsgRandomSelected.prototype, "player", 2);
3652
+ __decorateClass([
3653
+ BinaryField("u8", 1)
3654
+ ], YGOProMsgRandomSelected.prototype, "count", 2);
3655
+ __decorateClass([
3656
+ BinaryField("i32", 2, (obj) => obj.count)
3657
+ ], YGOProMsgRandomSelected.prototype, "cards", 2);
3658
+
3659
+ // src/protos/msg/proto/recover.ts
3660
+ var YGOProMsgRecover = class extends YGOProMsgBase {
3661
+ };
3662
+ YGOProMsgRecover.identifier = OcgcoreCommonConstants.MSG_RECOVER;
3663
+ __decorateClass([
3664
+ BinaryField("u8", 0)
3665
+ ], YGOProMsgRecover.prototype, "player", 2);
3666
+ __decorateClass([
3667
+ BinaryField("i32", 1)
3668
+ ], YGOProMsgRecover.prototype, "value", 2);
3669
+
3670
+ // src/protos/msg/proto/reload-field.ts
3671
+ var YGOProMsgReloadField_ZoneCard = class {
3672
+ };
3673
+ var YGOProMsgReloadField_PlayerInfo = class {
3674
+ };
3675
+ var YGOProMsgReloadField_ChainInfo = class {
3676
+ };
3677
+ var YGOProMsgReloadField = class extends YGOProMsgBase {
3678
+ fromPayload(data) {
3679
+ if (data.length < 1) {
3680
+ throw new Error("MSG data too short");
3681
+ }
3682
+ const msgType = data[0];
3683
+ if (msgType !== this.identifier) {
3684
+ throw new Error(
3685
+ `MSG type mismatch: expected ${this.identifier}, got ${msgType}`
3686
+ );
3687
+ }
3688
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
3689
+ let offset = 1;
3690
+ this.duelRule = view.getUint8(offset++);
3691
+ this.players = [];
3692
+ for (let i = 0; i < 2; i++) {
3693
+ const player = {
3694
+ lp: view.getInt32(offset, true),
3695
+ mzone: [],
3696
+ szone: [],
3697
+ deckCount: 0,
3698
+ handCount: 0,
3699
+ graveCount: 0,
3700
+ removedCount: 0,
3701
+ extraCount: 0,
3702
+ extraPCount: 0
3703
+ };
3704
+ offset += 4;
3705
+ for (let seq = 0; seq < 7; seq++) {
3706
+ const occupied = view.getUint8(offset++);
3707
+ const card = { occupied };
3708
+ if (occupied) {
3709
+ card.position = view.getUint8(offset++);
3710
+ card.xyzCount = view.getUint8(offset++);
3711
+ }
3712
+ player.mzone.push(card);
3713
+ }
3714
+ for (let seq = 0; seq < 8; seq++) {
3715
+ const occupied = view.getUint8(offset++);
3716
+ const card = { occupied };
3717
+ if (occupied) {
3718
+ card.position = view.getUint8(offset++);
3719
+ }
3720
+ player.szone.push(card);
3721
+ }
3722
+ player.deckCount = view.getUint8(offset++);
3723
+ player.handCount = view.getUint8(offset++);
3724
+ player.graveCount = view.getUint8(offset++);
3725
+ player.removedCount = view.getUint8(offset++);
3726
+ player.extraCount = view.getUint8(offset++);
3727
+ player.extraPCount = view.getUint8(offset++);
3728
+ this.players.push(player);
3729
+ }
3730
+ const chainCount = view.getUint8(offset++);
3731
+ this.chains = [];
3732
+ for (let i = 0; i < chainCount; i++) {
3733
+ const chain = {
3734
+ code: view.getInt32(offset, true),
3735
+ chainCardController: view.getUint8(offset + 4),
3736
+ chainCardLocation: view.getUint8(offset + 5),
3737
+ chainCardSequence: view.getUint8(offset + 6),
3738
+ chainCardSubsequence: view.getUint8(offset + 7),
3739
+ triggerController: view.getUint8(offset + 8),
3740
+ triggerLocation: view.getUint8(offset + 9),
3741
+ triggerSequence: view.getUint8(offset + 10),
3742
+ desc: view.getInt32(offset + 11, true)
3743
+ };
3744
+ offset += 15;
3745
+ this.chains.push(chain);
3746
+ }
3747
+ return this;
3748
+ }
3749
+ toPayload() {
3750
+ let size = 1 + 1;
3751
+ for (const player of this.players) {
3752
+ size += 4;
3753
+ for (const card of player.mzone) {
3754
+ size += 1;
3755
+ if (card.occupied) {
3756
+ size += 2;
3757
+ }
3758
+ }
3759
+ for (const card of player.szone) {
3760
+ size += 1;
3761
+ if (card.occupied) {
3762
+ size += 1;
3763
+ }
3764
+ }
3765
+ size += 6;
3766
+ }
3767
+ size += 1;
3768
+ size += this.chains.length * 15;
3769
+ const result = new Uint8Array(size);
3770
+ const view = new DataView(result.buffer);
3771
+ let offset = 0;
3772
+ result[offset++] = this.identifier;
3773
+ result[offset++] = this.duelRule;
3774
+ for (const player of this.players) {
3775
+ view.setInt32(offset, player.lp, true);
3776
+ offset += 4;
3777
+ for (const card of player.mzone) {
3778
+ result[offset++] = card.occupied;
3779
+ if (card.occupied) {
3780
+ result[offset++] = card.position || 0;
3781
+ result[offset++] = card.xyzCount || 0;
3782
+ }
3783
+ }
3784
+ for (const card of player.szone) {
3785
+ result[offset++] = card.occupied;
3786
+ if (card.occupied) {
3787
+ result[offset++] = card.position || 0;
3788
+ }
3789
+ }
3790
+ result[offset++] = player.deckCount;
3791
+ result[offset++] = player.handCount;
3792
+ result[offset++] = player.graveCount;
3793
+ result[offset++] = player.removedCount;
3794
+ result[offset++] = player.extraCount;
3795
+ result[offset++] = player.extraPCount;
3796
+ }
3797
+ result[offset++] = this.chains.length;
3798
+ for (const chain of this.chains) {
3799
+ view.setInt32(offset, chain.code, true);
3800
+ result[offset + 4] = chain.chainCardController;
3801
+ result[offset + 5] = chain.chainCardLocation;
3802
+ result[offset + 6] = chain.chainCardSequence;
3803
+ result[offset + 7] = chain.chainCardSubsequence;
3804
+ result[offset + 8] = chain.triggerController;
3805
+ result[offset + 9] = chain.triggerLocation;
3806
+ result[offset + 10] = chain.triggerSequence;
3807
+ view.setInt32(offset + 11, chain.desc, true);
3808
+ offset += 15;
3809
+ }
3810
+ return result;
3811
+ }
3812
+ };
3813
+ YGOProMsgReloadField.identifier = 162;
3814
+
3815
+ // src/protos/msg/proto/remove-counter.ts
3816
+ var YGOProMsgRemoveCounter = class extends YGOProMsgBase {
3817
+ };
3818
+ YGOProMsgRemoveCounter.identifier = OcgcoreCommonConstants.MSG_REMOVE_COUNTER;
3819
+ __decorateClass([
3820
+ BinaryField("u16", 0)
3821
+ ], YGOProMsgRemoveCounter.prototype, "counterType", 2);
3822
+ __decorateClass([
3823
+ BinaryField("u8", 2)
3824
+ ], YGOProMsgRemoveCounter.prototype, "controller", 2);
3825
+ __decorateClass([
3826
+ BinaryField("u8", 3)
3827
+ ], YGOProMsgRemoveCounter.prototype, "location", 2);
3828
+ __decorateClass([
3829
+ BinaryField("u8", 4)
3830
+ ], YGOProMsgRemoveCounter.prototype, "sequence", 2);
3831
+ __decorateClass([
3832
+ BinaryField("u16", 5)
3833
+ ], YGOProMsgRemoveCounter.prototype, "count", 2);
3834
+
3835
+ // src/protos/msg/proto/reset-time.ts
3836
+ var YGOProMsgResetTime = class extends YGOProMsgBase {
3837
+ getSendTargets() {
3838
+ return [];
3839
+ }
3840
+ };
3841
+ YGOProMsgResetTime.identifier = OcgcoreCommonConstants.MSG_RESET_TIME;
3842
+ __decorateClass([
3843
+ BinaryField("i8", 0)
3844
+ ], YGOProMsgResetTime.prototype, "player", 2);
3845
+ __decorateClass([
3846
+ BinaryField("i16", 1)
3847
+ ], YGOProMsgResetTime.prototype, "time", 2);
3848
+
3849
+ // src/protos/msg/proto/retry.ts
3850
+ var YGOProMsgRetry = class extends YGOProMsgBase {
3851
+ getSendTargets() {
3852
+ return [];
3853
+ }
3854
+ };
3855
+ YGOProMsgRetry.identifier = OcgcoreCommonConstants.MSG_RETRY;
3856
+
3857
+ // src/protos/msg/proto/reverse-deck.ts
3858
+ var YGOProMsgReverseDeck = class extends YGOProMsgBase {
3859
+ };
3860
+ YGOProMsgReverseDeck.identifier = OcgcoreCommonConstants.MSG_REVERSE_DECK;
3861
+
3862
+ // src/protos/msg/proto/rock-paper-scissors.ts
3863
+ var YGOProMsgRockPaperScissors = class extends YGOProMsgResponseBase {
3864
+ responsePlayer() {
3865
+ return this.player;
3866
+ }
3867
+ prepareResponse(choice) {
3868
+ if (choice < 1 /* ROCK */ || choice > 3 /* PAPER */) {
3869
+ throw new TypeError(
3870
+ `Invalid choice: ${choice}. Must be 1 (ROCK), 2 (SCISSORS), or 3 (PAPER)`
3871
+ );
3872
+ }
3873
+ const buffer = new Uint8Array(1);
3874
+ buffer[0] = choice;
3875
+ return buffer;
3876
+ }
3877
+ };
3878
+ YGOProMsgRockPaperScissors.identifier = OcgcoreCommonConstants.MSG_ROCK_PAPER_SCISSORS;
3879
+ __decorateClass([
3880
+ BinaryField("u8", 0)
3881
+ ], YGOProMsgRockPaperScissors.prototype, "player", 2);
3882
+
3883
+ // src/protos/msg/proto/select-battlecmd.ts
3884
+ var BattleCmdType = /* @__PURE__ */ ((BattleCmdType2) => {
3885
+ BattleCmdType2[BattleCmdType2["ACTIVATE"] = 0] = "ACTIVATE";
3886
+ BattleCmdType2[BattleCmdType2["ATTACK"] = 1] = "ATTACK";
3887
+ BattleCmdType2[BattleCmdType2["TO_M2"] = 2] = "TO_M2";
3888
+ BattleCmdType2[BattleCmdType2["TO_EP"] = 3] = "TO_EP";
3889
+ return BattleCmdType2;
3890
+ })(BattleCmdType || {});
3891
+ var YGOProMsgSelectBattleCmd_ActivatableInfo = class {
3892
+ };
3893
+ __decorateClass([
3894
+ BinaryField("i32", 0)
3895
+ ], YGOProMsgSelectBattleCmd_ActivatableInfo.prototype, "code", 2);
3896
+ __decorateClass([
3897
+ BinaryField("u8", 4)
3898
+ ], YGOProMsgSelectBattleCmd_ActivatableInfo.prototype, "controller", 2);
3899
+ __decorateClass([
3900
+ BinaryField("u8", 5)
3901
+ ], YGOProMsgSelectBattleCmd_ActivatableInfo.prototype, "location", 2);
3902
+ __decorateClass([
3903
+ BinaryField("u8", 6)
3904
+ ], YGOProMsgSelectBattleCmd_ActivatableInfo.prototype, "sequence", 2);
3905
+ __decorateClass([
3906
+ BinaryField("i32", 7)
3907
+ ], YGOProMsgSelectBattleCmd_ActivatableInfo.prototype, "desc", 2);
3908
+ var YGOProMsgSelectBattleCmd_AttackableInfo = class {
3909
+ };
3910
+ __decorateClass([
3911
+ BinaryField("i32", 0)
3912
+ ], YGOProMsgSelectBattleCmd_AttackableInfo.prototype, "code", 2);
3913
+ __decorateClass([
3914
+ BinaryField("u8", 4)
3915
+ ], YGOProMsgSelectBattleCmd_AttackableInfo.prototype, "controller", 2);
3916
+ __decorateClass([
3917
+ BinaryField("u8", 5)
3918
+ ], YGOProMsgSelectBattleCmd_AttackableInfo.prototype, "location", 2);
3919
+ __decorateClass([
3920
+ BinaryField("u8", 6)
3921
+ ], YGOProMsgSelectBattleCmd_AttackableInfo.prototype, "sequence", 2);
3922
+ __decorateClass([
3923
+ BinaryField("u8", 7)
3924
+ ], YGOProMsgSelectBattleCmd_AttackableInfo.prototype, "directAttack", 2);
3925
+ var YGOProMsgSelectBattleCmd = class extends YGOProMsgResponseBase {
3926
+ responsePlayer() {
3927
+ return this.player;
3928
+ }
3929
+ prepareResponse(type, option) {
3930
+ let sequence;
3931
+ if (type === 0 /* ACTIVATE */) {
3932
+ if (option == null) {
3933
+ throw new TypeError("Option required for ACTIVATE");
3934
+ }
3935
+ if (isIndexResponse(option)) {
3936
+ sequence = option.index;
3937
+ if (sequence < 0 || sequence >= this.activatableCount) {
3938
+ throw new TypeError(`Index out of range: ${sequence}`);
3939
+ }
3940
+ } else {
3941
+ const idx = this.activatableCards.findIndex(
3942
+ (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)
3943
+ );
3944
+ if (idx === -1) {
3945
+ throw new TypeError("Activatable card not found");
3946
+ }
3947
+ sequence = idx;
3948
+ }
3949
+ } else if (type === 1 /* ATTACK */) {
3950
+ if (option == null) {
3951
+ throw new TypeError("Option required for ATTACK");
3952
+ }
3953
+ if (isIndexResponse(option)) {
3954
+ sequence = option.index;
3955
+ if (sequence < 0 || sequence >= this.attackableCount) {
3956
+ throw new TypeError(`Index out of range: ${sequence}`);
3957
+ }
3958
+ } else {
3959
+ const idx = this.attackableCards.findIndex(
3960
+ (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)
3961
+ );
3962
+ if (idx === -1) {
3963
+ throw new TypeError("Attackable card not found");
3964
+ }
3965
+ sequence = idx;
3966
+ }
3967
+ } else if (type === 2 /* TO_M2 */) {
3968
+ if (this.canM2 === 0) {
3969
+ throw new TypeError("Cannot go to M2");
3970
+ }
3971
+ sequence = 0;
3972
+ } else if (type === 3 /* TO_EP */) {
3973
+ if (this.canEp === 0) {
3974
+ throw new TypeError("Cannot go to EP");
3975
+ }
3976
+ sequence = 0;
3977
+ } else {
3978
+ throw new TypeError(`Unknown type: ${type}`);
3979
+ }
3980
+ const buffer = new Uint8Array(4);
3981
+ const view = new DataView(buffer.buffer);
3982
+ view.setUint32(0, sequence << 16 | type, true);
3983
+ return buffer;
3984
+ }
3985
+ };
3986
+ YGOProMsgSelectBattleCmd.identifier = OcgcoreCommonConstants.MSG_SELECT_BATTLECMD;
3987
+ __decorateClass([
3988
+ BinaryField("u8", 0)
3989
+ ], YGOProMsgSelectBattleCmd.prototype, "player", 2);
3990
+ __decorateClass([
3991
+ BinaryField("u8", 1)
3992
+ ], YGOProMsgSelectBattleCmd.prototype, "activatableCount", 2);
3993
+ __decorateClass([
3994
+ BinaryField(
3995
+ () => YGOProMsgSelectBattleCmd_ActivatableInfo,
3996
+ 2,
3997
+ (obj) => obj.activatableCount
3998
+ )
3999
+ ], YGOProMsgSelectBattleCmd.prototype, "activatableCards", 2);
4000
+ __decorateClass([
4001
+ BinaryField("u8", (obj) => {
4002
+ return 2 + obj.activatableCount * 11;
4003
+ })
4004
+ ], YGOProMsgSelectBattleCmd.prototype, "attackableCount", 2);
4005
+ __decorateClass([
4006
+ BinaryField(
4007
+ () => YGOProMsgSelectBattleCmd_AttackableInfo,
4008
+ (obj) => {
4009
+ return 3 + obj.activatableCount * 11;
4010
+ },
4011
+ (obj) => obj.attackableCount
4012
+ )
4013
+ ], YGOProMsgSelectBattleCmd.prototype, "attackableCards", 2);
4014
+ __decorateClass([
4015
+ BinaryField("u8", (obj) => {
4016
+ return 3 + obj.activatableCount * 11 + obj.attackableCount * 8;
4017
+ })
4018
+ ], YGOProMsgSelectBattleCmd.prototype, "canM2", 2);
4019
+ __decorateClass([
4020
+ BinaryField("u8", (obj) => {
4021
+ return 4 + obj.activatableCount * 11 + obj.attackableCount * 8;
4022
+ })
4023
+ ], YGOProMsgSelectBattleCmd.prototype, "canEp", 2);
4024
+
4025
+ // src/protos/msg/proto/select-card.ts
4026
+ var YGOProMsgSelectCard_CardInfo = class {
4027
+ };
4028
+ __decorateClass([
4029
+ BinaryField("i32", 0)
4030
+ ], YGOProMsgSelectCard_CardInfo.prototype, "code", 2);
4031
+ __decorateClass([
4032
+ BinaryField("u8", 4)
4033
+ ], YGOProMsgSelectCard_CardInfo.prototype, "controller", 2);
4034
+ __decorateClass([
4035
+ BinaryField("u8", 5)
4036
+ ], YGOProMsgSelectCard_CardInfo.prototype, "location", 2);
4037
+ __decorateClass([
4038
+ BinaryField("u8", 6)
4039
+ ], YGOProMsgSelectCard_CardInfo.prototype, "sequence", 2);
4040
+ __decorateClass([
4041
+ BinaryField("u8", 7)
4042
+ ], YGOProMsgSelectCard_CardInfo.prototype, "subsequence", 2);
4043
+ var YGOProMsgSelectCard = class extends YGOProMsgResponseBase {
4044
+ responsePlayer() {
4045
+ return this.player;
4046
+ }
4047
+ defaultResponse() {
4048
+ if (this.cancelable === 0) {
4049
+ return void 0;
4050
+ }
4051
+ return this.prepareResponse(null);
4052
+ }
4053
+ prepareResponse(cardOptions) {
4054
+ if (cardOptions == null) {
4055
+ const buffer2 = new Uint8Array(4);
4056
+ const view = new DataView(buffer2.buffer);
4057
+ view.setInt32(0, -1, true);
4058
+ return buffer2;
4059
+ }
4060
+ const indices = [];
4061
+ const usedIndices = /* @__PURE__ */ new Set();
4062
+ for (const option of cardOptions) {
4063
+ let index;
4064
+ if (isIndexResponse(option)) {
4065
+ index = option.index;
4066
+ if (index < 0 || index >= this.count) {
4067
+ throw new TypeError(`Index out of range: ${index}`);
4068
+ }
4069
+ } else {
4070
+ index = this.cards.findIndex(
4071
+ (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)
4072
+ );
4073
+ if (index === -1) {
4074
+ throw new TypeError("Card not found");
4075
+ }
4076
+ }
4077
+ indices.push(index);
4078
+ usedIndices.add(index);
4079
+ }
4080
+ const buffer = new Uint8Array(1 + indices.length);
4081
+ buffer[0] = indices.length;
4082
+ indices.forEach((idx, i) => {
4083
+ buffer[1 + i] = idx;
4084
+ });
4085
+ return buffer;
4086
+ }
4087
+ };
4088
+ YGOProMsgSelectCard.identifier = OcgcoreCommonConstants.MSG_SELECT_CARD;
4089
+ __decorateClass([
4090
+ BinaryField("u8", 0)
4091
+ ], YGOProMsgSelectCard.prototype, "player", 2);
4092
+ __decorateClass([
4093
+ BinaryField("u8", 1)
4094
+ ], YGOProMsgSelectCard.prototype, "cancelable", 2);
4095
+ __decorateClass([
4096
+ BinaryField("u8", 2)
4097
+ ], YGOProMsgSelectCard.prototype, "min", 2);
4098
+ __decorateClass([
4099
+ BinaryField("u8", 3)
4100
+ ], YGOProMsgSelectCard.prototype, "max", 2);
4101
+ __decorateClass([
4102
+ BinaryField("u8", 4)
4103
+ ], YGOProMsgSelectCard.prototype, "count", 2);
4104
+ __decorateClass([
4105
+ BinaryField(() => YGOProMsgSelectCard_CardInfo, 5, (obj) => obj.count)
4106
+ ], YGOProMsgSelectCard.prototype, "cards", 2);
4107
+
4108
+ // src/protos/msg/proto/select-chain.ts
4109
+ var YGOProMsgSelectChain_ChainInfo = class {
4110
+ };
4111
+ __decorateClass([
4112
+ BinaryField("u8", 0)
4113
+ ], YGOProMsgSelectChain_ChainInfo.prototype, "edesc", 2);
4114
+ __decorateClass([
4115
+ BinaryField("u8", 1)
4116
+ ], YGOProMsgSelectChain_ChainInfo.prototype, "forced", 2);
4117
+ __decorateClass([
4118
+ BinaryField("i32", 2)
4119
+ ], YGOProMsgSelectChain_ChainInfo.prototype, "code", 2);
4120
+ __decorateClass([
4121
+ BinaryField("u8", 6)
4122
+ ], YGOProMsgSelectChain_ChainInfo.prototype, "controller", 2);
4123
+ __decorateClass([
4124
+ BinaryField("u8", 7)
4125
+ ], YGOProMsgSelectChain_ChainInfo.prototype, "location", 2);
4126
+ __decorateClass([
4127
+ BinaryField("u8", 8)
4128
+ ], YGOProMsgSelectChain_ChainInfo.prototype, "sequence", 2);
4129
+ __decorateClass([
4130
+ BinaryField("u8", 9)
4131
+ ], YGOProMsgSelectChain_ChainInfo.prototype, "subsequence", 2);
4132
+ __decorateClass([
4133
+ BinaryField("i32", 10)
4134
+ ], YGOProMsgSelectChain_ChainInfo.prototype, "desc", 2);
4135
+ var YGOProMsgSelectChain = class extends YGOProMsgResponseBase {
4136
+ responsePlayer() {
4137
+ return this.player;
4138
+ }
4139
+ defaultResponse() {
4140
+ const hasForced = this.chains.some((chain) => chain.forced !== 0);
4141
+ if (hasForced) {
4142
+ return void 0;
4143
+ }
4144
+ return this.prepareResponse(null);
4145
+ }
4146
+ prepareResponse(option) {
4147
+ let index;
4148
+ if (option == null) {
4149
+ index = -1;
4150
+ } else if (isIndexResponse(option)) {
4151
+ index = option.index;
4152
+ if (index < -1 || index >= this.count) {
4153
+ throw new TypeError(`Index out of range: ${index}`);
4154
+ }
4155
+ } else {
4156
+ index = this.chains.findIndex(
4157
+ (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)
4158
+ );
4159
+ if (index === -1) {
4160
+ throw new TypeError("Chain not found");
4161
+ }
4162
+ }
4163
+ const buffer = new Uint8Array(4);
4164
+ const view = new DataView(buffer.buffer);
4165
+ view.setInt32(0, index, true);
4166
+ return buffer;
4167
+ }
4168
+ };
4169
+ YGOProMsgSelectChain.identifier = OcgcoreCommonConstants.MSG_SELECT_CHAIN;
4170
+ __decorateClass([
4171
+ BinaryField("u8", 0)
4172
+ ], YGOProMsgSelectChain.prototype, "player", 2);
4173
+ __decorateClass([
4174
+ BinaryField("u8", 1)
4175
+ ], YGOProMsgSelectChain.prototype, "count", 2);
4176
+ __decorateClass([
4177
+ BinaryField("u8", 2)
4178
+ ], YGOProMsgSelectChain.prototype, "specialCount", 2);
4179
+ __decorateClass([
4180
+ BinaryField("i32", 3)
4181
+ ], YGOProMsgSelectChain.prototype, "hint0", 2);
4182
+ __decorateClass([
4183
+ BinaryField("i32", 7)
4184
+ ], YGOProMsgSelectChain.prototype, "hint1", 2);
4185
+ __decorateClass([
4186
+ BinaryField(() => YGOProMsgSelectChain_ChainInfo, 11, (obj) => obj.count)
4187
+ ], YGOProMsgSelectChain.prototype, "chains", 2);
4188
+
4189
+ // src/protos/msg/proto/select-counter.ts
4190
+ var YGOProMsgSelectCounter_CardInfo = class {
4191
+ };
4192
+ __decorateClass([
4193
+ BinaryField("i32", 0)
4194
+ ], YGOProMsgSelectCounter_CardInfo.prototype, "code", 2);
4195
+ __decorateClass([
4196
+ BinaryField("u8", 4)
4197
+ ], YGOProMsgSelectCounter_CardInfo.prototype, "controller", 2);
4198
+ __decorateClass([
4199
+ BinaryField("u8", 5)
4200
+ ], YGOProMsgSelectCounter_CardInfo.prototype, "location", 2);
4201
+ __decorateClass([
4202
+ BinaryField("u8", 6)
4203
+ ], YGOProMsgSelectCounter_CardInfo.prototype, "sequence", 2);
4204
+ __decorateClass([
4205
+ BinaryField("u16", 7)
4206
+ ], YGOProMsgSelectCounter_CardInfo.prototype, "counterCount", 2);
4207
+ var YGOProMsgSelectCounter = class extends YGOProMsgResponseBase {
4208
+ responsePlayer() {
4209
+ return this.player;
4210
+ }
4211
+ prepareResponse(counterOptions) {
4212
+ const counterCounts = new Array(this.count).fill(0);
4213
+ for (const option of counterOptions) {
4214
+ let index;
4215
+ if (isIndexResponse(option.card)) {
4216
+ index = option.card.index;
4217
+ if (index < 0 || index >= this.count) {
4218
+ throw new TypeError(`Index out of range: ${index}`);
4219
+ }
4220
+ } else {
4221
+ const card = option.card;
4222
+ index = this.cards.findIndex(
4223
+ (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)
4224
+ );
4225
+ if (index === -1) {
4226
+ throw new TypeError("Card not found");
4227
+ }
4228
+ }
4229
+ counterCounts[index] = option.count;
4230
+ }
4231
+ const buffer = new Uint8Array(counterCounts.length * 2);
4232
+ const view = new DataView(buffer.buffer);
4233
+ counterCounts.forEach((count, i) => {
4234
+ view.setUint16(i * 2, count, true);
4235
+ });
4236
+ return buffer;
4237
+ }
4238
+ };
4239
+ YGOProMsgSelectCounter.identifier = OcgcoreCommonConstants.MSG_SELECT_COUNTER;
4240
+ __decorateClass([
4241
+ BinaryField("u8", 0)
4242
+ ], YGOProMsgSelectCounter.prototype, "player", 2);
4243
+ __decorateClass([
4244
+ BinaryField("u16", 1)
4245
+ ], YGOProMsgSelectCounter.prototype, "counterType", 2);
4246
+ __decorateClass([
4247
+ BinaryField("u16", 3)
4248
+ ], YGOProMsgSelectCounter.prototype, "counterCount", 2);
4249
+ __decorateClass([
4250
+ BinaryField("u8", 5)
4251
+ ], YGOProMsgSelectCounter.prototype, "count", 2);
4252
+ __decorateClass([
4253
+ BinaryField(() => YGOProMsgSelectCounter_CardInfo, 6, (obj) => obj.count)
4254
+ ], YGOProMsgSelectCounter.prototype, "cards", 2);
4255
+
4094
4256
  // src/protos/msg/proto/select-place-common.ts
4095
4257
  var YGOProMsgSelectPlaceCommon = class extends YGOProMsgResponseBase {
4096
4258
  getSelectablePlaces() {
@@ -4926,6 +5088,25 @@ YGOProMsgSpSummoned.identifier = OcgcoreCommonConstants.MSG_SPSUMMONED;
4926
5088
 
4927
5089
  // src/protos/msg/proto/spsummoning.ts
4928
5090
  var YGOProMsgSpSummoning = class extends YGOProMsgBase {
5091
+ opponentView() {
5092
+ const view = this.copy();
5093
+ if (view.position & OcgcoreCommonConstants.POS_FACEDOWN) {
5094
+ view.code = 0;
5095
+ }
5096
+ return view;
5097
+ }
5098
+ teammateView() {
5099
+ return this.copy();
5100
+ }
5101
+ playerView(playerId) {
5102
+ if (playerId === 7 /* OBSERVER */) {
5103
+ return this.observerView();
5104
+ }
5105
+ if (playerId === this.controller) {
5106
+ return this.copy();
5107
+ }
5108
+ return this.opponentView();
5109
+ }
4929
5110
  };
4930
5111
  YGOProMsgSpSummoning.identifier = OcgcoreCommonConstants.MSG_SPSUMMONING;
4931
5112
  __decorateClass([
@@ -5144,6 +5325,9 @@ var YGOProMsgUpdateCard = class extends YGOProMsgBase {
5144
5325
  }
5145
5326
  }
5146
5327
  playerView(playerId) {
5328
+ if (playerId === 7 /* OBSERVER */) {
5329
+ return this.observerView();
5330
+ }
5147
5331
  if (this.controller === playerId) {
5148
5332
  return this.copy();
5149
5333
  }
@@ -5193,6 +5377,9 @@ var YGOProMsgUpdateCard = class extends YGOProMsgBase {
5193
5377
  result.set(cardPayload, 8);
5194
5378
  return result;
5195
5379
  }
5380
+ getSendTargets() {
5381
+ return [];
5382
+ }
5196
5383
  };
5197
5384
  YGOProMsgUpdateCard.identifier = OcgcoreCommonConstants.MSG_UPDATE_CARD;
5198
5385
 
@@ -5296,12 +5483,18 @@ var YGOProMsgUpdateData = class extends YGOProMsgBase {
5296
5483
  }
5297
5484
  return result;
5298
5485
  }
5486
+ getSendTargets() {
5487
+ return [this.player, 1 - this.player, 7 /* OBSERVER */];
5488
+ }
5299
5489
  };
5300
5490
  YGOProMsgUpdateData.identifier = 6;
5301
5491
 
5302
5492
  // src/protos/msg/proto/waiting.ts
5303
5493
  var YGOProMsgWaiting = class extends YGOProMsgBase {
5304
5494
  // MSG_WAITING
5495
+ getSendTargets() {
5496
+ return [];
5497
+ }
5305
5498
  };
5306
5499
  YGOProMsgWaiting.identifier = 3;
5307
5500
 
@@ -5774,80 +5967,6 @@ YGOProStoc.register(YGOProStocHsWatchChange);
5774
5967
  YGOProStoc.register(YGOProStocTeammateSurrender);
5775
5968
  YGOProStoc.register(YGOProStocFieldFinish);
5776
5969
  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
5970
  // Annotate the CommonJS export names for ESM import in node:
5852
5971
  0 && (module.exports = {
5853
5972
  BattleCmdType,
@@ -5869,6 +5988,8 @@ var RoomStatus = /* @__PURE__ */ ((RoomStatus2) => {
5869
5988
  OcgcoreScriptConstants,
5870
5989
  PlayerChangeState,
5871
5990
  RoomStatus,
5991
+ SEND_TO_ALL,
5992
+ SEND_TO_PLAYERS,
5872
5993
  SrvproRoomInfo,
5873
5994
  TurnPlayerResult,
5874
5995
  YGOProCtos,