@crowdedkingdoms/crowdyjs 17.14.0-dev.1 → 18.0.0-dev.1
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/MIGRATION.md +92 -1
- package/README.md +93 -162
- package/dist/crowdy-client.d.ts +12 -31
- package/dist/crowdy-client.d.ts.map +1 -1
- package/dist/crowdy-client.js +15 -37
- package/dist/crowdy-dsh/bridge.d.ts.map +1 -1
- package/dist/crowdy-dsh/bridge.js +3 -6
- package/dist/crowdy-studio/controller.d.ts +34 -59
- package/dist/crowdy-studio/controller.d.ts.map +1 -1
- package/dist/crowdy-studio/controller.js +96 -225
- package/dist/crowdy-studio/diagnostics.d.ts +3 -12
- package/dist/crowdy-studio/diagnostics.d.ts.map +1 -1
- package/dist/crowdy-studio/dom-shell.d.ts +2 -4
- package/dist/crowdy-studio/dom-shell.d.ts.map +1 -1
- package/dist/crowdy-studio/dom-shell.js +16 -49
- package/dist/crowdy-studio/embed/hud-layer.d.ts +1 -2
- package/dist/crowdy-studio/embed/hud-layer.d.ts.map +1 -1
- package/dist/crowdy-studio/embed/panel.d.ts +3 -13
- package/dist/crowdy-studio/embed/panel.d.ts.map +1 -1
- package/dist/crowdy-studio/embed/panel.js +3 -6
- package/dist/crowdy-studio/index.d.ts +1 -3
- package/dist/crowdy-studio/index.d.ts.map +1 -1
- package/dist/crowdy-studio/index.js +0 -2
- package/dist/crowdy-studio/models.d.ts +3 -4
- package/dist/crowdy-studio/models.d.ts.map +1 -1
- package/dist/crowdy-studio/starter-projects.d.ts +8 -12
- package/dist/crowdy-studio/starter-projects.d.ts.map +1 -1
- package/dist/crowdy-studio/starter-projects.js +12 -103
- package/dist/domains/appAccess.d.ts +14 -1
- package/dist/domains/appAccess.d.ts.map +1 -1
- package/dist/domains/appAccess.js +37 -1
- package/dist/domains/host.d.ts +3 -3
- package/dist/domains/host.js +3 -3
- package/dist/domains/marketplace.d.ts +9 -70
- package/dist/domains/marketplace.d.ts.map +1 -1
- package/dist/domains/marketplace.js +9 -120
- package/dist/domains/playerWallet.d.ts +6 -12
- package/dist/domains/playerWallet.d.ts.map +1 -1
- package/dist/domains/playerWallet.js +6 -21
- package/dist/errors.d.ts +7 -13
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +6 -10
- package/dist/generated/graphql.d.ts +141 -7083
- package/dist/generated/graphql.d.ts.map +1 -1
- package/dist/generated/graphql.js +5 -313
- package/dist/grid-mods/exec-client-halves.d.ts +19 -3
- package/dist/grid-mods/exec-client-halves.d.ts.map +1 -1
- package/dist/grid-mods/exec-client-halves.js +17 -2
- package/dist/grid-mods/grid-host-calls.d.ts +29 -17
- package/dist/grid-mods/grid-host-calls.d.ts.map +1 -1
- package/dist/grid-mods/grid-host-calls.js +40 -46
- package/dist/grid-mods/mod-runtime.d.ts +18 -11
- package/dist/grid-mods/mod-runtime.d.ts.map +1 -1
- package/dist/grid-mods/mod-runtime.js +4 -2
- package/dist/grid-scope.d.ts +0 -189
- package/dist/grid-scope.d.ts.map +1 -1
- package/dist/grid-scope.js +0 -70
- package/dist/index.d.ts +11 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -16
- package/dist/kit/actions.d.ts +5 -9
- package/dist/kit/actions.d.ts.map +1 -1
- package/dist/kit/actions.js +5 -9
- package/dist/kit/index.d.ts +2 -33
- package/dist/kit/index.d.ts.map +1 -1
- package/dist/kit/index.js +1 -32
- package/dist/kit/kit.d.ts +8 -208
- package/dist/kit/kit.d.ts.map +1 -1
- package/dist/kit/kit.js +5 -163
- package/dist/kit/social.d.ts +1 -3
- package/dist/kit/social.d.ts.map +1 -1
- package/dist/kit/social.js +1 -3
- package/dist/kit/wire.d.ts +16 -5
- package/dist/kit/wire.d.ts.map +1 -1
- package/dist/kit/wire.js +19 -5
- package/dist/live-coding/assets/browser-authoring-index.json +1 -1
- package/dist/live-coding/assets/manifest.json +1 -1
- package/dist/live-coding/browser-authoring-index.generated.d.ts.map +1 -1
- package/dist/live-coding/browser-authoring-index.generated.js +1496 -4386
- package/dist/live-coding/rust-analysis.d.ts.map +1 -1
- package/dist/live-coding/rust-analysis.js +30 -34
- package/dist/player-runtime/client-host-calls.d.ts +8 -0
- package/dist/player-runtime/client-host-calls.d.ts.map +1 -0
- package/dist/player-runtime/client-host-calls.js +28 -0
- package/dist/player-runtime/glue-runtime.d.ts +24 -20
- package/dist/player-runtime/glue-runtime.d.ts.map +1 -1
- package/dist/player-runtime/glue-runtime.js +26 -55
- package/dist/player-runtime/glue-sab.d.ts +2 -2
- package/dist/player-runtime/glue-sab.js +2 -2
- package/dist/player-runtime/player-code-broker.d.ts +70 -43
- package/dist/player-runtime/player-code-broker.d.ts.map +1 -1
- package/dist/player-runtime/player-code-broker.js +159 -64
- package/dist/player-runtime/player-glue-worker.d.ts +8 -9
- package/dist/player-runtime/player-glue-worker.d.ts.map +1 -1
- package/dist/player-runtime/player-glue-worker.js +26 -11
- package/dist/stores/inbox.d.ts +1 -1
- package/dist/stores/inbox.d.ts.map +1 -1
- package/dist/stores/index.d.ts +0 -11
- package/dist/stores/index.d.ts.map +1 -1
- package/dist/stores/index.js +0 -4
- package/dist/stores/session.d.ts +0 -2
- package/dist/stores/session.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/crowdy-studio/model-lint-log.d.ts +0 -76
- package/dist/crowdy-studio/model-lint-log.d.ts.map +0 -1
- package/dist/crowdy-studio/model-lint-log.js +0 -93
- package/dist/crowdy-studio/model-lint.d.ts +0 -61
- package/dist/crowdy-studio/model-lint.d.ts.map +0 -1
- package/dist/crowdy-studio/model-lint.js +0 -45
- package/dist/domains/compute.d.ts +0 -208
- package/dist/domains/compute.d.ts.map +0 -1
- package/dist/domains/compute.js +0 -274
- package/dist/domains/controlPlane.d.ts +0 -38
- package/dist/domains/controlPlane.d.ts.map +0 -1
- package/dist/domains/controlPlane.js +0 -43
- package/dist/domains/gameModel.d.ts +0 -1174
- package/dist/domains/gameModel.d.ts.map +0 -1
- package/dist/domains/gameModel.js +0 -1333
- package/dist/domains/playerCompute.d.ts +0 -91
- package/dist/domains/playerCompute.d.ts.map +0 -1
- package/dist/domains/playerCompute.js +0 -136
- package/dist/domains/playerModel.d.ts +0 -20
- package/dist/domains/playerModel.d.ts.map +0 -1
- package/dist/domains/playerModel.js +0 -54
- package/dist/kit/abilities.d.ts +0 -66
- package/dist/kit/abilities.d.ts.map +0 -1
- package/dist/kit/abilities.js +0 -71
- package/dist/kit/blueprints/combat.d.ts +0 -81
- package/dist/kit/blueprints/combat.d.ts.map +0 -1
- package/dist/kit/blueprints/combat.js +0 -357
- package/dist/kit/blueprints/core.d.ts +0 -222
- package/dist/kit/blueprints/core.d.ts.map +0 -1
- package/dist/kit/blueprints/core.js +0 -185
- package/dist/kit/blueprints/decks.d.ts +0 -50
- package/dist/kit/blueprints/decks.d.ts.map +0 -1
- package/dist/kit/blueprints/decks.js +0 -163
- package/dist/kit/blueprints/economy.d.ts +0 -88
- package/dist/kit/blueprints/economy.d.ts.map +0 -1
- package/dist/kit/blueprints/economy.js +0 -533
- package/dist/kit/blueprints/guild.d.ts +0 -51
- package/dist/kit/blueprints/guild.d.ts.map +0 -1
- package/dist/kit/blueprints/guild.js +0 -50
- package/dist/kit/blueprints/index.d.ts +0 -23
- package/dist/kit/blueprints/index.d.ts.map +0 -1
- package/dist/kit/blueprints/index.js +0 -22
- package/dist/kit/blueprints/inventory.d.ts +0 -84
- package/dist/kit/blueprints/inventory.d.ts.map +0 -1
- package/dist/kit/blueprints/inventory.js +0 -257
- package/dist/kit/blueprints/leaderboards.d.ts +0 -49
- package/dist/kit/blueprints/leaderboards.d.ts.map +0 -1
- package/dist/kit/blueprints/leaderboards.js +0 -126
- package/dist/kit/blueprints/liveops.d.ts +0 -42
- package/dist/kit/blueprints/liveops.d.ts.map +0 -1
- package/dist/kit/blueprints/liveops.js +0 -170
- package/dist/kit/blueprints/locks.d.ts +0 -82
- package/dist/kit/blueprints/locks.d.ts.map +0 -1
- package/dist/kit/blueprints/locks.js +0 -155
- package/dist/kit/blueprints/loot.d.ts +0 -90
- package/dist/kit/blueprints/loot.d.ts.map +0 -1
- package/dist/kit/blueprints/loot.js +0 -229
- package/dist/kit/blueprints/matches.d.ts +0 -84
- package/dist/kit/blueprints/matches.d.ts.map +0 -1
- package/dist/kit/blueprints/matches.js +0 -349
- package/dist/kit/blueprints/moderation.d.ts +0 -32
- package/dist/kit/blueprints/moderation.d.ts.map +0 -1
- package/dist/kit/blueprints/moderation.js +0 -140
- package/dist/kit/blueprints/npcs.d.ts +0 -78
- package/dist/kit/blueprints/npcs.d.ts.map +0 -1
- package/dist/kit/blueprints/npcs.js +0 -125
- package/dist/kit/blueprints/plots.d.ts +0 -63
- package/dist/kit/blueprints/plots.d.ts.map +0 -1
- package/dist/kit/blueprints/plots.js +0 -151
- package/dist/kit/blueprints/progression.d.ts +0 -68
- package/dist/kit/blueprints/progression.d.ts.map +0 -1
- package/dist/kit/blueprints/progression.js +0 -324
- package/dist/kit/blueprints/quests.d.ts +0 -72
- package/dist/kit/blueprints/quests.d.ts.map +0 -1
- package/dist/kit/blueprints/quests.js +0 -285
- package/dist/kit/blueprints/worldsim.d.ts +0 -91
- package/dist/kit/blueprints/worldsim.d.ts.map +0 -1
- package/dist/kit/blueprints/worldsim.js +0 -468
- package/dist/kit/combat.d.ts +0 -141
- package/dist/kit/combat.d.ts.map +0 -1
- package/dist/kit/combat.js +0 -196
- package/dist/kit/decks.d.ts +0 -157
- package/dist/kit/decks.d.ts.map +0 -1
- package/dist/kit/decks.js +0 -186
- package/dist/kit/director.d.ts +0 -88
- package/dist/kit/director.d.ts.map +0 -1
- package/dist/kit/director.js +0 -86
- package/dist/kit/economy.d.ts +0 -289
- package/dist/kit/economy.d.ts.map +0 -1
- package/dist/kit/economy.js +0 -427
- package/dist/kit/engine.d.ts +0 -48
- package/dist/kit/engine.d.ts.map +0 -1
- package/dist/kit/engine.js +0 -113
- package/dist/kit/features.d.ts +0 -60
- package/dist/kit/features.d.ts.map +0 -1
- package/dist/kit/features.js +0 -65
- package/dist/kit/instances.d.ts +0 -52
- package/dist/kit/instances.d.ts.map +0 -1
- package/dist/kit/instances.js +0 -60
- package/dist/kit/inventory.d.ts +0 -129
- package/dist/kit/inventory.d.ts.map +0 -1
- package/dist/kit/inventory.js +0 -200
- package/dist/kit/leaderboards.d.ts +0 -86
- package/dist/kit/leaderboards.d.ts.map +0 -1
- package/dist/kit/leaderboards.js +0 -133
- package/dist/kit/liveops.d.ts +0 -112
- package/dist/kit/liveops.d.ts.map +0 -1
- package/dist/kit/liveops.js +0 -183
- package/dist/kit/loot.d.ts +0 -128
- package/dist/kit/loot.d.ts.map +0 -1
- package/dist/kit/loot.js +0 -160
- package/dist/kit/matches.d.ts +0 -301
- package/dist/kit/matches.d.ts.map +0 -1
- package/dist/kit/matches.js +0 -458
- package/dist/kit/matchmaking.d.ts +0 -57
- package/dist/kit/matchmaking.d.ts.map +0 -1
- package/dist/kit/matchmaking.js +0 -59
- package/dist/kit/minigames.d.ts +0 -30
- package/dist/kit/minigames.d.ts.map +0 -1
- package/dist/kit/minigames.js +0 -38
- package/dist/kit/mobs.d.ts +0 -90
- package/dist/kit/mobs.d.ts.map +0 -1
- package/dist/kit/mobs.js +0 -98
- package/dist/kit/moderation.d.ts +0 -73
- package/dist/kit/moderation.d.ts.map +0 -1
- package/dist/kit/moderation.js +0 -103
- package/dist/kit/movement.d.ts +0 -78
- package/dist/kit/movement.d.ts.map +0 -1
- package/dist/kit/movement.js +0 -103
- package/dist/kit/notifications.d.ts +0 -45
- package/dist/kit/notifications.d.ts.map +0 -1
- package/dist/kit/notifications.js +0 -67
- package/dist/kit/npcs.d.ts +0 -226
- package/dist/kit/npcs.d.ts.map +0 -1
- package/dist/kit/npcs.js +0 -141
- package/dist/kit/objects.d.ts +0 -116
- package/dist/kit/objects.d.ts.map +0 -1
- package/dist/kit/objects.js +0 -119
- package/dist/kit/pets.d.ts +0 -85
- package/dist/kit/pets.d.ts.map +0 -1
- package/dist/kit/pets.js +0 -96
- package/dist/kit/plots.d.ts +0 -85
- package/dist/kit/plots.d.ts.map +0 -1
- package/dist/kit/plots.js +0 -113
- package/dist/kit/progression.d.ts +0 -181
- package/dist/kit/progression.d.ts.map +0 -1
- package/dist/kit/progression.js +0 -265
- package/dist/kit/quests.d.ts +0 -171
- package/dist/kit/quests.d.ts.map +0 -1
- package/dist/kit/quests.js +0 -237
- package/dist/kit/racing.d.ts +0 -85
- package/dist/kit/racing.d.ts.map +0 -1
- package/dist/kit/racing.js +0 -99
- package/dist/kit/shared.d.ts +0 -73
- package/dist/kit/shared.d.ts.map +0 -1
- package/dist/kit/shared.js +0 -101
- package/dist/kit/telemetry.d.ts +0 -66
- package/dist/kit/telemetry.d.ts.map +0 -1
- package/dist/kit/telemetry.js +0 -133
- package/dist/kit/territory.d.ts +0 -97
- package/dist/kit/territory.d.ts.map +0 -1
- package/dist/kit/territory.js +0 -114
- package/dist/kit/worldsim.d.ts +0 -263
- package/dist/kit/worldsim.d.ts.map +0 -1
- package/dist/kit/worldsim.js +0 -268
- package/dist/stores/model.d.ts +0 -81
- package/dist/stores/model.d.ts.map +0 -1
- package/dist/stores/model.js +0 -163
package/dist/kit/combat.js
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { combatNames } from './blueprints/index.js';
|
|
2
|
-
import { kitContainerProperties, kitInvoke, } from './shared.js';
|
|
3
|
-
/**
|
|
4
|
-
* Runtime helpers for the {@link combatBlueprint} conventions: spawn
|
|
5
|
-
* combatants, attack (server-side damage formula + death flip), arm status
|
|
6
|
-
* effects the tick automation applies over time, respawn, and route
|
|
7
|
-
* competitive realtime attacks through a compute referee. `hostSynced`
|
|
8
|
-
* remains a low-stakes/legacy fallback for persisting elected-host state;
|
|
9
|
-
* it is not an anti-cheat boundary. Denials resolve with `success: false`.
|
|
10
|
-
*
|
|
11
|
-
* Obtained via `client.kit(appId).combat`.
|
|
12
|
-
*/
|
|
13
|
-
export class CombatKit {
|
|
14
|
-
constructor(appId, gameModel, options = {}, engines) {
|
|
15
|
-
this.appId = appId;
|
|
16
|
-
this.gameModel = gameModel;
|
|
17
|
-
this.engines = engines;
|
|
18
|
-
this.names = combatNames(options.typePrefix ?? '');
|
|
19
|
-
this.engineModuleName = options.engineModuleName ?? 'mob-engine';
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Route an attack through the strongest available authority: the compute
|
|
23
|
-
* referee (`attack_mob` on the mob engine — presence/range validated
|
|
24
|
-
* server-side) when the engine is deployed (capability-detected, cached),
|
|
25
|
-
* else today's model attack function. One call, both deployments.
|
|
26
|
-
*
|
|
27
|
-
* @param input.targetId - The target container (engine mob slot or model
|
|
28
|
-
* combatant).
|
|
29
|
-
* @param input.attackerId - The caller's combatant container — required
|
|
30
|
-
* for the model path, ignored by the engine referee (it referees by the
|
|
31
|
-
* caller's live actor position).
|
|
32
|
-
* @param input.amount - Engine-path damage (clamped by the referee).
|
|
33
|
-
*/
|
|
34
|
-
async attackRouted(input) {
|
|
35
|
-
if (this.engines && (await this.engines.has(this.engineModuleName))) {
|
|
36
|
-
const result = await this.engines.invoke(this.engineModuleName, 'attack_mob', {
|
|
37
|
-
containerId: input.targetId,
|
|
38
|
-
amount: input.amount ?? 1,
|
|
39
|
-
});
|
|
40
|
-
return {
|
|
41
|
-
success: result.success,
|
|
42
|
-
health: typeof result.body.health === 'number' ? result.body.health : undefined,
|
|
43
|
-
killed: typeof result.body.killed === 'boolean' ? result.body.killed : undefined,
|
|
44
|
-
reason: result.reason,
|
|
45
|
-
via: 'engine',
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
if (!input.attackerId) {
|
|
49
|
-
return {
|
|
50
|
-
success: false,
|
|
51
|
-
reason: 'attackerId is required for the model combat path',
|
|
52
|
-
via: 'model',
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
const result = await this.attack(input.attackerId, input.targetId);
|
|
56
|
-
return {
|
|
57
|
-
success: result.success,
|
|
58
|
-
health: result.returnValue,
|
|
59
|
-
reason: result.errorMessage,
|
|
60
|
-
via: 'model',
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Spawn a combatant with a unique `combat_key` (the status-effect join
|
|
65
|
-
* key) and the `owner_user_id` mirror.
|
|
66
|
-
*/
|
|
67
|
-
async spawnCombatant(input) {
|
|
68
|
-
const combatKey = input.combatKey ?? `ck-${input.ownerUserId}-${Math.random().toString(16).slice(2, 10)}`;
|
|
69
|
-
const maxHp = input.maxHp ?? 100;
|
|
70
|
-
return this.gameModel.createContainer({
|
|
71
|
-
appId: this.appId,
|
|
72
|
-
typeName: this.names.combatantType,
|
|
73
|
-
displayName: input.displayName,
|
|
74
|
-
...(input.sessionId !== undefined ? { sessionId: input.sessionId } : {}),
|
|
75
|
-
properties: [
|
|
76
|
-
{ key: 'owner_user_id', valueType: 'int', valueJson: String(input.ownerUserId) },
|
|
77
|
-
{ key: 'combat_key', valueType: 'string', valueJson: JSON.stringify(combatKey) },
|
|
78
|
-
{ key: 'hp', valueType: 'int', valueJson: String(input.hp ?? maxHp) },
|
|
79
|
-
{ key: 'max_hp', valueType: 'int', valueJson: String(maxHp) },
|
|
80
|
-
{ key: 'attack', valueType: 'int', valueJson: String(input.attack ?? 10) },
|
|
81
|
-
{ key: 'defense', valueType: 'int', valueJson: String(input.defense ?? 0) },
|
|
82
|
-
...(input.properties ?? []),
|
|
83
|
-
],
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
/** Read one combatant's state. */
|
|
87
|
-
async state(combatantId) {
|
|
88
|
-
const container = await this.gameModel.container({
|
|
89
|
-
appId: this.appId,
|
|
90
|
-
containerId: combatantId,
|
|
91
|
-
});
|
|
92
|
-
const props = await kitContainerProperties(this.gameModel, String(this.appId), combatantId);
|
|
93
|
-
return {
|
|
94
|
-
containerId: container.containerId,
|
|
95
|
-
displayName: container.displayName,
|
|
96
|
-
ownerUserId: container.ownerUserId != null ? String(container.ownerUserId) : null,
|
|
97
|
-
combatKey: String(props.combat_key ?? ''),
|
|
98
|
-
hp: Number(props.hp ?? 0),
|
|
99
|
-
maxHp: Number(props.max_hp ?? 0),
|
|
100
|
-
attack: Number(props.attack ?? 0),
|
|
101
|
-
defense: Number(props.defense ?? 0),
|
|
102
|
-
alive: props.alive === true,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Attack a target with your combatant. The damage formula and the death
|
|
107
|
-
* flip run server-side. Resolves with the target's remaining hp.
|
|
108
|
-
*/
|
|
109
|
-
async attack(attackerId, targetId) {
|
|
110
|
-
return kitInvoke(this.gameModel, {
|
|
111
|
-
appId: String(this.appId),
|
|
112
|
-
functionName: this.names.attackFn,
|
|
113
|
-
selfContainerId: attackerId,
|
|
114
|
-
params: { target_id: targetId },
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Arm a status effect against a target's `combat_key`: creates the
|
|
119
|
-
* caller's StatusEffect container (when `effectContainerId` is omitted)
|
|
120
|
-
* and invokes the gated apply function; the interval automation then
|
|
121
|
-
* ticks it server-side.
|
|
122
|
-
*/
|
|
123
|
-
async applyEffect(input) {
|
|
124
|
-
let effectId = input.effectContainerId;
|
|
125
|
-
if (!effectId) {
|
|
126
|
-
const created = await this.gameModel.createContainer({
|
|
127
|
-
appId: this.appId,
|
|
128
|
-
typeName: this.names.effectType,
|
|
129
|
-
displayName: `Effect ${input.effectId}`,
|
|
130
|
-
...(input.sessionId !== undefined ? { sessionId: input.sessionId } : {}),
|
|
131
|
-
});
|
|
132
|
-
effectId = created.containerId;
|
|
133
|
-
}
|
|
134
|
-
return kitInvoke(this.gameModel, {
|
|
135
|
-
appId: String(this.appId),
|
|
136
|
-
functionName: this.names.applyEffectFn,
|
|
137
|
-
selfContainerId: effectId,
|
|
138
|
-
params: {
|
|
139
|
-
target_key: input.targetKey,
|
|
140
|
-
effect_id: input.effectId,
|
|
141
|
-
magnitude: input.magnitude,
|
|
142
|
-
ticks: input.ticks,
|
|
143
|
-
},
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
/** List the active status effects targeting a combat_key. */
|
|
147
|
-
async effects(targetKey) {
|
|
148
|
-
const containers = await this.gameModel.containers({
|
|
149
|
-
appId: this.appId,
|
|
150
|
-
typeName: this.names.effectType,
|
|
151
|
-
});
|
|
152
|
-
const all = await Promise.all(containers.map(async (c) => {
|
|
153
|
-
const props = await kitContainerProperties(this.gameModel, String(this.appId), c.containerId);
|
|
154
|
-
return {
|
|
155
|
-
containerId: c.containerId,
|
|
156
|
-
displayName: c.displayName,
|
|
157
|
-
ownerUserId: c.ownerUserId != null ? String(c.ownerUserId) : null,
|
|
158
|
-
effectId: String(props.effect_id ?? ''),
|
|
159
|
-
targetKey: String(props.target_key ?? ''),
|
|
160
|
-
magnitude: Number(props.magnitude ?? 0),
|
|
161
|
-
ticksLeft: Number(props.ticks_left ?? 0),
|
|
162
|
-
};
|
|
163
|
-
}));
|
|
164
|
-
return all.filter((e) => e.ticksLeft > 0 && (targetKey === undefined || e.targetKey === targetKey));
|
|
165
|
-
}
|
|
166
|
-
/** Respawn your downed combatant at full hp. */
|
|
167
|
-
async respawn(combatantId) {
|
|
168
|
-
return kitInvoke(this.gameModel, {
|
|
169
|
-
appId: String(this.appId),
|
|
170
|
-
functionName: this.names.respawnFn,
|
|
171
|
-
selfContainerId: combatantId,
|
|
172
|
-
params: {},
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
/** Revive a downed combatant (blueprint deployed with `reviveGroup`). */
|
|
176
|
-
async revive(combatantId) {
|
|
177
|
-
return kitInvoke(this.gameModel, {
|
|
178
|
-
appId: String(this.appId),
|
|
179
|
-
functionName: this.names.reviveFn,
|
|
180
|
-
selfContainerId: combatantId,
|
|
181
|
-
params: {},
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Persist host-simulated hp (blueprint deployed with `hostSynced: true`;
|
|
186
|
-
* `is_host` enforced server-side). Resolves with the clamped hp.
|
|
187
|
-
*/
|
|
188
|
-
async syncCombatant(combatantId, hp) {
|
|
189
|
-
return kitInvoke(this.gameModel, {
|
|
190
|
-
appId: String(this.appId),
|
|
191
|
-
functionName: this.names.syncFn,
|
|
192
|
-
selfContainerId: combatantId,
|
|
193
|
-
params: { hp },
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
}
|
package/dist/kit/decks.d.ts
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import type { GameModelAPI } from '../domains/gameModel.js';
|
|
2
|
-
import type { EngineDetector } from './engine.js';
|
|
3
|
-
import type { Scalars } from '../generated/graphql.js';
|
|
4
|
-
import { type KitInvokeResult } from './shared.js';
|
|
5
|
-
/** Options for {@link DecksKit}. Must match the deployed decks blueprint. */
|
|
6
|
-
export interface DecksKitOptions {
|
|
7
|
-
/**
|
|
8
|
-
* The compute module holding hidden hands when the app runs a deck
|
|
9
|
-
* engine. Defaults to `'deck-engine'`.
|
|
10
|
-
*/
|
|
11
|
-
engineModuleName?: string;
|
|
12
|
-
/** The `typePrefix` the decks blueprint was deployed with. */
|
|
13
|
-
typePrefix?: string;
|
|
14
|
-
}
|
|
15
|
-
/** A parsed view of one card instance, as visible to the CALLER. */
|
|
16
|
-
export interface KitCard {
|
|
17
|
-
containerId: string;
|
|
18
|
-
displayName: string;
|
|
19
|
-
ownerUserId: string | null;
|
|
20
|
-
/**
|
|
21
|
-
* The hidden identity — non-empty only when the caller may see it (their
|
|
22
|
-
* own cards, or any revealed card via `revealedCardId`).
|
|
23
|
-
*/
|
|
24
|
-
cardId: string;
|
|
25
|
-
/** The public identity (empty until played/discarded). */
|
|
26
|
-
revealedCardId: string;
|
|
27
|
-
zone: string;
|
|
28
|
-
position: number;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Runtime helpers for the {@link decksBlueprint} conventions: deal
|
|
32
|
-
* session-scoped cards, shuffle by dealing random positions (admin-run
|
|
33
|
-
* automation), and draw/play/discard through the zone-guarded functions.
|
|
34
|
-
* Hidden information is enforced by property visibility server-side: reads
|
|
35
|
-
* go through `containerState`, which strips other players' `card_id`.
|
|
36
|
-
*
|
|
37
|
-
* Obtained via `client.kit(appId).decks`.
|
|
38
|
-
*/
|
|
39
|
-
export declare class DecksKit {
|
|
40
|
-
private readonly appId;
|
|
41
|
-
private readonly gameModel;
|
|
42
|
-
private readonly engines?;
|
|
43
|
-
private readonly names;
|
|
44
|
-
constructor(appId: Scalars['BigInt']['input'], gameModel: GameModelAPI, options?: DecksKitOptions, engines?: EngineDetector | undefined);
|
|
45
|
-
private readonly engineModuleName;
|
|
46
|
-
/**
|
|
47
|
-
* Is a deck compute engine deployed + enabled (cached per session)? When
|
|
48
|
-
* true, hands and deck order live in MODULE state (server-held secrets);
|
|
49
|
-
* the blueprint's owner-visibility hands remain for model-only apps.
|
|
50
|
-
*/
|
|
51
|
-
engineAvailable(): Promise<boolean>;
|
|
52
|
-
/** Create an engine table with seeded shuffle + hidden deals (creator seats itself). */
|
|
53
|
-
engineNewTable(input: {
|
|
54
|
-
tableId: string;
|
|
55
|
-
players: string[];
|
|
56
|
-
handSize?: number;
|
|
57
|
-
deckDef?: string;
|
|
58
|
-
}): Promise<Record<string, unknown>>;
|
|
59
|
-
/** YOUR hidden hand (the only read path; opponents can never see it). */
|
|
60
|
-
engineHand(tableId: string): Promise<string[]>;
|
|
61
|
-
/** Draw one card into your hidden hand. */
|
|
62
|
-
engineDraw(tableId: string): Promise<Record<string, unknown>>;
|
|
63
|
-
/** Play (reveal) a card from your hand into a public zone. */
|
|
64
|
-
enginePlay(tableId: string, card: string, zone?: string): Promise<Record<string, unknown>>;
|
|
65
|
-
/** Collect a public zone to the discard (trick taken). */
|
|
66
|
-
engineTakeZone(tableId: string, zone: string): Promise<Record<string, unknown>>;
|
|
67
|
-
/** The public table view (counts + zones — never hidden hands). */
|
|
68
|
-
engineTable(tableId: string): Promise<Record<string, unknown>>;
|
|
69
|
-
private engineInvoke;
|
|
70
|
-
/**
|
|
71
|
-
* Deal a deck to a player: creates one CardInstance per card id (zone
|
|
72
|
-
* `deck`), owned by the player. Run {@link shuffle} afterwards to deal
|
|
73
|
-
* random positions.
|
|
74
|
-
*/
|
|
75
|
-
deal(input: {
|
|
76
|
-
ownerUserId: Scalars['BigInt']['input'];
|
|
77
|
-
cardIds: string[];
|
|
78
|
-
sessionId?: string;
|
|
79
|
-
}): Promise<{
|
|
80
|
-
__typename?: "GmContainer";
|
|
81
|
-
containerId: string;
|
|
82
|
-
appId: string;
|
|
83
|
-
sessionId: string | null;
|
|
84
|
-
typeName: string;
|
|
85
|
-
displayName: string;
|
|
86
|
-
description: string | null;
|
|
87
|
-
ownerUserId: string | null;
|
|
88
|
-
metadataJson: string;
|
|
89
|
-
}[]>;
|
|
90
|
-
/**
|
|
91
|
-
* Shuffle every deck-zone card by running the manual `assign_position`
|
|
92
|
-
* automation (admin): each card gets a fresh `rand_int` position
|
|
93
|
-
* server-side.
|
|
94
|
-
*/
|
|
95
|
-
shuffle(): Promise<{
|
|
96
|
-
__typename?: "GmAutomationRun";
|
|
97
|
-
runId: string;
|
|
98
|
-
appId: string;
|
|
99
|
-
flowId: string | null;
|
|
100
|
-
automationId: string | null;
|
|
101
|
-
automationName: string;
|
|
102
|
-
triggerSource: string;
|
|
103
|
-
triggerId: string | null;
|
|
104
|
-
parentRunId: string | null;
|
|
105
|
-
cascadeDepth: number;
|
|
106
|
-
startedAt: string;
|
|
107
|
-
finishedAt: string | null;
|
|
108
|
-
durationUs: number;
|
|
109
|
-
targets: number;
|
|
110
|
-
invocations: number;
|
|
111
|
-
mutations: number;
|
|
112
|
-
fnCalls: number;
|
|
113
|
-
gasUsed: number;
|
|
114
|
-
success: boolean;
|
|
115
|
-
errorMessage: string | null;
|
|
116
|
-
circuitAction: string | null;
|
|
117
|
-
computeUnits: number;
|
|
118
|
-
}>;
|
|
119
|
-
/** A player's cards in one zone, as visible to the caller. */
|
|
120
|
-
cards(ownerUserId: Scalars['BigInt']['input'] | null, options?: {
|
|
121
|
-
zone?: string;
|
|
122
|
-
sessionId?: string;
|
|
123
|
-
}): Promise<KitCard[]>;
|
|
124
|
-
/** Your hand (owner-visible card ids included by the server). */
|
|
125
|
-
myHand(ownerUserId: Scalars['BigInt']['input'], options?: {
|
|
126
|
-
sessionId?: string;
|
|
127
|
-
}): Promise<KitCard[]>;
|
|
128
|
-
/** Every card on the board (public: revealed ids). */
|
|
129
|
-
board(options?: {
|
|
130
|
-
sessionId?: string;
|
|
131
|
-
}): Promise<KitCard[]>;
|
|
132
|
-
/**
|
|
133
|
-
* Draw the top of your deck (lowest position — positions were dealt by
|
|
134
|
-
* the shuffle automation). The server enforces ownership, turn (when
|
|
135
|
-
* `turnBased`), and the deck→hand zone transition.
|
|
136
|
-
*/
|
|
137
|
-
draw(ownerUserId: Scalars['BigInt']['input'], options?: {
|
|
138
|
-
sessionId?: string;
|
|
139
|
-
}): Promise<KitInvokeResult<string>>;
|
|
140
|
-
/** Draw one specific deck card (prefer {@link draw} for top-of-deck). */
|
|
141
|
-
drawCard(cardInstanceId: string, options?: {
|
|
142
|
-
sessionId?: string;
|
|
143
|
-
}): Promise<KitInvokeResult<string>>;
|
|
144
|
-
/**
|
|
145
|
-
* Play a card from your hand: the zone flip and the public reveal commit
|
|
146
|
-
* together. Resolves with the revealed card id.
|
|
147
|
-
*/
|
|
148
|
-
play(cardInstanceId: string, options?: {
|
|
149
|
-
sessionId?: string;
|
|
150
|
-
}): Promise<KitInvokeResult<string>>;
|
|
151
|
-
/** Discard a card face-up. */
|
|
152
|
-
discard(cardInstanceId: string, options?: {
|
|
153
|
-
sessionId?: string;
|
|
154
|
-
}): Promise<KitInvokeResult<string>>;
|
|
155
|
-
private toCard;
|
|
156
|
-
}
|
|
157
|
-
//# sourceMappingURL=decks.d.ts.map
|
package/dist/kit/decks.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decks.d.ts","sourceRoot":"","sources":["../../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E,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAIrE;;;;OAIG;IACG,IAAI,CACR,WAAW,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,EACvC,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GACnC,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IASnC,yEAAyE;IACnE,QAAQ,CACZ,cAAc,EAAE,MAAM,EACtB,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GACnC,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAUnC;;;OAGG;IACG,IAAI,CACR,cAAc,EAAE,MAAM,EACtB,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GACnC,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAUnC,8BAA8B;IACxB,OAAO,CACX,cAAc,EAAE,MAAM,EACtB,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GACnC,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;YAUrB,MAAM;CAsBrB"}
|
package/dist/kit/decks.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { decksNames } from './blueprints/index.js';
|
|
2
|
-
import { kitContainerProperties, kitInvoke, } from './shared.js';
|
|
3
|
-
/**
|
|
4
|
-
* Runtime helpers for the {@link decksBlueprint} conventions: deal
|
|
5
|
-
* session-scoped cards, shuffle by dealing random positions (admin-run
|
|
6
|
-
* automation), and draw/play/discard through the zone-guarded functions.
|
|
7
|
-
* Hidden information is enforced by property visibility server-side: reads
|
|
8
|
-
* go through `containerState`, which strips other players' `card_id`.
|
|
9
|
-
*
|
|
10
|
-
* Obtained via `client.kit(appId).decks`.
|
|
11
|
-
*/
|
|
12
|
-
export class DecksKit {
|
|
13
|
-
constructor(appId, gameModel, options = {}, engines) {
|
|
14
|
-
this.appId = appId;
|
|
15
|
-
this.gameModel = gameModel;
|
|
16
|
-
this.engines = engines;
|
|
17
|
-
this.names = decksNames(options.typePrefix ?? '');
|
|
18
|
-
this.engineModuleName = options.engineModuleName ?? 'deck-engine';
|
|
19
|
-
}
|
|
20
|
-
// -- Engine path (Wave 2): true hidden information over the deck engine --
|
|
21
|
-
/**
|
|
22
|
-
* Is a deck compute engine deployed + enabled (cached per session)? When
|
|
23
|
-
* true, hands and deck order live in MODULE state (server-held secrets);
|
|
24
|
-
* the blueprint's owner-visibility hands remain for model-only apps.
|
|
25
|
-
*/
|
|
26
|
-
engineAvailable() {
|
|
27
|
-
if (!this.engines)
|
|
28
|
-
return Promise.resolve(false);
|
|
29
|
-
return this.engines.has(this.engineModuleName);
|
|
30
|
-
}
|
|
31
|
-
/** Create an engine table with seeded shuffle + hidden deals (creator seats itself). */
|
|
32
|
-
async engineNewTable(input) {
|
|
33
|
-
return this.engineInvoke('new_table', input);
|
|
34
|
-
}
|
|
35
|
-
/** YOUR hidden hand (the only read path; opponents can never see it). */
|
|
36
|
-
async engineHand(tableId) {
|
|
37
|
-
const body = await this.engineInvoke('hand', { tableId });
|
|
38
|
-
return Array.isArray(body.hand) ? body.hand.map(String) : [];
|
|
39
|
-
}
|
|
40
|
-
/** Draw one card into your hidden hand. */
|
|
41
|
-
async engineDraw(tableId) {
|
|
42
|
-
return this.engineInvoke('draw', { tableId });
|
|
43
|
-
}
|
|
44
|
-
/** Play (reveal) a card from your hand into a public zone. */
|
|
45
|
-
async enginePlay(tableId, card, zone = 'table') {
|
|
46
|
-
return this.engineInvoke('play', { tableId, card, zone });
|
|
47
|
-
}
|
|
48
|
-
/** Collect a public zone to the discard (trick taken). */
|
|
49
|
-
async engineTakeZone(tableId, zone) {
|
|
50
|
-
return this.engineInvoke('take_zone', { tableId, zone });
|
|
51
|
-
}
|
|
52
|
-
/** The public table view (counts + zones — never hidden hands). */
|
|
53
|
-
async engineTable(tableId) {
|
|
54
|
-
return this.engineInvoke('table', { tableId });
|
|
55
|
-
}
|
|
56
|
-
async engineInvoke(exportName, params) {
|
|
57
|
-
if (!this.engines) {
|
|
58
|
-
throw new Error('deck engine unavailable: compute domain not wired');
|
|
59
|
-
}
|
|
60
|
-
const result = await this.engines.invoke(this.engineModuleName, exportName, params);
|
|
61
|
-
if (!result.success) {
|
|
62
|
-
throw new Error(`decks.${exportName} failed: ${result.reason ?? 'unknown'}`);
|
|
63
|
-
}
|
|
64
|
-
return result.body;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Deal a deck to a player: creates one CardInstance per card id (zone
|
|
68
|
-
* `deck`), owned by the player. Run {@link shuffle} afterwards to deal
|
|
69
|
-
* random positions.
|
|
70
|
-
*/
|
|
71
|
-
async deal(input) {
|
|
72
|
-
const created = [];
|
|
73
|
-
for (const [index, cardId] of input.cardIds.entries()) {
|
|
74
|
-
created.push(await this.gameModel.createContainer({
|
|
75
|
-
appId: this.appId,
|
|
76
|
-
typeName: this.names.cardType,
|
|
77
|
-
displayName: `Card ${index + 1}`,
|
|
78
|
-
...(input.sessionId !== undefined ? { sessionId: input.sessionId } : {}),
|
|
79
|
-
properties: [
|
|
80
|
-
{
|
|
81
|
-
key: 'owner_user_id',
|
|
82
|
-
valueType: 'int',
|
|
83
|
-
valueJson: String(input.ownerUserId),
|
|
84
|
-
},
|
|
85
|
-
{ key: 'card_id', valueType: 'string', valueJson: JSON.stringify(cardId) },
|
|
86
|
-
{ key: 'position', valueType: 'int', valueJson: String(index) },
|
|
87
|
-
],
|
|
88
|
-
}));
|
|
89
|
-
}
|
|
90
|
-
return created;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Shuffle every deck-zone card by running the manual `assign_position`
|
|
94
|
-
* automation (admin): each card gets a fresh `rand_int` position
|
|
95
|
-
* server-side.
|
|
96
|
-
*/
|
|
97
|
-
async shuffle() {
|
|
98
|
-
return this.gameModel.runAutomation({
|
|
99
|
-
appId: this.appId,
|
|
100
|
-
name: this.names.shuffleAutomation,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
/** A player's cards in one zone, as visible to the caller. */
|
|
104
|
-
async cards(ownerUserId, options = {}) {
|
|
105
|
-
const containers = await this.gameModel.containers({
|
|
106
|
-
appId: this.appId,
|
|
107
|
-
typeName: this.names.cardType,
|
|
108
|
-
...(options.sessionId !== undefined ? { sessionId: options.sessionId } : {}),
|
|
109
|
-
});
|
|
110
|
-
const filtered = ownerUserId === null
|
|
111
|
-
? containers
|
|
112
|
-
: containers.filter((c) => c.ownerUserId != null && String(c.ownerUserId) === String(ownerUserId));
|
|
113
|
-
const cards = await Promise.all(filtered.map((c) => this.toCard(c.containerId, c.displayName, c.ownerUserId != null ? String(c.ownerUserId) : null)));
|
|
114
|
-
return options.zone !== undefined
|
|
115
|
-
? cards.filter((c) => c.zone === options.zone)
|
|
116
|
-
: cards;
|
|
117
|
-
}
|
|
118
|
-
/** Your hand (owner-visible card ids included by the server). */
|
|
119
|
-
async myHand(ownerUserId, options = {}) {
|
|
120
|
-
return this.cards(ownerUserId, { ...options, zone: 'hand' });
|
|
121
|
-
}
|
|
122
|
-
/** Every card on the board (public: revealed ids). */
|
|
123
|
-
async board(options = {}) {
|
|
124
|
-
return this.cards(null, { ...options, zone: 'board' });
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Draw the top of your deck (lowest position — positions were dealt by
|
|
128
|
-
* the shuffle automation). The server enforces ownership, turn (when
|
|
129
|
-
* `turnBased`), and the deck→hand zone transition.
|
|
130
|
-
*/
|
|
131
|
-
async draw(ownerUserId, options = {}) {
|
|
132
|
-
const deck = await this.cards(ownerUserId, { ...options, zone: 'deck' });
|
|
133
|
-
if (deck.length === 0) {
|
|
134
|
-
throw new Error('Deck is empty — nothing to draw');
|
|
135
|
-
}
|
|
136
|
-
const top = deck.reduce((a, b) => (b.position < a.position ? b : a));
|
|
137
|
-
return this.drawCard(top.containerId, options);
|
|
138
|
-
}
|
|
139
|
-
/** Draw one specific deck card (prefer {@link draw} for top-of-deck). */
|
|
140
|
-
async drawCard(cardInstanceId, options = {}) {
|
|
141
|
-
return kitInvoke(this.gameModel, {
|
|
142
|
-
appId: String(this.appId),
|
|
143
|
-
functionName: this.names.drawFn,
|
|
144
|
-
selfContainerId: cardInstanceId,
|
|
145
|
-
...(options.sessionId !== undefined ? { sessionId: options.sessionId } : {}),
|
|
146
|
-
params: {},
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Play a card from your hand: the zone flip and the public reveal commit
|
|
151
|
-
* together. Resolves with the revealed card id.
|
|
152
|
-
*/
|
|
153
|
-
async play(cardInstanceId, options = {}) {
|
|
154
|
-
return kitInvoke(this.gameModel, {
|
|
155
|
-
appId: String(this.appId),
|
|
156
|
-
functionName: this.names.playFn,
|
|
157
|
-
selfContainerId: cardInstanceId,
|
|
158
|
-
...(options.sessionId !== undefined ? { sessionId: options.sessionId } : {}),
|
|
159
|
-
params: {},
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
/** Discard a card face-up. */
|
|
163
|
-
async discard(cardInstanceId, options = {}) {
|
|
164
|
-
return kitInvoke(this.gameModel, {
|
|
165
|
-
appId: String(this.appId),
|
|
166
|
-
functionName: this.names.discardFn,
|
|
167
|
-
selfContainerId: cardInstanceId,
|
|
168
|
-
...(options.sessionId !== undefined ? { sessionId: options.sessionId } : {}),
|
|
169
|
-
params: {},
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
async toCard(containerId, displayName, ownerUserId) {
|
|
173
|
-
// containerState filters properties by visibility: other players' hands
|
|
174
|
-
// come back WITHOUT card_id — the hidden-info guarantee is server-side.
|
|
175
|
-
const props = await kitContainerProperties(this.gameModel, String(this.appId), containerId);
|
|
176
|
-
return {
|
|
177
|
-
containerId,
|
|
178
|
-
displayName,
|
|
179
|
-
ownerUserId,
|
|
180
|
-
cardId: String(props.card_id ?? ''),
|
|
181
|
-
revealedCardId: String(props.revealed_card_id ?? ''),
|
|
182
|
-
zone: String(props.zone ?? ''),
|
|
183
|
-
position: Number(props.position ?? 0),
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
}
|
package/dist/kit/director.d.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import type { GameModelAPI } from '../domains/gameModel.js';
|
|
2
|
-
import type { Scalars } from '../generated/graphql.js';
|
|
3
|
-
import type { EngineDetector } from './engine.js';
|
|
4
|
-
/** Options for {@link DirectorKit}. */
|
|
5
|
-
export interface DirectorKitOptions {
|
|
6
|
-
/** The director module name. Defaults to `'director'`. */
|
|
7
|
-
moduleName?: string;
|
|
8
|
-
/** The encounter-definition container type. Defaults to `'EncounterDef'`. */
|
|
9
|
-
defTypeName?: string;
|
|
10
|
-
}
|
|
11
|
-
/** One wave of an encounter definition. */
|
|
12
|
-
export interface KitWaveSpec {
|
|
13
|
-
units: Array<{
|
|
14
|
-
mobId: string;
|
|
15
|
-
count: number;
|
|
16
|
-
}>;
|
|
17
|
-
delayMs?: number;
|
|
18
|
-
/** Boss wave: hp + phase thresholds (descending hp percentages). */
|
|
19
|
-
boss?: {
|
|
20
|
-
hp: number;
|
|
21
|
-
phases?: number[];
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
/** A director run's state. */
|
|
25
|
-
export interface KitDirectorRun {
|
|
26
|
-
runId: string;
|
|
27
|
-
encounterId: string;
|
|
28
|
-
players: number;
|
|
29
|
-
phase: Record<string, unknown>;
|
|
30
|
-
pending: number;
|
|
31
|
-
wavesCleared: number;
|
|
32
|
-
wavesTotal: number;
|
|
33
|
-
boss: {
|
|
34
|
-
hp: number;
|
|
35
|
-
maxHp: number;
|
|
36
|
-
phase: number;
|
|
37
|
-
thresholds: number[];
|
|
38
|
-
} | null;
|
|
39
|
-
finished: boolean;
|
|
40
|
-
outcome: string;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Runtime helpers for the director engine (Wave 2): data-driven encounter
|
|
44
|
-
* direction — wave schedules, spawn budgets, boss phases, party scaling.
|
|
45
|
-
* The director emits `director_spawn` compute events; the mob layer
|
|
46
|
-
* simulates and reports kills back.
|
|
47
|
-
*
|
|
48
|
-
* Obtained via `client.kit(appId).director`.
|
|
49
|
-
*/
|
|
50
|
-
export declare class DirectorKit {
|
|
51
|
-
private readonly appId;
|
|
52
|
-
private readonly gameModel;
|
|
53
|
-
private readonly engines;
|
|
54
|
-
private readonly moduleName;
|
|
55
|
-
private readonly defTypeName;
|
|
56
|
-
constructor(appId: Scalars['BigInt']['input'], gameModel: GameModelAPI, engines: EngineDetector, options?: DirectorKitOptions);
|
|
57
|
-
/** Is the director deployed + enabled (cached per session)? */
|
|
58
|
-
engineAvailable(): Promise<boolean>;
|
|
59
|
-
/** STUDIO (admin) — create an encounter definition container. */
|
|
60
|
-
defineEncounter(input: {
|
|
61
|
-
encounterId: string;
|
|
62
|
-
displayName?: string;
|
|
63
|
-
waves: KitWaveSpec[];
|
|
64
|
-
spawnBudget?: number;
|
|
65
|
-
}): Promise<{
|
|
66
|
-
__typename?: "GmContainer";
|
|
67
|
-
containerId: string;
|
|
68
|
-
appId: string;
|
|
69
|
-
sessionId: string | null;
|
|
70
|
-
typeName: string;
|
|
71
|
-
displayName: string;
|
|
72
|
-
description: string | null;
|
|
73
|
-
ownerUserId: string | null;
|
|
74
|
-
metadataJson: string;
|
|
75
|
-
}>;
|
|
76
|
-
/** Start a run (party size scales unit counts server-side). */
|
|
77
|
-
startRun(encounterId: string, players?: number): Promise<KitDirectorRun>;
|
|
78
|
-
/** Report kills toward the live wave (trusted callers/engines). */
|
|
79
|
-
reportKill(runId: string, count?: number): Promise<KitDirectorRun>;
|
|
80
|
-
/** Report boss hp; phase transitions announce on the compute bus. */
|
|
81
|
-
reportBossHp(runId: string, hp: number): Promise<KitDirectorRun>;
|
|
82
|
-
/** Force-clear the live wave (run creator only). */
|
|
83
|
-
skipWave(runId: string): Promise<KitDirectorRun>;
|
|
84
|
-
/** One run's state (or engine totals without an id). */
|
|
85
|
-
runState(runId?: string): Promise<KitDirectorRun | Record<string, unknown>>;
|
|
86
|
-
private invoke;
|
|
87
|
-
}
|
|
88
|
-
//# sourceMappingURL=director.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"director.d.ts","sourceRoot":"","sources":["../../src/kit/director.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IACjC,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,2CAA2C;AAC3C,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,IAAI,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;CAC1C;AAED,8BAA8B;AAC9B,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAA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