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.
- package/dist/browser/dredless.global.js +141 -0
- package/dist/browser/dredless.global.js.map +4 -4
- package/docs/API_REFERENCE.md +1 -0
- package/docs/PROTOCOL.md +27 -0
- package/docs/README.md +2 -1
- package/docs/WORLD_STATE.md +99 -0
- package/package.json +6 -1
- package/src/browser.d.ts +14 -0
- package/src/browser.js +1 -0
- package/src/client/core.js +2 -0
- package/src/client/domains/index.js +63 -0
- package/src/index.d.ts +92 -0
- package/src/index.js +1 -0
- package/src/protocol/index.d.ts +1 -0
- package/src/protocol/index.js +1 -0
- package/src/protocol/outbound/pvp.d.ts +13 -0
- package/src/protocol/outbound/pvp.js +45 -0
- package/src/state/model/decoder.js +48 -0
- package/src/state/model/index.d.ts +4 -0
- package/src/state/model/state.js +27 -0
- package/src/state/world/index.d.ts +4 -0
- package/src/state/world/state.js +2 -0
package/docs/API_REFERENCE.md
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
| Client readiness, retention, disconnects | `DredlessClient`, `client.net` | [Client](CLIENT.md) |
|
|
12
12
|
| Callbacks and event payloads | `on`, `off`, `once` | [Events](EVENTS.md) |
|
|
13
13
|
| World, entity, and nearby ship reads | `currentShip`, `overworld`, entity handles | [World state](WORLD_STATE.md) |
|
|
14
|
+
| PvP event state and party commands | `client.pvpEvent` | [PvP events and parties](WORLD_STATE.md#pvp-events-and-parties) |
|
|
14
15
|
| Input, inventory, blueprints, chat | `client.player`, `client.inventory` | [Player and inventory](PLAYER_INVENTORY.md) |
|
|
15
16
|
| Machine configuration and context menus | `ship.machines`, `client.tips` | [Machines](MACHINES.md) |
|
|
16
17
|
| Crew, logs, ship settings, saving, perks | `client.management` | [Management](MANAGEMENT.md) |
|
package/docs/PROTOCOL.md
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
- [Import map](#import-map)
|
|
8
8
|
- [Commands and payloads](#commands-and-payloads)
|
|
9
9
|
- [Management builders](#management-builders)
|
|
10
|
+
- [Party builders](#party-builders)
|
|
10
11
|
- [Configuration builders](#configuration-builders)
|
|
11
12
|
- [Generator maze helpers](#generator-maze-helpers)
|
|
12
13
|
- [HTTP and invite tools](#http-and-invite-tools)
|
|
@@ -26,6 +27,7 @@ Prefer high-level domains when implementing game actions. These tools are for in
|
|
|
26
27
|
| `dredless/protocol/comms` | Comms builder, rich-text flattening/normalization | [comms.d.ts](../src/protocol/outbound/comms.d.ts) |
|
|
27
28
|
| `dredless/protocol/inventory` | Drag/equip builders and slot normalization | [inventory.d.ts](../src/protocol/outbound/inventory.d.ts) |
|
|
28
29
|
| `dredless/protocol/ship-management` | Management builders, normalizers, action constants | [ship-management.d.ts](../src/protocol/outbound/ship-management.d.ts) |
|
|
30
|
+
| `dredless/protocol/pvp` | PvP party command builders | [pvp.d.ts](../src/protocol/outbound/pvp.d.ts) |
|
|
29
31
|
| `dredless/protocol/sign` | Sign builder/display-mode helpers | [sign.d.ts](../src/protocol/outbound/sign.d.ts) |
|
|
30
32
|
| `dredless/protocol/ui-config` | Binary config/clipboard builders and enums | [ui-config.d.ts](../src/protocol/outbound/ui-config.d.ts) |
|
|
31
33
|
| `dredless/game/generator-maze` | Maze generation/solution helpers | [generator-maze.d.ts](../src/state/generator-maze.d.ts) |
|
|
@@ -109,6 +111,29 @@ normalizeCrewLog(event: unknown, previous?: CrewLog | null): CrewLog;
|
|
|
109
111
|
|
|
110
112
|
Pass the inner session submessage, not the outer `{type: 25, submessage}` packet. Player-list/log normalizers merge with the previous normalized state; omitting it begins a fresh state. [Management](MANAGEMENT.md) describes their reset/amend/remove semantics. Action-name constants, `SHIP_MANAGEMENT_TYPE`, and `CREW_LOG_LENGTH` are exported by the management subpath.
|
|
111
113
|
|
|
114
|
+
## Party builders
|
|
115
|
+
|
|
116
|
+
These return `PvpPartyMessage` objects, with no I/O or response waiting. Prefer the
|
|
117
|
+
[party domain methods](WORLD_STATE.md#pvp-events-and-parties) for game actions.
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
buildPvpPartyMessage(kind: "NewTeam" | "Leave"): PvpPartyMessage;
|
|
121
|
+
buildPvpPartyMessage(kind: "Join" | "Invite" | "Kick" | "JoinCancel" | "InviteCancel",
|
|
122
|
+
hexCode: string): PvpPartyMessage;
|
|
123
|
+
buildCreatePvpPartyMessage(): PvpPartyMessage;
|
|
124
|
+
buildLeavePvpPartyMessage(): PvpPartyMessage;
|
|
125
|
+
buildJoinPvpPartyMessage(hexCode: string): PvpPartyMessage;
|
|
126
|
+
buildInvitePvpPartyMessage(hexCode: string): PvpPartyMessage;
|
|
127
|
+
buildKickPvpPartyMessage(hexCode: string): PvpPartyMessage;
|
|
128
|
+
buildCancelPvpPartyJoinMessage(hexCode: string): PvpPartyMessage;
|
|
129
|
+
buildCancelPvpPartyInviteMessage(hexCode: string): PvpPartyMessage;
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
The wire shape is `{type: 10, info: {kind, hex}}`; `NewTeam` and `Leave` omit `hex`.
|
|
133
|
+
Targeted commands require a nonempty hexadecimal ship code string without braces. For `Join` and `JoinCancel`,
|
|
134
|
+
target a ship in the other party. `Join` also accepts an invitation; `Invite` also accepts a join request.
|
|
135
|
+
Send a built object with `client.sendMessage(message)`.
|
|
136
|
+
|
|
112
137
|
## Configuration builders
|
|
113
138
|
|
|
114
139
|
All return `Uint8Array` payloads. Their configuration types and operational prerequisites are covered in [machines](MACHINES.md); these low-level functions do not merge cached state or open an interaction.
|
|
@@ -216,6 +241,8 @@ modelState.bots(): BotSummary[];
|
|
|
216
241
|
modelState.rcds(): RcdSummary[];
|
|
217
242
|
modelState.balls(): BallSummary[];
|
|
218
243
|
modelState.recyclers(): RecyclerSummary[];
|
|
244
|
+
modelState.pvpEvent(): PvpEventSummary | null;
|
|
245
|
+
modelState.pvpParties(): PvpPartiesSummary | null;
|
|
219
246
|
modelState.setLocalPlayerEntity(entity: number | null): void;
|
|
220
247
|
modelState.shipControls(): ShipControlSummary[];
|
|
221
248
|
modelState.shipMetadata(): ShipWorldMetadataSummary | null;
|
package/docs/README.md
CHANGED
|
@@ -19,7 +19,8 @@ In a browser, `BrowserSession` uses the ambient browser cookie jar.
|
|
|
19
19
|
| Handle disconnects and retain useful state | [Client lifecycle](CLIENT.md) |
|
|
20
20
|
| Subscribe to model, inventory, or management updates | [Event catalog](EVENTS.md) |
|
|
21
21
|
| Find an entity, machine, or nearby ship | [World and entity reads](WORLD_STATE.md) |
|
|
22
|
-
| Read
|
|
22
|
+
| Read PvP event state or manage parties | [PvP events and parties](WORLD_STATE.md#pvp-events-and-parties) |
|
|
23
|
+
| Read projectiles, bots, balls/eggs, RCDs, or recyclers | [Special entity reads](WORLD_STATE.md#projectiles-bots-and-special-entities) |
|
|
23
24
|
| Move, aim, equip, or place a blueprint | [Player and inventory](PLAYER_INVENTORY.md) |
|
|
24
25
|
| Use a context menu or set door access | [Machines and context menus](MACHINES.md#context-menus-and-access) |
|
|
25
26
|
| Configure a loader, pusher, launcher, or navigation unit | [Machine reference](MACHINES.md) |
|
package/docs/WORLD_STATE.md
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
- [Entities and features](#entities-and-features)
|
|
9
9
|
- [Machine and other collections](#machine-and-other-collections)
|
|
10
10
|
- [Projectiles, bots, and special entities](#projectiles-bots-and-special-entities)
|
|
11
|
+
- [PvP events and parties](#pvp-events-and-parties)
|
|
11
12
|
- [Nearby ships](#nearby-ships)
|
|
12
13
|
- [Live reads and snapshots](#live-reads-and-snapshots)
|
|
13
14
|
- [Coordinates and incomplete data](#coordinates-and-incomplete-data)
|
|
@@ -176,6 +177,104 @@ Footprints and the block index are coarse occupancy aids, not collision polygons
|
|
|
176
177
|
`footprint.source`: `"default"` and `"heuristic"` dimensions are estimates, and hover outlines describe highlights.
|
|
177
178
|
Helm/comms occupancy retains its existing inference rules; these collections do not establish player-to-machine links.
|
|
178
179
|
|
|
180
|
+
## PvP events and parties
|
|
181
|
+
|
|
182
|
+
Read singleton event and party state through the top-level client domain:
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
client.pvpEvent.state(): PvpEventSummary | null;
|
|
186
|
+
client.pvpEvent.parties(): PvpPartiesSummary | null;
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
The domain checks the overworld first, then other loaded worlds for the replicated components.
|
|
190
|
+
Reads follow the currently loaded state without retaining a separate cache.
|
|
191
|
+
`state()` returns `null` when the event component is absent. Otherwise it includes:
|
|
192
|
+
|
|
193
|
+
| Field | Meaning |
|
|
194
|
+
|----------------------|--------------------------------------------------------------------------------------------------------------|
|
|
195
|
+
| `entity` | Event metadata entity ID. |
|
|
196
|
+
| `active` | Event timer is non-negative, matching when the official HUD displays event status. |
|
|
197
|
+
| `bounds` | `{minX, minY, maxX, maxY}`: current red boundary in world coordinates. Wire coordinates are divided by `10`. |
|
|
198
|
+
| `worldBounds` | Outer drawing rectangle, starting at `(0, 0)`, used to shade the area outside the boundary. |
|
|
199
|
+
| `timeSeconds` | Server-reported event time in seconds. No local extrapolation is applied. |
|
|
200
|
+
| `damageBonusPercent` | Additional zone-wide PvP damage percentage. |
|
|
201
|
+
| `damagePercent` | `100 + damageBonusPercent`; normal damage is `100`. |
|
|
202
|
+
| `damageMultiplier` | `damagePercent / 100`; normal damage is `1`. |
|
|
203
|
+
| `shipsLeft` | Counts observed ship components without the event exclusion flag, matching the HUD calculation. |
|
|
204
|
+
| `state` | Raw event record, including the still-unconfirmed `q48` value. |
|
|
205
|
+
|
|
206
|
+
**Fragment:**
|
|
207
|
+
|
|
208
|
+
```js
|
|
209
|
+
const event = client.pvpEvent.state();
|
|
210
|
+
if (event?.active) {
|
|
211
|
+
console.log(event.timeSeconds, event.shipsLeft, event.damageMultiplier, event.bounds);
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
`parties()` is independent of the event timer and may be available in the Event Lobby when `state()` is `null`.
|
|
216
|
+
It returns `null` only when both party configuration and party entries are absent. Its shape is:
|
|
217
|
+
|
|
218
|
+
```ts
|
|
219
|
+
{
|
|
220
|
+
configEntity: number | null;
|
|
221
|
+
maxShips: number;
|
|
222
|
+
entries: {
|
|
223
|
+
entity: number;
|
|
224
|
+
partyId: number;
|
|
225
|
+
hexCode: string | null;
|
|
226
|
+
kind: "invitation" | "join-request";
|
|
227
|
+
state: ModelRecord;
|
|
228
|
+
}[];
|
|
229
|
+
configState: ModelRecord | null;
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
`maxShips` uses the official party UI's default of `35` when the configuration component is absent. Each entry
|
|
234
|
+
associates a party ID with a ship hex code. `kind: "invitation"` means the party invited the ship;
|
|
235
|
+
`kind: "join-request"` means the ship requested to join the party. The recipient can accept and the sender can cancel.
|
|
236
|
+
These are pending relationships, not accepted members, so no member count is inferred from them.
|
|
237
|
+
Ship hex codes are not decimal ship IDs or ECS entity IDs. The raw flag remains available as `state.q37`.
|
|
238
|
+
|
|
239
|
+
World and model snapshots include `pvpEvent` and `pvpParties`. Standalone `ModelState` exposes `pvpEvent()` and
|
|
240
|
+
`pvpParties()` with the same summary shapes.
|
|
241
|
+
|
|
242
|
+
Party commands are available on the same domain:
|
|
243
|
+
|
|
244
|
+
```ts
|
|
245
|
+
client.pvpEvent.createParty(): DredlessClient;
|
|
246
|
+
client.pvpEvent.leaveParty(): DredlessClient;
|
|
247
|
+
client.pvpEvent.joinParty(hexCode: string): DredlessClient;
|
|
248
|
+
client.pvpEvent.inviteShip(hexCode: string): DredlessClient;
|
|
249
|
+
client.pvpEvent.acceptInvitation(hexCode: string): DredlessClient;
|
|
250
|
+
client.pvpEvent.acceptJoinRequest(hexCode: string): DredlessClient;
|
|
251
|
+
client.pvpEvent.kickShip(hexCode: string): DredlessClient;
|
|
252
|
+
client.pvpEvent.cancelJoinRequest(hexCode: string): DredlessClient;
|
|
253
|
+
client.pvpEvent.cancelInvitation(hexCode: string): DredlessClient;
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
For `joinParty()`, `acceptInvitation()`, and `cancelJoinRequest()`, supply a ship hex code belonging to the
|
|
257
|
+
target party. The other targeted methods take the hex code of the ship being invited, accepted, kicked, or whose
|
|
258
|
+
invitation is being withdrawn. Use hexadecimal strings without braces; whitespace is trimmed. Numeric party IDs
|
|
259
|
+
and entity IDs are not accepted. An invitation entry's `hexCode` identifies the invited ship, so it does not
|
|
260
|
+
necessarily identify a ship in the inviting party.
|
|
261
|
+
|
|
262
|
+
`acceptInvitation()` sends the same command as `joinParty()`; `acceptJoinRequest()` sends the same command as
|
|
263
|
+
`inviteShip()`. All commands act on the connection's current ship.
|
|
264
|
+
The server enforces captain access and party/zone restrictions. Methods return after sending or queueing,
|
|
265
|
+
without waiting for confirmation; observe subsequent replicated state for the outcome.
|
|
266
|
+
|
|
267
|
+
**Fragment:**
|
|
268
|
+
|
|
269
|
+
```js
|
|
270
|
+
const parties = client.pvpEvent;
|
|
271
|
+
parties.joinParty(targetPartyShip.hexCode);
|
|
272
|
+
// From the party leader's connection, accept the requesting ship:
|
|
273
|
+
parties.acceptJoinRequest(requestingShip.hexCode);
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
[Protocol builders](PROTOCOL.md#party-builders) expose the same commands for payload construction.
|
|
277
|
+
|
|
179
278
|
## Nearby ships
|
|
180
279
|
|
|
181
280
|
```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dredless",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "A fully-featured and from-scratch headless drednot.io client implementation written in pure js.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/certainhuman/dredless#readme",
|
|
@@ -130,6 +130,11 @@
|
|
|
130
130
|
"import": "./src/protocol/outbound/ship-management.js",
|
|
131
131
|
"default": "./src/protocol/outbound/ship-management.js"
|
|
132
132
|
},
|
|
133
|
+
"./protocol/pvp": {
|
|
134
|
+
"types": "./src/protocol/outbound/pvp.d.ts",
|
|
135
|
+
"import": "./src/protocol/outbound/pvp.js",
|
|
136
|
+
"default": "./src/protocol/outbound/pvp.js"
|
|
137
|
+
},
|
|
133
138
|
"./protocol/sign": {
|
|
134
139
|
"types": "./src/protocol/outbound/sign.d.ts",
|
|
135
140
|
"import": "./src/protocol/outbound/sign.js",
|
package/src/browser.d.ts
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
export {
|
|
2
|
+
buildPvpPartyMessage,
|
|
3
|
+
buildCreatePvpPartyMessage,
|
|
4
|
+
buildLeavePvpPartyMessage,
|
|
5
|
+
buildJoinPvpPartyMessage,
|
|
6
|
+
buildInvitePvpPartyMessage,
|
|
7
|
+
buildKickPvpPartyMessage,
|
|
8
|
+
buildCancelPvpPartyJoinMessage,
|
|
9
|
+
buildCancelPvpPartyInviteMessage,
|
|
10
|
+
type PvpPartyCommandKind,
|
|
11
|
+
type PvpPartyMessage,
|
|
12
|
+
type PvpPartyInfo
|
|
13
|
+
} from "./index.js";
|
|
14
|
+
|
|
1
15
|
export {
|
|
2
16
|
Connection,
|
|
3
17
|
DredlessClient,
|
package/src/browser.js
CHANGED
|
@@ -5,6 +5,7 @@ export {WorldStore, WorldState} from "./state/world/index.js";
|
|
|
5
5
|
export {FabricatorType, ModelState, decodeModelData} from "./state/model/index.js";
|
|
6
6
|
export {generateGeneratorMaze, solveGeneratorMazeSeed, maybeSolveGeneratorMazeSeed} from "./state/generator-maze.js";
|
|
7
7
|
export {buildBlueprintPlacementMessage} from "./protocol/outbound/blueprint.js";
|
|
8
|
+
export * from "./protocol/outbound/pvp.js";
|
|
8
9
|
export {decodeMsgpack, encodeMsgpack} from "./protocol/codec/msgpack.js";
|
|
9
10
|
export {buildCommsMessage, flattenRichText, normalizeCommsEvent} from "./protocol/outbound/comms.js";
|
|
10
11
|
export {buildSignedCommandPacket} from "./protocol/outbound/commands.js";
|
package/src/client/core.js
CHANGED
|
@@ -69,6 +69,7 @@ import {
|
|
|
69
69
|
PlayerDomain,
|
|
70
70
|
ShipManagementDomain,
|
|
71
71
|
InventoryDomain,
|
|
72
|
+
PvpEventDomain,
|
|
72
73
|
WorldDomain,
|
|
73
74
|
ShipDomain,
|
|
74
75
|
OverworldDomain,
|
|
@@ -155,6 +156,7 @@ export class DredlessClient extends EventBus {
|
|
|
155
156
|
this.inventory = new InventoryDomain(this);
|
|
156
157
|
this.tips = new TipDomain(this);
|
|
157
158
|
this.management = new ShipManagementDomain(this);
|
|
159
|
+
this.pvpEvent = new PvpEventDomain(this);
|
|
158
160
|
this.cpuLoad = null;
|
|
159
161
|
this.inventoryState = normalizeInventoryEvent({type: "inventory", general_slots: 5});
|
|
160
162
|
this.puiPanels = new Map();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {itemEquipmentSlotFromId} from "../../state/items.js";
|
|
2
|
+
import {buildPvpPartyMessage} from "../../protocol/outbound/pvp.js";
|
|
2
3
|
import {buildInventoryDragCommand, normalizeEquipmentSlot, normalizeInventoryEvent} from "../../protocol/outbound/inventory.js";
|
|
3
4
|
|
|
4
5
|
export function normalizeAttachMode(mode = "observe") {
|
|
@@ -449,6 +450,68 @@ export class WorldDomain {
|
|
|
449
450
|
}
|
|
450
451
|
}
|
|
451
452
|
|
|
453
|
+
export class PvpEventDomain {
|
|
454
|
+
constructor(client) {
|
|
455
|
+
this.client = client;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
state() {
|
|
459
|
+
return this.#read("pvpEvent");
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
parties() {
|
|
463
|
+
return this.#read("pvpParties");
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
#read(method) {
|
|
467
|
+
const overworld = this.client.worlds.overworld();
|
|
468
|
+
const summary = overworld?.model[method]();
|
|
469
|
+
if (summary != null) return summary;
|
|
470
|
+
for (const world of this.client.worlds.worlds.values()) {
|
|
471
|
+
if (world === overworld) continue;
|
|
472
|
+
const value = world.model[method]();
|
|
473
|
+
if (value != null) return value;
|
|
474
|
+
}
|
|
475
|
+
return null;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
createParty() {
|
|
479
|
+
return this.client.sendMessage(buildPvpPartyMessage("NewTeam"));
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
leaveParty() {
|
|
483
|
+
return this.client.sendMessage(buildPvpPartyMessage("Leave"));
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
joinParty(hexCode) {
|
|
487
|
+
return this.client.sendMessage(buildPvpPartyMessage("Join", hexCode));
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
inviteShip(hexCode) {
|
|
491
|
+
return this.client.sendMessage(buildPvpPartyMessage("Invite", hexCode));
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
acceptInvitation(hexCode) {
|
|
495
|
+
return this.joinParty(hexCode);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
acceptJoinRequest(hexCode) {
|
|
499
|
+
return this.inviteShip(hexCode);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
kickShip(hexCode) {
|
|
503
|
+
return this.client.sendMessage(buildPvpPartyMessage("Kick", hexCode));
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
cancelJoinRequest(hexCode) {
|
|
507
|
+
return this.client.sendMessage(buildPvpPartyMessage("JoinCancel", hexCode));
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
cancelInvitation(hexCode) {
|
|
511
|
+
return this.client.sendMessage(buildPvpPartyMessage("InviteCancel", hexCode));
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
452
515
|
export class ShipDomain extends WorldDomain {
|
|
453
516
|
entity() {
|
|
454
517
|
const summary = this.client.worlds.currentShipEntity();
|
package/src/index.d.ts
CHANGED
|
@@ -626,6 +626,7 @@ export class DredlessClient {
|
|
|
626
626
|
inventory: InventoryDomain;
|
|
627
627
|
tips: TipDomain;
|
|
628
628
|
management: ShipManagementDomain;
|
|
629
|
+
pvpEvent: PvpEventDomain;
|
|
629
630
|
readyPromise: Promise<this>;
|
|
630
631
|
|
|
631
632
|
whenReady(): Promise<this>;
|
|
@@ -957,6 +958,69 @@ export interface ShipDomain extends WorldDomain {
|
|
|
957
958
|
overworldEntity: EntityHandle | null;
|
|
958
959
|
}
|
|
959
960
|
|
|
961
|
+
export interface PvpEventDomain {
|
|
962
|
+
state(): PvpEventSummary | null;
|
|
963
|
+
parties(): PvpPartiesSummary | null;
|
|
964
|
+
/** Party commands return after sending or queueing, without server confirmation. */
|
|
965
|
+
createParty(): DredlessClient;
|
|
966
|
+
leaveParty(): DredlessClient;
|
|
967
|
+
/** Request to join the party containing the target ship. */
|
|
968
|
+
joinParty(hexCode: string): DredlessClient;
|
|
969
|
+
inviteShip(hexCode: string): DredlessClient;
|
|
970
|
+
/** Accept an invitation using a ship hex code from the inviting party. */
|
|
971
|
+
acceptInvitation(hexCode: string): DredlessClient;
|
|
972
|
+
/** Accept the target ship's join request. */
|
|
973
|
+
acceptJoinRequest(hexCode: string): DredlessClient;
|
|
974
|
+
kickShip(hexCode: string): DredlessClient;
|
|
975
|
+
/** Target a ship in the party the local ship requested to join. */
|
|
976
|
+
cancelJoinRequest(hexCode: string): DredlessClient;
|
|
977
|
+
cancelInvitation(hexCode: string): DredlessClient;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
export interface PvpEventBounds {
|
|
981
|
+
minX: number;
|
|
982
|
+
minY: number;
|
|
983
|
+
maxX: number;
|
|
984
|
+
maxY: number;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
export interface PvpEventSummary {
|
|
988
|
+
entity: number;
|
|
989
|
+
/** Whether the event timer is non-negative, matching HUD visibility. */
|
|
990
|
+
active: boolean;
|
|
991
|
+
/** Current red boundary rectangle, in world coordinates. */
|
|
992
|
+
bounds: PvpEventBounds;
|
|
993
|
+
/** Outer rectangle used to shade the area outside the event bounds. */
|
|
994
|
+
worldBounds: PvpEventBounds;
|
|
995
|
+
timeSeconds: number;
|
|
996
|
+
/** Additional damage percentage; zero means no bonus. */
|
|
997
|
+
damageBonusPercent: number;
|
|
998
|
+
/** Total damage percentage; 100 means normal damage. */
|
|
999
|
+
damagePercent: number;
|
|
1000
|
+
damageMultiplier: number;
|
|
1001
|
+
/** HUD count of observed ship components without the exclusion flag. */
|
|
1002
|
+
shipsLeft: number;
|
|
1003
|
+
state: ModelRecord;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
export interface PvpPartyEntrySummary {
|
|
1007
|
+
entity: number;
|
|
1008
|
+
partyId: number;
|
|
1009
|
+
hexCode: string | null;
|
|
1010
|
+
/** Invitation sent by the party, or join request sent by the ship. */
|
|
1011
|
+
kind: "invitation" | "join-request";
|
|
1012
|
+
state: ModelRecord;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
export interface PvpPartiesSummary {
|
|
1016
|
+
configEntity: number | null;
|
|
1017
|
+
/** Defaults to 35 when the configuration component is absent, matching the party UI. */
|
|
1018
|
+
maxShips: number;
|
|
1019
|
+
/** Relationship entries, not an authoritative list of accepted members. */
|
|
1020
|
+
entries: PvpPartyEntrySummary[];
|
|
1021
|
+
configState: ModelRecord | null;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
960
1024
|
export interface OverworldDomain extends WorldDomain {
|
|
961
1025
|
ships(options?: ShipReadOptions): ShipHandle[];
|
|
962
1026
|
|
|
@@ -1823,6 +1887,8 @@ export interface WorldSnapshot {
|
|
|
1823
1887
|
balls: BallSummary[];
|
|
1824
1888
|
recyclers: RecyclerSummary[];
|
|
1825
1889
|
shipControls: ShipControlSummary[];
|
|
1890
|
+
pvpEvent: PvpEventSummary | null;
|
|
1891
|
+
pvpParties: PvpPartiesSummary | null;
|
|
1826
1892
|
commsBubbles: CommsBubbleSummary[];
|
|
1827
1893
|
tiles?: Tile[];
|
|
1828
1894
|
}
|
|
@@ -1924,6 +1990,9 @@ export class ModelState {
|
|
|
1924
1990
|
|
|
1925
1991
|
shipControls(): ShipControlSummary[];
|
|
1926
1992
|
|
|
1993
|
+
pvpEvent(): PvpEventSummary | null;
|
|
1994
|
+
pvpParties(): PvpPartiesSummary | null;
|
|
1995
|
+
|
|
1927
1996
|
shipMetadata(): ShipWorldMetadataSummary | null;
|
|
1928
1997
|
|
|
1929
1998
|
machines(): MachineSummary;
|
|
@@ -1949,6 +2018,8 @@ export interface ModelSnapshot {
|
|
|
1949
2018
|
balls: BallSummary[];
|
|
1950
2019
|
recyclers: RecyclerSummary[];
|
|
1951
2020
|
shipControls: ShipControlSummary[];
|
|
2021
|
+
pvpEvent: PvpEventSummary | null;
|
|
2022
|
+
pvpParties: PvpPartiesSummary | null;
|
|
1952
2023
|
machines: MachineSummary;
|
|
1953
2024
|
tables: unknown[];
|
|
1954
2025
|
}
|
|
@@ -2555,6 +2626,27 @@ export function encodeMsgpack(value: unknown): Uint8Array;
|
|
|
2555
2626
|
|
|
2556
2627
|
export function buildChatMessage(message?: string): ChatMessage;
|
|
2557
2628
|
|
|
2629
|
+
export type PvpPartyCommandKind = "NewTeam" | "Leave" | "Join" | "Invite" | "Kick" | "JoinCancel" | "InviteCancel";
|
|
2630
|
+
|
|
2631
|
+
export type PvpPartyInfo =
|
|
2632
|
+
| {kind: "NewTeam" | "Leave"}
|
|
2633
|
+
| {kind: "Join" | "Invite" | "Kick" | "JoinCancel" | "InviteCancel"; hex: string};
|
|
2634
|
+
|
|
2635
|
+
export interface PvpPartyMessage {
|
|
2636
|
+
type: 10;
|
|
2637
|
+
info: PvpPartyInfo;
|
|
2638
|
+
}
|
|
2639
|
+
|
|
2640
|
+
export function buildPvpPartyMessage(kind: "NewTeam" | "Leave"): PvpPartyMessage;
|
|
2641
|
+
export function buildPvpPartyMessage(kind: Exclude<PvpPartyCommandKind, "NewTeam" | "Leave">, hexCode: string): PvpPartyMessage;
|
|
2642
|
+
export function buildCreatePvpPartyMessage(): PvpPartyMessage;
|
|
2643
|
+
export function buildLeavePvpPartyMessage(): PvpPartyMessage;
|
|
2644
|
+
export function buildJoinPvpPartyMessage(hexCode: string): PvpPartyMessage;
|
|
2645
|
+
export function buildInvitePvpPartyMessage(hexCode: string): PvpPartyMessage;
|
|
2646
|
+
export function buildKickPvpPartyMessage(hexCode: string): PvpPartyMessage;
|
|
2647
|
+
export function buildCancelPvpPartyJoinMessage(hexCode: string): PvpPartyMessage;
|
|
2648
|
+
export function buildCancelPvpPartyInviteMessage(hexCode: string): PvpPartyMessage;
|
|
2649
|
+
|
|
2558
2650
|
export function buildCommsMessage(message?: string): CommsMessage;
|
|
2559
2651
|
|
|
2560
2652
|
export function normalizeCommsEvent(event: unknown): CommsEvent;
|
package/src/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export {FabricatorType, ModelState, decodeModelData} from "./state/model/index.j
|
|
|
7
7
|
export {generateGeneratorMaze, solveGeneratorMazeSeed, maybeSolveGeneratorMazeSeed} from "./state/generator-maze.js";
|
|
8
8
|
export {buildBlueprintPlacementMessage} from "./protocol/outbound/blueprint.js";
|
|
9
9
|
export {buildChatMessage} from "./protocol/outbound/chat.js";
|
|
10
|
+
export * from "./protocol/outbound/pvp.js";
|
|
10
11
|
export {decodeMsgpack, encodeMsgpack} from "./protocol/codec/msgpack.js";
|
|
11
12
|
export {
|
|
12
13
|
buildCommsMessage,
|
package/src/protocol/index.d.ts
CHANGED
|
@@ -8,5 +8,6 @@ export * from "./outbound/comms.js";
|
|
|
8
8
|
export * from "./outbound/commands.js";
|
|
9
9
|
export * from "./outbound/inventory.js";
|
|
10
10
|
export * from "./outbound/ship-management.js";
|
|
11
|
+
export * from "./outbound/pvp.js";
|
|
11
12
|
export * from "./outbound/sign.js";
|
|
12
13
|
export * from "./outbound/ui-config.js";
|
package/src/protocol/index.js
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export {
|
|
2
|
+
buildPvpPartyMessage,
|
|
3
|
+
buildCreatePvpPartyMessage,
|
|
4
|
+
buildLeavePvpPartyMessage,
|
|
5
|
+
buildJoinPvpPartyMessage,
|
|
6
|
+
buildInvitePvpPartyMessage,
|
|
7
|
+
buildKickPvpPartyMessage,
|
|
8
|
+
buildCancelPvpPartyJoinMessage,
|
|
9
|
+
buildCancelPvpPartyInviteMessage,
|
|
10
|
+
type PvpPartyCommandKind,
|
|
11
|
+
type PvpPartyMessage,
|
|
12
|
+
type PvpPartyInfo
|
|
13
|
+
} from "../../index.js";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const TARGETED_KINDS = new Set(["Join", "Invite", "Kick", "JoinCancel", "InviteCancel"]);
|
|
2
|
+
|
|
3
|
+
function requireHexCode(value) {
|
|
4
|
+
if (typeof value !== "string") throw new TypeError("hexCode must be a ship hex code string");
|
|
5
|
+
const hexCode = value.trim();
|
|
6
|
+
if (!/^[0-9a-f]+$/i.test(hexCode)) throw new RangeError("hexCode must contain hexadecimal digits");
|
|
7
|
+
return hexCode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function buildPvpPartyMessage(kind, hexCode) {
|
|
11
|
+
if (kind === "NewTeam" || kind === "Leave") {
|
|
12
|
+
if (hexCode !== undefined) throw new TypeError(`${kind} does not take a ship hex code`);
|
|
13
|
+
return {type: 10, info: {kind}};
|
|
14
|
+
}
|
|
15
|
+
if (!TARGETED_KINDS.has(kind)) throw new RangeError("unsupported PvP party command kind");
|
|
16
|
+
return {type: 10, info: {kind, hex: requireHexCode(hexCode)}};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function buildCreatePvpPartyMessage() {
|
|
20
|
+
return buildPvpPartyMessage("NewTeam");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function buildLeavePvpPartyMessage() {
|
|
24
|
+
return buildPvpPartyMessage("Leave");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function buildJoinPvpPartyMessage(hexCode) {
|
|
28
|
+
return buildPvpPartyMessage("Join", hexCode);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function buildInvitePvpPartyMessage(hexCode) {
|
|
32
|
+
return buildPvpPartyMessage("Invite", hexCode);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function buildKickPvpPartyMessage(hexCode) {
|
|
36
|
+
return buildPvpPartyMessage("Kick", hexCode);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function buildCancelPvpPartyJoinMessage(hexCode) {
|
|
40
|
+
return buildPvpPartyMessage("JoinCancel", hexCode);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function buildCancelPvpPartyInviteMessage(hexCode) {
|
|
44
|
+
return buildPvpPartyMessage("InviteCancel", hexCode);
|
|
45
|
+
}
|
|
@@ -240,6 +240,19 @@ export const MODEL_TABLE_SPECS = new Map([
|
|
|
240
240
|
defaults: {q28: 10},
|
|
241
241
|
fields: numericFields({1: 20, 2: 24, 4: 28})
|
|
242
242
|
}],
|
|
243
|
+
[33, {
|
|
244
|
+
name: "pvp_event",
|
|
245
|
+
fields: numericFields({2: 20, 4: 24, 8: 28, 16: 32, 32: 36, 64: 40, 128: 44, 256: 48, 512: 52})
|
|
246
|
+
}],
|
|
247
|
+
[34, {name: "pvp_party_config", fields: numericFields({2: 20})}],
|
|
248
|
+
[35, {
|
|
249
|
+
name: "pvp_party_entry",
|
|
250
|
+
packedBeforeValues: true,
|
|
251
|
+
orderedValues: true,
|
|
252
|
+
packedBits: [{bit: 4, offset: 37}],
|
|
253
|
+
blobs: [{bit: 1, offset: 24}],
|
|
254
|
+
fields: numericFields({2: 20})
|
|
255
|
+
}],
|
|
243
256
|
[37, {name: "loose_item_marker", packedBits: [{bit: 2, offset: 29}], fields: numericFields({1: 20, 4: 24})}],
|
|
244
257
|
[38, {name: "flag_state", packedBits: [{bit: 1, offset: 21}], fields: []}],
|
|
245
258
|
[39, {name: "comms_transmit", ...TWO_FIELD_SPEC}],
|
|
@@ -395,6 +408,9 @@ export const WIRE_TAG_TABLES = new Map([
|
|
|
395
408
|
[93, 30],
|
|
396
409
|
[94, 31],
|
|
397
410
|
[95, 32],
|
|
411
|
+
[96, 33],
|
|
412
|
+
[97, 34],
|
|
413
|
+
[98, 35],
|
|
398
414
|
[99, 36],
|
|
399
415
|
[120, 37],
|
|
400
416
|
[121, 38],
|
|
@@ -1118,6 +1134,38 @@ export function summarizeShipControl(entity, record) {
|
|
|
1118
1134
|
};
|
|
1119
1135
|
}
|
|
1120
1136
|
|
|
1137
|
+
export function summarizePvpEvent(entity, record, shipsLeft) {
|
|
1138
|
+
if (!record) return null;
|
|
1139
|
+
const damageBonusPercent = record.q52 ?? 0;
|
|
1140
|
+
return {
|
|
1141
|
+
entity,
|
|
1142
|
+
active: (record.q44 ?? 0) >= 0,
|
|
1143
|
+
bounds: {
|
|
1144
|
+
minX: (record.q20 ?? 0) / 10,
|
|
1145
|
+
minY: (record.q24 ?? 0) / 10,
|
|
1146
|
+
maxX: (record.q28 ?? 0) / 10,
|
|
1147
|
+
maxY: (record.q32 ?? 0) / 10
|
|
1148
|
+
},
|
|
1149
|
+
worldBounds: {minX: 0, minY: 0, maxX: record.q36 ?? 0, maxY: record.q40 ?? 0},
|
|
1150
|
+
timeSeconds: record.q44 ?? 0,
|
|
1151
|
+
damageBonusPercent,
|
|
1152
|
+
damagePercent: damageBonusPercent + 100,
|
|
1153
|
+
damageMultiplier: (damageBonusPercent + 100) / 100,
|
|
1154
|
+
shipsLeft,
|
|
1155
|
+
state: cloneRecord(record)
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
export function summarizePvpPartyEntry(entity, record) {
|
|
1160
|
+
return {
|
|
1161
|
+
entity,
|
|
1162
|
+
partyId: record.q20 ?? 0,
|
|
1163
|
+
hexCode: decodeText(record.blob24),
|
|
1164
|
+
kind: record.q37 ? "join-request" : "invitation",
|
|
1165
|
+
state: cloneRecord(record)
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1121
1169
|
export function summarizeShipSize(entity, record) {
|
|
1122
1170
|
if (!record) return null;
|
|
1123
1171
|
return {
|