@v12-engine/engine 0.1.0 → 0.4.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 (951) hide show
  1. package/dist/abilities/amounts.d.ts +28 -0
  2. package/dist/abilities/amounts.js +74 -0
  3. package/dist/abilities/amounts.js.map +1 -0
  4. package/dist/abilities/buffs.d.ts +106 -6
  5. package/dist/abilities/buffs.js +443 -0
  6. package/dist/abilities/buffs.js.map +1 -0
  7. package/dist/abilities/castTold.d.ts +2 -0
  8. package/dist/abilities/castTold.js +66 -0
  9. package/dist/abilities/castTold.js.map +1 -0
  10. package/dist/abilities/chance.d.ts +38 -0
  11. package/dist/abilities/chance.js +77 -0
  12. package/dist/abilities/chance.js.map +1 -0
  13. package/dist/abilities/charges.d.ts +18 -0
  14. package/dist/abilities/charges.js +101 -0
  15. package/dist/abilities/charges.js.map +1 -0
  16. package/dist/abilities/control.d.ts +28 -0
  17. package/dist/abilities/control.js +113 -0
  18. package/dist/abilities/control.js.map +1 -0
  19. package/dist/abilities/dispel.js +51 -0
  20. package/dist/abilities/dispel.js.map +1 -0
  21. package/dist/abilities/effectFields.d.ts +1 -1
  22. package/dist/abilities/effectFields.js +676 -0
  23. package/dist/abilities/effectFields.js.map +1 -0
  24. package/dist/abilities/effectIndex.d.ts +27 -0
  25. package/dist/abilities/effectIndex.js +64 -0
  26. package/dist/abilities/effectIndex.js.map +1 -0
  27. package/dist/abilities/effects/buff.d.ts +9 -3
  28. package/dist/abilities/effects/buff.js +84 -0
  29. package/dist/abilities/effects/buff.js.map +1 -0
  30. package/dist/abilities/effects/conditions.d.ts +2 -0
  31. package/dist/abilities/effects/conditions.js +41 -0
  32. package/dist/abilities/effects/conditions.js.map +1 -0
  33. package/dist/abilities/effects/core.js +54 -0
  34. package/dist/abilities/effects/core.js.map +1 -0
  35. package/dist/abilities/effects/damage.d.ts +1 -1
  36. package/dist/abilities/effects/damage.js +43 -0
  37. package/dist/abilities/effects/damage.js.map +1 -0
  38. package/dist/abilities/effects/heal.d.ts +2 -2
  39. package/dist/abilities/effects/heal.js +51 -0
  40. package/dist/abilities/effects/heal.js.map +1 -0
  41. package/dist/abilities/effects/missile.d.ts +13 -1
  42. package/dist/abilities/effects/missile.js +104 -0
  43. package/dist/abilities/effects/missile.js.map +1 -0
  44. package/dist/abilities/effects/morph.d.ts +5 -0
  45. package/dist/abilities/effects/morph.js +43 -0
  46. package/dist/abilities/effects/morph.js.map +1 -0
  47. package/dist/abilities/effects/moves.d.ts +16 -4
  48. package/dist/abilities/effects/moves.js +212 -0
  49. package/dist/abilities/effects/moves.js.map +1 -0
  50. package/dist/abilities/effects/passives.d.ts +19 -9
  51. package/dist/abilities/effects/passives.js +131 -0
  52. package/dist/abilities/effects/passives.js.map +1 -0
  53. package/dist/abilities/effects/proxy.d.ts +5 -0
  54. package/dist/abilities/effects/proxy.js +60 -0
  55. package/dist/abilities/effects/proxy.js.map +1 -0
  56. package/dist/abilities/effects/sight.d.ts +2 -2
  57. package/dist/abilities/effects/sight.js +39 -0
  58. package/dist/abilities/effects/sight.js.map +1 -0
  59. package/dist/abilities/effects/spawn.d.ts +5 -2
  60. package/dist/abilities/effects/spawn.js +40 -0
  61. package/dist/abilities/effects/spawn.js.map +1 -0
  62. package/dist/abilities/effects/timed.d.ts +2 -2
  63. package/dist/abilities/effects/timed.js +96 -0
  64. package/dist/abilities/effects/timed.js.map +1 -0
  65. package/dist/abilities/effects/trade.d.ts +1 -1
  66. package/dist/abilities/effects/trade.js +25 -0
  67. package/dist/abilities/effects/trade.js.map +1 -0
  68. package/dist/abilities/effects.d.ts +97 -23
  69. package/dist/abilities/effects.js +860 -0
  70. package/dist/abilities/effects.js.map +1 -0
  71. package/dist/abilities/land.d.ts +38 -4
  72. package/dist/abilities/land.js +189 -0
  73. package/dist/abilities/land.js.map +1 -0
  74. package/dist/abilities/recast.d.ts +45 -0
  75. package/dist/abilities/recast.js +118 -0
  76. package/dist/abilities/recast.js.map +1 -0
  77. package/dist/abilities/scaled.js +40 -0
  78. package/dist/abilities/scaled.js.map +1 -0
  79. package/dist/abilities/screen.d.ts +6 -0
  80. package/dist/abilities/screen.js +83 -0
  81. package/dist/abilities/screen.js.map +1 -0
  82. package/dist/abilities/shapes.d.ts +66 -0
  83. package/dist/abilities/shapes.js +122 -0
  84. package/dist/abilities/shapes.js.map +1 -0
  85. package/dist/abilities/text.d.ts +14 -2
  86. package/dist/abilities/text.js +204 -0
  87. package/dist/abilities/text.js.map +1 -0
  88. package/dist/abilities/triggers.d.ts +98 -0
  89. package/dist/abilities/triggers.js +351 -0
  90. package/dist/abilities/triggers.js.map +1 -0
  91. package/dist/abilityChanges.d.ts +131 -0
  92. package/dist/abilityChanges.js +345 -0
  93. package/dist/abilityChanges.js.map +1 -0
  94. package/dist/ai/area.d.ts +4 -1
  95. package/dist/ai/brain.d.ts +4 -1
  96. package/dist/ai/brain.js +844 -0
  97. package/dist/ai/brain.js.map +1 -0
  98. package/dist/ai/budget.js +74 -0
  99. package/dist/ai/budget.js.map +1 -0
  100. package/dist/ai/checks.d.ts +9 -1
  101. package/dist/ai/checks.js +242 -0
  102. package/dist/ai/checks.js.map +1 -0
  103. package/dist/ai/computer.d.ts +11 -4
  104. package/dist/ai/computer.js +251 -0
  105. package/dist/ai/computer.js.map +1 -0
  106. package/dist/ai/defence.d.ts +4 -0
  107. package/dist/ai/defence.js +430 -0
  108. package/dist/ai/defence.js.map +1 -0
  109. package/dist/ai/define.d.ts +3 -2
  110. package/dist/ai/define.js +31 -0
  111. package/dist/ai/define.js.map +1 -0
  112. package/dist/ai/economy.d.ts +10 -7
  113. package/dist/ai/economy.js +780 -0
  114. package/dist/ai/economy.js.map +1 -0
  115. package/dist/ai/geometry.js +38 -0
  116. package/dist/ai/geometry.js.map +1 -0
  117. package/dist/ai/goals.d.ts +1 -0
  118. package/dist/ai/goals.js +560 -0
  119. package/dist/ai/goals.js.map +1 -0
  120. package/dist/ai/knowledge.d.ts +72 -7
  121. package/dist/ai/knowledge.js +804 -0
  122. package/dist/ai/knowledge.js.map +1 -0
  123. package/dist/ai/lanes.d.ts +10 -2
  124. package/dist/ai/lanes.js +715 -0
  125. package/dist/ai/lanes.js.map +1 -0
  126. package/dist/ai/melee/build.js +264 -0
  127. package/dist/ai/melee/build.js.map +1 -0
  128. package/dist/ai/melee/goals.d.ts +7 -0
  129. package/dist/ai/melee/goals.js +720 -0
  130. package/dist/ai/melee/goals.js.map +1 -0
  131. package/dist/ai/melee/heroes.js +68 -0
  132. package/dist/ai/melee/heroes.js.map +1 -0
  133. package/dist/ai/melee/index.d.ts +1 -1
  134. package/dist/ai/melee/index.js +51 -0
  135. package/dist/ai/melee/index.js.map +1 -0
  136. package/dist/ai/melee/production.js +29 -0
  137. package/dist/ai/melee/production.js.map +1 -0
  138. package/dist/ai/melee/surrender.js +64 -0
  139. package/dist/ai/melee/surrender.js.map +1 -0
  140. package/dist/ai/micro.d.ts +9 -0
  141. package/dist/ai/micro.js +1316 -0
  142. package/dist/ai/micro.js.map +1 -0
  143. package/dist/ai/mission.d.ts +9 -2
  144. package/dist/ai/mission.js +538 -0
  145. package/dist/ai/mission.js.map +1 -0
  146. package/dist/ai/missionRules.d.ts +1 -1
  147. package/dist/ai/missionRules.js +26 -0
  148. package/dist/ai/missionRules.js.map +1 -0
  149. package/dist/ai/module.d.ts +6 -2
  150. package/dist/ai/module.js +37 -0
  151. package/dist/ai/module.js.map +1 -0
  152. package/dist/ai/options.d.ts +3 -3
  153. package/dist/ai/plans/build.d.ts +20 -1
  154. package/dist/ai/plans/build.js +608 -0
  155. package/dist/ai/plans/build.js.map +1 -0
  156. package/dist/ai/plans/placement.d.ts +4 -1
  157. package/dist/ai/plans/placement.js +295 -0
  158. package/dist/ai/plans/placement.js.map +1 -0
  159. package/dist/ai/plans/plans.d.ts +9 -0
  160. package/dist/ai/plans/plans.js +110 -0
  161. package/dist/ai/plans/plans.js.map +1 -0
  162. package/dist/ai/plans/production.d.ts +14 -2
  163. package/dist/ai/plans/production.js +434 -0
  164. package/dist/ai/plans/production.js.map +1 -0
  165. package/dist/ai/plans/purse.d.ts +6 -3
  166. package/dist/ai/plans/purse.js +139 -0
  167. package/dist/ai/plans/purse.js.map +1 -0
  168. package/dist/ai/plans/tech.d.ts +6 -0
  169. package/dist/ai/plans/tech.js +122 -0
  170. package/dist/ai/plans/tech.js.map +1 -0
  171. package/dist/ai/profiles.d.ts +4 -4
  172. package/dist/{profiles-B3NS9jwk.js → ai/profiles.js} +3 -98
  173. package/dist/ai/profiles.js.map +1 -0
  174. package/dist/ai/reach.js +54 -0
  175. package/dist/ai/reach.js.map +1 -0
  176. package/dist/ai/report.d.ts +8 -0
  177. package/dist/ai/report.js +87 -0
  178. package/dist/ai/report.js.map +1 -0
  179. package/dist/ai/roles.d.ts +4 -0
  180. package/dist/ai/roles.js +207 -0
  181. package/dist/ai/roles.js.map +1 -0
  182. package/dist/ai/rules.d.ts +8 -2
  183. package/dist/ai/rules.js +416 -0
  184. package/dist/ai/rules.js.map +1 -0
  185. package/dist/ai/scouting.d.ts +6 -0
  186. package/dist/ai/scouting.js +324 -0
  187. package/dist/ai/scouting.js.map +1 -0
  188. package/dist/ai/settings.js +99 -0
  189. package/dist/ai/settings.js.map +1 -0
  190. package/dist/ai/squads.d.ts +21 -2
  191. package/dist/ai/squads.js +916 -0
  192. package/dist/ai/squads.js.map +1 -0
  193. package/dist/ai/strength.js +320 -0
  194. package/dist/ai/strength.js.map +1 -0
  195. package/dist/ai/task.d.ts +3 -1
  196. package/dist/ai/task.js +17 -0
  197. package/dist/ai/task.js.map +1 -0
  198. package/dist/ai/tasks/attack.js +24 -0
  199. package/dist/ai/tasks/attack.js.map +1 -0
  200. package/dist/ai/tasks/capture.d.ts +3 -3
  201. package/dist/ai/tasks/capture.js +37 -0
  202. package/dist/ai/tasks/capture.js.map +1 -0
  203. package/dist/ai/tasks/creep.js +29 -0
  204. package/dist/ai/tasks/creep.js.map +1 -0
  205. package/dist/ai/tasks/defend.js +61 -0
  206. package/dist/ai/tasks/defend.js.map +1 -0
  207. package/dist/ai/tasks/drop.js +81 -0
  208. package/dist/ai/tasks/drop.js.map +1 -0
  209. package/dist/ai/tasks/escort.js +59 -0
  210. package/dist/ai/tasks/escort.js.map +1 -0
  211. package/dist/ai/tasks/gather.js +48 -0
  212. package/dist/ai/tasks/gather.js.map +1 -0
  213. package/dist/ai/tasks/harass.js +39 -0
  214. package/dist/ai/tasks/harass.js.map +1 -0
  215. package/dist/ai/tasks/hold.js +32 -0
  216. package/dist/ai/tasks/hold.js.map +1 -0
  217. package/dist/ai/tasks/index.js +34 -0
  218. package/dist/ai/tasks/index.js.map +1 -0
  219. package/dist/ai/tasks/move.js +26 -0
  220. package/dist/ai/tasks/move.js.map +1 -0
  221. package/dist/ai/tasks/patrol.js +59 -0
  222. package/dist/ai/tasks/patrol.js.map +1 -0
  223. package/dist/ai/tasks/retreat.js +28 -0
  224. package/dist/ai/tasks/retreat.js.map +1 -0
  225. package/dist/ai/tasks/scout.js +73 -0
  226. package/dist/ai/tasks/scout.js.map +1 -0
  227. package/dist/ai/tasks/shared.d.ts +1 -1
  228. package/dist/ai/tasks/shared.js +137 -0
  229. package/dist/ai/tasks/shared.js.map +1 -0
  230. package/dist/ai/team.d.ts +18 -1
  231. package/dist/ai/team.js +492 -0
  232. package/dist/ai/team.js.map +1 -0
  233. package/dist/ai/threat.d.ts +6 -0
  234. package/dist/ai/threat.js +206 -0
  235. package/dist/ai/threat.js.map +1 -0
  236. package/dist/ai/view.d.ts +21 -7
  237. package/dist/ai/view.js +677 -0
  238. package/dist/ai/view.js.map +1 -0
  239. package/dist/ai/waves.d.ts +6 -0
  240. package/dist/ai/waves.js +410 -0
  241. package/dist/ai/waves.js.map +1 -0
  242. package/dist/ai.js +54 -6239
  243. package/dist/aiTesting.d.ts +6 -3
  244. package/dist/aiTesting.js +229 -0
  245. package/dist/aiTesting.js.map +1 -0
  246. package/dist/areas.d.ts +4 -1
  247. package/dist/areas.js +295 -0
  248. package/dist/areas.js.map +1 -0
  249. package/dist/attacks.d.ts +3 -3
  250. package/dist/attacks.js +127 -0
  251. package/dist/attacks.js.map +1 -0
  252. package/dist/burning.d.ts +267 -0
  253. package/dist/burning.js +795 -0
  254. package/dist/burning.js.map +1 -0
  255. package/dist/bytes.js +21 -0
  256. package/dist/bytes.js.map +1 -0
  257. package/dist/callings.d.ts +71 -0
  258. package/dist/callings.js +157 -0
  259. package/dist/callings.js.map +1 -0
  260. package/dist/cameraOrders.d.ts +78 -0
  261. package/dist/cameraOrders.js +114 -0
  262. package/dist/cameraOrders.js.map +1 -0
  263. package/dist/camps.d.ts +70 -4
  264. package/dist/camps.js +501 -0
  265. package/dist/camps.js.map +1 -0
  266. package/dist/capture.d.ts +15 -3
  267. package/dist/capture.js +304 -0
  268. package/dist/capture.js.map +1 -0
  269. package/dist/cellLayers.d.ts +78 -13
  270. package/dist/cellLayers.js +275 -0
  271. package/dist/cellLayers.js.map +1 -0
  272. package/dist/cellPatches.d.ts +24 -0
  273. package/dist/cellPatches.js +73 -0
  274. package/dist/cellPatches.js.map +1 -0
  275. package/dist/cinematics.d.ts +10 -5
  276. package/dist/cinematics.js +161 -0
  277. package/dist/cinematics.js.map +1 -0
  278. package/dist/clock.d.ts +2 -2
  279. package/dist/clock.js +78 -0
  280. package/dist/clock.js.map +1 -0
  281. package/dist/commands.d.ts +36 -4
  282. package/dist/commands.js +636 -0
  283. package/dist/commands.js.map +1 -0
  284. package/dist/components.d.ts +31 -10
  285. package/dist/components.js +74 -0
  286. package/dist/components.js.map +1 -0
  287. package/dist/computers.d.ts +4 -4
  288. package/dist/computers.js +194 -0
  289. package/dist/computers.js.map +1 -0
  290. package/dist/concealment.d.ts +25 -2
  291. package/dist/concealment.js +409 -0
  292. package/dist/concealment.js.map +1 -0
  293. package/dist/coreComponents.js +130 -0
  294. package/dist/coreComponents.js.map +1 -0
  295. package/dist/createGame.d.ts +306 -0
  296. package/dist/createGame.js +405 -0
  297. package/dist/createGame.js.map +1 -0
  298. package/dist/dashing.d.ts +18 -2
  299. package/dist/dashing.js +41 -0
  300. package/dist/dashing.js.map +1 -0
  301. package/dist/debug.d.ts +8 -0
  302. package/dist/debug.js +5 -3
  303. package/dist/debug2.js +76 -0
  304. package/dist/debug2.js.map +1 -0
  305. package/dist/debugCommands.d.ts +6 -6
  306. package/dist/debugCommands.js +537 -0
  307. package/dist/debugCommands.js.map +1 -0
  308. package/dist/debugging.d.ts +1 -0
  309. package/dist/defaultSets.d.ts +183 -0
  310. package/dist/defaultSets.js +216 -0
  311. package/dist/defaultSets.js.map +1 -0
  312. package/dist/definitions.d.ts +6 -0
  313. package/dist/definitions.js +78 -0
  314. package/dist/definitions.js.map +1 -0
  315. package/dist/defs.d.ts +1895 -165
  316. package/dist/defs.js +380 -0
  317. package/dist/defs.js.map +1 -0
  318. package/dist/denying.d.ts +4 -4
  319. package/dist/denying.js +106 -0
  320. package/dist/denying.js.map +1 -0
  321. package/dist/destructibles.d.ts +2 -2
  322. package/dist/destructibles.js +36 -0
  323. package/dist/destructibles.js.map +1 -0
  324. package/dist/determinism.d.ts +4 -4
  325. package/dist/determinism.js +247 -0
  326. package/dist/determinism.js.map +1 -0
  327. package/dist/dialog.d.ts +17 -2
  328. package/dist/dialog.js +108 -0
  329. package/dist/dialog.js.map +1 -0
  330. package/dist/effectRefs.js +28 -0
  331. package/dist/effectRefs.js.map +1 -0
  332. package/dist/effects.d.ts +27 -11
  333. package/dist/effects.js +110 -0
  334. package/dist/effects.js.map +1 -0
  335. package/dist/endings.d.ts +1 -1
  336. package/dist/endings.js +78 -0
  337. package/dist/endings.js.map +1 -0
  338. package/dist/engagement.d.ts +40 -6
  339. package/dist/engagement.js +530 -0
  340. package/dist/engagement.js.map +1 -0
  341. package/dist/engineEvents.d.ts +72 -9
  342. package/dist/engineEvents.js +520 -0
  343. package/dist/engineEvents.js.map +1 -0
  344. package/dist/entity.d.ts +275 -26
  345. package/dist/entity.js +441 -0
  346. package/dist/entity.js.map +1 -0
  347. package/dist/entityIndex.d.ts +10 -3
  348. package/dist/entityIndex.js +149 -0
  349. package/dist/entityIndex.js.map +1 -0
  350. package/dist/errors.d.ts +6 -2
  351. package/dist/errors.js +59 -0
  352. package/dist/errors.js.map +1 -0
  353. package/dist/events.d.ts +11 -5
  354. package/dist/events.js +158 -0
  355. package/dist/events.js.map +1 -0
  356. package/dist/exactMath.js +273 -0
  357. package/dist/exactMath.js.map +1 -0
  358. package/dist/features.d.ts +1 -1
  359. package/dist/features.js +127 -0
  360. package/dist/features.js.map +1 -0
  361. package/dist/fields.d.ts +25 -5
  362. package/dist/fields.js +140 -0
  363. package/dist/fields.js.map +1 -0
  364. package/dist/fixture.d.ts +3 -3
  365. package/dist/fixture.js +512 -0
  366. package/dist/fixture.js.map +1 -0
  367. package/dist/fog.d.ts +26 -3
  368. package/dist/fog.js +333 -0
  369. package/dist/fog.js.map +1 -0
  370. package/dist/foliage.d.ts +476 -0
  371. package/dist/foliage.js +1478 -0
  372. package/dist/foliage.js.map +1 -0
  373. package/dist/foliageDebug.d.ts +57 -0
  374. package/dist/foliageDebug.js +172 -0
  375. package/dist/foliageDebug.js.map +1 -0
  376. package/dist/foliageRegrowth.d.ts +20 -0
  377. package/dist/foliageRegrowth.js +332 -0
  378. package/dist/foliageRegrowth.js.map +1 -0
  379. package/dist/formState.d.ts +67 -0
  380. package/dist/formState.js +65 -0
  381. package/dist/formState.js.map +1 -0
  382. package/dist/formation.d.ts +46 -8
  383. package/dist/formation.js +297 -0
  384. package/dist/formation.js.map +1 -0
  385. package/dist/forms.d.ts +58 -0
  386. package/dist/forms.js +146 -0
  387. package/dist/forms.js.map +1 -0
  388. package/dist/friendlyFire.d.ts +2 -2
  389. package/dist/friendlyFire.js +37 -0
  390. package/dist/friendlyFire.js.map +1 -0
  391. package/dist/game.d.ts +141 -48
  392. package/dist/game.js +834 -0
  393. package/dist/game.js.map +1 -0
  394. package/dist/gameData.d.ts +96 -22
  395. package/dist/gameData.js +1690 -0
  396. package/dist/gameData.js.map +1 -0
  397. package/dist/gameFiles.d.ts +3 -3
  398. package/dist/gameFiles.js +14 -0
  399. package/dist/gameFiles.js.map +1 -0
  400. package/dist/gates.js +92 -0
  401. package/dist/gates.js.map +1 -0
  402. package/dist/generate.d.ts +28 -1
  403. package/dist/generate.js +1062 -0
  404. package/dist/generate.js.map +1 -0
  405. package/dist/generateWorker.d.ts +7 -3
  406. package/dist/generateWorker.js +86 -0
  407. package/dist/generateWorker.js.map +1 -0
  408. package/dist/grid.d.ts +9 -0
  409. package/dist/grid.js +102 -0
  410. package/dist/grid.js.map +1 -0
  411. package/dist/ground.d.ts +17 -1
  412. package/dist/ground.js +375 -0
  413. package/dist/ground.js.map +1 -0
  414. package/dist/groundObjects.d.ts +70 -0
  415. package/dist/groundObjects.js +371 -0
  416. package/dist/groundObjects.js.map +1 -0
  417. package/dist/groundSpeed.d.ts +20 -3
  418. package/dist/groundSpeed.js +117 -0
  419. package/dist/groundSpeed.js.map +1 -0
  420. package/dist/hero.d.ts +126 -10
  421. package/dist/hero.js +432 -0
  422. package/dist/hero.js.map +1 -0
  423. package/dist/holds.d.ts +94 -0
  424. package/dist/holds.js +305 -0
  425. package/dist/holds.js.map +1 -0
  426. package/dist/home.d.ts +1 -1
  427. package/dist/home.js +30 -0
  428. package/dist/home.js.map +1 -0
  429. package/dist/hooks.d.ts +339 -57
  430. package/dist/hooks.js +105 -0
  431. package/dist/hooks.js.map +1 -0
  432. package/dist/hotReload.d.ts +6 -5
  433. package/dist/hotReload.js +145 -0
  434. package/dist/hotReload.js.map +1 -0
  435. package/dist/ids.d.ts +3 -3
  436. package/dist/ids.js +30 -0
  437. package/dist/ids.js.map +1 -0
  438. package/dist/idsFile.d.ts +36 -0
  439. package/dist/idsFile.js +134 -0
  440. package/dist/idsFile.js.map +1 -0
  441. package/dist/index.d.ts +105 -68
  442. package/dist/index.js +194 -4701
  443. package/dist/inspect.d.ts +29 -2
  444. package/dist/{inspect-D9dWHmZ0.js → inspect.js} +21 -12
  445. package/dist/inspect.js.map +1 -0
  446. package/dist/inventory.d.ts +14 -1
  447. package/dist/inventory.js +84 -0
  448. package/dist/inventory.js.map +1 -0
  449. package/dist/items.d.ts +136 -8
  450. package/dist/items.js +585 -0
  451. package/dist/items.js.map +1 -0
  452. package/dist/lanes.d.ts +12 -3
  453. package/dist/lanes.js +496 -0
  454. package/dist/lanes.js.map +1 -0
  455. package/dist/life.d.ts +6 -2
  456. package/dist/life.js +287 -0
  457. package/dist/life.js.map +1 -0
  458. package/dist/log.d.ts +26 -3
  459. package/dist/log.js +192 -0
  460. package/dist/log.js.map +1 -0
  461. package/dist/manaBurn.d.ts +2 -2
  462. package/dist/manaBurn.js +75 -0
  463. package/dist/manaBurn.js.map +1 -0
  464. package/dist/map/file.d.ts +56 -3
  465. package/dist/map/file.js +264 -0
  466. package/dist/map/file.js.map +1 -0
  467. package/dist/map/images.js +61 -0
  468. package/dist/map/images.js.map +1 -0
  469. package/dist/map/look.d.ts +1 -1
  470. package/dist/map/look.js +30 -0
  471. package/dist/map/look.js.map +1 -0
  472. package/dist/map/pathProfile.js +183 -0
  473. package/dist/map/pathProfile.js.map +1 -0
  474. package/dist/map/resize.d.ts +4 -0
  475. package/dist/map/resize.js +136 -0
  476. package/dist/map/resize.js.map +1 -0
  477. package/dist/map/schema.js +257 -0
  478. package/dist/map/schema.js.map +1 -0
  479. package/dist/map/terrain.js +214 -0
  480. package/dist/map/terrain.js.map +1 -0
  481. package/dist/map/types.d.ts +92 -13
  482. package/dist/map/types.js +251 -0
  483. package/dist/map/types.js.map +1 -0
  484. package/dist/mapCheck/cells.js +94 -0
  485. package/dist/mapCheck/cells.js.map +1 -0
  486. package/dist/mapCheck/rules/foliage.d.ts +9 -0
  487. package/dist/mapCheck/rules/foliage.js +83 -0
  488. package/dist/mapCheck/rules/foliage.js.map +1 -0
  489. package/dist/mapCheck/rules/names.js +39 -0
  490. package/dist/mapCheck/rules/names.js.map +1 -0
  491. package/dist/mapCheck/rules/objects.d.ts +1 -1
  492. package/dist/mapCheck/rules/objects.js +56 -0
  493. package/dist/mapCheck/rules/objects.js.map +1 -0
  494. package/dist/mapCheck/rules/paths.js +32 -0
  495. package/dist/mapCheck/rules/paths.js.map +1 -0
  496. package/dist/mapCheck/rules/players.js +20 -0
  497. package/dist/mapCheck/rules/players.js.map +1 -0
  498. package/dist/mapCheck/rules/races.js +56 -0
  499. package/dist/mapCheck/rules/races.js.map +1 -0
  500. package/dist/mapCheck/rules/random.js +47 -0
  501. package/dist/mapCheck/rules/random.js.map +1 -0
  502. package/dist/mapCheck/rules/regions.js +30 -0
  503. package/dist/mapCheck/rules/regions.js.map +1 -0
  504. package/dist/mapCheck/rules/targets.js +31 -0
  505. package/dist/mapCheck/rules/targets.js.map +1 -0
  506. package/dist/mapCheck/rules/walking.js +45 -0
  507. package/dist/mapCheck/rules/walking.js.map +1 -0
  508. package/dist/mapCheck.d.ts +2 -2
  509. package/dist/mapCheck.js +63 -0
  510. package/dist/mapCheck.js.map +1 -0
  511. package/dist/mapFields.d.ts +25 -2
  512. package/dist/mapFields.js +134 -0
  513. package/dist/mapFields.js.map +1 -0
  514. package/dist/mapFile.js +176 -0
  515. package/dist/mapFile.js.map +1 -0
  516. package/dist/mapMeasure.d.ts +8 -0
  517. package/dist/mapMeasure.js +283 -0
  518. package/dist/mapMeasure.js.map +1 -0
  519. package/dist/mapMerge.d.ts +1 -0
  520. package/dist/mapMerge.js +172 -0
  521. package/dist/mapMerge.js.map +1 -0
  522. package/dist/mapObjectives.js +138 -0
  523. package/dist/mapObjectives.js.map +1 -0
  524. package/dist/mapObjects.js +80 -0
  525. package/dist/mapObjects.js.map +1 -0
  526. package/dist/math.d.ts +37 -7
  527. package/dist/math.js +155 -0
  528. package/dist/math.js.map +1 -0
  529. package/dist/messages.d.ts +71 -4
  530. package/dist/messages.js +29 -0
  531. package/dist/messages.js.map +1 -0
  532. package/dist/missionRules.d.ts +10 -2
  533. package/dist/{missionRules-C-bGxm0Q.js → missionRules.js} +30 -150
  534. package/dist/missionRules.js.map +1 -0
  535. package/dist/mods.d.ts +39 -20
  536. package/dist/mods.js +271 -0
  537. package/dist/mods.js.map +1 -0
  538. package/dist/moves.d.ts +87 -0
  539. package/dist/moves.js +539 -0
  540. package/dist/moves.js.map +1 -0
  541. package/dist/names.d.ts +7 -0
  542. package/dist/names.js +122 -0
  543. package/dist/names.js.map +1 -0
  544. package/dist/navigation/agentParams.js +14 -0
  545. package/dist/navigation/agentParams.js.map +1 -0
  546. package/dist/navigation/air.d.ts +7 -3
  547. package/dist/navigation/air.js +401 -0
  548. package/dist/navigation/air.js.map +1 -0
  549. package/dist/navigation/builds.d.ts +34 -2
  550. package/dist/navigation/builds.js +287 -0
  551. package/dist/navigation/builds.js.map +1 -0
  552. package/dist/navigation/groundAreas.d.ts +59 -1
  553. package/dist/navigation/groundAreas.js +407 -0
  554. package/dist/navigation/groundAreas.js.map +1 -0
  555. package/dist/navigation/navigation.d.ts +98 -9
  556. package/dist/navigation/recast.d.ts +194 -18
  557. package/dist/navigation/recast.js +1379 -0
  558. package/dist/navigation/recast.js.map +1 -0
  559. package/dist/navigation/sidePaths.d.ts +8 -3
  560. package/dist/navigation/sidePaths.js +241 -0
  561. package/dist/navigation/sidePaths.js.map +1 -0
  562. package/dist/navigation/sized.js +243 -0
  563. package/dist/navigation/sized.js.map +1 -0
  564. package/dist/nearest.js +32 -0
  565. package/dist/nearest.js.map +1 -0
  566. package/dist/noise.js +59 -0
  567. package/dist/noise.js.map +1 -0
  568. package/dist/objectives.d.ts +12 -3
  569. package/dist/objectives.js +144 -0
  570. package/dist/objectives.js.map +1 -0
  571. package/dist/orders/basic.d.ts +5 -5
  572. package/dist/orders/basic.js +417 -0
  573. package/dist/orders/basic.js.map +1 -0
  574. package/dist/orders/build.js +278 -0
  575. package/dist/orders/build.js.map +1 -0
  576. package/dist/orders/cast.d.ts +13 -3
  577. package/dist/orders/cast.js +558 -0
  578. package/dist/orders/cast.js.map +1 -0
  579. package/dist/orders/facts.js +16 -0
  580. package/dist/orders/facts.js.map +1 -0
  581. package/dist/orders/harvest.d.ts +21 -5
  582. package/dist/orders/harvest.js +540 -0
  583. package/dist/orders/harvest.js.map +1 -0
  584. package/dist/orders/idle.d.ts +3 -1
  585. package/dist/orders/idle.js +234 -0
  586. package/dist/orders/idle.js.map +1 -0
  587. package/dist/orders/items.js +92 -0
  588. package/dist/orders/items.js.map +1 -0
  589. package/dist/orders/queue.js +108 -0
  590. package/dist/orders/queue.js.map +1 -0
  591. package/dist/orders/waiting.d.ts +39 -0
  592. package/dist/orders/waiting.js +149 -0
  593. package/dist/orders/waiting.js.map +1 -0
  594. package/dist/pack.schema.js +13 -0
  595. package/dist/pack.schema.js.map +1 -0
  596. package/dist/pack.schema.json +7622 -841
  597. package/dist/packs/director/index.d.ts +13 -5
  598. package/dist/packs/director/index.js +204 -0
  599. package/dist/packs/director/index.js.map +1 -0
  600. package/dist/packs/heroes/campaign.d.ts +3 -2
  601. package/dist/packs/heroes/campaign.js +241 -0
  602. package/dist/packs/heroes/campaign.js.map +1 -0
  603. package/dist/packs/heroes/carry.d.ts +6 -0
  604. package/dist/packs/heroes/carry.js +112 -0
  605. package/dist/packs/heroes/carry.js.map +1 -0
  606. package/dist/packs/heroes/commands.js +115 -0
  607. package/dist/packs/heroes/commands.js.map +1 -0
  608. package/dist/packs/heroes/fallen.d.ts +43 -0
  609. package/dist/packs/heroes/fallen.js +61 -0
  610. package/dist/packs/heroes/fallen.js.map +1 -0
  611. package/dist/packs/heroes/hire.js +60 -0
  612. package/dist/packs/heroes/hire.js.map +1 -0
  613. package/dist/packs/heroes/index.d.ts +7 -6
  614. package/dist/packs/heroes/index.js +130 -0
  615. package/dist/packs/heroes/index.js.map +1 -0
  616. package/dist/packs/heroes/loop.d.ts +95 -0
  617. package/dist/packs/heroes/loop.js +250 -0
  618. package/dist/packs/heroes/loop.js.map +1 -0
  619. package/dist/packs/heroes/making.d.ts +6 -3
  620. package/dist/packs/heroes/making.js +55 -0
  621. package/dist/packs/heroes/making.js.map +1 -0
  622. package/dist/packs/heroes/respawn.d.ts +3 -3
  623. package/dist/packs/heroes/respawn.js +87 -0
  624. package/dist/packs/heroes/respawn.js.map +1 -0
  625. package/dist/packs/heroes/sets.d.ts +32 -0
  626. package/dist/packs/heroes/sets.js +51 -0
  627. package/dist/packs/heroes/sets.js.map +1 -0
  628. package/dist/packs/heroes/spells.d.ts +16 -0
  629. package/dist/packs/heroes/spells.js +269 -0
  630. package/dist/packs/heroes/spells.js.map +1 -0
  631. package/dist/packs/items/defaults.d.ts +43 -0
  632. package/dist/packs/items/defaults.js +1504 -0
  633. package/dist/packs/items/defaults.js.map +1 -0
  634. package/dist/packs/items/index.d.ts +27 -0
  635. package/dist/packs/items/index.js +214 -0
  636. package/dist/packs/items/index.js.map +1 -0
  637. package/dist/packs/moba/index.d.ts +3 -3
  638. package/dist/packs/moba/index.js +174 -0
  639. package/dist/packs/moba/index.js.map +1 -0
  640. package/dist/packs/pack.d.ts +15 -15
  641. package/dist/packs/pack.js +14 -0
  642. package/dist/packs/pack.js.map +1 -0
  643. package/dist/packs.d.ts +15 -7
  644. package/dist/packs.js +222 -0
  645. package/dist/packs.js.map +1 -0
  646. package/dist/paths.d.ts +2 -0
  647. package/dist/paths.js +109 -0
  648. package/dist/paths.js.map +1 -0
  649. package/dist/plain.js +57 -0
  650. package/dist/plain.js.map +1 -0
  651. package/dist/player.d.ts +33 -10
  652. package/dist/player.js +159 -0
  653. package/dist/player.js.map +1 -0
  654. package/dist/portals.d.ts +1 -1
  655. package/dist/portals.js +194 -0
  656. package/dist/portals.js.map +1 -0
  657. package/dist/prefabs.d.ts +25 -2
  658. package/dist/prefabs.js +239 -0
  659. package/dist/prefabs.js.map +1 -0
  660. package/dist/presetBuildings.js +58 -0
  661. package/dist/presetBuildings.js.map +1 -0
  662. package/dist/presetFoliage.d.ts +27 -0
  663. package/dist/presetFoliage.js +98 -0
  664. package/dist/presetFoliage.js.map +1 -0
  665. package/dist/presetGround.js +65 -0
  666. package/dist/presetGround.js.map +1 -0
  667. package/dist/proxies.d.ts +12 -0
  668. package/dist/proxies.js +79 -0
  669. package/dist/proxies.js.map +1 -0
  670. package/dist/query.d.ts +56 -0
  671. package/dist/query.js +88 -0
  672. package/dist/query.js.map +1 -0
  673. package/dist/races.d.ts +15 -14
  674. package/dist/races.js +172 -0
  675. package/dist/races.js.map +1 -0
  676. package/dist/randomGroups.js +91 -0
  677. package/dist/randomGroups.js.map +1 -0
  678. package/dist/registry.d.ts +117 -53
  679. package/dist/registry.js +323 -0
  680. package/dist/registry.js.map +1 -0
  681. package/dist/remains.d.ts +11 -9
  682. package/dist/remains.js +188 -0
  683. package/dist/remains.js.map +1 -0
  684. package/dist/replication.d.ts +12 -7
  685. package/dist/replication.js +100 -0
  686. package/dist/replication.js.map +1 -0
  687. package/dist/rng.d.ts +2 -0
  688. package/dist/rng.js +40 -0
  689. package/dist/rng.js.map +1 -0
  690. package/dist/rules.d.ts +186 -99
  691. package/dist/rules.js +179 -0
  692. package/dist/rules.js.map +1 -0
  693. package/dist/rulesCheck.d.ts +5 -4
  694. package/dist/rulesCheck.js +693 -0
  695. package/dist/rulesCheck.js.map +1 -0
  696. package/dist/runes.d.ts +2 -2
  697. package/dist/runes.js +80 -0
  698. package/dist/runes.js.map +1 -0
  699. package/dist/save.d.ts +37 -12
  700. package/dist/save.js +532 -0
  701. package/dist/save.js.map +1 -0
  702. package/dist/scenario.d.ts +2 -2
  703. package/dist/scenario.js +99 -0
  704. package/dist/scenario.js.map +1 -0
  705. package/dist/scheduler.d.ts +3 -0
  706. package/dist/scheduler.js +156 -0
  707. package/dist/scheduler.js.map +1 -0
  708. package/dist/score.d.ts +19 -19
  709. package/dist/score.js +709 -0
  710. package/dist/score.js.map +1 -0
  711. package/dist/sequences.d.ts +10 -6
  712. package/dist/sequences.js +206 -0
  713. package/dist/sequences.js.map +1 -0
  714. package/dist/server/doorman.js +154 -0
  715. package/dist/server/doorman.js.map +1 -0
  716. package/dist/server/gameServer.d.ts +16 -1
  717. package/dist/server/gameServer.js +643 -0
  718. package/dist/server/gameServer.js.map +1 -0
  719. package/dist/server/index.d.ts +1 -1
  720. package/dist/server/lobby.js +199 -0
  721. package/dist/server/lobby.js.map +1 -0
  722. package/dist/server/log.js +18 -0
  723. package/dist/server/log.js.map +1 -0
  724. package/dist/server/match.js +267 -0
  725. package/dist/server/match.js.map +1 -0
  726. package/dist/server/mode.d.ts +18 -9
  727. package/dist/server/mode.js +220 -0
  728. package/dist/server/mode.js.map +1 -0
  729. package/dist/{navigation-worker.js → server/navigation-worker.js} +1 -1
  730. package/dist/server/navigation-worker.js.map +1 -0
  731. package/dist/server/navigation.js +39 -0
  732. package/dist/server/navigation.js.map +1 -0
  733. package/dist/server/ops.d.ts +4 -0
  734. package/dist/server/ops.js +137 -0
  735. package/dist/server/ops.js.map +1 -0
  736. package/dist/server/packs.d.ts +3 -3
  737. package/dist/server/packs.js +32 -0
  738. package/dist/server/packs.js.map +1 -0
  739. package/dist/server/ratings.d.ts +5 -0
  740. package/dist/server/ratings.js +104 -0
  741. package/dist/server/ratings.js.map +1 -0
  742. package/dist/server/relay.d.ts +12 -2
  743. package/dist/server/relay.js +144 -0
  744. package/dist/server/relay.js.map +1 -0
  745. package/dist/server/rooms.d.ts +9 -2
  746. package/dist/server/rooms.js +442 -0
  747. package/dist/server/rooms.js.map +1 -0
  748. package/dist/server/seat.js +116 -0
  749. package/dist/server/seat.js.map +1 -0
  750. package/dist/server/seatSettings.d.ts +3 -3
  751. package/dist/server/seatSettings.js +63 -0
  752. package/dist/server/seatSettings.js.map +1 -0
  753. package/dist/server/secret.js +13 -0
  754. package/dist/server/secret.js.map +1 -0
  755. package/dist/server/start.d.ts +13 -6
  756. package/dist/server/start.js +76 -0
  757. package/dist/server/start.js.map +1 -0
  758. package/dist/server/websocket.d.ts +9 -1
  759. package/dist/server/websocket.js +306 -0
  760. package/dist/server/websocket.js.map +1 -0
  761. package/dist/server.js +15 -2861
  762. package/dist/session/can.js +26 -0
  763. package/dist/session/can.js.map +1 -0
  764. package/dist/session/commandReplay.d.ts +8 -2
  765. package/dist/session/commandReplay.js +293 -0
  766. package/dist/session/commandReplay.js.map +1 -0
  767. package/dist/session/debug.js +151 -0
  768. package/dist/session/debug.js.map +1 -0
  769. package/dist/session/delay.js +62 -0
  770. package/dist/session/delay.js.map +1 -0
  771. package/dist/session/delta.d.ts +14 -1
  772. package/dist/session/delta.js +407 -0
  773. package/dist/session/delta.js.map +1 -0
  774. package/dist/session/entityState.js +415 -0
  775. package/dist/session/entityState.js.map +1 -0
  776. package/dist/session/local.d.ts +47 -5
  777. package/dist/session/local.js +670 -0
  778. package/dist/session/local.js.map +1 -0
  779. package/dist/session/memory.d.ts +20 -2
  780. package/dist/session/memory.js +131 -0
  781. package/dist/session/memory.js.map +1 -0
  782. package/dist/session/protocol.d.ts +325 -31
  783. package/dist/session/protocol.js +55 -0
  784. package/dist/session/protocol.js.map +1 -0
  785. package/dist/session/remote.d.ts +74 -12
  786. package/dist/session/remote.js +1394 -0
  787. package/dist/session/remote.js.map +1 -0
  788. package/dist/session/replay.d.ts +11 -2
  789. package/dist/session/replay.js +160 -0
  790. package/dist/session/replay.js.map +1 -0
  791. package/dist/session/seed.js +12 -0
  792. package/dist/session/seed.js.map +1 -0
  793. package/dist/session/share.d.ts +5 -1
  794. package/dist/session/share.js +94 -0
  795. package/dist/session/share.js.map +1 -0
  796. package/dist/session/socket.d.ts +1 -1
  797. package/dist/session/socket.js +29 -0
  798. package/dist/session/socket.js.map +1 -0
  799. package/dist/session/wire.d.ts +5 -0
  800. package/dist/session/wire.js +84 -0
  801. package/dist/session/wire.js.map +1 -0
  802. package/dist/session/worker.d.ts +77 -12
  803. package/dist/session/worker.js +499 -0
  804. package/dist/session/worker.js.map +1 -0
  805. package/dist/shared.d.ts +31 -5
  806. package/dist/shared.js +166 -0
  807. package/dist/shared.js.map +1 -0
  808. package/dist/sides.d.ts +9 -3
  809. package/dist/sides.js +149 -0
  810. package/dist/sides.js.map +1 -0
  811. package/dist/sight.js +85 -0
  812. package/dist/sight.js.map +1 -0
  813. package/dist/simulate-worker.js +1 -1
  814. package/dist/simulate.d.ts +12 -8
  815. package/dist/{simulate-oXBiw1Ff.js → simulate.js} +10 -11
  816. package/dist/simulate.js.map +1 -0
  817. package/dist/smart.js +77 -0
  818. package/dist/smart.js.map +1 -0
  819. package/dist/spatial.d.ts +32 -16
  820. package/dist/spatial.js +234 -0
  821. package/dist/spatial.js.map +1 -0
  822. package/dist/spawning.d.ts +1 -0
  823. package/dist/spawning.js +224 -0
  824. package/dist/spawning.js.map +1 -0
  825. package/dist/stances.d.ts +6 -3
  826. package/dist/stances.js +169 -0
  827. package/dist/stances.js.map +1 -0
  828. package/dist/start.d.ts +10 -10
  829. package/dist/start.js +75 -0
  830. package/dist/start.js.map +1 -0
  831. package/dist/stats.d.ts +42 -16
  832. package/dist/stats.js +290 -0
  833. package/dist/stats.js.map +1 -0
  834. package/dist/summoned.d.ts +52 -0
  835. package/dist/summoned.js +38 -0
  836. package/dist/summoned.js.map +1 -0
  837. package/dist/summons.d.ts +10 -13
  838. package/dist/summons.js +271 -0
  839. package/dist/summons.js.map +1 -0
  840. package/dist/systems/abilities.js +224 -0
  841. package/dist/systems/abilities.js.map +1 -0
  842. package/dist/systems/combat.d.ts +35 -1
  843. package/dist/systems/combat.js +677 -0
  844. package/dist/systems/combat.js.map +1 -0
  845. package/dist/systems/combatTold.d.ts +3 -1
  846. package/dist/systems/combatTold.js +85 -0
  847. package/dist/systems/combatTold.js.map +1 -0
  848. package/dist/systems/construction.js +80 -0
  849. package/dist/systems/construction.js.map +1 -0
  850. package/dist/systems/economy.d.ts +0 -6
  851. package/dist/systems/economy.js +128 -0
  852. package/dist/systems/economy.js.map +1 -0
  853. package/dist/systems/fog.d.ts +1 -1
  854. package/dist/systems/fog.js +120 -0
  855. package/dist/systems/fog.js.map +1 -0
  856. package/dist/systems/life.js +32 -0
  857. package/dist/systems/life.js.map +1 -0
  858. package/dist/systems/movement.d.ts +24 -12
  859. package/dist/systems/movement.js +1247 -0
  860. package/dist/systems/movement.js.map +1 -0
  861. package/dist/systems/orders.js +64 -0
  862. package/dist/systems/orders.js.map +1 -0
  863. package/dist/systems/production.js +322 -0
  864. package/dist/systems/production.js.map +1 -0
  865. package/dist/systems/productionQueue.js +120 -0
  866. package/dist/systems/productionQueue.js.map +1 -0
  867. package/dist/systems/victory.d.ts +1 -1
  868. package/dist/systems/victory.js +56 -0
  869. package/dist/systems/victory.js.map +1 -0
  870. package/dist/talk.d.ts +6 -6
  871. package/dist/talk.js +153 -0
  872. package/dist/talk.js.map +1 -0
  873. package/dist/targeting.d.ts +142 -0
  874. package/dist/targeting.js +49 -0
  875. package/dist/targeting.js.map +1 -0
  876. package/dist/tech.d.ts +20 -3
  877. package/dist/tech.js +239 -0
  878. package/dist/tech.js.map +1 -0
  879. package/dist/techTree.d.ts +7 -0
  880. package/dist/techTree.js +90 -0
  881. package/dist/techTree.js.map +1 -0
  882. package/dist/terrain.d.ts +59 -7
  883. package/dist/terrain.js +389 -0
  884. package/dist/terrain.js.map +1 -0
  885. package/dist/terrainSave.d.ts +6 -0
  886. package/dist/terrainSave.js +74 -0
  887. package/dist/terrainSave.js.map +1 -0
  888. package/dist/testing.d.ts +8 -7
  889. package/dist/testing.js +13 -739
  890. package/dist/testing.js.map +1 -1
  891. package/dist/tiles.d.ts +1 -1
  892. package/dist/tiles.js +43 -0
  893. package/dist/tiles.js.map +1 -0
  894. package/dist/timers.d.ts +29 -4
  895. package/dist/timers.js +242 -0
  896. package/dist/timers.js.map +1 -0
  897. package/dist/tomes.d.ts +4 -4
  898. package/dist/tomes.js +94 -0
  899. package/dist/tomes.js.map +1 -0
  900. package/dist/trade.js +103 -0
  901. package/dist/trade.js.map +1 -0
  902. package/dist/transport.d.ts +6 -1
  903. package/dist/transport.js +281 -0
  904. package/dist/transport.js.map +1 -0
  905. package/dist/tunables.d.ts +10 -3
  906. package/dist/tunables.js +56 -0
  907. package/dist/tunables.js.map +1 -0
  908. package/dist/unitResources.d.ts +67 -0
  909. package/dist/unitResources.js +266 -0
  910. package/dist/unitResources.js.map +1 -0
  911. package/dist/upkeep.d.ts +6 -1
  912. package/dist/upkeep.js +26 -0
  913. package/dist/upkeep.js.map +1 -0
  914. package/dist/veterancy.d.ts +8 -3
  915. package/dist/veterancy.js +131 -0
  916. package/dist/veterancy.js.map +1 -0
  917. package/dist/vision.d.ts +36 -0
  918. package/dist/vision.js +133 -0
  919. package/dist/vision.js.map +1 -0
  920. package/dist/walls.d.ts +1 -1
  921. package/dist/walls.js +278 -0
  922. package/dist/walls.js.map +1 -0
  923. package/dist/world.d.ts +606 -88
  924. package/dist/world.js +1263 -0
  925. package/dist/world.js.map +1 -0
  926. package/package.json +2 -2
  927. package/dist/ai.js.map +0 -1
  928. package/dist/attributes.d.ts +0 -66
  929. package/dist/brain-BvVdUhX8.js +0 -7659
  930. package/dist/brain-BvVdUhX8.js.map +0 -1
  931. package/dist/builds-C6LfgvEU.js +0 -460
  932. package/dist/builds-C6LfgvEU.js.map +0 -1
  933. package/dist/coreComponents-syuh2fPG.js +0 -5149
  934. package/dist/coreComponents-syuh2fPG.js.map +0 -1
  935. package/dist/debugCommands-CzjrSm66.js +0 -14739
  936. package/dist/debugCommands-CzjrSm66.js.map +0 -1
  937. package/dist/determinism-BCymQwiE.js +0 -518
  938. package/dist/determinism-BCymQwiE.js.map +0 -1
  939. package/dist/game-DiJEN-Ks.js +0 -5800
  940. package/dist/game-DiJEN-Ks.js.map +0 -1
  941. package/dist/index.js.map +0 -1
  942. package/dist/inspect-D9dWHmZ0.js.map +0 -1
  943. package/dist/local-Dkovq42k.js +0 -1379
  944. package/dist/local-Dkovq42k.js.map +0 -1
  945. package/dist/missionRules-C-bGxm0Q.js.map +0 -1
  946. package/dist/navigation-worker.js.map +0 -1
  947. package/dist/packs-g5thvmGn.js +0 -3199
  948. package/dist/packs-g5thvmGn.js.map +0 -1
  949. package/dist/profiles-B3NS9jwk.js.map +0 -1
  950. package/dist/server.js.map +0 -1
  951. package/dist/simulate-oXBiw1Ff.js.map +0 -1
