dredless 1.2.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4121,6 +4121,8 @@
4121
4121
  summarizeProjectile: () => summarizeProjectile,
4122
4122
  summarizePusher: () => summarizePusher,
4123
4123
  summarizePusherBeam: () => summarizePusherBeam,
4124
+ summarizePvpEvent: () => summarizePvpEvent,
4125
+ summarizePvpPartyEntry: () => summarizePvpPartyEntry,
4124
4126
  summarizeRcd: () => summarizeRcd,
4125
4127
  summarizeRecycler: () => summarizeRecycler,
4126
4128
  summarizeShieldGenerator: () => summarizeShieldGenerator,
@@ -4810,6 +4812,19 @@
4810
4812
  defaults: { q28: 10 },
4811
4813
  fields: numericFields({ 1: 20, 2: 24, 4: 28 })
4812
4814
  }],
4815
+ [33, {
4816
+ name: "pvp_event",
4817
+ fields: numericFields({ 2: 20, 4: 24, 8: 28, 16: 32, 32: 36, 64: 40, 128: 44, 256: 48, 512: 52 })
4818
+ }],
4819
+ [34, { name: "pvp_party_config", fields: numericFields({ 2: 20 }) }],
4820
+ [35, {
4821
+ name: "pvp_party_entry",
4822
+ packedBeforeValues: true,
4823
+ orderedValues: true,
4824
+ packedBits: [{ bit: 4, offset: 37 }],
4825
+ blobs: [{ bit: 1, offset: 24 }],
4826
+ fields: numericFields({ 2: 20 })
4827
+ }],
4813
4828
  [37, { name: "loose_item_marker", packedBits: [{ bit: 2, offset: 29 }], fields: numericFields({ 1: 20, 4: 24 }) }],
4814
4829
  [38, { name: "flag_state", packedBits: [{ bit: 1, offset: 21 }], fields: [] }],
4815
4830
  [39, { name: "comms_transmit", ...TWO_FIELD_SPEC }],
@@ -4972,6 +4987,9 @@
4972
4987
  [93, 30],
4973
4988
  [94, 31],
4974
4989
  [95, 32],
4990
+ [96, 33],
4991
+ [97, 34],
4992
+ [98, 35],
4975
4993
  [99, 36],
4976
4994
  [120, 37],
4977
4995
  [121, 38],
@@ -5623,6 +5641,36 @@
5623
5641
  state: cloneRecord(record)
5624
5642
  };
5625
5643
  }
5644
+ function summarizePvpEvent(entity, record, shipsLeft) {
5645
+ if (!record) return null;
5646
+ const damageBonusPercent = record.q52 ?? 0;
5647
+ return {
5648
+ entity,
5649
+ active: (record.q44 ?? 0) >= 0,
5650
+ bounds: {
5651
+ minX: (record.q20 ?? 0) / 10,
5652
+ minY: (record.q24 ?? 0) / 10,
5653
+ maxX: (record.q28 ?? 0) / 10,
5654
+ maxY: (record.q32 ?? 0) / 10
5655
+ },
5656
+ worldBounds: { minX: 0, minY: 0, maxX: record.q36 ?? 0, maxY: record.q40 ?? 0 },
5657
+ timeSeconds: record.q44 ?? 0,
5658
+ damageBonusPercent,
5659
+ damagePercent: damageBonusPercent + 100,
5660
+ damageMultiplier: (damageBonusPercent + 100) / 100,
5661
+ shipsLeft,
5662
+ state: cloneRecord(record)
5663
+ };
5664
+ }
5665
+ function summarizePvpPartyEntry(entity, record) {
5666
+ return {
5667
+ entity,
5668
+ partyId: record.q20 ?? 0,
5669
+ hexCode: decodeText(record.blob24),
5670
+ kind: record.q37 ? "join-request" : "invitation",
5671
+ state: cloneRecord(record)
5672
+ };
5673
+ }
5626
5674
  function summarizeShipSize(entity, record) {
5627
5675
  if (!record) return null;
5628
5676
  return {
@@ -6251,6 +6299,8 @@
6251
6299
  botIdentifierFromState: botIdentifierFromState2,
6252
6300
  summarizeShieldGenerator: summarizeShieldGenerator2,
6253
6301
  summarizeShipControl: summarizeShipControl2,
6302
+ summarizePvpEvent: summarizePvpEvent2,
6303
+ summarizePvpPartyEntry: summarizePvpPartyEntry2,
6254
6304
  summarizeShipSize: summarizeShipSize2,
6255
6305
  summarizeShipWorldMetadata: summarizeShipWorldMetadata2,
6256
6306
  summarizeItemCrate: summarizeItemCrate2,
@@ -6421,6 +6471,8 @@
6421
6471
  balls: derived.specialEntities.balls.slice(),
6422
6472
  recyclers: derived.specialEntities.recyclers.slice(),
6423
6473
  shipControls: derived.shipControls.slice(),
6474
+ pvpEvent: this.pvpEvent(),
6475
+ pvpParties: this.pvpParties(),
6424
6476
  machines: this.#machinesSnapshot(derived.machines),
6425
6477
  tables: includeTables ? this.tablesSnapshot() : derived.tableSummaries.slice()
6426
6478
  };
@@ -6462,6 +6514,26 @@
6462
6514
  shipControls() {
6463
6515
  return this.#derivedState().shipControls.slice();
6464
6516
  }
6517
+ pvpEvent() {
6518
+ const entry = this.table(33).entries().next().value;
6519
+ if (!entry) return null;
6520
+ let shipsLeft = 0;
6521
+ for (const ship of this.table(20).values()) {
6522
+ if (!ship.q153) shipsLeft += 1;
6523
+ }
6524
+ return summarizePvpEvent2(entry[0], entry[1], shipsLeft);
6525
+ }
6526
+ pvpParties() {
6527
+ const config = this.table(34).entries().next().value;
6528
+ const entries = this.table(35);
6529
+ if (!config && entries.size === 0) return null;
6530
+ return {
6531
+ configEntity: config?.[0] ?? null,
6532
+ maxShips: config ? config[1].q20 ?? 0 : 35,
6533
+ entries: [...entries].map(([entity, record]) => summarizePvpPartyEntry2(entity, record)),
6534
+ configState: config ? cloneRecord2(config[1]) : null
6535
+ };
6536
+ }
6465
6537
  shipMetadata() {
6466
6538
  if (this.isOverworld) return null;
6467
6539
  const lockdownRecord = firstRecord2(this.table(11));
@@ -7730,6 +7802,8 @@
7730
7802
  balls: model.balls,
7731
7803
  recyclers: model.recyclers,
7732
7804
  shipControls: model.shipControls,
7805
+ pvpEvent: model.pvpEvent,
7806
+ pvpParties: model.pvpParties,
7733
7807
  commsBubbles: this.commsBubbles.slice(),
7734
7808
  tiles: includeTiles ? [...this.tiles.values()] : void 0
7735
7809
  };
@@ -8810,6 +8884,23 @@
8810
8884
  return typeof data === "string" ? JSON.parse(data) : decodeMsgpack(toUint8Array(data));
8811
8885
  }
