@crowdedkingdoms/crowdyjs 17.13.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 (284) hide show
  1. package/MIGRATION.md +163 -1
  2. package/README.md +142 -146
  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 +59 -57
  9. package/dist/crowdy-studio/controller.d.ts.map +1 -1
  10. package/dist/crowdy-studio/controller.js +268 -206
  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 -47
  16. package/dist/crowdy-studio/embed/hud-layer.d.ts +1 -1
  17. package/dist/crowdy-studio/embed/panel.d.ts +3 -12
  18. package/dist/crowdy-studio/embed/panel.d.ts.map +1 -1
  19. package/dist/crowdy-studio/embed/panel.js +3 -6
  20. package/dist/crowdy-studio/index.d.ts +1 -3
  21. package/dist/crowdy-studio/index.d.ts.map +1 -1
  22. package/dist/crowdy-studio/index.js +0 -2
  23. package/dist/crowdy-studio/models.d.ts +3 -4
  24. package/dist/crowdy-studio/models.d.ts.map +1 -1
  25. package/dist/crowdy-studio/starter-projects.d.ts +8 -4
  26. package/dist/crowdy-studio/starter-projects.d.ts.map +1 -1
  27. package/dist/crowdy-studio/starter-projects.js +83 -100
  28. package/dist/domains/appAccess.d.ts +14 -1
  29. package/dist/domains/appAccess.d.ts.map +1 -1
  30. package/dist/domains/appAccess.js +37 -1
  31. package/dist/domains/exec.d.ts +162 -15
  32. package/dist/domains/exec.d.ts.map +1 -1
  33. package/dist/domains/exec.js +180 -18
  34. package/dist/domains/host.d.ts +3 -3
  35. package/dist/domains/host.js +3 -3
  36. package/dist/domains/marketplace.d.ts +9 -58
  37. package/dist/domains/marketplace.d.ts.map +1 -1
  38. package/dist/domains/marketplace.js +9 -106
  39. package/dist/domains/playerWallet.d.ts +6 -12
  40. package/dist/domains/playerWallet.d.ts.map +1 -1
  41. package/dist/domains/playerWallet.js +6 -21
  42. package/dist/errors.d.ts +7 -13
  43. package/dist/errors.d.ts.map +1 -1
  44. package/dist/errors.js +6 -10
  45. package/dist/generated/graphql.d.ts +1384 -7977
  46. package/dist/generated/graphql.d.ts.map +1 -1
  47. package/dist/generated/graphql.js +22 -321
  48. package/dist/grid-mods/exec-client-halves.d.ts +156 -0
  49. package/dist/grid-mods/exec-client-halves.d.ts.map +1 -0
  50. package/dist/grid-mods/exec-client-halves.js +356 -0
  51. package/dist/grid-mods/grid-host-calls.d.ts +29 -15
  52. package/dist/grid-mods/grid-host-calls.d.ts.map +1 -1
  53. package/dist/grid-mods/grid-host-calls.js +40 -44
  54. package/dist/grid-mods/index.d.ts +1 -0
  55. package/dist/grid-mods/index.d.ts.map +1 -1
  56. package/dist/grid-mods/index.js +1 -0
  57. package/dist/grid-mods/mod-runtime.d.ts +21 -6
  58. package/dist/grid-mods/mod-runtime.d.ts.map +1 -1
  59. package/dist/grid-mods/mod-runtime.js +6 -2
  60. package/dist/grid-scope.d.ts +0 -188
  61. package/dist/grid-scope.d.ts.map +1 -1
  62. package/dist/grid-scope.js +0 -69
  63. package/dist/index.d.ts +12 -18
  64. package/dist/index.d.ts.map +1 -1
  65. package/dist/index.js +11 -16
  66. package/dist/kit/actions.d.ts +5 -9
  67. package/dist/kit/actions.d.ts.map +1 -1
  68. package/dist/kit/actions.js +5 -9
  69. package/dist/kit/index.d.ts +2 -33
  70. package/dist/kit/index.d.ts.map +1 -1
  71. package/dist/kit/index.js +1 -32
  72. package/dist/kit/kit.d.ts +8 -208
  73. package/dist/kit/kit.d.ts.map +1 -1
  74. package/dist/kit/kit.js +5 -163
  75. package/dist/kit/social.d.ts +1 -3
  76. package/dist/kit/social.d.ts.map +1 -1
  77. package/dist/kit/social.js +1 -3
  78. package/dist/kit/wire.d.ts +16 -5
  79. package/dist/kit/wire.d.ts.map +1 -1
  80. package/dist/kit/wire.js +19 -5
  81. package/dist/live-coding/assets/browser-authoring-index.json +1 -1
  82. package/dist/live-coding/assets/manifest.json +1 -1
  83. package/dist/live-coding/browser-authoring-index.generated.d.ts.map +1 -1
  84. package/dist/live-coding/browser-authoring-index.generated.js +1496 -4386
  85. package/dist/live-coding/rust-analysis.d.ts.map +1 -1
  86. package/dist/live-coding/rust-analysis.js +31 -23
  87. package/dist/player-runtime/client-host-calls.d.ts +8 -0
  88. package/dist/player-runtime/client-host-calls.d.ts.map +1 -0
  89. package/dist/player-runtime/client-host-calls.js +28 -0
  90. package/dist/player-runtime/glue-runtime.d.ts +27 -10
  91. package/dist/player-runtime/glue-runtime.d.ts.map +1 -1
  92. package/dist/player-runtime/glue-runtime.js +40 -45
  93. package/dist/player-runtime/glue-sab.d.ts +2 -2
  94. package/dist/player-runtime/glue-sab.js +2 -2
  95. package/dist/player-runtime/player-code-broker.d.ts +80 -24
  96. package/dist/player-runtime/player-code-broker.d.ts.map +1 -1
  97. package/dist/player-runtime/player-code-broker.js +169 -41
  98. package/dist/player-runtime/player-glue-worker.d.ts +8 -8
  99. package/dist/player-runtime/player-glue-worker.d.ts.map +1 -1
  100. package/dist/player-runtime/player-glue-worker.js +26 -9
  101. package/dist/stores/actors.d.ts +12 -2
  102. package/dist/stores/actors.d.ts.map +1 -1
  103. package/dist/stores/actors.js +43 -18
  104. package/dist/stores/chunks.d.ts +12 -0
  105. package/dist/stores/chunks.d.ts.map +1 -1
  106. package/dist/stores/chunks.js +112 -39
  107. package/dist/stores/durable.d.ts.map +1 -1
  108. package/dist/stores/durable.js +2 -1
  109. package/dist/stores/inbox.d.ts +1 -1
  110. package/dist/stores/inbox.d.ts.map +1 -1
  111. package/dist/stores/index.d.ts +0 -11
  112. package/dist/stores/index.d.ts.map +1 -1
  113. package/dist/stores/index.js +0 -4
  114. package/dist/stores/session.d.ts +0 -2
  115. package/dist/stores/session.d.ts.map +1 -1
  116. package/package.json +1 -1
  117. package/dist/crowdy-studio/model-lint-log.d.ts +0 -76
  118. package/dist/crowdy-studio/model-lint-log.d.ts.map +0 -1
  119. package/dist/crowdy-studio/model-lint-log.js +0 -93
  120. package/dist/crowdy-studio/model-lint.d.ts +0 -61
  121. package/dist/crowdy-studio/model-lint.d.ts.map +0 -1
  122. package/dist/crowdy-studio/model-lint.js +0 -45
  123. package/dist/domains/compute.d.ts +0 -208
  124. package/dist/domains/compute.d.ts.map +0 -1
  125. package/dist/domains/compute.js +0 -274
  126. package/dist/domains/controlPlane.d.ts +0 -38
  127. package/dist/domains/controlPlane.d.ts.map +0 -1
  128. package/dist/domains/controlPlane.js +0 -43
  129. package/dist/domains/gameModel.d.ts +0 -1174
  130. package/dist/domains/gameModel.d.ts.map +0 -1
  131. package/dist/domains/gameModel.js +0 -1333
  132. package/dist/domains/playerCompute.d.ts +0 -91
  133. package/dist/domains/playerCompute.d.ts.map +0 -1
  134. package/dist/domains/playerCompute.js +0 -136
  135. package/dist/domains/playerModel.d.ts +0 -20
  136. package/dist/domains/playerModel.d.ts.map +0 -1
  137. package/dist/domains/playerModel.js +0 -54
  138. package/dist/kit/abilities.d.ts +0 -66
  139. package/dist/kit/abilities.d.ts.map +0 -1
  140. package/dist/kit/abilities.js +0 -71
  141. package/dist/kit/blueprints/combat.d.ts +0 -81
  142. package/dist/kit/blueprints/combat.d.ts.map +0 -1
  143. package/dist/kit/blueprints/combat.js +0 -357
  144. package/dist/kit/blueprints/core.d.ts +0 -222
  145. package/dist/kit/blueprints/core.d.ts.map +0 -1
  146. package/dist/kit/blueprints/core.js +0 -185
  147. package/dist/kit/blueprints/decks.d.ts +0 -50
  148. package/dist/kit/blueprints/decks.d.ts.map +0 -1
  149. package/dist/kit/blueprints/decks.js +0 -163
  150. package/dist/kit/blueprints/economy.d.ts +0 -88
  151. package/dist/kit/blueprints/economy.d.ts.map +0 -1
  152. package/dist/kit/blueprints/economy.js +0 -533
  153. package/dist/kit/blueprints/guild.d.ts +0 -51
  154. package/dist/kit/blueprints/guild.d.ts.map +0 -1
  155. package/dist/kit/blueprints/guild.js +0 -50
  156. package/dist/kit/blueprints/index.d.ts +0 -23
  157. package/dist/kit/blueprints/index.d.ts.map +0 -1
  158. package/dist/kit/blueprints/index.js +0 -22
  159. package/dist/kit/blueprints/inventory.d.ts +0 -84
  160. package/dist/kit/blueprints/inventory.d.ts.map +0 -1
  161. package/dist/kit/blueprints/inventory.js +0 -257
  162. package/dist/kit/blueprints/leaderboards.d.ts +0 -49
  163. package/dist/kit/blueprints/leaderboards.d.ts.map +0 -1
  164. package/dist/kit/blueprints/leaderboards.js +0 -126
  165. package/dist/kit/blueprints/liveops.d.ts +0 -42
  166. package/dist/kit/blueprints/liveops.d.ts.map +0 -1
  167. package/dist/kit/blueprints/liveops.js +0 -170
  168. package/dist/kit/blueprints/locks.d.ts +0 -82
  169. package/dist/kit/blueprints/locks.d.ts.map +0 -1
  170. package/dist/kit/blueprints/locks.js +0 -155
  171. package/dist/kit/blueprints/loot.d.ts +0 -90
  172. package/dist/kit/blueprints/loot.d.ts.map +0 -1
  173. package/dist/kit/blueprints/loot.js +0 -229
  174. package/dist/kit/blueprints/matches.d.ts +0 -84
  175. package/dist/kit/blueprints/matches.d.ts.map +0 -1
  176. package/dist/kit/blueprints/matches.js +0 -349
  177. package/dist/kit/blueprints/moderation.d.ts +0 -32
  178. package/dist/kit/blueprints/moderation.d.ts.map +0 -1
  179. package/dist/kit/blueprints/moderation.js +0 -140
  180. package/dist/kit/blueprints/npcs.d.ts +0 -78
  181. package/dist/kit/blueprints/npcs.d.ts.map +0 -1
  182. package/dist/kit/blueprints/npcs.js +0 -125
  183. package/dist/kit/blueprints/plots.d.ts +0 -63
  184. package/dist/kit/blueprints/plots.d.ts.map +0 -1
  185. package/dist/kit/blueprints/plots.js +0 -151
  186. package/dist/kit/blueprints/progression.d.ts +0 -68
  187. package/dist/kit/blueprints/progression.d.ts.map +0 -1
  188. package/dist/kit/blueprints/progression.js +0 -324
  189. package/dist/kit/blueprints/quests.d.ts +0 -72
  190. package/dist/kit/blueprints/quests.d.ts.map +0 -1
  191. package/dist/kit/blueprints/quests.js +0 -285
  192. package/dist/kit/blueprints/worldsim.d.ts +0 -91
  193. package/dist/kit/blueprints/worldsim.d.ts.map +0 -1
  194. package/dist/kit/blueprints/worldsim.js +0 -468
  195. package/dist/kit/combat.d.ts +0 -141
  196. package/dist/kit/combat.d.ts.map +0 -1
  197. package/dist/kit/combat.js +0 -196
  198. package/dist/kit/decks.d.ts +0 -157
  199. package/dist/kit/decks.d.ts.map +0 -1
  200. package/dist/kit/decks.js +0 -186
  201. package/dist/kit/director.d.ts +0 -88
  202. package/dist/kit/director.d.ts.map +0 -1
  203. package/dist/kit/director.js +0 -86
  204. package/dist/kit/economy.d.ts +0 -289
  205. package/dist/kit/economy.d.ts.map +0 -1
  206. package/dist/kit/economy.js +0 -427
  207. package/dist/kit/engine.d.ts +0 -48
  208. package/dist/kit/engine.d.ts.map +0 -1
  209. package/dist/kit/engine.js +0 -113
  210. package/dist/kit/features.d.ts +0 -60
  211. package/dist/kit/features.d.ts.map +0 -1
  212. package/dist/kit/features.js +0 -65
  213. package/dist/kit/instances.d.ts +0 -52
  214. package/dist/kit/instances.d.ts.map +0 -1
  215. package/dist/kit/instances.js +0 -60
  216. package/dist/kit/inventory.d.ts +0 -129
  217. package/dist/kit/inventory.d.ts.map +0 -1
  218. package/dist/kit/inventory.js +0 -200
  219. package/dist/kit/leaderboards.d.ts +0 -86
  220. package/dist/kit/leaderboards.d.ts.map +0 -1
  221. package/dist/kit/leaderboards.js +0 -133
  222. package/dist/kit/liveops.d.ts +0 -112
  223. package/dist/kit/liveops.d.ts.map +0 -1
  224. package/dist/kit/liveops.js +0 -183
  225. package/dist/kit/loot.d.ts +0 -128
  226. package/dist/kit/loot.d.ts.map +0 -1
  227. package/dist/kit/loot.js +0 -160
  228. package/dist/kit/matches.d.ts +0 -301
  229. package/dist/kit/matches.d.ts.map +0 -1
  230. package/dist/kit/matches.js +0 -458
  231. package/dist/kit/matchmaking.d.ts +0 -57
  232. package/dist/kit/matchmaking.d.ts.map +0 -1
  233. package/dist/kit/matchmaking.js +0 -59
  234. package/dist/kit/minigames.d.ts +0 -30
  235. package/dist/kit/minigames.d.ts.map +0 -1
  236. package/dist/kit/minigames.js +0 -38
  237. package/dist/kit/mobs.d.ts +0 -90
  238. package/dist/kit/mobs.d.ts.map +0 -1
  239. package/dist/kit/mobs.js +0 -98
  240. package/dist/kit/moderation.d.ts +0 -73
  241. package/dist/kit/moderation.d.ts.map +0 -1
  242. package/dist/kit/moderation.js +0 -103
  243. package/dist/kit/movement.d.ts +0 -78
  244. package/dist/kit/movement.d.ts.map +0 -1
  245. package/dist/kit/movement.js +0 -103
  246. package/dist/kit/notifications.d.ts +0 -45
  247. package/dist/kit/notifications.d.ts.map +0 -1
  248. package/dist/kit/notifications.js +0 -67
  249. package/dist/kit/npcs.d.ts +0 -226
  250. package/dist/kit/npcs.d.ts.map +0 -1
  251. package/dist/kit/npcs.js +0 -141
  252. package/dist/kit/objects.d.ts +0 -116
  253. package/dist/kit/objects.d.ts.map +0 -1
  254. package/dist/kit/objects.js +0 -119
  255. package/dist/kit/pets.d.ts +0 -85
  256. package/dist/kit/pets.d.ts.map +0 -1
  257. package/dist/kit/pets.js +0 -96
  258. package/dist/kit/plots.d.ts +0 -85
  259. package/dist/kit/plots.d.ts.map +0 -1
  260. package/dist/kit/plots.js +0 -113
  261. package/dist/kit/progression.d.ts +0 -181
  262. package/dist/kit/progression.d.ts.map +0 -1
  263. package/dist/kit/progression.js +0 -265
  264. package/dist/kit/quests.d.ts +0 -171
  265. package/dist/kit/quests.d.ts.map +0 -1
  266. package/dist/kit/quests.js +0 -237
  267. package/dist/kit/racing.d.ts +0 -85
  268. package/dist/kit/racing.d.ts.map +0 -1
  269. package/dist/kit/racing.js +0 -99
  270. package/dist/kit/shared.d.ts +0 -73
  271. package/dist/kit/shared.d.ts.map +0 -1
  272. package/dist/kit/shared.js +0 -101
  273. package/dist/kit/telemetry.d.ts +0 -66
  274. package/dist/kit/telemetry.d.ts.map +0 -1
  275. package/dist/kit/telemetry.js +0 -133
  276. package/dist/kit/territory.d.ts +0 -97
  277. package/dist/kit/territory.d.ts.map +0 -1
  278. package/dist/kit/territory.js +0 -114
  279. package/dist/kit/worldsim.d.ts +0 -263
  280. package/dist/kit/worldsim.d.ts.map +0 -1
  281. package/dist/kit/worldsim.js +0 -268
  282. package/dist/stores/model.d.ts +0 -81
  283. package/dist/stores/model.d.ts.map +0 -1
  284. 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"}