package/dist/items.js ADDED
@@ -0,0 +1,585 @@
1
+ import { dist } from "./math.js";
2
+ import { defineComponent } from "./components.js";
3
+ import { freeSlot, inventorySlots, slotsOf } from "./inventory.js";
4
+ import { refreshVitals } from "./stats.js";
5
+ import { inventoryChanged as inventoryChanged$1, itemDropped, itemPicked, itemUndone } from "./engineEvents.js";
6
+ import { replicateEvent, snapshotField } from "./replication.js";
7
+ import { currencyOf, earn, giveBack, shortOf, spend } from "./player.js";
8
+ import { engineMessage, toMessage } from "./messages.js";
9
+ import { sellValue } from "./shared.js";
10
+ //#region src/items.ts
11
+ /**
12
+ * A hero has to stand this close to a shop to buy from it
13
+ *
14
+ * @internal
15
+ */
16
+ var SHOP_RANGE = 6;
17
+ /**
18
+ * And this close to something on the ground to pick it up, or to someone to hand it over
19
+ *
20
+ * @internal
21
+ */
22
+ var REACH = 1.2;
23
+ /**
24
+ * Makes an instance of an item type with an id of its own, with the charges given or those of the type (0 when it has none)
25
+ *
26
+ * @beta
27
+ */
28
+ function createItem(world, item, charges) {
29
+ const def = world.registry.item(item);
30
+ return {
31
+ id: world.newId(),
32
+ item,
33
+ charges: charges ?? def.charges ?? 0,
34
+ state: def.ability ? {
35
+ id: def.ability,
36
+ level: 1,
37
+ cooldown: 0,
38
+ autocast: false
39
+ } : void 0
40
+ };
41
+ }
42
+ /** Call after the inventory changed: what is carried changes what the carrier can do, and the game is told */
43
+ function inventoryChanged(world, entity) {
44
+ refreshVitals(world, entity);
45
+ world.events.emit(inventoryChanged$1, { entity });
46
+ }
47
+ /**
48
+ * The tier of an item, `epic` (the old word) read as `intermediate`: what the registry keeps of it (`ItemTier`)
49
+ *
50
+ * @beta
51
+ */
52
+ function itemTier(def) {
53
+ return def.tier === "epic" ? "intermediate" : def.tier;
54
+ }
55
+ /**
56
+ * The items of the game with a tag (`ItemDef.tags`), in the game's order: `itemsTagged(registry, 'lifesteal')`
57
+ *
58
+ * @beta
59
+ */
60
+ function itemsTagged(registry, tag) {
61
+ const wanted = tag.toLowerCase();
62
+ return registry.items.all().filter((def) => def.tags?.some((each) => each.toLowerCase() === wanted));
63
+ }
64
+ /**
65
+ * The most of an item's group one carrier may have (`ItemDef.group`): the item's own limit, the game's of the group
66
+ * (`ItemSettings.groups`), or 1. No limit for an item of no group
67
+ *
68
+ * @beta
69
+ */
70
+ function groupLimitOf(world, def) {
71
+ if (def.group === void 0) return Infinity;
72
+ return def.groupLimit ?? world.settings.items.groups[def.group] ?? 1;
73
+ }
74
+ /** The slot of a carried one of the item that another of it (with these charges) goes into: a stack with room. -1 for none */
75
+ function stackSlot(world, entity, item, charges) {
76
+ const def = world.registry.item(item);
77
+ if (!def.stack || def.stack < 2) return -1;
78
+ const most = def.stack * Math.max(def.charges ?? 1, 1);
79
+ return slotsOf(entity)?.findIndex((carried) => carried?.item === item && carried.charges + charges <= most) ?? -1;
80
+ }
81
+ /**
82
+ * Whether the entity has room for an item: a free slot, or a stack of it with room (`ItemDef.stack`)
83
+ *
84
+ * @beta
85
+ */
86
+ function hasRoomFor(world, entity, item, charges = world.registry.item(item).charges ?? 0) {
87
+ return freeSlot(entity) >= 0 || stackSlot(world, entity, item, charges) >= 0;
88
+ }
89
+ /**
90
+ * Why a carrier may not take an item, or nothing when it may: one more of its group than it may carry (`ItemDef.group`),
91
+ * or what the game's own rule says (`ItemSettings.mayCarry`). `uses`, the parts buying it uses up, by id: they go out as
92
+ * it comes in. `handed`: it is handed over, and the words say "they". Asked as an item is bought, picked up or handed
93
+ * over; room in the inventory is asked apart (`hasRoomFor`)
94
+ *
95
+ * @beta
96
+ */
97
+ function carryRefusal(world, carrier, item, uses = [], handed = false) {
98
+ const refused = groupRefusal(world.registry, carriedBy(carrier), item, uses, handed);
99
+ if (refused) return refused;
100
+ const own = world.settings.items.mayCarry?.(world, carrier, world.registry.item(item), uses);
101
+ return own === void 0 ? void 0 : toMessage(own);
102
+ }
103
+ /**
104
+ * Why one who carries these items (by id) may not take one more of an item's group (`ItemDef.group`), or nothing when
105
+ * it may: the engine's part of `carryRefusal`, which a screen asks too, with the game's registry alone, to say so before
106
+ * the buy (the shop window). `uses` are the parts buying it uses up: they go out as it comes in, so they are not
107
+ * counted. The limit is the item's own, the game's of the group (`ItemSettings.groups`), or 1
108
+ *
109
+ * @beta
110
+ */
111
+ function groupRefusal(registry, carried, item, uses = [], handed = false) {
112
+ const def = registry.items.find(item);
113
+ if (!def || def.group === void 0) return void 0;
114
+ const limit = def.groupLimit ?? registry.settings.items.groups[def.group] ?? 1;
115
+ const going = [...uses];
116
+ let count = 0;
117
+ for (const other of carried) {
118
+ const index = going.indexOf(other);
119
+ if (index >= 0) {
120
+ going.splice(index, 1);
121
+ continue;
122
+ }
123
+ if (registry.items.find(other)?.group === def.group) count++;
124
+ }
125
+ return count + 1 > limit ? engineMessage(handed ? "theirGroupLimit" : "groupLimit", {
126
+ item,
127
+ group: def.group,
128
+ limit
129
+ }) : void 0;
130
+ }
131
+ /**
132
+ * Puts an item into the inventory: into a stack of it with room (`ItemDef.stack`, its charges added), or the first free
133
+ * slot. False when there is neither. The engine's rules of what may be carried are asked before (`carryRefusal`)
134
+ *
135
+ * @beta
136
+ */
137
+ function giveItem(world, entity, instance) {
138
+ const slots = slotsOf(entity);
139
+ if (!slots) return false;
140
+ const stack = world.registry.items.has(instance.item) ? stackSlot(world, entity, instance.item, instance.charges) : -1;
141
+ if (stack >= 0) {
142
+ slots[stack].charges += instance.charges;
143
+ inventoryChanged(world, entity);
144
+ return true;
145
+ }
146
+ const slot = freeSlot(entity);
147
+ if (slot < 0) return false;
148
+ slots[slot] = instance;
149
+ inventoryChanged(world, entity);
150
+ return true;
151
+ }
152
+ /**
153
+ * Takes the item instance with this id out of the entity's inventory and returns it; undefined when it does not carry it
154
+ *
155
+ * @beta
156
+ */
157
+ function takeItem(world, entity, instanceId) {
158
+ const slots = slotsOf(entity);
159
+ const slot = slots?.findIndex((instance) => instance?.id === instanceId) ?? -1;
160
+ if (slot < 0) return void 0;
161
+ const instance = slots[slot];
162
+ slots[slot] = null;
163
+ inventoryChanged(world, entity);
164
+ return instance;
165
+ }
166
+ /**
167
+ * Finds the item instance with this id in the entity's inventory; undefined when it is not there or no id is given
168
+ *
169
+ * @beta
170
+ */
171
+ function findItem(entity, instanceId) {
172
+ return slotsOf(entity)?.find((instance) => instance?.id === instanceId) ?? void 0;
173
+ }
174
+ /**
175
+ * Puts the item on the ground at the closest walkable point to `at`, tells the game (`itemDropped`) and returns the ground item
176
+ *
177
+ * @beta
178
+ */
179
+ function dropOnGround(world, instance, at) {
180
+ const point = world.nav.closestPoint(at, 6) ?? at;
181
+ const item = {
182
+ id: instance.id,
183
+ item: instance.item,
184
+ charges: instance.charges,
185
+ x: point.x,
186
+ z: point.z
187
+ };
188
+ world.items.push(item);
189
+ world.events.emit(itemDropped, item);
190
+ return item;
191
+ }
192
+ /**
193
+ * Has the entity pick up the item lying on the ground by its id; returns false when none is there, no slot is free or `beforePickUp` refuses
194
+ *
195
+ * @beta
196
+ */
197
+ function pickUp(world, entity, groundId) {
198
+ const index = world.items.findIndex((item) => item.id === groundId);
199
+ if (index < 0 || !hasRoomFor(world, entity, world.items[index].item, world.items[index].charges)) return false;
200
+ const refused = carryRefusal(world, entity, world.items[index].item);
201
+ if (refused) {
202
+ world.message(entity.owner, refused);
203
+ return false;
204
+ }
205
+ if (world.hooks.has("beforePickUp")) {
206
+ const before = world.hooks.run("beforePickUp", {
207
+ entity,
208
+ item: world.items[index].item,
209
+ ground: groundId,
210
+ cancelled: false
211
+ });
212
+ if (before.cancelled) {
213
+ if (before.reason) world.message(entity.owner, before.reason);
214
+ return false;
215
+ }
216
+ }
217
+ const [item] = world.items.splice(index, 1);
218
+ const instance = createItem(world, item.item, item.charges);
219
+ instance.id = item.id;
220
+ giveItem(world, entity, instance);
221
+ world.events.emit(itemPicked, {
222
+ entity,
223
+ item: instance
224
+ });
225
+ return true;
226
+ }
227
+ /**
228
+ * One use of an item that has charges. The last one takes the item with it
229
+ *
230
+ * @beta
231
+ */
232
+ function spendCharge(world, entity, instance) {
233
+ const def = world.registry.item(instance.item);
234
+ if (!def.charges) return;
235
+ instance.charges--;
236
+ if (instance.charges <= 0 && !def.refill) takeItem(world, entity, instance.id);
237
+ }
238
+ /**
239
+ * The charges of what an entity carries coming back (`ItemDef.refill`): every one while it stands at a shop it may
240
+ * trade with, one every so many seconds wherever it is. Run by the abilities system every tick
241
+ *
242
+ * @internal
243
+ */
244
+ function refillItems(world, entity, dt) {
245
+ let atShop;
246
+ for (const instance of slotsOf(entity) ?? []) {
247
+ if (!instance) continue;
248
+ const def = world.registry.item(instance.item);
249
+ if (!def.refill || !def.charges) continue;
250
+ const most = def.charges * Math.max(def.stack ?? 1, 1);
251
+ if (instance.charges >= most) {
252
+ instance.refill = void 0;
253
+ continue;
254
+ }
255
+ if (def.refill.shop && entity.alive && (atShop ??= !!shopNear(world, entity))) {
256
+ instance.charges = most;
257
+ instance.refill = void 0;
258
+ continue;
259
+ }
260
+ if (!def.refill.every || def.refill.every <= 0) continue;
261
+ instance.refill = (instance.refill ?? def.refill.every) - dt;
262
+ if (instance.refill <= 0) {
263
+ instance.charges++;
264
+ instance.refill = instance.charges < most ? def.refill.every : void 0;
265
+ }
266
+ }
267
+ }
268
+ /** Part of its price an item is bought back for */
269
+ /**
270
+ * Whether someone stands close enough to a shop to trade with it. Anything with a place will do: an entity, or what a screen knows of one
271
+ *
272
+ * @beta
273
+ */
274
+ var atShop = (entity, shop) => dist(entity.pos, shop.pos) <= 6 + shop.def.radius;
275
+ /**
276
+ * What buying an item comes to for someone who carries these things: the items it is made of that are there are
277
+ * used up and taken off the price, and so are the parts of the ones that are not
278
+ *
279
+ * @beta
280
+ */
281
+ function priceOf(registry, item, carried) {
282
+ const left = [...carried];
283
+ const uses = [];
284
+ const listed = (id) => currencyOf(registry, registry.item(id).cost);
285
+ const remaining = (id) => {
286
+ const def = registry.item(id);
287
+ let price = listed(id);
288
+ for (const part of def.from ?? []) {
289
+ const index = left.indexOf(part);
290
+ if (index >= 0) {
291
+ left.splice(index, 1);
292
+ uses.push(part);
293
+ price -= listed(part);
294
+ } else price -= listed(part) - remaining(part);
295
+ }
296
+ return Math.max(price, 0);
297
+ };
298
+ return {
299
+ price: remaining(item),
300
+ uses
301
+ };
302
+ }
303
+ var carriedBy = (entity) => (slotsOf(entity) ?? []).flatMap((instance) => instance ? [instance.item] : []);
304
+ /** Whether the entity has room for the item, counting what buying it would use up, and may carry it (`carryRefusal`) */
305
+ function fits(world, entity, item) {
306
+ const { uses } = priceOf(world.registry, item, carriedBy(entity));
307
+ return (hasRoomFor(world, entity, item) || uses.length > 0) && !carryRefusal(world, entity, item, uses);
308
+ }
309
+ /**
310
+ * What a shop has of each of its wares (`UnitTypeDef.sells`): how many are left and the seconds until the next one.
311
+ * Set as the shop is spawned, counted down by the abilities system while the shop stands; filed in the index
312
+ * (`world.index.with(shopStock)`); sent to everyone who sees the shop as `StockInfo` (how far the next one is, 0..1, not
313
+ * the seconds), the delta comparing ware by ware
314
+ *
315
+ * @beta
316
+ */
317
+ var shopStock = defineComponent({
318
+ id: "core.shop",
319
+ refs: (stock) => ({ items: stock.map((entry) => entry.item) }),
320
+ replicate: "everyone",
321
+ index: true,
322
+ snapshot(stock, _entity, { world }) {
323
+ return stock.map((entry) => {
324
+ const def = world.registry.item(entry.item).stock;
325
+ if (!def) return {
326
+ item: entry.item,
327
+ restock: 0
328
+ };
329
+ const full = entry.count >= def.max;
330
+ return {
331
+ item: entry.item,
332
+ count: entry.count,
333
+ restock: full ? 0 : Math.round((1 - entry.restock / def.restock) * 100) / 100
334
+ };
335
+ });
336
+ },
337
+ same: (a, b) => a.length === b.length && a.every((ware, i) => ware.item === b[i].item && ware.count === b[i].count && ware.restock === b[i].restock)
338
+ });
339
+ /** The player's hero that is closest to a shop and has room for the item, or for anything when none is named, if one is close enough */
340
+ function shopper(world, shop, player, item) {
341
+ let best;
342
+ let bestDistance = Infinity;
343
+ for (const entity of world.index.ownedBy(player)) {
344
+ if (!entity.alive || entity.hidden || !entity.has(inventorySlots)) continue;
345
+ const distance = dist(entity.pos, shop.pos);
346
+ if (!atShop(entity, shop) || distance >= bestDistance) continue;
347
+ if (item ? !fits(world, entity, item) : freeSlot(entity) < 0) continue;
348
+ bestDistance = distance;
349
+ best = entity;
350
+ }
351
+ return best;
352
+ }
353
+ /**
354
+ * Sells an item to a hero standing at the shop: the one that is named, or the closest one with room.
355
+ * Tells the player why when it cannot
356
+ *
357
+ * @beta
358
+ */
359
+ function buy(world, shop, item, player, buyer) {
360
+ const stock = shop.get(shopStock)?.find((entry) => entry.item === item);
361
+ if (!stock || !shop.operational || !world.registry.items.has(item)) return false;
362
+ const def = world.registry.item(item);
363
+ const purse = world.player(player).resources;
364
+ if (def.stock && stock.count <= 0) {
365
+ world.message(player, engineMessage("outOfStock"));
366
+ return false;
367
+ }
368
+ const hero = (buyer?.alive && !buyer.hidden && buyer.has(inventorySlots) && atShop(buyer, shop) && fits(world, buyer, item) ? buyer : void 0) ?? shopper(world, shop, player, item);
369
+ if (!hero) {
370
+ const there = buyer?.alive && buyer.has(inventorySlots) && atShop(buyer, shop) ? buyer : shopper(world, shop, player);
371
+ const refused = there && carryRefusal(world, there, item, priceOf(world.registry, item, carriedBy(there)).uses);
372
+ world.message(player, refused || engineMessage("heroAtShop"));
373
+ return false;
374
+ }
375
+ const { price, uses } = priceOf(world.registry, item, carriedBy(hero));
376
+ let cost = world.registry.currency ? {
377
+ ...def.cost,
378
+ [world.registry.currency]: price
379
+ } : def.cost;
380
+ if (world.hooks.has("beforeBuy")) {
381
+ const before = world.hooks.run("beforeBuy", {
382
+ buyer: hero,
383
+ shop,
384
+ item,
385
+ cost: { ...cost },
386
+ cancelled: false
387
+ });
388
+ if (before.cancelled) {
389
+ if (before.reason) world.message(player, before.reason);
390
+ return false;
391
+ }
392
+ cost = before.cost;
393
+ }
394
+ const short = shortOf(purse, cost);
395
+ if (short) {
396
+ world.message(player, engineMessage("notEnough", { resource: short }));
397
+ return false;
398
+ }
399
+ spend(world, player, cost, "item", item);
400
+ if (def.stock) stock.count--;
401
+ const used = [];
402
+ for (const part of uses) {
403
+ const taken = slotsOf(hero).find((instance) => instance?.item === part);
404
+ if (taken) used.push(takeItem(world, hero, taken.id));
405
+ }
406
+ const instance = createItem(world, item);
407
+ const stack = stackSlot(world, hero, item, instance.charges);
408
+ const into = stack >= 0 ? slotsOf(hero)[stack] : void 0;
409
+ giveItem(world, hero, instance);
410
+ if (world.settings.shop.undo > 0) {
411
+ const list = hero.get(purchases) ?? [];
412
+ list.push({
413
+ id: instance.id,
414
+ item,
415
+ shop: shop.id,
416
+ at: world.time,
417
+ paid: cost,
418
+ charges: into ? into.charges : instance.charges,
419
+ ...into && { into: into.id },
420
+ used,
421
+ stocked: !!def.stock
422
+ });
423
+ hero.set(purchases, list);
424
+ }
425
+ world.events.emit(itemPicked, {
426
+ entity: hero,
427
+ item: instance
428
+ });
429
+ return true;
430
+ }
431
+ /**
432
+ * The purchases a hero may still undo (`Purchase`, `undoBuy`): kept on the buyer, sent to its player (`PurchaseInfo`:
433
+ * each with the seconds left to undo it), dropped as they run out, as the hero leaves the shop or as the item is used
434
+ * (`expirePurchases`, the abilities system's every tick)
435
+ *
436
+ * @beta
437
+ */
438
+ var purchases = defineComponent({
439
+ id: "core.purchases",
440
+ replicate: "owner",
441
+ snapshot(list, entity, { world }) {
442
+ const undo = world.settings.shop.undo;
443
+ return list.filter((purchase) => undoable(world, entity, purchase)).map((purchase) => ({
444
+ id: purchase.id,
445
+ item: purchase.item,
446
+ left: Math.max(Math.ceil(purchase.at + undo - world.time), 0)
447
+ }));
448
+ },
449
+ same: (a, b) => a.length === b.length && a.every((purchase, i) => purchase.id === b[i].id && purchase.left === b[i].left)
450
+ });
451
+ /**
452
+ * Whether a purchase may still be undone (`undoBuy`): within `ShopSettings.undo` seconds of it, the buyer alive and at
453
+ * the shop still, the shop standing, the item carried with its charges as bought and its ability not used
454
+ *
455
+ * @beta
456
+ */
457
+ function undoable(world, entity, purchase) {
458
+ if (!inTime(world, entity, purchase)) return false;
459
+ const instance = findItem(entity, purchase.into ?? purchase.id);
460
+ if (!instance || instance.charges < purchase.charges) return false;
461
+ return !instance.state || instance.state.cooldown <= 0;
462
+ }
463
+ /** Whether a purchase is within its seconds, with the buyer alive and at the shop still, and the shop standing */
464
+ function inTime(world, entity, purchase) {
465
+ const undo = world.settings.shop.undo;
466
+ if (undo <= 0 || world.time - purchase.at > undo || !entity.alive || entity.hidden) return false;
467
+ const shop = world.entities.get(purchase.shop);
468
+ return !!shop?.alive && shop.operational && atShop(entity, shop);
469
+ }
470
+ /** Whether a later purchase of the list used the purchase's item up as a part: undoing the later brings it back */
471
+ var usedUp = (list, purchase) => list.some((later) => later.used.some((part) => part.id === purchase.id));
472
+ /**
473
+ * Drops the purchases of an entity that may not be undone any more (`undoable`): a purchase a later one used up as a
474
+ * part is kept while the later may be undone, to be undone after it. Run by the abilities system every tick
475
+ *
476
+ * @internal
477
+ */
478
+ function expirePurchases(world, entity) {
479
+ const list = entity.get(purchases);
480
+ if (!list?.length) return;
481
+ const kept = list.filter((purchase) => undoable(world, entity, purchase) || inTime(world, entity, purchase) && usedUp(list, purchase));
482
+ if (kept.length !== list.length) entity.set(purchases, kept);
483
+ }
484
+ /**
485
+ * Why a purchase of the hero's may not be undone, or nothing when it may: nothing to undo (none within the time, the
486
+ * hero away from the shop, the item used), or no room for the parts to come back
487
+ *
488
+ * @beta
489
+ */
490
+ function undoRefusal(world, entity, purchaseId) {
491
+ const purchase = purchaseOf(world, entity, purchaseId);
492
+ if (!purchase) return engineMessage("nothingToUndo");
493
+ const free = (slotsOf(entity) ?? []).filter((slot) => !slot).length + (purchase.into === void 0 ? 1 : 0);
494
+ if (purchase.used.length > free) return engineMessage("inventoryFull");
495
+ }
496
+ /** The purchase named, or the latest, of those that may be undone */
497
+ function purchaseOf(world, entity, purchaseId) {
498
+ const list = (entity.get(purchases) ?? []).filter((purchase) => undoable(world, entity, purchase));
499
+ return purchaseId === void 0 ? list.at(-1) : list.find((purchase) => purchase.id === purchaseId);
500
+ }
501
+ /**
502
+ * Takes a purchase back (`ShopSettings.undo`): the latest the hero may still undo, or the one named by its id. The
503
+ * item goes (out of its stack, where it went into one), what it cost comes back whole, the parts it used up come back
504
+ * as they were, and the shop has it back in stock. False, and the player told why, where it cannot (`undoRefusal`)
505
+ *
506
+ * @beta
507
+ */
508
+ function undoBuy(world, entity, purchaseId) {
509
+ const refusal = undoRefusal(world, entity, purchaseId);
510
+ if (refusal) {
511
+ world.message(entity.owner, refusal);
512
+ return false;
513
+ }
514
+ const purchase = purchaseOf(world, entity, purchaseId);
515
+ if (purchase.into !== void 0) {
516
+ const stack = findItem(entity, purchase.into);
517
+ stack.charges -= world.registry.item(purchase.item).charges ?? 0;
518
+ if (stack.charges <= 0) takeItem(world, entity, stack.id);
519
+ else inventoryChanged(world, entity);
520
+ } else takeItem(world, entity, purchase.id);
521
+ for (const part of purchase.used) giveItem(world, entity, part);
522
+ giveBack(world, entity.owner, purchase.paid, 1, "item", purchase.item);
523
+ const stock = world.entities.get(purchase.shop)?.get(shopStock)?.find((entry) => entry.item === purchase.item);
524
+ if (stock && purchase.stocked) {
525
+ const def = world.registry.item(purchase.item).stock;
526
+ stock.count = def ? Math.min(stock.count + 1, def.max) : stock.count;
527
+ }
528
+ entity.set(purchases, (entity.get(purchases) ?? []).filter((other) => other !== purchase));
529
+ world.events.emit(itemUndone, {
530
+ entity,
531
+ item: purchase.item,
532
+ shop: purchase.shop
533
+ });
534
+ return true;
535
+ }
536
+ /**
537
+ * Whether a shop the player can trade with is close enough to the entity
538
+ *
539
+ * @beta
540
+ */
541
+ function shopNear(world, entity) {
542
+ for (const shop of world.index.with(shopStock)) if (shop.alive && shop.operational && !world.areEnemies(shop.owner, entity.owner) && atShop(entity, shop)) return shop;
543
+ }
544
+ /**
545
+ * Gives an item back at a shop nearby, for a part of its price. What has charges is worth as much as is left of it
546
+ *
547
+ * @beta
548
+ */
549
+ function sell(world, entity, instanceId) {
550
+ const instance = findItem(entity, instanceId);
551
+ if (!instance || !entity.alive || entity.hidden) return false;
552
+ if (!shopNear(world, entity)) {
553
+ world.message(entity.owner, engineMessage("noShopNear"));
554
+ return false;
555
+ }
556
+ takeItem(world, entity, instance.id);
557
+ if (world.registry.currency) earn(world.player(entity.owner).resources, world.registry.currency, sellValue(world.registry, instance.item, instance.charges));
558
+ return true;
559
+ }
560
+ /** What a dead unit leaves behind: by its table of chances, or as its code decides */
561
+ function dropLoot(world, entity, killer) {
562
+ const { drops } = entity.def;
563
+ if (typeof drops === "function") {
564
+ for (const item of drops(world, entity, killer)) dropOnGround(world, createItem(world, item), entity.pos);
565
+ return;
566
+ }
567
+ for (const drop of drops ?? []) if (world.rng.next() < drop.chance) dropOnGround(world, createItem(world, drop.item), entity.pos);
568
+ }
569
+ /** An item picked up, to those who see who picked it */
570
+ var toldPicked = replicateEvent(itemPicked, "picked", ({ entity, item }, view) => view.knows(entity) ? {
571
+ type: "picked",
572
+ id: entity.id,
573
+ item: item.item
574
+ } : void 0);
575
+ /** The items on the ground where the player sees (`Snapshot.items`) */
576
+ var itemsPart = snapshotField("items", ({ world, sees }) => world.items.filter((item) => sees(item.x, item.z)).map(({ id, item, x, z }) => ({
577
+ id,
578
+ item,
579
+ x,
580
+ z
581
+ })));
582
+ //#endregion
583
+ export { REACH, SHOP_RANGE, atShop, buy, carryRefusal, createItem, dropLoot, dropOnGround, expirePurchases, findItem, giveItem, groupLimitOf, groupRefusal, hasRoomFor, itemTier, itemsPart, itemsTagged, pickUp, priceOf, purchases, refillItems, sell, shopNear, shopStock, shopper, spendCharge, takeItem, toldPicked, undoBuy, undoRefusal, undoable };
584
+
585
+ //# sourceMappingURL=items.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"items.js","names":["inventoryChangedEvent"],"sources":["../src/items.ts"],"sourcesContent":["import { inventoryChanged as inventoryChangedEvent, itemDropped, itemPicked, itemUndone } from '#engine/engineEvents'\nimport { defineComponent } from './components'\nimport { freeSlot, inventorySlots, slotsOf } from './inventory'\nimport type { Cost, ItemDef, ItemTier } from './defs'\nimport type { Entity, ItemInstance, Placed, StockState } from './entity'\nimport type { PurchaseInfo, StockInfo } from './session/protocol'\nimport { sellValue } from './shared'\nimport { refreshVitals } from './stats'\nimport { dist, type Vec2 } from './math'\nimport { currencyOf, earn, giveBack, shortOf, spend } from './player'\nimport type { World } from './world'\nimport { engineMessage, type Message, toMessage } from './messages'\nimport type { Registry } from './registry'\nimport { replicateEvent, snapshotField } from './replication'\n\n/**\n * A hero has to stand this close to a shop to buy from it\n *\n * @internal\n */\nexport const SHOP_RANGE = 6\n/**\n * And this close to something on the ground to pick it up, or to someone to hand it over\n *\n * @internal\n */\nexport const REACH = 1.2\n\n/**\n * An item lying on the ground\n *\n * @beta\n */\nexport interface GroundItem {\n\t/** The item instance's id, kept when it is picked up again */\n\tid: number\n\t/** The item type's id */\n\titem: string\n\t/** How many charges the item has left */\n\tcharges: number\n\t/** The item's place on the map's x axis */\n\tx: number\n\t/** The item's place on the map's z axis */\n\tz: number\n}\n\n/**\n * Makes an instance of an item type with an id of its own, with the charges given or those of the type (0 when it has none)\n *\n * @beta\n */\nexport function createItem(world: World, item: string, charges?: number): ItemInstance {\n\tconst def = world.registry.item(item)\n\treturn {\n\t\tid: world.newId(),\n\t\titem,\n\t\tcharges: charges ?? def.charges ?? 0,\n\t\tstate: def.ability ? { id: def.ability, level: 1, cooldown: 0, autocast: false } : undefined\n\t}\n}\n\n/** Call after the inventory changed: what is carried changes what the carrier can do, and the game is told */\nfunction inventoryChanged(world: World, entity: Entity): void {\n\trefreshVitals(world, entity)\n\tworld.events.emit(inventoryChangedEvent, { entity })\n}\n\n/**\n * The tier of an item, `epic` (the old word) read as `intermediate`: what the registry keeps of it (`ItemTier`)\n *\n * @beta\n */\nexport function itemTier(def: Pick<ItemDef, 'tier'>): ItemTier | undefined {\n\treturn def.tier === 'epic' ? 'intermediate' : def.tier\n}\n\n/**\n * The items of the game with a tag (`ItemDef.tags`), in the game's order: `itemsTagged(registry, 'lifesteal')`\n *\n * @beta\n */\nexport function itemsTagged(registry: Pick<Registry, 'items'>, tag: string): ItemDef[] {\n\tconst wanted = tag.toLowerCase()\n\treturn registry.items.all().filter((def) => def.tags?.some((each) => each.toLowerCase() === wanted))\n}\n\n/**\n * The most of an item's group one carrier may have (`ItemDef.group`): the item's own limit, the game's of the group\n * (`ItemSettings.groups`), or 1. No limit for an item of no group\n *\n * @beta\n */\nexport function groupLimitOf(world: World, def: ItemDef): number {\n\tif (def.group === undefined) return Infinity\n\treturn def.groupLimit ?? world.settings.items.groups[def.group] ?? 1\n}\n\n/** The slot of a carried one of the item that another of it (with these charges) goes into: a stack with room. -1 for none */\nfunction stackSlot(world: World, entity: Entity, item: string, charges: number): number {\n\tconst def = world.registry.item(item)\n\tif (!def.stack || def.stack < 2) return -1\n\tconst most = def.stack * Math.max(def.charges ?? 1, 1)\n\treturn slotsOf(entity)?.findIndex((carried) => carried?.item === item && carried.charges + charges <= most) ?? -1\n}\n\n/**\n * Whether the entity has room for an item: a free slot, or a stack of it with room (`ItemDef.stack`)\n *\n * @beta\n */\nexport function hasRoomFor(world: World, entity: Entity, item: string, charges = world.registry.item(item).charges ?? 0): boolean {\n\treturn freeSlot(entity) >= 0 || stackSlot(world, entity, item, charges) >= 0\n}\n\n/**\n * Why a carrier may not take an item, or nothing when it may: one more of its group than it may carry (`ItemDef.group`),\n * or what the game's own rule says (`ItemSettings.mayCarry`). `uses`, the parts buying it uses up, by id: they go out as\n * it comes in. `handed`: it is handed over, and the words say \"they\". Asked as an item is bought, picked up or handed\n * over; room in the inventory is asked apart (`hasRoomFor`)\n *\n * @beta\n */\nexport function carryRefusal(world: World, carrier: Entity, item: string, uses: readonly string[] = [], handed = false): Message | undefined {\n\tconst refused = groupRefusal(world.registry, carriedBy(carrier), item, uses, handed)\n\tif (refused) return refused\n\tconst own = world.settings.items.mayCarry?.(world, carrier, world.registry.item(item), uses)\n\treturn own === undefined ? undefined : toMessage(own)\n}\n\n/**\n * Why one who carries these items (by id) may not take one more of an item's group (`ItemDef.group`), or nothing when\n * it may: the engine's part of `carryRefusal`, which a screen asks too, with the game's registry alone, to say so before\n * the buy (the shop window). `uses` are the parts buying it uses up: they go out as it comes in, so they are not\n * counted. The limit is the item's own, the game's of the group (`ItemSettings.groups`), or 1\n *\n * @beta\n */\nexport function groupRefusal(\n\tregistry: Pick<Registry, 'items' | 'settings'>,\n\tcarried: readonly string[],\n\titem: string,\n\tuses: readonly string[] = [],\n\thanded = false\n): Message | undefined {\n\tconst def = registry.items.find(item)\n\tif (!def || def.group === undefined) return undefined\n\tconst limit = def.groupLimit ?? registry.settings.items.groups[def.group] ?? 1\n\tconst going = [...uses]\n\tlet count = 0\n\tfor (const other of carried) {\n\t\tconst index = going.indexOf(other)\n\t\tif (index >= 0) {\n\t\t\tgoing.splice(index, 1)\n\t\t\tcontinue\n\t\t}\n\t\tif (registry.items.find(other)?.group === def.group) count++\n\t}\n\treturn count + 1 > limit ? engineMessage(handed ? 'theirGroupLimit' : 'groupLimit', { item, group: def.group, limit }) : undefined\n}\n\n/**\n * Puts an item into the inventory: into a stack of it with room (`ItemDef.stack`, its charges added), or the first free\n * slot. False when there is neither. The engine's rules of what may be carried are asked before (`carryRefusal`)\n *\n * @beta\n */\nexport function giveItem(world: World, entity: Entity, instance: ItemInstance): boolean {\n\tconst slots = slotsOf(entity)\n\tif (!slots) return false\n\tconst stack = world.registry.items.has(instance.item) ? stackSlot(world, entity, instance.item, instance.charges) : -1\n\tif (stack >= 0) {\n\t\tslots[stack]!.charges += instance.charges\n\t\tinventoryChanged(world, entity)\n\t\treturn true\n\t}\n\tconst slot = freeSlot(entity)\n\tif (slot < 0) return false\n\tslots[slot] = instance\n\tinventoryChanged(world, entity)\n\treturn true\n}\n\n/**\n * Takes the item instance with this id out of the entity's inventory and returns it; undefined when it does not carry it\n *\n * @beta\n */\nexport function takeItem(world: World, entity: Entity, instanceId: number): ItemInstance | undefined {\n\tconst slots = slotsOf(entity)\n\tconst slot = slots?.findIndex((instance) => instance?.id === instanceId) ?? -1\n\tif (slot < 0) return undefined\n\tconst instance = slots![slot]!\n\tslots![slot] = null\n\tinventoryChanged(world, entity)\n\treturn instance\n}\n\n/**\n * Finds the item instance with this id in the entity's inventory; undefined when it is not there or no id is given\n *\n * @beta\n */\nexport function findItem(entity: Entity, instanceId: number | undefined): ItemInstance | undefined {\n\treturn slotsOf(entity)?.find((instance) => instance?.id === instanceId) ?? undefined\n}\n\n/**\n * Puts the item on the ground at the closest walkable point to `at`, tells the game (`itemDropped`) and returns the ground item\n *\n * @beta\n */\nexport function dropOnGround(world: World, instance: ItemInstance, at: Vec2): GroundItem {\n\tconst point = world.nav.closestPoint(at, 6) ?? at\n\tconst item = { id: instance.id, item: instance.item, charges: instance.charges, x: point.x, z: point.z }\n\tworld.items.push(item)\n\tworld.events.emit(itemDropped, item)\n\treturn item\n}\n\n/**\n * Has the entity pick up the item lying on the ground by its id; returns false when none is there, no slot is free or `beforePickUp` refuses\n *\n * @beta\n */\nexport function pickUp(world: World, entity: Entity, groundId: number): boolean {\n\tconst index = world.items.findIndex((item) => item.id === groundId)\n\tif (index < 0 || !hasRoomFor(world, entity, world.items[index].item, world.items[index].charges)) return false\n\tconst refused = carryRefusal(world, entity, world.items[index].item)\n\tif (refused) {\n\t\tworld.message(entity.owner, refused)\n\t\treturn false\n\t}\n\tif (world.hooks.has('beforePickUp')) {\n\t\tconst before = world.hooks.run('beforePickUp', { entity, item: world.items[index].item, ground: groundId, cancelled: false })\n\t\tif (before.cancelled) {\n\t\t\tif (before.reason) world.message(entity.owner, before.reason)\n\t\t\treturn false\n\t\t}\n\t}\n\tconst [item] = world.items.splice(index, 1)\n\tconst instance = createItem(world, item.item, item.charges)\n\tinstance.id = item.id\n\tgiveItem(world, entity, instance)\n\tworld.events.emit(itemPicked, { entity, item: instance })\n\treturn true\n}\n\n/**\n * One use of an item that has charges. The last one takes the item with it\n *\n * @beta\n */\nexport function spendCharge(world: World, entity: Entity, instance: ItemInstance): void {\n\tconst def = world.registry.item(instance.item)\n\tif (!def.charges) return\n\tinstance.charges--\n\t// what refills is kept, empty, until its charges come back\n\tif (instance.charges <= 0 && !def.refill) takeItem(world, entity, instance.id)\n}\n\n/**\n * The charges of what an entity carries coming back (`ItemDef.refill`): every one while it stands at a shop it may\n * trade with, one every so many seconds wherever it is. Run by the abilities system every tick\n *\n * @internal\n */\nexport function refillItems(world: World, entity: Entity, dt: number): void {\n\tlet atShop: boolean | undefined\n\tfor (const instance of slotsOf(entity) ?? []) {\n\t\tif (!instance) continue\n\t\tconst def = world.registry.item(instance.item)\n\t\tif (!def.refill || !def.charges) continue\n\t\tconst most = def.charges * Math.max(def.stack ?? 1, 1)\n\t\tif (instance.charges >= most) {\n\t\t\tinstance.refill = undefined\n\t\t\tcontinue\n\t\t}\n\t\tif (def.refill.shop && entity.alive && (atShop ??= !!shopNear(world, entity))) {\n\t\t\tinstance.charges = most\n\t\t\tinstance.refill = undefined\n\t\t\tcontinue\n\t\t}\n\t\tif (!def.refill.every || def.refill.every <= 0) continue\n\t\tinstance.refill = (instance.refill ?? def.refill.every) - dt\n\t\tif (instance.refill <= 0) {\n\t\t\tinstance.charges++\n\t\t\tinstance.refill = instance.charges < most ? def.refill.every : undefined\n\t\t}\n\t}\n}\n\n\n/** Part of its price an item is bought back for */\n\n/**\n * Whether someone stands close enough to a shop to trade with it. Anything with a place will do: an entity, or what a screen knows of one\n *\n * @beta\n */\nexport const atShop = (entity: Placed, shop: Placed) => dist(entity.pos, shop.pos) <= SHOP_RANGE + shop.def.radius\n\n/**\n * What buying an item comes to for someone who carries these things: the items it is made of that are there are\n * used up and taken off the price, and so are the parts of the ones that are not\n *\n * @beta\n */\nexport function priceOf(registry: World['registry'], item: string, carried: readonly string[]): { price: number; uses: string[] } {\n\tconst left = [...carried]\n\tconst uses: string[] = []\n\tconst listed = (id: string) => currencyOf(registry, registry.item(id).cost)\n\tconst remaining = (id: string): number => {\n\t\tconst def: ItemDef = registry.item(id)\n\t\tlet price = listed(id)\n\t\tfor (const part of def.from ?? []) {\n\t\t\tconst index = left.indexOf(part)\n\t\t\tif (index >= 0) {\n\t\t\t\tleft.splice(index, 1)\n\t\t\t\tuses.push(part)\n\t\t\t\tprice -= listed(part)\n\t\t\t} else {\n\t\t\t\tprice -= listed(part) - remaining(part)\n\t\t\t}\n\t\t}\n\t\treturn Math.max(price, 0)\n\t}\n\treturn { price: remaining(item), uses }\n}\n\nconst carriedBy = (entity: Entity) => (slotsOf(entity) ?? []).flatMap((instance) => (instance ? [instance.item] : []))\n\n/** Whether the entity has room for the item, counting what buying it would use up, and may carry it (`carryRefusal`) */\nfunction fits(world: World, entity: Entity, item: string): boolean {\n\tconst { uses } = priceOf(world.registry, item, carriedBy(entity))\n\treturn (hasRoomFor(world, entity, item) || uses.length > 0) && !carryRefusal(world, entity, item, uses)\n}\n\n/**\n * What a shop has of each of its wares (`UnitTypeDef.sells`): how many are left and the seconds until the next one.\n * Set as the shop is spawned, counted down by the abilities system while the shop stands; filed in the index\n * (`world.index.with(shopStock)`); sent to everyone who sees the shop as `StockInfo` (how far the next one is, 0..1, not\n * the seconds), the delta comparing ware by ware\n *\n * @beta\n */\nexport const shopStock = defineComponent<StockState[], StockInfo[]>({ id: 'core.shop', refs: (stock) => ({ items: (stock as StockState[]).map((entry) => entry.item) }),\n\treplicate: 'everyone',\n\tindex: true,\n\tsnapshot(stock, _entity, { world }) {\n\t\treturn stock.map((entry) => {\n\t\t\tconst def = world.registry.item(entry.item).stock\n\t\t\t// what there is no end of has no count\n\t\t\tif (!def) return { item: entry.item, restock: 0 }\n\t\t\tconst full = entry.count >= def.max\n\t\t\treturn { item: entry.item, count: entry.count, restock: full ? 0 : Math.round((1 - entry.restock / def.restock) * 100) / 100 }\n\t\t})\n\t},\n\tsame: (a, b) => a.length === b.length && a.every((ware, i) => ware.item === b[i].item && ware.count === b[i].count && ware.restock === b[i].restock) })\n\n/** The player's hero that is closest to a shop and has room for the item, or for anything when none is named, if one is close enough */\nexport function shopper(world: World, shop: Entity, player: number, item?: string): Entity | undefined {\n\tlet best: Entity | undefined\n\tlet bestDistance = Infinity\n\tfor (const entity of world.index.ownedBy(player)) {\n\t\tif (!entity.alive || entity.hidden || !entity.has(inventorySlots)) continue\n\t\tconst distance = dist(entity.pos, shop.pos)\n\t\tif (!atShop(entity, shop) || distance >= bestDistance) continue\n\t\tif (item ? !fits(world, entity, item) : freeSlot(entity) < 0) continue\n\t\tbestDistance = distance\n\t\tbest = entity\n\t}\n\treturn best\n}\n\n/**\n * Sells an item to a hero standing at the shop: the one that is named, or the closest one with room.\n * Tells the player why when it cannot\n *\n * @beta\n */\nexport function buy(world: World, shop: Entity, item: string, player: number, buyer?: Entity): boolean {\n\tconst stock = shop.get(shopStock)?.find((entry) => entry.item === item)\n\tif (!stock || !shop.operational || !world.registry.items.has(item)) return false\n\tconst def: ItemDef = world.registry.item(item)\n\tconst purse = world.player(player).resources\n\tif (def.stock && stock.count <= 0) {\n\t\tworld.message(player, engineMessage('outOfStock'))\n\t\treturn false\n\t}\n\tconst named = buyer?.alive && !buyer.hidden && buyer.has(inventorySlots) && atShop(buyer, shop) && fits(world, buyer, item) ? buyer : undefined\n\tconst hero = named ?? shopper(world, shop, player, item)\n\tif (!hero) {\n\t\t// a hero there that has room and may not carry it is told why: one pair of boots\n\t\tconst there = buyer?.alive && buyer.has(inventorySlots) && atShop(buyer, shop) ? buyer : shopper(world, shop, player)\n\t\tconst refused = there && carryRefusal(world, there, item, priceOf(world.registry, item, carriedBy(there)).uses)\n\t\tworld.message(player, refused || engineMessage('heroAtShop'))\n\t\treturn false\n\t}\n\tconst { price, uses } = priceOf(world.registry, item, carriedBy(hero))\n\tlet cost = world.registry.currency ? { ...def.cost, [world.registry.currency]: price } : def.cost\n\t// what the game makes of it: a discount, only heroes of a kind\n\tif (world.hooks.has('beforeBuy')) {\n\t\tconst before = world.hooks.run('beforeBuy', { buyer: hero, shop, item, cost: { ...cost }, cancelled: false })\n\t\tif (before.cancelled) {\n\t\t\tif (before.reason) world.message(player, before.reason)\n\t\t\treturn false\n\t\t}\n\t\tcost = before.cost\n\t}\n\tconst short = shortOf(purse, cost)\n\tif (short) {\n\t\tworld.message(player, engineMessage('notEnough', { resource: short }))\n\t\treturn false\n\t}\n\tspend(world, player, cost, 'item', item)\n\tif (def.stock) stock.count--\n\tconst used: ItemInstance[] = []\n\tfor (const part of uses) {\n\t\tconst taken = slotsOf(hero)!.find((instance) => instance?.item === part)\n\t\tif (taken) used.push(takeItem(world, hero, taken.id)!)\n\t}\n\tconst instance = createItem(world, item)\n\t// into a stack of it, when there is one with room: then undoing takes its charges back out of the stack\n\tconst stack = stackSlot(world, hero, item, instance.charges)\n\tconst into = stack >= 0 ? slotsOf(hero)![stack]! : undefined\n\tgiveItem(world, hero, instance)\n\tif (world.settings.shop.undo > 0) {\n\t\tconst list = hero.get(purchases) ?? []\n\t\tlist.push({\n\t\t\tid: instance.id,\n\t\t\titem,\n\t\t\tshop: shop.id,\n\t\t\tat: world.time,\n\t\t\tpaid: cost,\n\t\t\tcharges: into ? into.charges : instance.charges,\n\t\t\t...(into && { into: into.id }),\n\t\t\tused,\n\t\t\tstocked: !!def.stock\n\t\t})\n\t\thero.set(purchases, list)\n\t}\n\tworld.events.emit(itemPicked, { entity: hero, item: instance })\n\treturn true\n}\n\n/**\n * A purchase that may still be undone (`undoBuy`), kept on the buyer (`purchases`) for `ShopSettings.undo` seconds\n * while it stands at the shop and has not used the item\n *\n * @beta\n */\nexport interface Purchase {\n\t/** The purchase's id: the id of the item instance bought (what `undoBuy` names it by) */\n\tid: number\n\t/** The item type's id */\n\titem: string\n\t/** The shop it was bought at: the buyer has to be there still */\n\tshop: number\n\t/** The game's time it was bought at */\n\tat: number\n\t/** What was paid, given back whole */\n\tpaid: Cost\n\t/** The charges the item had as bought, or the stack had with it: fewer, and it was used */\n\tcharges: number\n\t/** The stack it went into (its instance id), when it was stacked onto one carried rather than put in a slot of its own */\n\tinto?: number\n\t/** The parts it used up, as they were, to come back */\n\tused: ItemInstance[]\n\t/** Whether the shop counted it off its stock, to count it back */\n\tstocked: boolean\n}\n\n/**\n * The purchases a hero may still undo (`Purchase`, `undoBuy`): kept on the buyer, sent to its player (`PurchaseInfo`:\n * each with the seconds left to undo it), dropped as they run out, as the hero leaves the shop or as the item is used\n * (`expirePurchases`, the abilities system's every tick)\n *\n * @beta\n */\nexport const purchases = defineComponent<Purchase[], PurchaseInfo[]>({\n\tid: 'core.purchases',\n\treplicate: 'owner',\n\tsnapshot(list, entity, { world }) {\n\t\tconst undo = world.settings.shop.undo\n\t\t// (one a later purchase used up is kept for after it, and not shown until then)\n\t\treturn list\n\t\t\t.filter((purchase) => undoable(world, entity, purchase))\n\t\t\t.map((purchase) => ({ id: purchase.id, item: purchase.item, left: Math.max(Math.ceil(purchase.at + undo - world.time), 0) }))\n\t},\n\tsame: (a, b) => a.length === b.length && a.every((purchase, i) => purchase.id === b[i].id && purchase.left === b[i].left)\n})\n\n/**\n * Whether a purchase may still be undone (`undoBuy`): within `ShopSettings.undo` seconds of it, the buyer alive and at\n * the shop still, the shop standing, the item carried with its charges as bought and its ability not used\n *\n * @beta\n */\nexport function undoable(world: World, entity: Entity, purchase: Purchase): boolean {\n\tif (!inTime(world, entity, purchase)) return false\n\tconst instance = findItem(entity, purchase.into ?? purchase.id)\n\tif (!instance || instance.charges < purchase.charges) return false\n\t// its ability cast is a use, whether or not it has charges\n\treturn !instance.state || instance.state.cooldown <= 0\n}\n\n/** Whether a purchase is within its seconds, with the buyer alive and at the shop still, and the shop standing */\nfunction inTime(world: World, entity: Entity, purchase: Purchase): boolean {\n\tconst undo = world.settings.shop.undo\n\tif (undo <= 0 || world.time - purchase.at > undo || !entity.alive || entity.hidden) return false\n\tconst shop = world.entities.get(purchase.shop)\n\treturn !!shop?.alive && shop.operational && atShop(entity, shop)\n}\n\n/** Whether a later purchase of the list used the purchase's item up as a part: undoing the later brings it back */\nconst usedUp = (list: readonly Purchase[], purchase: Purchase): boolean => list.some((later) => later.used.some((part) => part.id === purchase.id))\n\n/**\n * Drops the purchases of an entity that may not be undone any more (`undoable`): a purchase a later one used up as a\n * part is kept while the later may be undone, to be undone after it. Run by the abilities system every tick\n *\n * @internal\n */\nexport function expirePurchases(world: World, entity: Entity): void {\n\tconst list = entity.get(purchases)\n\tif (!list?.length) return\n\tconst kept = list.filter((purchase) => undoable(world, entity, purchase) || (inTime(world, entity, purchase) && usedUp(list, purchase)))\n\tif (kept.length !== list.length) entity.set(purchases, kept)\n}\n\n/**\n * Why a purchase of the hero's may not be undone, or nothing when it may: nothing to undo (none within the time, the\n * hero away from the shop, the item used), or no room for the parts to come back\n *\n * @beta\n */\nexport function undoRefusal(world: World, entity: Entity, purchaseId?: number): Message | undefined {\n\tconst purchase = purchaseOf(world, entity, purchaseId)\n\tif (!purchase) return engineMessage('nothingToUndo')\n\t// the item's slot is freed as it goes; the parts need one each besides\n\tconst free = (slotsOf(entity) ?? []).filter((slot) => !slot).length + (purchase.into === undefined ? 1 : 0)\n\tif (purchase.used.length > free) return engineMessage('inventoryFull')\n\treturn undefined\n}\n\n/** The purchase named, or the latest, of those that may be undone */\nfunction purchaseOf(world: World, entity: Entity, purchaseId?: number): Purchase | undefined {\n\tconst list = (entity.get(purchases) ?? []).filter((purchase) => undoable(world, entity, purchase))\n\treturn purchaseId === undefined ? list.at(-1) : list.find((purchase) => purchase.id === purchaseId)\n}\n\n/**\n * Takes a purchase back (`ShopSettings.undo`): the latest the hero may still undo, or the one named by its id. The\n * item goes (out of its stack, where it went into one), what it cost comes back whole, the parts it used up come back\n * as they were, and the shop has it back in stock. False, and the player told why, where it cannot (`undoRefusal`)\n *\n * @beta\n */\nexport function undoBuy(world: World, entity: Entity, purchaseId?: number): boolean {\n\tconst refusal = undoRefusal(world, entity, purchaseId)\n\tif (refusal) {\n\t\tworld.message(entity.owner, refusal)\n\t\treturn false\n\t}\n\tconst purchase = purchaseOf(world, entity, purchaseId)!\n\tif (purchase.into !== undefined) {\n\t\t// out of the stack it went into: the charges it brought (the stack had the rest before, or got them since)\n\t\tconst stack = findItem(entity, purchase.into)!\n\t\tstack.charges -= world.registry.item(purchase.item).charges ?? 0\n\t\tif (stack.charges <= 0) takeItem(world, entity, stack.id)\n\t\telse inventoryChanged(world, entity)\n\t} else takeItem(world, entity, purchase.id)\n\tfor (const part of purchase.used) giveItem(world, entity, part)\n\tgiveBack(world, entity.owner, purchase.paid, 1, 'item', purchase.item)\n\tconst shop = world.entities.get(purchase.shop)\n\tconst stock = shop?.get(shopStock)?.find((entry) => entry.item === purchase.item)\n\tif (stock && purchase.stocked) {\n\t\tconst def = world.registry.item(purchase.item).stock\n\t\tstock.count = def ? Math.min(stock.count + 1, def.max) : stock.count\n\t}\n\tentity.set(\n\t\tpurchases,\n\t\t(entity.get(purchases) ?? []).filter((other) => other !== purchase)\n\t)\n\tworld.events.emit(itemUndone, { entity, item: purchase.item, shop: purchase.shop })\n\treturn true\n}\n\n/**\n * Whether a shop the player can trade with is close enough to the entity\n *\n * @beta\n */\nexport function shopNear(world: World, entity: Entity): Entity | undefined {\n\tfor (const shop of world.index.with(shopStock)) {\n\t\tif (shop.alive && shop.operational && !world.areEnemies(shop.owner, entity.owner) && atShop(entity, shop)) return shop\n\t}\n\treturn undefined\n}\n\n/**\n * Gives an item back at a shop nearby, for a part of its price. What has charges is worth as much as is left of it\n *\n * @beta\n */\nexport function sell(world: World, entity: Entity, instanceId: number): boolean {\n\tconst instance = findItem(entity, instanceId)\n\tif (!instance || !entity.alive || entity.hidden) return false\n\tif (!shopNear(world, entity)) {\n\t\tworld.message(entity.owner, engineMessage('noShopNear'))\n\t\treturn false\n\t}\n\ttakeItem(world, entity, instance.id)\n\tif (world.registry.currency)\n\t\tearn(world.player(entity.owner).resources, world.registry.currency, sellValue(world.registry, instance.item, instance.charges))\n\treturn true\n}\n\n/** What a dead unit leaves behind: by its table of chances, or as its code decides */\nexport function dropLoot(world: World, entity: Entity, killer?: Entity): void {\n\tconst { drops } = entity.def\n\tif (typeof drops === 'function') {\n\t\tfor (const item of drops(world, entity, killer)) dropOnGround(world, createItem(world, item), entity.pos)\n\t\treturn\n\t}\n\tfor (const drop of drops ?? []) {\n\t\tif (world.rng.next() < drop.chance) dropOnGround(world, createItem(world, drop.item), entity.pos)\n\t}\n}\n\n/** An item picked up, to those who see who picked it */\nexport const toldPicked = replicateEvent(itemPicked, 'picked', ({ entity, item }, view) =>\n\tview.knows(entity) ? { type: 'picked', id: entity.id, item: item.item } : undefined\n)\n\n/** The items on the ground where the player sees (`Snapshot.items`) */\nexport const itemsPart = snapshotField('items', ({ world, sees }) =>\n\tworld.items.filter((item) => sees(item.x, item.z)).map(({ id, item, x, z }) => ({ id, item, x, z }))\n)\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,IAAa,aAAa;;;;;;AAM1B,IAAa,QAAQ;;;;;;AAyBrB,SAAgB,WAAW,OAAc,MAAc,SAAgC;CACtF,MAAM,MAAM,MAAM,SAAS,KAAK,IAAI;CACpC,OAAO;EACN,IAAI,MAAM,MAAM;EAChB;EACA,SAAS,WAAW,IAAI,WAAW;EACnC,OAAO,IAAI,UAAU;GAAE,IAAI,IAAI;GAAS,OAAO;GAAG,UAAU;GAAG,UAAU;EAAM,IAAI,KAAA;CACpF;AACD;;AAGA,SAAS,iBAAiB,OAAc,QAAsB;CAC7D,cAAc,OAAO,MAAM;CAC3B,MAAM,OAAO,KAAKA,oBAAuB,EAAE,OAAO,CAAC;AACpD;;;;;;AAOA,SAAgB,SAAS,KAAkD;CAC1E,OAAO,IAAI,SAAS,SAAS,iBAAiB,IAAI;AACnD;;;;;;AAOA,SAAgB,YAAY,UAAmC,KAAwB;CACtF,MAAM,SAAS,IAAI,YAAY;CAC/B,OAAO,SAAS,MAAM,IAAI,CAAC,CAAC,QAAQ,QAAQ,IAAI,M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