@crowdedkingdoms/crowdyjs 8.5.0 → 8.7.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.
Files changed (43) hide show
  1. package/MIGRATION.md +66 -0
  2. package/README.md +3 -2
  3. package/dist/crowdy-client.d.ts +3 -0
  4. package/dist/crowdy-client.d.ts.map +1 -1
  5. package/dist/crowdy-client.js +3 -0
  6. package/dist/domains/compute.d.ts +175 -0
  7. package/dist/domains/compute.d.ts.map +1 -0
  8. package/dist/domains/compute.js +232 -0
  9. package/dist/generated/graphql.d.ts +893 -1
  10. package/dist/generated/graphql.d.ts.map +1 -1
  11. package/dist/generated/graphql.js +22 -0
  12. package/dist/index.d.ts +3 -2
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +3 -2
  15. package/dist/kit/combat.d.ts +38 -1
  16. package/dist/kit/combat.d.ts.map +1 -1
  17. package/dist/kit/combat.js +45 -1
  18. package/dist/kit/engine.d.ts +43 -0
  19. package/dist/kit/engine.d.ts.map +1 -0
  20. package/dist/kit/engine.js +108 -0
  21. package/dist/kit/index.d.ts +7 -3
  22. package/dist/kit/index.d.ts.map +1 -1
  23. package/dist/kit/index.js +5 -1
  24. package/dist/kit/kit.d.ts +15 -1
  25. package/dist/kit/kit.d.ts.map +1 -1
  26. package/dist/kit/kit.js +9 -3
  27. package/dist/kit/mobs.d.ts +90 -0
  28. package/dist/kit/mobs.d.ts.map +1 -0
  29. package/dist/kit/mobs.js +98 -0
  30. package/dist/kit/npcs.d.ts +38 -1
  31. package/dist/kit/npcs.d.ts.map +1 -1
  32. package/dist/kit/npcs.js +36 -1
  33. package/dist/kit/pets.d.ts +85 -0
  34. package/dist/kit/pets.d.ts.map +1 -0
  35. package/dist/kit/pets.js +96 -0
  36. package/dist/kit/social.d.ts.map +1 -1
  37. package/dist/kit/wire.d.ts +87 -0
  38. package/dist/kit/wire.d.ts.map +1 -0
  39. package/dist/kit/wire.js +156 -0
  40. package/dist/kit/worldsim.d.ts +34 -1
  41. package/dist/kit/worldsim.d.ts.map +1 -1
  42. package/dist/kit/worldsim.js +38 -1
  43. package/package.json +1 -1
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Compute-engine capability detection + invoke envelope for the kit helpers.
3
+ * Games deploy engines (mob-engine, world-engine, bwf-mobs, ...) as compute
4
+ * modules; kit helpers probe once per module per session and route through
5
+ * the engine when it is present, falling back to the model/automation path
6
+ * when it is not — so the same client code works on model-only deployments.
7
+ */
8
+ import { CrowdyGraphQLError } from '../errors.js';
9
+ /**
10
+ * Per-session cached probe of which compute modules an app has enabled.
11
+ * Obtained internally by kit helpers; share one via `kit.engines`.
12
+ */
13
+ export class EngineDetector {
14
+ constructor(appId, compute) {
15
+ this.appId = appId;
16
+ this.compute = compute;
17
+ this.cache = new Map();
18
+ }
19
+ /**
20
+ * Is `moduleName` deployed + enabled? Cached per module for the client's
21
+ * lifetime ({@link reset} to re-probe after deploys). Resolves false when
22
+ * the client has no compute domain wired.
23
+ */
24
+ has(moduleName) {
25
+ if (!this.compute)
26
+ return Promise.resolve(false);
27
+ let probe = this.cache.get(moduleName);
28
+ if (!probe) {
29
+ probe = this.probe(moduleName);
30
+ this.cache.set(moduleName, probe);
31
+ }
32
+ return probe;
33
+ }
34
+ /** Drop cached probes (call after deploying/enabling modules). */
35
+ reset() {
36
+ this.cache.clear();
37
+ }
38
+ /**
39
+ * Invoke an engine export and parse the `{success, ...}` envelope.
40
+ * Envelope failures (denials) resolve — only transport/user errors throw.
41
+ */
42
+ async invoke(moduleName, exportName, params) {
43
+ if (!this.compute) {
44
+ return {
45
+ success: false,
46
+ reason: 'compute domain unavailable',
47
+ body: {},
48
+ };
49
+ }
50
+ try {
51
+ const result = await this.compute.invoke({
52
+ appId: this.appId,
53
+ moduleName,
54
+ exportName,
55
+ ...(params !== undefined ? { paramsJson: JSON.stringify(params) } : {}),
56
+ });
57
+ let body = {};
58
+ try {
59
+ body = JSON.parse(result.resultJson ?? '{}');
60
+ }
61
+ catch {
62
+ body = {};
63
+ }
64
+ return {
65
+ success: body.success !== false,
66
+ reason: typeof body.reason === 'string' ? body.reason : undefined,
67
+ body: body,
68
+ fuelUsed: result.fuelUsed != null ? String(result.fuelUsed) : undefined,
69
+ durationUs: result.durationUs != null ? Number(result.durationUs) : undefined,
70
+ };
71
+ }
72
+ catch (error) {
73
+ if (error instanceof CrowdyGraphQLError) {
74
+ return {
75
+ success: false,
76
+ reason: error.message,
77
+ body: {},
78
+ };
79
+ }
80
+ throw error;
81
+ }
82
+ }
83
+ async probe(moduleName) {
84
+ if (!this.compute)
85
+ return false;
86
+ try {
87
+ const module = await this.compute.module({ appId: this.appId, name: moduleName });
88
+ return module != null && module.enabled === true;
89
+ }
90
+ catch (error) {
91
+ if (!(error instanceof CrowdyGraphQLError))
92
+ throw error;
93
+ if (error.code !== 'FORBIDDEN')
94
+ return false;
95
+ }
96
+ // Player tokens lack view_compute_diagnostics: probe via a status invoke
97
+ // (engines all export one). Missing modules reject; denials mean present.
98
+ try {
99
+ const result = await this.invoke(moduleName, 'status');
100
+ if (result.success)
101
+ return true;
102
+ return !/not found|no such module|not enabled/i.test(result.reason ?? '');
103
+ }
104
+ catch {
105
+ return false;
106
+ }
107
+ }
108
+ }
@@ -2,18 +2,22 @@ export { andPolicies, combatBlueprint, combatNames, composeBlueprints, decksBlue
2
2
  export { GameKitClient, type GameKitDomains, type GameKitOptions, type KitDeployResult, } from './kit.js';
3
3
  export { MatchesKit, type KitMatch, type KitMatchScore, type MatchesKitOptions, } from './matches.js';
4
4
  export { InventoryKit, type InventoryKitOptions, type KitItemStack } from './inventory.js';
5
- export { CombatKit, type CombatKitOptions, type KitCombatant, type KitStatusEffect, } from './combat.js';
5
+ export { CombatKit, type CombatKitOptions, type KitCombatant, type KitRoutedAttack, type KitStatusEffect, } from './combat.js';
6
6
  export { DecksKit, type DecksKitOptions, type KitCard } from './decks.js';
7
7
  export { FeaturesKit } from './features.js';
8
8
  export { EconomyKit, type EconomyKitOptions, type KitMarketListing, type KitShopListing, type KitTradeOffer, type KitWallet, } from './economy.js';
9
9
  export { LeaderboardsKit, type KitLeaderboardEntry, type LeaderboardsKitOptions, } from './leaderboards.js';
10
10
  export { LootKit, type KitLootRoll, type LootKitOptions } from './loot.js';
11
11
  export { ObjectsKit, type ObjectsKitOptions } from './objects.js';
12
- export { NpcsKit, type NpcsKitOptions, type KitNpc } from './npcs.js';
12
+ export { NpcsKit, type KitNpc, type LiveNpcPose, type NpcsKitOptions, } from './npcs.js';
13
+ export { MobsKit, type KitAttackResult, type KitMobDef, type KitMobSlot, type MobsKitOptions, } from './mobs.js';
14
+ export { PetsKit, type KitPet, type KitPetResult, type PetsKitOptions, } from './pets.js';
15
+ export { EngineDetector, type EngineInvokeResult } from './engine.js';
16
+ export { EVENT_CONTACT_DAMAGE, EVENT_WEATHER, FLAG_GROUNDED, FLAG_MOB, FLAG_NPC, FLAG_RESERVED3, POSE_BYTES, decodeEnginePose, encodeEnginePose, engineLanes, enginePoseCodec, parseContactDamage, parseEngineEvent, parseWeatherEvent, poseSuffix, type ContactDamageEvent, type EnginePose, type WeatherEvent, } from './wire.js';
13
17
  export { PlotsKit, type PlotsKitOptions, type KitPlot } from './plots.js';
14
18
  export { QuestsKit, type KitQuestDef, type KitQuestProgress, type QuestsKitOptions, } from './quests.js';
15
19
  export { ProgressionKit, type KitAchievementDef, type KitAchievementUnlock, type KitProgress, type KitSkillDef, type KitSkillRank, type ProgressionKitOptions, } from './progression.js';
16
20
  export { SocialKit, type KitChatMessage, type KitGroupWithChannel, type SocialKitOptions, } from './social.js';
17
- export { WorldsimKit, type KitCrop, type KitResourceNode, type KitWaveSpawner, type KitWorldState, type WorldsimKitOptions, } from './worldsim.js';
21
+ export { WorldsimKit, type KitCrop, type KitForecast, type KitResourceNode, type KitWaveSpawner, type KitWorldState, type WorldsimKitOptions, } from './worldsim.js';
18
22
  export { kitInvoke, toKitInvokeResult, type KitInvokeResult, type RawInvokeResult, } from './shared.js';
19
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/kit/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,SAAS,EACT,aAAa,EACb,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,uBAAuB,EACvB,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,SAAS,EACT,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,WAAW,EACX,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EACb,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EACf,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EACf,KAAK,yBAAyB,EAC9B,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,SAAS,EACd,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,kBAAkB,E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,WAAW,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EACL,SAAS,EACT,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,cAAc,EACd,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,qBAAqB,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,SAAS,EACT,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,WAAW,EACX,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,kBAAkB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/kit/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,SAAS,EACT,aAAa,EACb,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,uBAAuB,EACvB,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,SAAS,EACT,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,WAAW,E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ACf,KAAK,YAAY,GAClB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EACL,SAAS,EACT,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,cAAc,EACd,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,qBAAqB,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,SAAS,EACT,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,WAAW,EACX,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,kBAAkB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,aAAa,CAAC"}
package/dist/kit/index.js CHANGED
@@ -9,7 +9,11 @@ export { EconomyKit, } from './economy.js';
9
9
  export { LeaderboardsKit, } from './leaderboards.js';
10
10
  export { LootKit } from './loot.js';
11
11
  export { ObjectsKit } from './objects.js';
12
- export { NpcsKit } from './npcs.js';
12
+ export { NpcsKit, } from './npcs.js';
13
+ export { MobsKit, } from './mobs.js';
14
+ export { PetsKit, } from './pets.js';
15
+ export { EngineDetector } from './engine.js';
16
+ export { EVENT_CONTACT_DAMAGE, EVENT_WEATHER, FLAG_GROUNDED, FLAG_MOB, FLAG_NPC, FLAG_RESERVED3, POSE_BYTES, decodeEnginePose, encodeEnginePose, engineLanes, enginePoseCodec, parseContactDamage, parseEngineEvent, parseWeatherEvent, poseSuffix, } from './wire.js';
13
17
  export { PlotsKit } from './plots.js';
14
18
  export { QuestsKit, } from './quests.js';
15
19
  export { ProgressionKit, } from './progression.js';
package/dist/kit/kit.d.ts CHANGED
@@ -4,16 +4,20 @@ import type { GameModelAPI } from '../domains/gameModel.js';
4
4
  import type { TeamsAPI } from '../domains/teams.js';
5
5
  import type { UdpAPI } from '../domains/udp.js';
6
6
  import type { GameModelSeedMutation, GameModelUpsertAutomationMutation, GameModelUpsertAutomationTriggerMutation, Scalars } from '../generated/graphql.js';
7
+ import type { ComputeAPI } from '../domains/compute.js';
7
8
  import { type KitBlueprint } from './blueprints/index.js';
8
9
  import { CombatKit, type CombatKitOptions } from './combat.js';
9
10
  import { DecksKit, type DecksKitOptions } from './decks.js';
10
11
  import { EconomyKit, type EconomyKitOptions } from './economy.js';
12
+ import { EngineDetector } from './engine.js';
11
13
  import { FeaturesKit } from './features.js';
12
14
  import { InventoryKit, type InventoryKitOptions } from './inventory.js';
13
15
  import { LeaderboardsKit, type LeaderboardsKitOptions } from './leaderboards.js';
14
16
  import { LootKit, type LootKitOptions } from './loot.js';
17
+ import { MobsKit, type MobsKitOptions } from './mobs.js';
15
18
  import { NpcsKit, type NpcsKitOptions } from './npcs.js';
16
19
  import { ObjectsKit, type ObjectsKitOptions } from './objects.js';
20
+ import { PetsKit, type PetsKitOptions } from './pets.js';
17
21
  import { PlotsKit, type PlotsKitOptions } from './plots.js';
18
22
  import { MatchesKit, type MatchesKitOptions } from './matches.js';
19
23
  import { ProgressionKit, type ProgressionKitOptions } from './progression.js';
@@ -36,16 +40,20 @@ export interface GameKitOptions {
36
40
  worldsim?: WorldsimKitOptions;
37
41
  social?: SocialKitOptions;
38
42
  leaderboards?: LeaderboardsKitOptions;
43
+ mobs?: MobsKitOptions;
44
+ pets?: PetsKitOptions;
39
45
  }
40
46
  /**
41
47
  * The extra (non-model) domains some kit helpers compose: channels + udp for
42
- * matches (notify-to-pull) and social chat, teams for parties/guilds.
48
+ * matches (notify-to-pull) and social chat, teams for parties/guilds, and
49
+ * compute for the engine-backed helpers (mobs/pets, capability detection).
43
50
  * `client.kit(appId)` wires them automatically.
44
51
  */
45
52
  export interface GameKitDomains {
46
53
  channels?: ChannelsAPI;
47
54
  teams?: TeamsAPI;
48
55
  udp?: UdpAPI;
56
+ compute?: ComputeAPI;
49
57
  }
50
58
  /** The result of {@link GameKitClient.deploy}: the seed outcome plus each automation/trigger upserted. */
51
59
  export interface KitDeployResult {
@@ -126,6 +134,12 @@ export declare class GameKitClient {
126
134
  readonly leaderboards: LeaderboardsKit;
127
135
  /** Monetization helpers (feature keys, tier grants, featureGate policies). */
128
136
  readonly features: FeaturesKit;
137
+ /** Mob-engine helpers (defs/slots, refereed attacks, contact events). */
138
+ readonly mobs: MobsKit;
139
+ /** Pet helpers (adopt/summon/dismiss/rename over the npc engine). */
140
+ readonly pets: PetsKit;
141
+ /** Compute-engine capability detection shared by the engine-aware kits. */
142
+ readonly engines: EngineDetector;
129
143
  constructor(appId: Scalars['BigInt']['input'], gameModel: GameModelAPI, gameApps: GameAppsAPI, options?: GameKitOptions, domains?: GameKitDomains);
130
144
  /**
131
145
  * Helpers for an additional lockable object type deployed under a different
@@ -1 +1 @@
1
- {"version":3,"file":"kit.d.ts","sourceRoot":"","sources":["../../src/kit/kit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EACV,qBAAqB,EACrB,iCAAiC,EACjC,wCAAwC,EACxC,OAAO,EACR,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,u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AAE,eAAe,CAAC;IACvC,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,qEAAqE;IACrE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;gBAGd,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,EACjC,SAAS,EAAE,YAAY,EACxC,QAAQ,EAAE,WAAW,EACrB,OAAO,GAAE,cAAmB,EAC5B,OAAO,GAAE,cAAmB;IAmC9B;;;OAGG;IACH,UAAU,CAAC,cAAc,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,UAAU;IAOpE;;;;;;;;;;;;;;;;;OAiBG;IACG,MAAM,CACV,UAAU,EAAE,YAAY,GAAG,YAAY,EAAE,EACzC,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GACnC,OAAO,CAAC,eAAe,CAAC;CAsB5B"}
package/dist/kit/kit.js CHANGED
@@ -2,12 +2,15 @@ import { mergeBlueprints } from './blueprints/index.js';
2
2
  import { CombatKit } from './combat.js';
3
3
  import { DecksKit } from './decks.js';
4
4
  import { EconomyKit } from './economy.js';
5
+ import { EngineDetector } from './engine.js';
5
6
  import { FeaturesKit } from './features.js';
6
7
  import { InventoryKit } from './inventory.js';
7
8
  import { LeaderboardsKit } from './leaderboards.js';
8
9
  import { LootKit } from './loot.js';
10
+ import { MobsKit } from './mobs.js';
9
11
  import { NpcsKit } from './npcs.js';
10
12
  import { ObjectsKit } from './objects.js';
13
+ import { PetsKit } from './pets.js';
11
14
  import { PlotsKit } from './plots.js';
12
15
  import { MatchesKit } from './matches.js';
13
16
  import { ProgressionKit } from './progression.js';
@@ -56,18 +59,21 @@ export class GameKitClient {
56
59
  constructor(appId, gameModel, gameApps, options = {}, domains = {}) {
57
60
  this.appId = appId;
58
61
  this.gameModel = gameModel;
62
+ this.engines = new EngineDetector(String(appId), domains.compute);
59
63
  this.inventory = new InventoryKit(appId, gameModel, options.inventory);
60
64
  this.objects = new ObjectsKit(appId, gameModel, options.objects);
61
- this.npcs = new NpcsKit(appId, gameModel, options.npcs);
65
+ this.npcs = new NpcsKit(appId, gameModel, options.npcs, this.engines);
62
66
  this.plots = new PlotsKit(appId, gameModel, gameApps, options.plots);
63
67
  this.economy = new EconomyKit(appId, gameModel, options.economy);
64
68
  this.progression = new ProgressionKit(appId, gameModel, options.progression);
65
69
  this.loot = new LootKit(appId, gameModel, options.loot);
66
70
  this.quests = new QuestsKit(appId, gameModel, options.quests);
67
- this.combat = new CombatKit(appId, gameModel, options.combat);
71
+ this.combat = new CombatKit(appId, gameModel, options.combat, this.engines);
68
72
  this.matches = new MatchesKit(appId, gameModel, domains.channels, domains.udp, options.matches);
69
73
  this.decks = new DecksKit(appId, gameModel, options.decks);
70
- this.worldsim = new WorldsimKit(appId, gameModel, options.worldsim);
74
+ this.worldsim = new WorldsimKit(appId, gameModel, options.worldsim, this.engines);
75
+ this.mobs = new MobsKit(appId, gameModel, this.engines, options.mobs);
76
+ this.pets = new PetsKit(appId, gameModel, this.engines, options.pets);
71
77
  this.social = new SocialKit(appId, domains.teams, domains.channels, domains.udp, gameApps, options.social);
72
78
  this.leaderboards = new LeaderboardsKit(appId, gameModel, options.leaderboards);
73
79
  this.features = new FeaturesKit(appId, gameModel);
@@ -0,0 +1,90 @@
1
+ import type { GameModelAPI } from '../domains/gameModel.js';
2
+ import type { Scalars } from '../generated/graphql.js';
3
+ import type { EngineDetector, EngineInvokeResult } from './engine.js';
4
+ import { type ContactDamageEvent } from './wire.js';
5
+ /** Options for {@link MobsKit}. Must match the deployed mob engine. */
6
+ export interface MobsKitOptions {
7
+ /** The compute module serving `attack_mob`/`status`. Defaults to `'mob-engine'`. */
8
+ moduleName?: string;
9
+ /** The mob-definition container type. Defaults to `'MobDef'`. */
10
+ defTypeName?: string;
11
+ /** The mob slot container type. Defaults to `'Mob'`. */
12
+ slotTypeName?: string;
13
+ }
14
+ /** A parsed mob definition container. */
15
+ export interface KitMobDef {
16
+ containerId: string;
17
+ displayName: string;
18
+ mobId: string;
19
+ maxHealth: number;
20
+ damage: number;
21
+ speed: number;
22
+ hostile: boolean;
23
+ spawnTime: string;
24
+ properties: Record<string, unknown>;
25
+ }
26
+ /** A parsed mob slot container (durable state; live poses ride the mob lane). */
27
+ export interface KitMobSlot {
28
+ containerId: string;
29
+ displayName: string;
30
+ mobId: string;
31
+ actorUuid: string;
32
+ health: number;
33
+ x: number;
34
+ y: number;
35
+ z: number;
36
+ /** health > 0 — the slot is live and being simulated. */
37
+ alive: boolean;
38
+ properties: Record<string, unknown>;
39
+ }
40
+ /** The referee's verdict for an accepted/denied attack. */
41
+ export interface KitAttackResult {
42
+ success: boolean;
43
+ /** Remaining health after an accepted hit. */
44
+ health?: number;
45
+ killed?: boolean;
46
+ /** The referee's denial reason ("out of range", "mob not live", ...). */
47
+ reason?: string;
48
+ }
49
+ /**
50
+ * Runtime helpers for compute-module mob engines (the Wave 1 `mob-engine`
51
+ * template / BWF's `bwf-mobs`): definition + slot reads off the model, the
52
+ * refereed `attack_mob` invoke, and the type-77 contact-damage event parser.
53
+ *
54
+ * Live mob poses arrive on the actor stream (FLAG_MOB, container-id
55
+ * suffix) — decode them with `kit/wire`'s {@link engineLanes} +
56
+ * `enginePoseCodec` in your world session; this kit reads the durable side.
57
+ *
58
+ * Obtained via `client.kit(appId).mobs`.
59
+ */
60
+ export declare class MobsKit {
61
+ private readonly appId;
62
+ private readonly gameModel;
63
+ private readonly engines;
64
+ private readonly moduleName;
65
+ private readonly defTypeName;
66
+ private readonly slotTypeName;
67
+ constructor(appId: Scalars['BigInt']['input'], gameModel: GameModelAPI, engines: EngineDetector, options?: MobsKitOptions);
68
+ /** Is the mob engine deployed + enabled (cached per session)? */
69
+ engineAvailable(): Promise<boolean>;
70
+ /**
71
+ * Attack a live mob slot through the server referee: presence, range and
72
+ * damage clamps are validated engine-side before health moves. Denials
73
+ * resolve with `success: false` and the referee's `reason`.
74
+ */
75
+ attack(containerId: string, amount?: number): Promise<KitAttackResult>;
76
+ /** The engine's `status` snapshot (mob/def counts, tick counter). */
77
+ status(): Promise<EngineInvokeResult>;
78
+ /** List mob definitions with parsed stats. */
79
+ defs(): Promise<KitMobDef[]>;
80
+ /** List mob slots (durable positions/health; `alive` = health > 0). */
81
+ slots(): Promise<KitMobSlot[]>;
82
+ /**
83
+ * Parse a server-event payload as engine contact damage (type 77), or
84
+ * null when it is another event type. Feed it your world session's
85
+ * server-event stream and apply the damage to your own player when
86
+ * `targetUuid` matches your actor uuid.
87
+ */
88
+ parseContactDamage(payload: Uint8Array): ContactDamageEvent | null;
89
+ }
90
+ //# sourceMappingURL=mobs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mobs.d.ts","sourceRoot":"","sources":["../../src/kit/mobs.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,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,EAAsB,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAExE,uEAAuE;AACvE,MAAM,WAAW,cAAc;IAC7B,oFAAoF;IACpF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,yCAAyC;AACzC,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB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AAO,CAAC,OAAO,CAAC;IAInC;;;;OAIG;IACG,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,SAAI,GAAG,OAAO,CAAC,eAAe,CAAC;IAcvE,qEAAqE;IAC/D,MAAM,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAI3C,8CAA8C;IACxC,IAAI,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IA2BlC,uEAAuE;IACjE,KAAK,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IA6BpC;;;;;OAKG;IACH,kBAAkB,CAAC,OAAO,EAAE,UAAU,GAAG,kBAAkB,GAAG,IAAI;CAGnE"}
@@ -0,0 +1,98 @@
1
+ import { kitContainerProperties } from './shared.js';
2
+ import { parseContactDamage } from './wire.js';
3
+ /**
4
+ * Runtime helpers for compute-module mob engines (the Wave 1 `mob-engine`
5
+ * template / BWF's `bwf-mobs`): definition + slot reads off the model, the
6
+ * refereed `attack_mob` invoke, and the type-77 contact-damage event parser.
7
+ *
8
+ * Live mob poses arrive on the actor stream (FLAG_MOB, container-id
9
+ * suffix) — decode them with `kit/wire`'s {@link engineLanes} +
10
+ * `enginePoseCodec` in your world session; this kit reads the durable side.
11
+ *
12
+ * Obtained via `client.kit(appId).mobs`.
13
+ */
14
+ export class MobsKit {
15
+ constructor(appId, gameModel, engines, options = {}) {
16
+ this.appId = appId;
17
+ this.gameModel = gameModel;
18
+ this.engines = engines;
19
+ this.moduleName = options.moduleName ?? 'mob-engine';
20
+ this.defTypeName = options.defTypeName ?? 'MobDef';
21
+ this.slotTypeName = options.slotTypeName ?? 'Mob';
22
+ }
23
+ /** Is the mob engine deployed + enabled (cached per session)? */
24
+ engineAvailable() {
25
+ return this.engines.has(this.moduleName);
26
+ }
27
+ /**
28
+ * Attack a live mob slot through the server referee: presence, range and
29
+ * damage clamps are validated engine-side before health moves. Denials
30
+ * resolve with `success: false` and the referee's `reason`.
31
+ */
32
+ async attack(containerId, amount = 1) {
33
+ const result = await this.engines.invoke(this.moduleName, 'attack_mob', { containerId, amount });
34
+ return {
35
+ success: result.success,
36
+ health: typeof result.body.health === 'number' ? result.body.health : undefined,
37
+ killed: typeof result.body.killed === 'boolean' ? result.body.killed : undefined,
38
+ reason: result.reason,
39
+ };
40
+ }
41
+ /** The engine's `status` snapshot (mob/def counts, tick counter). */
42
+ async status() {
43
+ return this.engines.invoke(this.moduleName, 'status');
44
+ }
45
+ /** List mob definitions with parsed stats. */
46
+ async defs() {
47
+ const containers = await this.gameModel.containers({
48
+ appId: this.appId,
49
+ typeName: this.defTypeName,
50
+ });
51
+ return Promise.all(containers.map(async (c) => {
52
+ const props = await kitContainerProperties(this.gameModel, String(this.appId), c.containerId);
53
+ return {
54
+ containerId: c.containerId,
55
+ displayName: c.displayName,
56
+ mobId: String(props.mob_id ?? ''),
57
+ maxHealth: Number(props.max_health ?? 0),
58
+ damage: Number(props.damage ?? 0),
59
+ speed: Number(props.speed ?? 0),
60
+ hostile: props.hostile === true || props.hostile === 'true',
61
+ spawnTime: String(props.spawn_time ?? 'any'),
62
+ properties: props,
63
+ };
64
+ }));
65
+ }
66
+ /** List mob slots (durable positions/health; `alive` = health > 0). */
67
+ async slots() {
68
+ const containers = await this.gameModel.containers({
69
+ appId: this.appId,
70
+ typeName: this.slotTypeName,
71
+ });
72
+ return Promise.all(containers.map(async (c) => {
73
+ const props = await kitContainerProperties(this.gameModel, String(this.appId), c.containerId);
74
+ const health = Number(props.health ?? 0);
75
+ return {
76
+ containerId: c.containerId,
77
+ displayName: c.displayName,
78
+ mobId: String(props.mob_id ?? ''),
79
+ actorUuid: String(props.actor_uuid ?? ''),
80
+ health,
81
+ x: Number(props.x ?? 0),
82
+ y: Number(props.y ?? 0),
83
+ z: Number(props.z ?? 0),
84
+ alive: health > 0,
85
+ properties: props,
86
+ };
87
+ }));
88
+ }
89
+ /**
90
+ * Parse a server-event payload as engine contact damage (type 77), or
91
+ * null when it is another event type. Feed it your world session's
92
+ * server-event stream and apply the damage to your own player when
93
+ * `targetUuid` matches your actor uuid.
94
+ */
95
+ parseContactDamage(payload) {
96
+ return parseContactDamage(payload);
97
+ }
98
+ }
@@ -1,9 +1,26 @@
1
1
  import type { GameModelAPI } from '../domains/gameModel.js';
2
2
  import type { Scalars, SeedPropertyInput } from '../generated/graphql.js';
3
+ import type { EngineDetector } from './engine.js';
4
+ import type { EnginePose } from './wire.js';
3
5
  /** Options for {@link NpcsKit}. Must match the deployed NPC blueprint. */
4
6
  export interface NpcsKitOptions {
5
7
  /** The `typeName` the NPC blueprint was deployed with. Defaults to `'Npc'`. */
6
8
  typeName?: string;
9
+ /**
10
+ * The compute module driving NPC movement when the app runs an engine
11
+ * (smooth FLAG_NPC actor emits instead of property nudges). Defaults to
12
+ * `'npc-engine'`.
13
+ */
14
+ moduleName?: string;
15
+ }
16
+ /**
17
+ * The minimal shape of a live actor entry {@link overlayLivePoses} reads —
18
+ * matches the world-session `RemoteActor<EnginePose>` without importing it.
19
+ */
20
+ export interface LiveNpcPose {
21
+ uuid: string;
22
+ state: Pick<EnginePose, 'x' | 'y' | 'z'>;
23
+ receivedAt: number;
7
24
  }
8
25
  /** A parsed view of one live NPC. */
9
26
  export interface KitNpc {
@@ -32,8 +49,28 @@ export interface KitNpc {
32
49
  export declare class NpcsKit {
33
50
  private readonly appId;
34
51
  private readonly gameModel;
52
+ private readonly engines?;
35
53
  private readonly typeName;
36
- constructor(appId: Scalars['BigInt']['input'], gameModel: GameModelAPI, options?: NpcsKitOptions);
54
+ private readonly moduleName;
55
+ constructor(appId: Scalars['BigInt']['input'], gameModel: GameModelAPI, options?: NpcsKitOptions, engines?: EngineDetector | undefined);
56
+ /**
57
+ * Is an NPC compute engine deployed + enabled (cached per session)? When
58
+ * true, NPCs stream smooth FLAG_NPC actor poses — overlay them with
59
+ * {@link overlayLivePoses}. When false (model-only deployment), the polled
60
+ * container positions are all there is, exactly as before.
61
+ */
62
+ engineAvailable(): Promise<boolean>;
63
+ /**
64
+ * Overlay live engine-driven poses onto a polled NPC snapshot (the
65
+ * generalized BWF `NpcService.withLivePoses` pattern): each NPC whose
66
+ * `actor_uuid` has a fresh pose in the npcs actor lane gets its position
67
+ * replaced; the rest keep their durable container position, so NPCs stand
68
+ * at their last synced spot instead of disappearing.
69
+ *
70
+ * @param npcs - The polled snapshot (from {@link list}).
71
+ * @param lane - The live actors, e.g. `session.actors.lane('npcs').list()`.
72
+ */
73
+ overlayLivePoses(npcs: KitNpc[], lane: LiveNpcPose[]): KitNpc[];
37
74
  /** Spawn a live NPC instance (admin — the type is admin-instantiable). */
38
75
  spawn(input: {
39
76
  displayName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"npcs.d.ts","sourceRoot":"","sources":["../../src/kit/npcs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG1E,0EAA0E;AAC1E,MAAM,WAAW,cAAc;IAC7B,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qCAAqC;AACrC,MAAM,WAAW,MAAM;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED;;;;;;;;;;GAUG;AACH,qBAAa,OAAO;IAIhB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAJ5B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;gBAGf,KAAK,EAAE,OAAO,CA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AC,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO;;;;;;;;;;;;;;;;;;;;;;YAIzE,KAAK;CAkBpB"}
package/dist/kit/npcs.js CHANGED
@@ -11,10 +11,45 @@ import { kitContainerProperties } from './shared.js';
11
11
  * Obtained via `client.kit(appId).npcs`.
12
12
  */
13
13
  export class NpcsKit {
14
- constructor(appId, gameModel, options = {}) {
14
+ constructor(appId, gameModel, options = {}, engines) {
15
15
  this.appId = appId;
16
16
  this.gameModel = gameModel;
17
+ this.engines = engines;
17
18
  this.typeName = options.typeName ?? 'Npc';
19
+ this.moduleName = options.moduleName ?? 'npc-engine';
20
+ }
21
+ /**
22
+ * Is an NPC compute engine deployed + enabled (cached per session)? When
23
+ * true, NPCs stream smooth FLAG_NPC actor poses — overlay them with
24
+ * {@link overlayLivePoses}. When false (model-only deployment), the polled
25
+ * container positions are all there is, exactly as before.
26
+ */
27
+ engineAvailable() {
28
+ if (!this.engines)
29
+ return Promise.resolve(false);
30
+ return this.engines.has(this.moduleName);
31
+ }
32
+ /**
33
+ * Overlay live engine-driven poses onto a polled NPC snapshot (the
34
+ * generalized BWF `NpcService.withLivePoses` pattern): each NPC whose
35
+ * `actor_uuid` has a fresh pose in the npcs actor lane gets its position
36
+ * replaced; the rest keep their durable container position, so NPCs stand
37
+ * at their last synced spot instead of disappearing.
38
+ *
39
+ * @param npcs - The polled snapshot (from {@link list}).
40
+ * @param lane - The live actors, e.g. `session.actors.lane('npcs').list()`.
41
+ */
42
+ overlayLivePoses(npcs, lane) {
43
+ if (lane.length === 0)
44
+ return npcs;
45
+ const poses = new Map(lane.map((actor) => [actor.uuid, actor]));
46
+ return npcs.map((npc) => {
47
+ const uuid = String(npc.properties.actor_uuid ?? '');
48
+ const live = uuid ? poses.get(uuid) : undefined;
49
+ if (!live)
50
+ return npc;
51
+ return { ...npc, x: live.state.x, y: live.state.y, z: live.state.z };
52
+ });
18
53
  }
19
54
  /** Spawn a live NPC instance (admin — the type is admin-instantiable). */
20
55
  async spawn(input) {