@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.
Files changed (271) hide show
  1. package/MIGRATION.md +92 -1
  2. package/README.md +93 -162
  3. package/dist/crowdy-client.d.ts +12 -31
  4. package/dist/crowdy-client.d.ts.map +1 -1
  5. package/dist/crowdy-client.js +15 -37
  6. package/dist/crowdy-dsh/bridge.d.ts.map +1 -1
  7. package/dist/crowdy-dsh/bridge.js +3 -6
  8. package/dist/crowdy-studio/controller.d.ts +34 -59
  9. package/dist/crowdy-studio/controller.d.ts.map +1 -1
  10. package/dist/crowdy-studio/controller.js +96 -225
  11. package/dist/crowdy-studio/diagnostics.d.ts +3 -12
  12. package/dist/crowdy-studio/diagnostics.d.ts.map +1 -1
  13. package/dist/crowdy-studio/dom-shell.d.ts +2 -4
  14. package/dist/crowdy-studio/dom-shell.d.ts.map +1 -1
  15. package/dist/crowdy-studio/dom-shell.js +16 -49
  16. package/dist/crowdy-studio/embed/hud-layer.d.ts +1 -2
  17. package/dist/crowdy-studio/embed/hud-layer.d.ts.map +1 -1
  18. package/dist/crowdy-studio/embed/panel.d.ts +3 -13
  19. package/dist/crowdy-studio/embed/panel.d.ts.map +1 -1
  20. package/dist/crowdy-studio/embed/panel.js +3 -6
  21. package/dist/crowdy-studio/index.d.ts +1 -3
  22. package/dist/crowdy-studio/index.d.ts.map +1 -1
  23. package/dist/crowdy-studio/index.js +0 -2
  24. package/dist/crowdy-studio/models.d.ts +3 -4
  25. package/dist/crowdy-studio/models.d.ts.map +1 -1
  26. package/dist/crowdy-studio/starter-projects.d.ts +8 -12
  27. package/dist/crowdy-studio/starter-projects.d.ts.map +1 -1
  28. package/dist/crowdy-studio/starter-projects.js +12 -103
  29. package/dist/domains/appAccess.d.ts +14 -1
  30. package/dist/domains/appAccess.d.ts.map +1 -1
  31. package/dist/domains/appAccess.js +37 -1
  32. package/dist/domains/host.d.ts +3 -3
  33. package/dist/domains/host.js +3 -3
  34. package/dist/domains/marketplace.d.ts +9 -70
  35. package/dist/domains/marketplace.d.ts.map +1 -1
  36. package/dist/domains/marketplace.js +9 -120
  37. package/dist/domains/playerWallet.d.ts +6 -12
  38. package/dist/domains/playerWallet.d.ts.map +1 -1
  39. package/dist/domains/playerWallet.js +6 -21
  40. package/dist/errors.d.ts +7 -13
  41. package/dist/errors.d.ts.map +1 -1
  42. package/dist/errors.js +6 -10
  43. package/dist/generated/graphql.d.ts +141 -7083
  44. package/dist/generated/graphql.d.ts.map +1 -1
  45. package/dist/generated/graphql.js +5 -313
  46. package/dist/grid-mods/exec-client-halves.d.ts +19 -3
  47. package/dist/grid-mods/exec-client-halves.d.ts.map +1 -1
  48. package/dist/grid-mods/exec-client-halves.js +17 -2
  49. package/dist/grid-mods/grid-host-calls.d.ts +29 -17
  50. package/dist/grid-mods/grid-host-calls.d.ts.map +1 -1
  51. package/dist/grid-mods/grid-host-calls.js +40 -46
  52. package/dist/grid-mods/mod-runtime.d.ts +18 -11
  53. package/dist/grid-mods/mod-runtime.d.ts.map +1 -1
  54. package/dist/grid-mods/mod-runtime.js +4 -2
  55. package/dist/grid-scope.d.ts +0 -189
  56. package/dist/grid-scope.d.ts.map +1 -1
  57. package/dist/grid-scope.js +0 -70
  58. package/dist/index.d.ts +11 -17
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +10 -16
  61. package/dist/kit/actions.d.ts +5 -9
  62. package/dist/kit/actions.d.ts.map +1 -1
  63. package/dist/kit/actions.js +5 -9
  64. package/dist/kit/index.d.ts +2 -33
  65. package/dist/kit/index.d.ts.map +1 -1
  66. package/dist/kit/index.js +1 -32
  67. package/dist/kit/kit.d.ts +8 -208
  68. package/dist/kit/kit.d.ts.map +1 -1
  69. package/dist/kit/kit.js +5 -163
  70. package/dist/kit/social.d.ts +1 -3
  71. package/dist/kit/social.d.ts.map +1 -1
  72. package/dist/kit/social.js +1 -3
  73. package/dist/kit/wire.d.ts +16 -5
  74. package/dist/kit/wire.d.ts.map +1 -1
  75. package/dist/kit/wire.js +19 -5
  76. package/dist/live-coding/assets/browser-authoring-index.json +1 -1
  77. package/dist/live-coding/assets/manifest.json +1 -1
  78. package/dist/live-coding/browser-authoring-index.generated.d.ts.map +1 -1
  79. package/dist/live-coding/browser-authoring-index.generated.js +1496 -4386
  80. package/dist/live-coding/rust-analysis.d.ts.map +1 -1
  81. package/dist/live-coding/rust-analysis.js +30 -34
  82. package/dist/player-runtime/client-host-calls.d.ts +8 -0
  83. package/dist/player-runtime/client-host-calls.d.ts.map +1 -0
  84. package/dist/player-runtime/client-host-calls.js +28 -0
  85. package/dist/player-runtime/glue-runtime.d.ts +24 -20
  86. package/dist/player-runtime/glue-runtime.d.ts.map +1 -1
  87. package/dist/player-runtime/glue-runtime.js +26 -55
  88. package/dist/player-runtime/glue-sab.d.ts +2 -2
  89. package/dist/player-runtime/glue-sab.js +2 -2
  90. package/dist/player-runtime/player-code-broker.d.ts +70 -43
  91. package/dist/player-runtime/player-code-broker.d.ts.map +1 -1
  92. package/dist/player-runtime/player-code-broker.js +159 -64
  93. package/dist/player-runtime/player-glue-worker.d.ts +8 -9
  94. package/dist/player-runtime/player-glue-worker.d.ts.map +1 -1
  95. package/dist/player-runtime/player-glue-worker.js +26 -11
  96. package/dist/stores/inbox.d.ts +1 -1
  97. package/dist/stores/inbox.d.ts.map +1 -1
  98. package/dist/stores/index.d.ts +0 -11
  99. package/dist/stores/index.d.ts.map +1 -1
  100. package/dist/stores/index.js +0 -4
  101. package/dist/stores/session.d.ts +0 -2
  102. package/dist/stores/session.d.ts.map +1 -1
  103. package/package.json +1 -1
  104. package/dist/crowdy-studio/model-lint-log.d.ts +0 -76
  105. package/dist/crowdy-studio/model-lint-log.d.ts.map +0 -1
  106. package/dist/crowdy-studio/model-lint-log.js +0 -93
  107. package/dist/crowdy-studio/model-lint.d.ts +0 -61
  108. package/dist/crowdy-studio/model-lint.d.ts.map +0 -1
  109. package/dist/crowdy-studio/model-lint.js +0 -45
  110. package/dist/domains/compute.d.ts +0 -208
  111. package/dist/domains/compute.d.ts.map +0 -1
  112. package/dist/domains/compute.js +0 -274
  113. package/dist/domains/controlPlane.d.ts +0 -38
  114. package/dist/domains/controlPlane.d.ts.map +0 -1
  115. package/dist/domains/controlPlane.js +0 -43
  116. package/dist/domains/gameModel.d.ts +0 -1174
  117. package/dist/domains/gameModel.d.ts.map +0 -1
  118. package/dist/domains/gameModel.js +0 -1333
  119. package/dist/domains/playerCompute.d.ts +0 -91
  120. package/dist/domains/playerCompute.d.ts.map +0 -1
  121. package/dist/domains/playerCompute.js +0 -136
  122. package/dist/domains/playerModel.d.ts +0 -20
  123. package/dist/domains/playerModel.d.ts.map +0 -1
  124. package/dist/domains/playerModel.js +0 -54
  125. package/dist/kit/abilities.d.ts +0 -66
  126. package/dist/kit/abilities.d.ts.map +0 -1
  127. package/dist/kit/abilities.js +0 -71
  128. package/dist/kit/blueprints/combat.d.ts +0 -81
  129. package/dist/kit/blueprints/combat.d.ts.map +0 -1
  130. package/dist/kit/blueprints/combat.js +0 -357
  131. package/dist/kit/blueprints/core.d.ts +0 -222
  132. package/dist/kit/blueprints/core.d.ts.map +0 -1
  133. package/dist/kit/blueprints/core.js +0 -185
  134. package/dist/kit/blueprints/decks.d.ts +0 -50
  135. package/dist/kit/blueprints/decks.d.ts.map +0 -1
  136. package/dist/kit/blueprints/decks.js +0 -163
  137. package/dist/kit/blueprints/economy.d.ts +0 -88
  138. package/dist/kit/blueprints/economy.d.ts.map +0 -1
  139. package/dist/kit/blueprints/economy.js +0 -533
  140. package/dist/kit/blueprints/guild.d.ts +0 -51
  141. package/dist/kit/blueprints/guild.d.ts.map +0 -1
  142. package/dist/kit/blueprints/guild.js +0 -50
  143. package/dist/kit/blueprints/index.d.ts +0 -23
  144. package/dist/kit/blueprints/index.d.ts.map +0 -1
  145. package/dist/kit/blueprints/index.js +0 -22
  146. package/dist/kit/blueprints/inventory.d.ts +0 -84
  147. package/dist/kit/blueprints/inventory.d.ts.map +0 -1
  148. package/dist/kit/blueprints/inventory.js +0 -257
  149. package/dist/kit/blueprints/leaderboards.d.ts +0 -49
  150. package/dist/kit/blueprints/leaderboards.d.ts.map +0 -1
  151. package/dist/kit/blueprints/leaderboards.js +0 -126
  152. package/dist/kit/blueprints/liveops.d.ts +0 -42
  153. package/dist/kit/blueprints/liveops.d.ts.map +0 -1
  154. package/dist/kit/blueprints/liveops.js +0 -170
  155. package/dist/kit/blueprints/locks.d.ts +0 -82
  156. package/dist/kit/blueprints/locks.d.ts.map +0 -1
  157. package/dist/kit/blueprints/locks.js +0 -155
  158. package/dist/kit/blueprints/loot.d.ts +0 -90
  159. package/dist/kit/blueprints/loot.d.ts.map +0 -1
  160. package/dist/kit/blueprints/loot.js +0 -229
  161. package/dist/kit/blueprints/matches.d.ts +0 -84
  162. package/dist/kit/blueprints/matches.d.ts.map +0 -1
  163. package/dist/kit/blueprints/matches.js +0 -349
  164. package/dist/kit/blueprints/moderation.d.ts +0 -32
  165. package/dist/kit/blueprints/moderation.d.ts.map +0 -1
  166. package/dist/kit/blueprints/moderation.js +0 -140
  167. package/dist/kit/blueprints/npcs.d.ts +0 -78
  168. package/dist/kit/blueprints/npcs.d.ts.map +0 -1
  169. package/dist/kit/blueprints/npcs.js +0 -125
  170. package/dist/kit/blueprints/plots.d.ts +0 -63
  171. package/dist/kit/blueprints/plots.d.ts.map +0 -1
  172. package/dist/kit/blueprints/plots.js +0 -151
  173. package/dist/kit/blueprints/progression.d.ts +0 -68
  174. package/dist/kit/blueprints/progression.d.ts.map +0 -1
  175. package/dist/kit/blueprints/progression.js +0 -324
  176. package/dist/kit/blueprints/quests.d.ts +0 -72
  177. package/dist/kit/blueprints/quests.d.ts.map +0 -1
  178. package/dist/kit/blueprints/quests.js +0 -285
  179. package/dist/kit/blueprints/worldsim.d.ts +0 -91
  180. package/dist/kit/blueprints/worldsim.d.ts.map +0 -1
  181. package/dist/kit/blueprints/worldsim.js +0 -468
  182. package/dist/kit/combat.d.ts +0 -141
  183. package/dist/kit/combat.d.ts.map +0 -1
  184. package/dist/kit/combat.js +0 -196
  185. package/dist/kit/decks.d.ts +0 -157
  186. package/dist/kit/decks.d.ts.map +0 -1
  187. package/dist/kit/decks.js +0 -186
  188. package/dist/kit/director.d.ts +0 -88
  189. package/dist/kit/director.d.ts.map +0 -1
  190. package/dist/kit/director.js +0 -86
  191. package/dist/kit/economy.d.ts +0 -289
  192. package/dist/kit/economy.d.ts.map +0 -1
  193. package/dist/kit/economy.js +0 -427
  194. package/dist/kit/engine.d.ts +0 -48
  195. package/dist/kit/engine.d.ts.map +0 -1
  196. package/dist/kit/engine.js +0 -113
  197. package/dist/kit/features.d.ts +0 -60
  198. package/dist/kit/features.d.ts.map +0 -1
  199. package/dist/kit/features.js +0 -65
  200. package/dist/kit/instances.d.ts +0 -52
  201. package/dist/kit/instances.d.ts.map +0 -1
  202. package/dist/kit/instances.js +0 -60
  203. package/dist/kit/inventory.d.ts +0 -129
  204. package/dist/kit/inventory.d.ts.map +0 -1
  205. package/dist/kit/inventory.js +0 -200
  206. package/dist/kit/leaderboards.d.ts +0 -86
  207. package/dist/kit/leaderboards.d.ts.map +0 -1
  208. package/dist/kit/leaderboards.js +0 -133
  209. package/dist/kit/liveops.d.ts +0 -112
  210. package/dist/kit/liveops.d.ts.map +0 -1
  211. package/dist/kit/liveops.js +0 -183
  212. package/dist/kit/loot.d.ts +0 -128
  213. package/dist/kit/loot.d.ts.map +0 -1
  214. package/dist/kit/loot.js +0 -160
  215. package/dist/kit/matches.d.ts +0 -301
  216. package/dist/kit/matches.d.ts.map +0 -1
  217. package/dist/kit/matches.js +0 -458
  218. package/dist/kit/matchmaking.d.ts +0 -57
  219. package/dist/kit/matchmaking.d.ts.map +0 -1
  220. package/dist/kit/matchmaking.js +0 -59
  221. package/dist/kit/minigames.d.ts +0 -30
  222. package/dist/kit/minigames.d.ts.map +0 -1
  223. package/dist/kit/minigames.js +0 -38
  224. package/dist/kit/mobs.d.ts +0 -90
  225. package/dist/kit/mobs.d.ts.map +0 -1
  226. package/dist/kit/mobs.js +0 -98
  227. package/dist/kit/moderation.d.ts +0 -73
  228. package/dist/kit/moderation.d.ts.map +0 -1
  229. package/dist/kit/moderation.js +0 -103
  230. package/dist/kit/movement.d.ts +0 -78
  231. package/dist/kit/movement.d.ts.map +0 -1
  232. package/dist/kit/movement.js +0 -103
  233. package/dist/kit/notifications.d.ts +0 -45
  234. package/dist/kit/notifications.d.ts.map +0 -1
  235. package/dist/kit/notifications.js +0 -67
  236. package/dist/kit/npcs.d.ts +0 -226
  237. package/dist/kit/npcs.d.ts.map +0 -1
  238. package/dist/kit/npcs.js +0 -141
  239. package/dist/kit/objects.d.ts +0 -116
  240. package/dist/kit/objects.d.ts.map +0 -1
  241. package/dist/kit/objects.js +0 -119
  242. package/dist/kit/pets.d.ts +0 -85
  243. package/dist/kit/pets.d.ts.map +0 -1
  244. package/dist/kit/pets.js +0 -96
  245. package/dist/kit/plots.d.ts +0 -85
  246. package/dist/kit/plots.d.ts.map +0 -1
  247. package/dist/kit/plots.js +0 -113
  248. package/dist/kit/progression.d.ts +0 -181
  249. package/dist/kit/progression.d.ts.map +0 -1
  250. package/dist/kit/progression.js +0 -265
  251. package/dist/kit/quests.d.ts +0 -171
  252. package/dist/kit/quests.d.ts.map +0 -1
  253. package/dist/kit/quests.js +0 -237
  254. package/dist/kit/racing.d.ts +0 -85
  255. package/dist/kit/racing.d.ts.map +0 -1
  256. package/dist/kit/racing.js +0 -99
  257. package/dist/kit/shared.d.ts +0 -73
  258. package/dist/kit/shared.d.ts.map +0 -1
  259. package/dist/kit/shared.js +0 -101
  260. package/dist/kit/telemetry.d.ts +0 -66
  261. package/dist/kit/telemetry.d.ts.map +0 -1
  262. package/dist/kit/telemetry.js +0 -133
  263. package/dist/kit/territory.d.ts +0 -97
  264. package/dist/kit/territory.d.ts.map +0 -1
  265. package/dist/kit/territory.js +0 -114
  266. package/dist/kit/worldsim.d.ts +0 -263
  267. package/dist/kit/worldsim.d.ts.map +0 -1
  268. package/dist/kit/worldsim.js +0 -268
  269. package/dist/stores/model.d.ts +0 -81
  270. package/dist/stores/model.d.ts.map +0 -1
  271. package/dist/stores/model.js +0 -163