8812
8886
 
8887
+ // src/protocol/outbound/pvp.js
8888
+ var TARGETED_KINDS = /* @__PURE__ */ new Set(["Join", "Invite", "Kick", "JoinCancel", "InviteCancel"]);
8889
+ function requireHexCode(value) {
8890
+ if (typeof value !== "string") throw new TypeError("hexCode must be a ship hex code string");
8891
+ const hexCode = value.trim();
8892
+ if (!/^[0-9a-f]+$/i.test(hexCode)) throw new RangeError("hexCode must contain hexadecimal digits");
8893
+ return hexCode;
8894
+ }
8895
+ function buildPvpPartyMessage(kind, hexCode) {
8896
+ if (kind === "NewTeam" || kind === "Leave") {
8897
+ if (hexCode !== void 0) throw new TypeError(`${kind} does not take a ship hex code`);
8898
+ return { type: 10, info: { kind } };
8899
+ }
8900
+ if (!TARGETED_KINDS.has(kind)) throw new RangeError("unsupported PvP party command kind");
8901
+ return { type: 10, info: { kind, hex: requireHexCode(hexCode) } };
8902
+ }
8903
+
8813
8904
  // src/client/domains/index.js
8814
8905
  function normalizeAttachMode(mode = "observe") {
8815
8906
  const value = String(mode || "observe").toLowerCase();
@@ -9159,6 +9250,55 @@
9159
9250
  return worldStateFor(this.client, this.scope)?.snapshot(options) || null;
9160
9251
  }
9161
9252
  };
9253
+ var PvpEventDomain = class {
9254
+ constructor(client) {
9255
+ this.client = client;
9256
+ }
9257
+ state() {
9258
+ return this.#read("pvpEvent");
9259
+ }
9260
+ parties() {
9261
+ return this.#read("pvpParties");
9262
+ }
9263
+ #read(method) {
9264
+ const overworld = this.client.worlds.overworld();
9265
+ const summary = overworld?.model[method]();
9266
+ if (summary != null) return summary;
9267
+ for (const world of this.client.worlds.worlds.values()) {
9268
+ if (world === overworld) continue;
9269
+ const value = world.model[method]();
9270
+ if (value != null) return value;
9271
+ }
9272
+ return null;
9273
+ }
9274
+ createParty() {
9275
+ return this.client.sendMessage(buildPvpPartyMessage("NewTeam"));
9276
+ }
9277
+ leaveParty() {
9278
+ return this.client.sendMessage(buildPvpPartyMessage("Leave"));
9279
+ }
9280
+ joinParty(hexCode) {
9281
+ return this.client.sendMessage(buildPvpPartyMessage("Join", hexCode));
9282
+ }
9283
+ inviteShip(hexCode) {
9284
+ return this.client.sendMessage(buildPvpPartyMessage("Invite", hexCode));
9285
+ }
9286
+ acceptInvitation(hexCode) {
9287
+ return this.joinParty(hexCode);
9288
+ }
9289
+ acceptJoinRequest(hexCode) {
9290
+ return this.inviteShip(hexCode);
9291
+ }
9292
+ kickShip(hexCode) {
9293
+ return this.client.sendMessage(buildPvpPartyMessage("Kick", hexCode));
9294
+ }
9295
+ cancelJoinRequest(hexCode) {
9296
+ return this.client.sendMessage(buildPvpPartyMessage("JoinCancel", hexCode));
9297
+ }
9298
+ cancelInvitation(hexCode) {
9299
+ return this.client.sendMessage(buildPvpPartyMessage("InviteCancel", hexCode));
9300
+ }
9301
+ };
9162
9302
  var ShipDomain = class extends WorldDomain {
9163
9303
  entity() {
9164
9304
  const summary = this.client.worlds.currentShipEntity();
@@ -10402,6 +10542,7 @@
10402
10542
  this.inventory = new InventoryDomain(this);
10403
10543
  this.tips = new TipDomain(this);
10404
10544
  this.management = new ShipManagementDomain(this);
10545
+ this.pvpEvent = new PvpEventDomain(this);
10405
10546
  this.cpuLoad = null;
10406
10547
  this.inventoryState = normalizeInventoryEvent({ type: "inventory", general_slots: 5 });
10407
10548
  this.puiPanels = /* @__PURE__ */ new Map();