@@ -1,285 +0,0 @@
1
- import { kitPolicyJson, ownerEqualsCaller, ownerMirrorProperty, toSnakeCase, trustedAuthorityFields, } from './core.js';
2
- /** Compute the type/function names a quests blueprint (and its runtime helper) uses. */
3
- export function questsNames(typePrefix = '') {
4
- const fnPrefix = typePrefix ? `${toSnakeCase(typePrefix)}_` : '';
5
- return {
6
- defType: `${typePrefix}QuestDef`,
7
- progressType: `${typePrefix}QuestProgress`,
8
- advanceFn: `${fnPrefix}advance_quest`,
9
- claimFn: `${fnPrefix}claim_reward`,
10
- resetFn: `${fnPrefix}reset_daily`,
11
- dailyResetAutomation: `${fnPrefix.replace(/_/g, '-')}daily-quest-reset`,
12
- };
13
- }
14
- /**
15
- * Blueprint for **quests**: an admin `QuestDef` catalog (objective count +
16
- * reward spec + daily flag) and per-player `QuestProgress` rows. Progress
17
- * advances through trusted calls or event automations on your gameplay
18
- * functions; `claim_reward` marks the progress claimed AND grants the item
19
- * and currency rewards through `container_ref` params in ONE transaction
20
- * (composing with the inventory stack and economy wallet types); a **cron
21
- * automation** resets daily quests at midnight.
22
- *
23
- * Runtime counterpart: `client.kit(appId).quests`.
24
- */
25
- export function questsBlueprint(options = {}) {
26
- const { typePrefix = '', advanceAuthority = 'server', currencyProperty = 'gold', dailyResetCron = '0 0 * * *', advanceOn = [], ownerIdKind: kind = 'int', } = options;
27
- const names = questsNames(typePrefix);
28
- const propertyDefinitions = [
29
- {
30
- containerTypeName: names.defType,
31
- key: 'quest_id',
32
- valueType: 'string',
33
- description: 'Stable quest identifier.',
34
- },
35
- {
36
- containerTypeName: names.defType,
37
- key: 'target_count',
38
- valueType: 'int',
39
- defaultValueJson: '1',
40
- description: 'Objective count required to complete.',
41
- },
42
- {
43
- containerTypeName: names.defType,
44
- key: 'reward_item_id',
45
- valueType: 'string',
46
- defaultValueJson: '""',
47
- description: 'Item reward (empty for currency-only quests).',
48
- },
49
- {
50
- containerTypeName: names.defType,
51
- key: 'reward_qty',
52
- valueType: 'int',
53
- defaultValueJson: '0',
54
- description: 'Item reward quantity.',
55
- },
56
- {
57
- containerTypeName: names.defType,
58
- key: 'reward_gold',
59
- valueType: 'int',
60
- defaultValueJson: '0',
61
- description: `Currency reward paid into the '${currencyProperty}' wallet property.`,
62
- },
63
- {
64
- containerTypeName: names.defType,
65
- key: 'repeatable',
66
- valueType: 'bool',
67
- defaultValueJson: 'false',
68
- description: 'Whether a player may accept the quest again after claiming.',
69
- },
70
- {
71
- containerTypeName: names.defType,
72
- key: 'daily',
73
- valueType: 'bool',
74
- defaultValueJson: 'false',
75
- description: 'Whether progress resets on the daily cron.',
76
- },
77
- ownerMirrorProperty(names.progressType, kind),
78
- {
79
- containerTypeName: names.progressType,
80
- key: 'quest_id',
81
- valueType: 'string',
82
- defaultValueJson: '""',
83
- description: 'The quest this row tracks.',
84
- },
85
- {
86
- containerTypeName: names.progressType,
87
- key: 'count',
88
- valueType: 'int',
89
- defaultValueJson: '0',
90
- description: 'Objective progress, clamped to target.',
91
- },
92
- {
93
- containerTypeName: names.progressType,
94
- key: 'target',
95
- valueType: 'int',
96
- defaultValueJson: '1',
97
- description: 'Objective count copied from the def at accept time.',
98
- },
99
- {
100
- containerTypeName: names.progressType,
101
- key: 'completed',
102
- valueType: 'bool',
103
- defaultValueJson: 'false',
104
- description: 'True once count reaches target.',
105
- },
106
- {
107
- containerTypeName: names.progressType,
108
- key: 'claimed',
109
- valueType: 'bool',
110
- defaultValueJson: 'false',
111
- description: 'True once the reward was granted (single-claim guard).',
112
- },
113
- {
114
- containerTypeName: names.progressType,
115
- key: 'daily',
116
- valueType: 'bool',
117
- defaultValueJson: 'false',
118
- description: 'Mirrors the def; selects rows for the daily reset automation.',
119
- },
120
- ];
121
- const functions = [
122
- {
123
- name: names.advanceFn,
124
- containerTypeName: names.progressType,
125
- returnType: 'int',
126
- parameters: [
127
- {
128
- name: 'amount',
129
- valueType: 'int',
130
- required: true,
131
- description: 'Progress to add (negative values are ignored; clamped to target).',
132
- },
133
- ],
134
- mutations: [
135
- {
136
- target: 'self',
137
- property: 'count',
138
- expression: 'min(self.target, self.count + max(0, $amount))',
139
- },
140
- {
141
- target: 'self',
142
- property: 'completed',
143
- expression: 'self.count >= self.target',
144
- },
145
- ],
146
- returnExpression: 'self.count',
147
- ...trustedAuthorityFields(advanceAuthority),
148
- // Event automations must be able to run it regardless of authority.
149
- ...(advanceOn.length ? { autonomousInvocable: true } : {}),
150
- description: 'Trusted quest progress bump (clamped to the target); completion flips server-side in the same transaction.',
151
- },
152
- {
153
- name: names.claimFn,
154
- containerTypeName: names.progressType,
155
- returnType: 'int',
156
- parameters: [
157
- {
158
- name: 'def_id',
159
- valueType: 'container_ref',
160
- required: true,
161
- description: 'The QuestDef holding the reward spec (must match quest_id).',
162
- },
163
- {
164
- name: 'to_stack_id',
165
- valueType: 'container_ref',
166
- required: true,
167
- description: 'A caller-owned stack receiving the item reward (item grant is 0 when the item id does not match, e.g. currency-only quests).',
168
- },
169
- {
170
- name: 'wallet_id',
171
- valueType: 'container_ref',
172
- required: true,
173
- description: "The caller's wallet receiving the currency reward.",
174
- },
175
- ],
176
- mutations: [
177
- { target: 'self', property: 'claimed', expression: 'true' },
178
- {
179
- target: 'ref($to_stack_id)',
180
- property: 'quantity',
181
- expression: 'ref($to_stack_id).quantity + if(ref($to_stack_id).item_id == ref($def_id).reward_item_id, ref($def_id).reward_qty, 0)',
182
- },
183
- {
184
- target: 'ref($wallet_id)',
185
- property: currencyProperty,
186
- expression: `ref($wallet_id).${currencyProperty} + ref($def_id).reward_gold`,
187
- },
188
- ],
189
- returnExpression: `ref($wallet_id).${currencyProperty}`,
190
- invokePolicyJson: kitPolicyJson({
191
- type: 'condition',
192
- expression: [
193
- ownerEqualsCaller('self.owner_user_id', kind),
194
- 'self.count >= self.target',
195
- 'not(self.claimed)',
196
- 'ref($def_id).quest_id == self.quest_id',
197
- ownerEqualsCaller('ref($wallet_id).owner_user_id', kind),
198
- ownerEqualsCaller('ref($to_stack_id).owner_user_id', kind),
199
- ].join(' && '),
200
- }),
201
- description: 'Turn in a completed quest: the claimed flag, item grant, and currency grant commit atomically — no double-claims, no client-chosen rewards.',
202
- },
203
- {
204
- name: names.resetFn,
205
- containerTypeName: names.progressType,
206
- returnType: 'bool',
207
- mutations: [
208
- { target: 'self', property: 'count', expression: '0' },
209
- { target: 'self', property: 'completed', expression: 'false' },
210
- { target: 'self', property: 'claimed', expression: 'false' },
211
- ],
212
- returnExpression: 'self.completed',
213
- invokePolicyJson: kitPolicyJson({ type: 'is_automation' }),
214
- autonomousInvocable: true,
215
- description: 'Server-driven daily quest reset (automation-only).',
216
- },
217
- ];
218
- const automations = [
219
- {
220
- name: names.dailyResetAutomation,
221
- functionName: names.resetFn,
222
- targetMode: 'type',
223
- targetTypeName: names.progressType,
224
- triggerType: 'schedule',
225
- scheduleKind: 'cron',
226
- cronExpr: dailyResetCron,
227
- maxTargets: 500,
228
- selectorJson: JSON.stringify({
229
- selfWhere: [{ key: 'daily', op: '==', value: true }],
230
- }),
231
- description: 'Resets daily quest progress on the cron schedule.',
232
- },
233
- ];
234
- const automationTriggers = [];
235
- for (const spec of advanceOn) {
236
- automations.push({
237
- name: spec.name,
238
- functionName: names.advanceFn,
239
- targetMode: 'type',
240
- targetTypeName: names.progressType,
241
- triggerType: 'event',
242
- maxTargets: spec.maxTargets ?? 8,
243
- selectorJson: JSON.stringify({
244
- selfWhere: [
245
- { key: 'quest_id', op: '==', value: spec.questId },
246
- { key: 'completed', op: '==', value: false },
247
- ],
248
- }),
249
- paramsJson: JSON.stringify({ amount: spec.amount ?? 1 }),
250
- description: `Advances '${spec.questId}' progress when the gameplay event fires.`,
251
- });
252
- automationTriggers.push({
253
- automationName: spec.name,
254
- onEvent: spec.onEvent,
255
- ...(spec.functionName !== undefined ? { functionName: spec.functionName } : {}),
256
- ...(spec.containerTypeName !== undefined
257
- ? { containerTypeName: spec.containerTypeName }
258
- : {}),
259
- ...(spec.propertyKey !== undefined ? { propertyKey: spec.propertyKey } : {}),
260
- ...(spec.writeSource !== undefined ? { writeSource: spec.writeSource } : {}),
261
- ...(spec.debounceMs !== undefined ? { debounceMs: spec.debounceMs } : {}),
262
- });
263
- }
264
- return {
265
- name: names.progressType,
266
- containerTypes: [
267
- {
268
- typeName: names.defType,
269
- displayName: names.defType,
270
- instantiableBy: 'admin',
271
- description: 'Studio quest catalog row (objective, rewards, daily flag).',
272
- },
273
- {
274
- typeName: names.progressType,
275
- displayName: names.progressType,
276
- instantiableBy: 'member',
277
- description: "A player's progress toward one quest.",
278
- },
279
- ],
280
- propertyDefinitions,
281
- functions,
282
- automations,
283
- automationTriggers,
284
- };
285
- }
@@ -1,91 +0,0 @@
1
- import { type KitBlueprint, type KitOwnerIdKind } from './core.js';
2
- /** Options for {@link worldsimBlueprint}. */
3
- export interface WorldsimBlueprintOptions {
4
- /** Prefix for the type/function names. Defaults to none. */
5
- typePrefix?: string;
6
- /**
7
- * Day/night + weather: an interval automation advances `time_of_day`
8
- * (wrapping at `hoursPerDay`, bumping `day`), optionally re-rolls the
9
- * weather, and emits a **spatial notification** at the world anchor chunk
10
- * so nearby clients update the sky without polling. Set `false` to omit.
11
- * Defaults to a 60s tick, 24-hour days, weather on.
12
- */
13
- time?: {
14
- intervalMs?: number;
15
- hoursPerDay?: number;
16
- weather?: boolean;
17
- /** Replication radius of the time-changed ping (chunks, 0-8). Defaults to 8. */
18
- notifyDistance?: number;
19
- } | false;
20
- /**
21
- * Resource-node regeneration: an interval automation raises `amount`
22
- * toward `max_amount` on depleted nodes; players `gather_node` into a
23
- * matching stack. Set `false` to omit. Defaults to a 60s tick.
24
- */
25
- nodes?: {
26
- intervalMs?: number;
27
- } | false;
28
- /**
29
- * Crop growth: an interval automation advances `stage` toward
30
- * `max_stage`; owners `harvest` grown crops into a matching stack. Set
31
- * `false` to omit. Defaults to a 60s tick.
32
- */
33
- crops?: {
34
- intervalMs?: number;
35
- } | false;
36
- /**
37
- * Wave spawner counters: an interval automation bumps `wave` and grows
38
- * `next_wave_size` — the actual entity spawning stays host-side on the
39
- * replication plane (the BWF hybrid). Off by default.
40
- */
41
- waves?: {
42
- intervalMs?: number;
43
- growth?: number;
44
- };
45
- /** Owner-mirror typing (see the kit convention). Defaults to `'int'`. */
46
- ownerIdKind?: KitOwnerIdKind;
47
- }
48
- /** Names derived by {@link worldsimBlueprint} for a given prefix. */
49
- export interface WorldsimNames {
50
- worldStateType: string;
51
- nodeType: string;
52
- cropType: string;
53
- spawnerType: string;
54
- advanceTimeFn: string;
55
- setWeatherFn: string;
56
- regenNodeFn: string;
57
- gatherNodeFn: string;
58
- growCropFn: string;
59
- harvestFn: string;
60
- spawnWaveFn: string;
61
- clockAutomation: string;
62
- regenAutomation: string;
63
- growthAutomation: string;
64
- waveAutomation: string;
65
- }
66
- /** Compute the type/function names a worldsim blueprint (and its runtime helper) uses. */
67
- export declare function worldsimNames(typePrefix?: string): WorldsimNames;
68
- /**
69
- * Blueprint for **world simulation**: day/night + weather (`WorldState`
70
- * singleton), regenerating `ResourceNode`s, growing `Crop`s / production
71
- * jobs, and `WaveSpawner` counters — all driven by interval automations on the
72
- * automations simulation tier (seconds, never per-frame).
73
- *
74
- * **These automations run only while the app has a player in it.** Since
75
- * 2026-09-01 scheduled work for an empty app is skipped and rescheduled from the
76
- * moment a player returns; missed runs are never made up. Design the tick to be
77
- * IDEMPOTENT IN ELAPSED TIME rather than to assume a fixed cadence: read the
78
- * clock, advance the world by however long it has been, and write the result. A
79
- * crop that grows by one step per tick will stall while nobody is playing; one
80
- * that grows by `now - lastTick` will be correct whenever anybody looks at it.
81
- *
82
- * The world clock emits a **spatial notification** at the world anchor chunk
83
- * each tick, so nearby clients update the sky push-style instead of polling;
84
- * everything else is pull-on-demand (or wire your own notify-to-pull pings).
85
- * Wave spawners only advance counters — actual entity spawning belongs on
86
- * the replication plane under host authority (the BWF hybrid).
87
- *
88
- * Runtime counterpart: `client.kit(appId).worldsim`.
89
- */
90
- export declare function worldsimBlueprint(options?: WorldsimBlueprintOptions): KitBlueprint;
91
- //# sourceMappingURL=worldsim.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worldsim.d.ts","sourceRoot":"","sources":["../../../src/kit/blueprints/worldsim.ts"],"names":[],"mappings":"AAIA,OAAO,EAML,KAAK,YAAY,EACjB,KAAK,cAAc,EACpB,MAAM,WAAW,CAAC;AAEnB,6CAA6C;AAC7C,MAAM,WAAW,wBAAwB;IACvC,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,IAAI,CAAC,EACD;QACE,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,gFAAgF;QAChF,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,GACD,KAAK,CAAC;IACV;;;;OAIG;IACH,KAAK,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,KAAK,CAAC;IACxC;;;;OAIG;IACH,KAAK,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,KAAK,CAAC;IACxC;;;;OAIG;IACH,KAAK,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD,yEAAyE;IACzE,WAAW,CAAC,EAAE,cAAc,CAAC;CAC9B;AAED,qEAAqE;AACrE,MAAM,WAAW,aAAa;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,0FAA0F;AAC1F,wBAAgB,aAAa,CAAC,UAAU,SAAK,GAAG,aAAa,CAoB5D;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE,wBAA6B,GACrC,YAAY,CAmdd"}