@rpgm-tools/neo-angband-core 0.10.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 (1183) hide show
  1. package/LICENSE.md +43 -0
  2. package/README.md +80 -0
  3. package/dist/agent/act.d.ts +22 -0
  4. package/dist/agent/act.d.ts.map +1 -0
  5. package/dist/agent/act.js +88 -0
  6. package/dist/agent/act.js.map +1 -0
  7. package/dist/agent/controller.d.ts +34 -0
  8. package/dist/agent/controller.d.ts.map +1 -0
  9. package/dist/agent/controller.js +90 -0
  10. package/dist/agent/controller.js.map +1 -0
  11. package/dist/agent/events.d.ts +27 -0
  12. package/dist/agent/events.d.ts.map +1 -0
  13. package/dist/agent/events.js +31 -0
  14. package/dist/agent/events.js.map +1 -0
  15. package/dist/agent/index.d.ts +17 -0
  16. package/dist/agent/index.d.ts.map +1 -0
  17. package/dist/agent/index.js +15 -0
  18. package/dist/agent/index.js.map +1 -0
  19. package/dist/agent/perceive.d.ts +21 -0
  20. package/dist/agent/perceive.d.ts.map +1 -0
  21. package/dist/agent/perceive.js +386 -0
  22. package/dist/agent/perceive.js.map +1 -0
  23. package/dist/agent/types.d.ts +436 -0
  24. package/dist/agent/types.d.ts.map +1 -0
  25. package/dist/agent/types.js +63 -0
  26. package/dist/agent/types.js.map +1 -0
  27. package/dist/bitflag.d.ts +199 -0
  28. package/dist/bitflag.d.ts.map +1 -0
  29. package/dist/bitflag.js +478 -0
  30. package/dist/bitflag.js.map +1 -0
  31. package/dist/cmd.d.ts +164 -0
  32. package/dist/cmd.d.ts.map +1 -0
  33. package/dist/cmd.js +350 -0
  34. package/dist/cmd.js.map +1 -0
  35. package/dist/color.d.ts +104 -0
  36. package/dist/color.d.ts.map +1 -0
  37. package/dist/color.js +240 -0
  38. package/dist/color.js.map +1 -0
  39. package/dist/combat/brand-slay.d.ts +119 -0
  40. package/dist/combat/brand-slay.d.ts.map +1 -0
  41. package/dist/combat/brand-slay.js +264 -0
  42. package/dist/combat/brand-slay.js.map +1 -0
  43. package/dist/combat/hit.d.ts +198 -0
  44. package/dist/combat/hit.d.ts.map +1 -0
  45. package/dist/combat/hit.js +310 -0
  46. package/dist/combat/hit.js.map +1 -0
  47. package/dist/combat/index.d.ts +15 -0
  48. package/dist/combat/index.d.ts.map +1 -0
  49. package/dist/combat/index.js +15 -0
  50. package/dist/combat/index.js.map +1 -0
  51. package/dist/combat/melee.d.ts +261 -0
  52. package/dist/combat/melee.d.ts.map +1 -0
  53. package/dist/combat/melee.js +402 -0
  54. package/dist/combat/melee.js.map +1 -0
  55. package/dist/combat/mon-melee.d.ts +233 -0
  56. package/dist/combat/mon-melee.d.ts.map +1 -0
  57. package/dist/combat/mon-melee.js +883 -0
  58. package/dist/combat/mon-melee.js.map +1 -0
  59. package/dist/combat/ranged.d.ts +89 -0
  60. package/dist/combat/ranged.d.ts.map +1 -0
  61. package/dist/combat/ranged.js +253 -0
  62. package/dist/combat/ranged.js.map +1 -0
  63. package/dist/constants.d.ts +134 -0
  64. package/dist/constants.d.ts.map +1 -0
  65. package/dist/constants.js +171 -0
  66. package/dist/constants.js.map +1 -0
  67. package/dist/dice.d.ts +91 -0
  68. package/dist/dice.d.ts.map +1 -0
  69. package/dist/dice.js +424 -0
  70. package/dist/dice.js.map +1 -0
  71. package/dist/effects/effect-choice.d.ts +15 -0
  72. package/dist/effects/effect-choice.d.ts.map +1 -0
  73. package/dist/effects/effect-choice.js +18 -0
  74. package/dist/effects/effect-choice.js.map +1 -0
  75. package/dist/effects/effect-info.d.ts +124 -0
  76. package/dist/effects/effect-info.d.ts.map +1 -0
  77. package/dist/effects/effect-info.js +706 -0
  78. package/dist/effects/effect-info.js.map +1 -0
  79. package/dist/effects/effect.d.ts +165 -0
  80. package/dist/effects/effect.d.ts.map +1 -0
  81. package/dist/effects/effect.js +452 -0
  82. package/dist/effects/effect.js.map +1 -0
  83. package/dist/effects/handlers.d.ts +70 -0
  84. package/dist/effects/handlers.d.ts.map +1 -0
  85. package/dist/effects/handlers.js +394 -0
  86. package/dist/effects/handlers.js.map +1 -0
  87. package/dist/effects/interpreter.d.ts +291 -0
  88. package/dist/effects/interpreter.d.ts.map +1 -0
  89. package/dist/effects/interpreter.js +325 -0
  90. package/dist/effects/interpreter.js.map +1 -0
  91. package/dist/events.d.ts +188 -0
  92. package/dist/events.d.ts.map +1 -0
  93. package/dist/events.js +138 -0
  94. package/dist/events.js.map +1 -0
  95. package/dist/expression.d.ts +83 -0
  96. package/dist/expression.d.ts.map +1 -0
  97. package/dist/expression.js +333 -0
  98. package/dist/expression.js.map +1 -0
  99. package/dist/game/cave-cmd.d.ts +195 -0
  100. package/dist/game/cave-cmd.d.ts.map +1 -0
  101. package/dist/game/cave-cmd.js +968 -0
  102. package/dist/game/cave-cmd.js.map +1 -0
  103. package/dist/game/char-sheet.d.ts +189 -0
  104. package/dist/game/char-sheet.d.ts.map +1 -0
  105. package/dist/game/char-sheet.js +381 -0
  106. package/dist/game/char-sheet.js.map +1 -0
  107. package/dist/game/chest.d.ts +94 -0
  108. package/dist/game/chest.d.ts.map +1 -0
  109. package/dist/game/chest.js +267 -0
  110. package/dist/game/chest.js.map +1 -0
  111. package/dist/game/context.d.ts +970 -0
  112. package/dist/game/context.d.ts.map +1 -0
  113. package/dist/game/context.js +353 -0
  114. package/dist/game/context.js.map +1 -0
  115. package/dist/game/curse-tick.d.ts +35 -0
  116. package/dist/game/curse-tick.d.ts.map +1 -0
  117. package/dist/game/curse-tick.js +100 -0
  118. package/dist/game/curse-tick.js.map +1 -0
  119. package/dist/game/describe.d.ts +20 -0
  120. package/dist/game/describe.d.ts.map +1 -0
  121. package/dist/game/describe.js +45 -0
  122. package/dist/game/describe.js.map +1 -0
  123. package/dist/game/display.d.ts +196 -0
  124. package/dist/game/display.d.ts.map +1 -0
  125. package/dist/game/display.js +684 -0
  126. package/dist/game/display.js.map +1 -0
  127. package/dist/game/dump-level.d.ts +37 -0
  128. package/dist/game/dump-level.d.ts.map +1 -0
  129. package/dist/game/dump-level.js +110 -0
  130. package/dist/game/dump-level.js.map +1 -0
  131. package/dist/game/effect-attack.d.ts +36 -0
  132. package/dist/game/effect-attack.d.ts.map +1 -0
  133. package/dist/game/effect-attack.js +694 -0
  134. package/dist/game/effect-attack.js.map +1 -0
  135. package/dist/game/effect-detect.d.ts +34 -0
  136. package/dist/game/effect-detect.d.ts.map +1 -0
  137. package/dist/game/effect-detect.js +456 -0
  138. package/dist/game/effect-detect.js.map +1 -0
  139. package/dist/game/effect-env.d.ts +77 -0
  140. package/dist/game/effect-env.d.ts.map +1 -0
  141. package/dist/game/effect-env.js +166 -0
  142. package/dist/game/effect-env.js.map +1 -0
  143. package/dist/game/effect-game-env.d.ts +76 -0
  144. package/dist/game/effect-game-env.d.ts.map +1 -0
  145. package/dist/game/effect-game-env.js +23 -0
  146. package/dist/game/effect-game-env.js.map +1 -0
  147. package/dist/game/effect-general.d.ts +98 -0
  148. package/dist/game/effect-general.d.ts.map +1 -0
  149. package/dist/game/effect-general.js +914 -0
  150. package/dist/game/effect-general.js.map +1 -0
  151. package/dist/game/effect-item.d.ts +124 -0
  152. package/dist/game/effect-item.d.ts.map +1 -0
  153. package/dist/game/effect-item.js +789 -0
  154. package/dist/game/effect-item.js.map +1 -0
  155. package/dist/game/effect-melee.d.ts +43 -0
  156. package/dist/game/effect-melee.d.ts.map +1 -0
  157. package/dist/game/effect-melee.js +477 -0
  158. package/dist/game/effect-melee.js.map +1 -0
  159. package/dist/game/effect-mon-origin.d.ts +67 -0
  160. package/dist/game/effect-mon-origin.d.ts.map +1 -0
  161. package/dist/game/effect-mon-origin.js +164 -0
  162. package/dist/game/effect-mon-origin.js.map +1 -0
  163. package/dist/game/effect-monster.d.ts +29 -0
  164. package/dist/game/effect-monster.d.ts.map +1 -0
  165. package/dist/game/effect-monster.js +281 -0
  166. package/dist/game/effect-monster.js.map +1 -0
  167. package/dist/game/effect-summon.d.ts +37 -0
  168. package/dist/game/effect-summon.d.ts.map +1 -0
  169. package/dist/game/effect-summon.js +113 -0
  170. package/dist/game/effect-summon.js.map +1 -0
  171. package/dist/game/effect-teleport.d.ts +130 -0
  172. package/dist/game/effect-teleport.d.ts.map +1 -0
  173. package/dist/game/effect-teleport.js +529 -0
  174. package/dist/game/effect-teleport.js.map +1 -0
  175. package/dist/game/effect-terrain.d.ts +91 -0
  176. package/dist/game/effect-terrain.d.ts.map +1 -0
  177. package/dist/game/effect-terrain.js +812 -0
  178. package/dist/game/effect-terrain.js.map +1 -0
  179. package/dist/game/energy.d.ts +45 -0
  180. package/dist/game/energy.d.ts.map +1 -0
  181. package/dist/game/energy.js +51 -0
  182. package/dist/game/energy.js.map +1 -0
  183. package/dist/game/equip-cmp.d.ts +138 -0
  184. package/dist/game/equip-cmp.d.ts.map +1 -0
  185. package/dist/game/equip-cmp.js +363 -0
  186. package/dist/game/equip-cmp.js.map +1 -0
  187. package/dist/game/floor.d.ts +182 -0
  188. package/dist/game/floor.d.ts.map +1 -0
  189. package/dist/game/floor.js +435 -0
  190. package/dist/game/floor.js.map +1 -0
  191. package/dist/game/gear.d.ts +408 -0
  192. package/dist/game/gear.d.ts.map +1 -0
  193. package/dist/game/gear.js +1037 -0
  194. package/dist/game/gear.js.map +1 -0
  195. package/dist/game/harness.d.ts +61 -0
  196. package/dist/game/harness.d.ts.map +1 -0
  197. package/dist/game/harness.js +198 -0
  198. package/dist/game/harness.js.map +1 -0
  199. package/dist/game/history.d.ts +49 -0
  200. package/dist/game/history.d.ts.map +1 -0
  201. package/dist/game/history.js +55 -0
  202. package/dist/game/history.js.map +1 -0
  203. package/dist/game/ignore-cmd.d.ts +42 -0
  204. package/dist/game/ignore-cmd.d.ts.map +1 -0
  205. package/dist/game/ignore-cmd.js +59 -0
  206. package/dist/game/ignore-cmd.js.map +1 -0
  207. package/dist/game/inscription-confirm.d.ts +80 -0
  208. package/dist/game/inscription-confirm.d.ts.map +1 -0
  209. package/dist/game/inscription-confirm.js +95 -0
  210. package/dist/game/inscription-confirm.js.map +1 -0
  211. package/dist/game/known.d.ts +297 -0
  212. package/dist/game/known.d.ts.map +1 -0
  213. package/dist/game/known.js +849 -0
  214. package/dist/game/known.js.map +1 -0
  215. package/dist/game/loop.d.ts +139 -0
  216. package/dist/game/loop.d.ts.map +1 -0
  217. package/dist/game/loop.js +631 -0
  218. package/dist/game/loop.js.map +1 -0
  219. package/dist/game/lore-color.d.ts +25 -0
  220. package/dist/game/lore-color.d.ts.map +1 -0
  221. package/dist/game/lore-color.js +95 -0
  222. package/dist/game/lore-color.js.map +1 -0
  223. package/dist/game/mon-cast.d.ts +150 -0
  224. package/dist/game/mon-cast.d.ts.map +1 -0
  225. package/dist/game/mon-cast.js +301 -0
  226. package/dist/game/mon-cast.js.map +1 -0
  227. package/dist/game/mon-cmd.d.ts +51 -0
  228. package/dist/game/mon-cmd.d.ts.map +1 -0
  229. package/dist/game/mon-cmd.js +670 -0
  230. package/dist/game/mon-cmd.js.map +1 -0
  231. package/dist/game/mon-death.d.ts +143 -0
  232. package/dist/game/mon-death.d.ts.map +1 -0
  233. package/dist/game/mon-death.js +328 -0
  234. package/dist/game/mon-death.js.map +1 -0
  235. package/dist/game/mon-group.d.ts +81 -0
  236. package/dist/game/mon-group.d.ts.map +1 -0
  237. package/dist/game/mon-group.js +323 -0
  238. package/dist/game/mon-group.js.map +1 -0
  239. package/dist/game/mon-list.d.ts +85 -0
  240. package/dist/game/mon-list.d.ts.map +1 -0
  241. package/dist/game/mon-list.js +154 -0
  242. package/dist/game/mon-list.js.map +1 -0
  243. package/dist/game/mon-message.d.ts +100 -0
  244. package/dist/game/mon-message.d.ts.map +1 -0
  245. package/dist/game/mon-message.js +336 -0
  246. package/dist/game/mon-message.js.map +1 -0
  247. package/dist/game/mon-place.d.ts +226 -0
  248. package/dist/game/mon-place.d.ts.map +1 -0
  249. package/dist/game/mon-place.js +642 -0
  250. package/dist/game/mon-place.js.map +1 -0
  251. package/dist/game/mon-ranged.d.ts +87 -0
  252. package/dist/game/mon-ranged.d.ts.map +1 -0
  253. package/dist/game/mon-ranged.js +353 -0
  254. package/dist/game/mon-ranged.js.map +1 -0
  255. package/dist/game/mon-shape.d.ts +43 -0
  256. package/dist/game/mon-shape.d.ts.map +1 -0
  257. package/dist/game/mon-shape.js +115 -0
  258. package/dist/game/mon-shape.js.map +1 -0
  259. package/dist/game/mon-side.d.ts +63 -0
  260. package/dist/game/mon-side.d.ts.map +1 -0
  261. package/dist/game/mon-side.js +403 -0
  262. package/dist/game/mon-side.js.map +1 -0
  263. package/dist/game/monster-turn.d.ts +195 -0
  264. package/dist/game/monster-turn.d.ts.map +1 -0
  265. package/dist/game/monster-turn.js +1560 -0
  266. package/dist/game/monster-turn.js.map +1 -0
  267. package/dist/game/obj-cmd.d.ts +453 -0
  268. package/dist/game/obj-cmd.d.ts.map +1 -0
  269. package/dist/game/obj-cmd.js +1530 -0
  270. package/dist/game/obj-cmd.js.map +1 -0
  271. package/dist/game/obj-list.d.ts +92 -0
  272. package/dist/game/obj-list.d.ts.map +1 -0
  273. package/dist/game/obj-list.js +251 -0
  274. package/dist/game/obj-list.js.map +1 -0
  275. package/dist/game/object-inspect.d.ts +37 -0
  276. package/dist/game/object-inspect.d.ts.map +1 -0
  277. package/dist/game/object-inspect.js +106 -0
  278. package/dist/game/object-inspect.js.map +1 -0
  279. package/dist/game/pickup.d.ts +126 -0
  280. package/dist/game/pickup.d.ts.map +1 -0
  281. package/dist/game/pickup.js +367 -0
  282. package/dist/game/pickup.js.map +1 -0
  283. package/dist/game/player-path.d.ts +133 -0
  284. package/dist/game/player-path.d.ts.map +1 -0
  285. package/dist/game/player-path.js +1268 -0
  286. package/dist/game/player-path.js.map +1 -0
  287. package/dist/game/player-side.d.ts +59 -0
  288. package/dist/game/player-side.d.ts.map +1 -0
  289. package/dist/game/player-side.js +506 -0
  290. package/dist/game/player-side.js.map +1 -0
  291. package/dist/game/player-turn.d.ts +161 -0
  292. package/dist/game/player-turn.d.ts.map +1 -0
  293. package/dist/game/player-turn.js +739 -0
  294. package/dist/game/player-turn.js.map +1 -0
  295. package/dist/game/project-cast.d.ts +268 -0
  296. package/dist/game/project-cast.d.ts.map +1 -0
  297. package/dist/game/project-cast.js +496 -0
  298. package/dist/game/project-cast.js.map +1 -0
  299. package/dist/game/project-feat.d.ts +47 -0
  300. package/dist/game/project-feat.d.ts.map +1 -0
  301. package/dist/game/project-feat.js +350 -0
  302. package/dist/game/project-feat.js.map +1 -0
  303. package/dist/game/project-monster.d.ts +106 -0
  304. package/dist/game/project-monster.d.ts.map +1 -0
  305. package/dist/game/project-monster.js +272 -0
  306. package/dist/game/project-monster.js.map +1 -0
  307. package/dist/game/project-obj.d.ts +60 -0
  308. package/dist/game/project-obj.d.ts.map +1 -0
  309. package/dist/game/project-obj.js +245 -0
  310. package/dist/game/project-obj.js.map +1 -0
  311. package/dist/game/project-player.d.ts +120 -0
  312. package/dist/game/project-player.d.ts.map +1 -0
  313. package/dist/game/project-player.js +108 -0
  314. package/dist/game/project-player.js.map +1 -0
  315. package/dist/game/quest.d.ts +101 -0
  316. package/dist/game/quest.d.ts.map +1 -0
  317. package/dist/game/quest.js +192 -0
  318. package/dist/game/quest.js.map +1 -0
  319. package/dist/game/ranged-cmd.d.ts +32 -0
  320. package/dist/game/ranged-cmd.d.ts.map +1 -0
  321. package/dist/game/ranged-cmd.js +372 -0
  322. package/dist/game/ranged-cmd.js.map +1 -0
  323. package/dist/game/scheduler.d.ts +47 -0
  324. package/dist/game/scheduler.d.ts.map +1 -0
  325. package/dist/game/scheduler.js +141 -0
  326. package/dist/game/scheduler.js.map +1 -0
  327. package/dist/game/spell-cmd.d.ts +104 -0
  328. package/dist/game/spell-cmd.d.ts.map +1 -0
  329. package/dist/game/spell-cmd.js +320 -0
  330. package/dist/game/spell-cmd.js.map +1 -0
  331. package/dist/game/spoil.d.ts +28 -0
  332. package/dist/game/spoil.d.ts.map +1 -0
  333. package/dist/game/spoil.js +435 -0
  334. package/dist/game/spoil.js.map +1 -0
  335. package/dist/game/steal.d.ts +35 -0
  336. package/dist/game/steal.d.ts.map +1 -0
  337. package/dist/game/steal.js +145 -0
  338. package/dist/game/steal.js.map +1 -0
  339. package/dist/game/take-hit-hooks.d.ts +52 -0
  340. package/dist/game/take-hit-hooks.d.ts.map +1 -0
  341. package/dist/game/take-hit-hooks.js +127 -0
  342. package/dist/game/take-hit-hooks.js.map +1 -0
  343. package/dist/game/target-loop.d.ts +119 -0
  344. package/dist/game/target-loop.d.ts.map +1 -0
  345. package/dist/game/target-loop.js +408 -0
  346. package/dist/game/target-loop.js.map +1 -0
  347. package/dist/game/target.d.ts +133 -0
  348. package/dist/game/target.d.ts.map +1 -0
  349. package/dist/game/target.js +353 -0
  350. package/dist/game/target.js.map +1 -0
  351. package/dist/game/thrust.d.ts +37 -0
  352. package/dist/game/thrust.d.ts.map +1 -0
  353. package/dist/game/thrust.js +155 -0
  354. package/dist/game/thrust.js.map +1 -0
  355. package/dist/game/trap.d.ts +218 -0
  356. package/dist/game/trap.d.ts.map +1 -0
  357. package/dist/game/trap.js +618 -0
  358. package/dist/game/trap.js.map +1 -0
  359. package/dist/game/ui-entry.d.ts +282 -0
  360. package/dist/game/ui-entry.d.ts.map +1 -0
  361. package/dist/game/ui-entry.js +1838 -0
  362. package/dist/game/ui-entry.js.map +1 -0
  363. package/dist/game/wizard.d.ts +654 -0
  364. package/dist/game/wizard.d.ts.map +1 -0
  365. package/dist/game/wizard.js +1323 -0
  366. package/dist/game/wizard.js.map +1 -0
  367. package/dist/game/world.d.ts +183 -0
  368. package/dist/game/world.d.ts.map +1 -0
  369. package/dist/game/world.js +685 -0
  370. package/dist/game/world.js.map +1 -0
  371. package/dist/gen/cave.d.ts +247 -0
  372. package/dist/gen/cave.d.ts.map +1 -0
  373. package/dist/gen/cave.js +2406 -0
  374. package/dist/gen/cave.js.map +1 -0
  375. package/dist/gen/gen-monster.d.ts +151 -0
  376. package/dist/gen/gen-monster.d.ts.map +1 -0
  377. package/dist/gen/gen-monster.js +473 -0
  378. package/dist/gen/gen-monster.js.map +1 -0
  379. package/dist/gen/generate.d.ts +240 -0
  380. package/dist/gen/generate.d.ts.map +1 -0
  381. package/dist/gen/generate.js +358 -0
  382. package/dist/gen/generate.js.map +1 -0
  383. package/dist/gen/room.d.ts +160 -0
  384. package/dist/gen/room.d.ts.map +1 -0
  385. package/dist/gen/room.js +1910 -0
  386. package/dist/gen/room.js.map +1 -0
  387. package/dist/gen/util.d.ts +466 -0
  388. package/dist/gen/util.d.ts.map +1 -0
  389. package/dist/gen/util.js +1553 -0
  390. package/dist/gen/util.js.map +1 -0
  391. package/dist/generated/dun-profiles.d.ts +44 -0
  392. package/dist/generated/dun-profiles.d.ts.map +1 -0
  393. package/dist/generated/dun-profiles.js +28 -0
  394. package/dist/generated/dun-profiles.js.map +1 -0
  395. package/dist/generated/effects.d.ts +1021 -0
  396. package/dist/generated/effects.d.ts.map +1 -0
  397. package/dist/generated/effects.js +239 -0
  398. package/dist/generated/effects.js.map +1 -0
  399. package/dist/generated/elements.d.ts +83 -0
  400. package/dist/generated/elements.d.ts.map +1 -0
  401. package/dist/generated/elements.js +60 -0
  402. package/dist/generated/elements.js.map +1 -0
  403. package/dist/generated/equip-slots.d.ts +104 -0
  404. package/dist/generated/equip-slots.d.ts.map +1 -0
  405. package/dist/generated/equip-slots.js +34 -0
  406. package/dist/generated/equip-slots.js.map +1 -0
  407. package/dist/generated/history-types.d.ts +52 -0
  408. package/dist/generated/history-types.d.ts.map +1 -0
  409. package/dist/generated/history-types.js +32 -0
  410. package/dist/generated/history-types.js.map +1 -0
  411. package/dist/generated/ignore-types.d.ts +116 -0
  412. package/dist/generated/ignore-types.d.ts.map +1 -0
  413. package/dist/generated/ignore-types.js +64 -0
  414. package/dist/generated/ignore-types.js.map +1 -0
  415. package/dist/generated/index.d.ts +32 -0
  416. package/dist/generated/index.d.ts.map +1 -0
  417. package/dist/generated/index.js +33 -0
  418. package/dist/generated/index.js.map +1 -0
  419. package/dist/generated/kind-flags.d.ts +72 -0
  420. package/dist/generated/kind-flags.d.ts.map +1 -0
  421. package/dist/generated/kind-flags.js +42 -0
  422. package/dist/generated/kind-flags.js.map +1 -0
  423. package/dist/generated/message.d.ts +624 -0
  424. package/dist/generated/message.d.ts.map +1 -0
  425. package/dist/generated/message.js +318 -0
  426. package/dist/generated/message.js.map +1 -0
  427. package/dist/generated/mon-message.d.ts +386 -0
  428. package/dist/generated/mon-message.d.ts.map +1 -0
  429. package/dist/generated/mon-message.js +136 -0
  430. package/dist/generated/mon-message.js.map +1 -0
  431. package/dist/generated/mon-race-flags.d.ts +433 -0
  432. package/dist/generated/mon-race-flags.d.ts.map +1 -0
  433. package/dist/generated/mon-race-flags.js +180 -0
  434. package/dist/generated/mon-race-flags.js.map +1 -0
  435. package/dist/generated/mon-spells.d.ts +380 -0
  436. package/dist/generated/mon-spells.d.ts.map +1 -0
  437. package/dist/generated/mon-spells.js +196 -0
  438. package/dist/generated/mon-spells.js.map +1 -0
  439. package/dist/generated/mon-temp-flags.d.ts +52 -0
  440. package/dist/generated/mon-temp-flags.d.ts.map +1 -0
  441. package/dist/generated/mon-temp-flags.js +32 -0
  442. package/dist/generated/mon-temp-flags.js.map +1 -0
  443. package/dist/generated/mon-timed.d.ts +118 -0
  444. package/dist/generated/mon-timed.d.ts.map +1 -0
  445. package/dist/generated/mon-timed.js +32 -0
  446. package/dist/generated/mon-timed.js.map +1 -0
  447. package/dist/generated/object-flags.d.ts +169 -0
  448. package/dist/generated/object-flags.d.ts.map +1 -0
  449. package/dist/generated/object-flags.js +93 -0
  450. package/dist/generated/object-flags.js.map +1 -0
  451. package/dist/generated/object-modifiers.d.ts +50 -0
  452. package/dist/generated/object-modifiers.d.ts.map +1 -0
  453. package/dist/generated/object-modifiers.js +41 -0
  454. package/dist/generated/object-modifiers.js.map +1 -0
  455. package/dist/generated/options.d.ts +284 -0
  456. package/dist/generated/options.d.ts.map +1 -0
  457. package/dist/generated/options.js +102 -0
  458. package/dist/generated/options.js.map +1 -0
  459. package/dist/generated/origins.d.ts +138 -0
  460. package/dist/generated/origins.d.ts.map +1 -0
  461. package/dist/generated/origins.js +62 -0
  462. package/dist/generated/origins.js.map +1 -0
  463. package/dist/generated/parser-errors.d.ts +264 -0
  464. package/dist/generated/parser-errors.d.ts.map +1 -0
  465. package/dist/generated/parser-errors.js +138 -0
  466. package/dist/generated/parser-errors.js.map +1 -0
  467. package/dist/generated/player-flags.d.ts +62 -0
  468. package/dist/generated/player-flags.d.ts.map +1 -0
  469. package/dist/generated/player-flags.js +46 -0
  470. package/dist/generated/player-flags.js.map +1 -0
  471. package/dist/generated/player-timed.d.ts +273 -0
  472. package/dist/generated/player-timed.d.ts.map +1 -0
  473. package/dist/generated/player-timed.js +116 -0
  474. package/dist/generated/player-timed.js.map +1 -0
  475. package/dist/generated/projections.d.ts +130 -0
  476. package/dist/generated/projections.d.ts.map +1 -0
  477. package/dist/generated/projections.js +101 -0
  478. package/dist/generated/projections.js.map +1 -0
  479. package/dist/generated/randart-properties.d.ts +388 -0
  480. package/dist/generated/randart-properties.d.ts.map +1 -0
  481. package/dist/generated/randart-properties.js +200 -0
  482. package/dist/generated/randart-properties.js.map +1 -0
  483. package/dist/generated/room-flags.d.ts +21 -0
  484. package/dist/generated/room-flags.d.ts.map +1 -0
  485. package/dist/generated/room-flags.js +19 -0
  486. package/dist/generated/room-flags.js.map +1 -0
  487. package/dist/generated/rooms.d.ts +122 -0
  488. package/dist/generated/rooms.d.ts.map +1 -0
  489. package/dist/generated/rooms.js +48 -0
  490. package/dist/generated/rooms.js.map +1 -0
  491. package/dist/generated/square-flags.d.ts +96 -0
  492. package/dist/generated/square-flags.d.ts.map +1 -0
  493. package/dist/generated/square-flags.js +54 -0
  494. package/dist/generated/square-flags.js.map +1 -0
  495. package/dist/generated/stats.d.ts +23 -0
  496. package/dist/generated/stats.d.ts.map +1 -0
  497. package/dist/generated/stats.js +20 -0
  498. package/dist/generated/stats.js.map +1 -0
  499. package/dist/generated/terrain-flags.d.ts +136 -0
  500. package/dist/generated/terrain-flags.d.ts.map +1 -0
  501. package/dist/generated/terrain-flags.js +74 -0
  502. package/dist/generated/terrain-flags.js.map +1 -0
  503. package/dist/generated/terrain.d.ts +83 -0
  504. package/dist/generated/terrain.d.ts.map +1 -0
  505. package/dist/generated/terrain.js +60 -0
  506. package/dist/generated/terrain.js.map +1 -0
  507. package/dist/generated/trap-flags.d.ts +68 -0
  508. package/dist/generated/trap-flags.d.ts.map +1 -0
  509. package/dist/generated/trap-flags.js +40 -0
  510. package/dist/generated/trap-flags.js.map +1 -0
  511. package/dist/generated/tvals.d.ts +152 -0
  512. package/dist/generated/tvals.d.ts.map +1 -0
  513. package/dist/generated/tvals.js +82 -0
  514. package/dist/generated/tvals.js.map +1 -0
  515. package/dist/generated/ui-entry-renderers.d.ts +62 -0
  516. package/dist/generated/ui-entry-renderers.d.ts.map +1 -0
  517. package/dist/generated/ui-entry-renderers.js +22 -0
  518. package/dist/generated/ui-entry-renderers.js.map +1 -0
  519. package/dist/guard.d.ts +43 -0
  520. package/dist/guard.d.ts.map +1 -0
  521. package/dist/guard.js +65 -0
  522. package/dist/guard.js.map +1 -0
  523. package/dist/host/args.d.ts +129 -0
  524. package/dist/host/args.d.ts.map +1 -0
  525. package/dist/host/args.js +251 -0
  526. package/dist/host/args.js.map +1 -0
  527. package/dist/host/bridge.d.ts +61 -0
  528. package/dist/host/bridge.d.ts.map +1 -0
  529. package/dist/host/bridge.js +176 -0
  530. package/dist/host/bridge.js.map +1 -0
  531. package/dist/host/index.d.ts +18 -0
  532. package/dist/host/index.d.ts.map +1 -0
  533. package/dist/host/index.js +18 -0
  534. package/dist/host/index.js.map +1 -0
  535. package/dist/host/io.d.ts +169 -0
  536. package/dist/host/io.d.ts.map +1 -0
  537. package/dist/host/io.js +137 -0
  538. package/dist/host/io.js.map +1 -0
  539. package/dist/host/memory.d.ts +56 -0
  540. package/dist/host/memory.d.ts.map +1 -0
  541. package/dist/host/memory.js +105 -0
  542. package/dist/host/memory.js.map +1 -0
  543. package/dist/host/raw.d.ts +114 -0
  544. package/dist/host/raw.d.ts.map +1 -0
  545. package/dist/host/raw.js +107 -0
  546. package/dist/host/raw.js.map +1 -0
  547. package/dist/index.d.ts +180 -0
  548. package/dist/index.d.ts.map +1 -0
  549. package/dist/index.js +222 -0
  550. package/dist/index.js.map +1 -0
  551. package/dist/loc.d.ts +63 -0
  552. package/dist/loc.d.ts.map +1 -0
  553. package/dist/loc.js +128 -0
  554. package/dist/loc.js.map +1 -0
  555. package/dist/mod/hooks.d.ts +204 -0
  556. package/dist/mod/hooks.d.ts.map +1 -0
  557. package/dist/mod/hooks.js +161 -0
  558. package/dist/mod/hooks.js.map +1 -0
  559. package/dist/mod/ids.d.ts +160 -0
  560. package/dist/mod/ids.d.ts.map +1 -0
  561. package/dist/mod/ids.js +343 -0
  562. package/dist/mod/ids.js.map +1 -0
  563. package/dist/mod/registry-host.d.ts +156 -0
  564. package/dist/mod/registry-host.d.ts.map +1 -0
  565. package/dist/mod/registry-host.js +142 -0
  566. package/dist/mod/registry-host.js.map +1 -0
  567. package/dist/mod/save-blocks.d.ts +201 -0
  568. package/dist/mod/save-blocks.d.ts.map +1 -0
  569. package/dist/mod/save-blocks.js +640 -0
  570. package/dist/mod/save-blocks.js.map +1 -0
  571. package/dist/mod/vocabulary.d.ts +104 -0
  572. package/dist/mod/vocabulary.d.ts.map +1 -0
  573. package/dist/mod/vocabulary.js +0 -0
  574. package/dist/mod/vocabulary.js.map +1 -0
  575. package/dist/mon/bind.d.ts +266 -0
  576. package/dist/mon/bind.d.ts.map +1 -0
  577. package/dist/mon/bind.js +610 -0
  578. package/dist/mon/bind.js.map +1 -0
  579. package/dist/mon/desc.d.ts +72 -0
  580. package/dist/mon/desc.d.ts.map +1 -0
  581. package/dist/mon/desc.js +237 -0
  582. package/dist/mon/desc.js.map +1 -0
  583. package/dist/mon/knowledge-groups.d.ts +61 -0
  584. package/dist/mon/knowledge-groups.d.ts.map +1 -0
  585. package/dist/mon/knowledge-groups.js +121 -0
  586. package/dist/mon/knowledge-groups.js.map +1 -0
  587. package/dist/mon/lore-describe.d.ts +216 -0
  588. package/dist/mon/lore-describe.d.ts.map +1 -0
  589. package/dist/mon/lore-describe.js +1105 -0
  590. package/dist/mon/lore-describe.js.map +1 -0
  591. package/dist/mon/lore.d.ts +117 -0
  592. package/dist/mon/lore.d.ts.map +1 -0
  593. package/dist/mon/lore.js +221 -0
  594. package/dist/mon/lore.js.map +1 -0
  595. package/dist/mon/make.d.ts +147 -0
  596. package/dist/mon/make.d.ts.map +1 -0
  597. package/dist/mon/make.js +353 -0
  598. package/dist/mon/make.js.map +1 -0
  599. package/dist/mon/monster.d.ts +94 -0
  600. package/dist/mon/monster.d.ts.map +1 -0
  601. package/dist/mon/monster.js +90 -0
  602. package/dist/mon/monster.js.map +1 -0
  603. package/dist/mon/predicate.d.ts +87 -0
  604. package/dist/mon/predicate.d.ts.map +1 -0
  605. package/dist/mon/predicate.js +190 -0
  606. package/dist/mon/predicate.js.map +1 -0
  607. package/dist/mon/project-mon.d.ts +129 -0
  608. package/dist/mon/project-mon.d.ts.map +1 -0
  609. package/dist/mon/project-mon.js +652 -0
  610. package/dist/mon/project-mon.js.map +1 -0
  611. package/dist/mon/spell.d.ts +155 -0
  612. package/dist/mon/spell.d.ts.map +1 -0
  613. package/dist/mon/spell.js +355 -0
  614. package/dist/mon/spell.js.map +1 -0
  615. package/dist/mon/steal.d.ts +112 -0
  616. package/dist/mon/steal.d.ts.map +1 -0
  617. package/dist/mon/steal.js +163 -0
  618. package/dist/mon/steal.js.map +1 -0
  619. package/dist/mon/summon.d.ts +62 -0
  620. package/dist/mon/summon.d.ts.map +1 -0
  621. package/dist/mon/summon.js +111 -0
  622. package/dist/mon/summon.js.map +1 -0
  623. package/dist/mon/take-hit.d.ts +75 -0
  624. package/dist/mon/take-hit.d.ts.map +1 -0
  625. package/dist/mon/take-hit.js +122 -0
  626. package/dist/mon/take-hit.js.map +1 -0
  627. package/dist/mon/timed.d.ts +74 -0
  628. package/dist/mon/timed.d.ts.map +1 -0
  629. package/dist/mon/timed.js +219 -0
  630. package/dist/mon/timed.js.map +1 -0
  631. package/dist/mon/types.d.ts +252 -0
  632. package/dist/mon/types.d.ts.map +1 -0
  633. package/dist/mon/types.js +46 -0
  634. package/dist/mon/types.js.map +1 -0
  635. package/dist/msg.d.ts +71 -0
  636. package/dist/msg.d.ts.map +1 -0
  637. package/dist/msg.js +126 -0
  638. package/dist/msg.js.map +1 -0
  639. package/dist/obj/artifact-fake.d.ts +39 -0
  640. package/dist/obj/artifact-fake.d.ts.map +1 -0
  641. package/dist/obj/artifact-fake.js +52 -0
  642. package/dist/obj/artifact-fake.js.map +1 -0
  643. package/dist/obj/artifact-known.d.ts +50 -0
  644. package/dist/obj/artifact-known.d.ts.map +1 -0
  645. package/dist/obj/artifact-known.js +55 -0
  646. package/dist/obj/artifact-known.js.map +1 -0
  647. package/dist/obj/bind.d.ts +219 -0
  648. package/dist/obj/bind.d.ts.map +1 -0
  649. package/dist/obj/bind.js +1239 -0
  650. package/dist/obj/bind.js.map +1 -0
  651. package/dist/obj/chest.d.ts +91 -0
  652. package/dist/obj/chest.d.ts.map +1 -0
  653. package/dist/obj/chest.js +220 -0
  654. package/dist/obj/chest.js.map +1 -0
  655. package/dist/obj/desc.d.ts +79 -0
  656. package/dist/obj/desc.d.ts.map +1 -0
  657. package/dist/obj/desc.js +602 -0
  658. package/dist/obj/desc.js.map +1 -0
  659. package/dist/obj/effects-info.d.ts +78 -0
  660. package/dist/obj/effects-info.d.ts.map +1 -0
  661. package/dist/obj/effects-info.js +240 -0
  662. package/dist/obj/effects-info.js.map +1 -0
  663. package/dist/obj/flavor.d.ts +68 -0
  664. package/dist/obj/flavor.d.ts.map +1 -0
  665. package/dist/obj/flavor.js +201 -0
  666. package/dist/obj/flavor.js.map +1 -0
  667. package/dist/obj/ignore.d.ts +143 -0
  668. package/dist/obj/ignore.d.ts.map +1 -0
  669. package/dist/obj/ignore.js +345 -0
  670. package/dist/obj/ignore.js.map +1 -0
  671. package/dist/obj/knowledge.d.ts +520 -0
  672. package/dist/obj/knowledge.d.ts.map +1 -0
  673. package/dist/obj/knowledge.js +1364 -0
  674. package/dist/obj/knowledge.js.map +1 -0
  675. package/dist/obj/known-object.d.ts +293 -0
  676. package/dist/obj/known-object.d.ts.map +1 -0
  677. package/dist/obj/known-object.js +532 -0
  678. package/dist/obj/known-object.js.map +1 -0
  679. package/dist/obj/make.d.ts +292 -0
  680. package/dist/obj/make.d.ts.map +1 -0
  681. package/dist/obj/make.js +1055 -0
  682. package/dist/obj/make.js.map +1 -0
  683. package/dist/obj/object-info.d.ts +188 -0
  684. package/dist/obj/object-info.d.ts.map +1 -0
  685. package/dist/obj/object-info.js +1407 -0
  686. package/dist/obj/object-info.js.map +1 -0
  687. package/dist/obj/object.d.ts +335 -0
  688. package/dist/obj/object.d.ts.map +1 -0
  689. package/dist/obj/object.js +1051 -0
  690. package/dist/obj/object.js.map +1 -0
  691. package/dist/obj/power.d.ts +65 -0
  692. package/dist/obj/power.d.ts.map +1 -0
  693. package/dist/obj/power.js +580 -0
  694. package/dist/obj/power.js.map +1 -0
  695. package/dist/obj/randart-build.d.ts +223 -0
  696. package/dist/obj/randart-build.d.ts.map +1 -0
  697. package/dist/obj/randart-build.js +1444 -0
  698. package/dist/obj/randart-build.js.map +1 -0
  699. package/dist/obj/randart-data.d.ts +179 -0
  700. package/dist/obj/randart-data.d.ts.map +1 -0
  701. package/dist/obj/randart-data.js +1153 -0
  702. package/dist/obj/randart-data.js.map +1 -0
  703. package/dist/obj/randart.d.ts +128 -0
  704. package/dist/obj/randart.d.ts.map +1 -0
  705. package/dist/obj/randart.js +458 -0
  706. package/dist/obj/randart.js.map +1 -0
  707. package/dist/obj/randname.d.ts +33 -0
  708. package/dist/obj/randname.d.ts.map +1 -0
  709. package/dist/obj/randname.js +116 -0
  710. package/dist/obj/randname.js.map +1 -0
  711. package/dist/obj/recharge.d.ts +28 -0
  712. package/dist/obj/recharge.d.ts.map +1 -0
  713. package/dist/obj/recharge.js +52 -0
  714. package/dist/obj/recharge.js.map +1 -0
  715. package/dist/obj/types.d.ts +584 -0
  716. package/dist/obj/types.d.ts.map +1 -0
  717. package/dist/obj/types.js +104 -0
  718. package/dist/obj/types.js.map +1 -0
  719. package/dist/obj/value.d.ts +64 -0
  720. package/dist/obj/value.d.ts.map +1 -0
  721. package/dist/obj/value.js +176 -0
  722. package/dist/obj/value.js.map +1 -0
  723. package/dist/player/abilities.d.ts +57 -0
  724. package/dist/player/abilities.d.ts.map +1 -0
  725. package/dist/player/abilities.js +118 -0
  726. package/dist/player/abilities.js.map +1 -0
  727. package/dist/player/best-digger.d.ts +42 -0
  728. package/dist/player/best-digger.d.ts.map +1 -0
  729. package/dist/player/best-digger.js +89 -0
  730. package/dist/player/best-digger.js.map +1 -0
  731. package/dist/player/bind.d.ts +270 -0
  732. package/dist/player/bind.d.ts.map +1 -0
  733. package/dist/player/bind.js +698 -0
  734. package/dist/player/bind.js.map +1 -0
  735. package/dist/player/birth.d.ts +258 -0
  736. package/dist/player/birth.d.ts.map +1 -0
  737. package/dist/player/birth.js +639 -0
  738. package/dist/player/birth.js.map +1 -0
  739. package/dist/player/calcs.d.ts +403 -0
  740. package/dist/player/calcs.d.ts.map +1 -0
  741. package/dist/player/calcs.js +1189 -0
  742. package/dist/player/calcs.js.map +1 -0
  743. package/dist/player/combat-regen.d.ts +14 -0
  744. package/dist/player/combat-regen.d.ts.map +1 -0
  745. package/dist/player/combat-regen.js +29 -0
  746. package/dist/player/combat-regen.js.map +1 -0
  747. package/dist/player/exp.d.ts +96 -0
  748. package/dist/player/exp.d.ts.map +1 -0
  749. package/dist/player/exp.js +229 -0
  750. package/dist/player/exp.js.map +1 -0
  751. package/dist/player/history.d.ts +91 -0
  752. package/dist/player/history.d.ts.map +1 -0
  753. package/dist/player/history.js +145 -0
  754. package/dist/player/history.js.map +1 -0
  755. package/dist/player/options.d.ts +123 -0
  756. package/dist/player/options.d.ts.map +1 -0
  757. package/dist/player/options.js +199 -0
  758. package/dist/player/options.js.map +1 -0
  759. package/dist/player/player.d.ts +242 -0
  760. package/dist/player/player.d.ts.map +1 -0
  761. package/dist/player/player.js +119 -0
  762. package/dist/player/player.js.map +1 -0
  763. package/dist/player/shape-lore.d.ts +56 -0
  764. package/dist/player/shape-lore.d.ts.map +1 -0
  765. package/dist/player/shape-lore.js +221 -0
  766. package/dist/player/shape-lore.js.map +1 -0
  767. package/dist/player/spell.d.ts +146 -0
  768. package/dist/player/spell.d.ts.map +1 -0
  769. package/dist/player/spell.js +519 -0
  770. package/dist/player/spell.js.map +1 -0
  771. package/dist/player/take-hit.d.ts +87 -0
  772. package/dist/player/take-hit.d.ts.map +1 -0
  773. package/dist/player/take-hit.js +99 -0
  774. package/dist/player/take-hit.js.map +1 -0
  775. package/dist/player/timed.d.ts +205 -0
  776. package/dist/player/timed.d.ts.map +1 -0
  777. package/dist/player/timed.js +310 -0
  778. package/dist/player/timed.js.map +1 -0
  779. package/dist/player/types.d.ts +390 -0
  780. package/dist/player/types.d.ts.map +1 -0
  781. package/dist/player/types.js +51 -0
  782. package/dist/player/types.js.map +1 -0
  783. package/dist/rational.d.ts +99 -0
  784. package/dist/rational.d.ts.map +1 -0
  785. package/dist/rational.js +345 -0
  786. package/dist/rational.js.map +1 -0
  787. package/dist/rng.d.ts +168 -0
  788. package/dist/rng.d.ts.map +1 -0
  789. package/dist/rng.js +404 -0
  790. package/dist/rng.js.map +1 -0
  791. package/dist/save/buffer.d.ts +120 -0
  792. package/dist/save/buffer.d.ts.map +1 -0
  793. package/dist/save/buffer.js +238 -0
  794. package/dist/save/buffer.js.map +1 -0
  795. package/dist/save/compress.d.ts +79 -0
  796. package/dist/save/compress.d.ts.map +1 -0
  797. package/dist/save/compress.js +97 -0
  798. package/dist/save/compress.js.map +1 -0
  799. package/dist/save/description.d.ts +61 -0
  800. package/dist/save/description.d.ts.map +1 -0
  801. package/dist/save/description.js +51 -0
  802. package/dist/save/description.js.map +1 -0
  803. package/dist/save/integrity.d.ts +59 -0
  804. package/dist/save/integrity.d.ts.map +1 -0
  805. package/dist/save/integrity.js +103 -0
  806. package/dist/save/integrity.js.map +1 -0
  807. package/dist/score/display.d.ts +40 -0
  808. package/dist/score/display.d.ts.map +1 -0
  809. package/dist/score/display.js +86 -0
  810. package/dist/score/display.js.map +1 -0
  811. package/dist/score/score.d.ts +166 -0
  812. package/dist/score/score.d.ts.map +1 -0
  813. package/dist/score/score.js +244 -0
  814. package/dist/score/score.js.map +1 -0
  815. package/dist/score/types.d.ts +98 -0
  816. package/dist/score/types.d.ts.map +1 -0
  817. package/dist/score/types.js +27 -0
  818. package/dist/score/types.js.map +1 -0
  819. package/dist/session/boot.d.ts +207 -0
  820. package/dist/session/boot.d.ts.map +1 -0
  821. package/dist/session/boot.js +151 -0
  822. package/dist/session/boot.js.map +1 -0
  823. package/dist/session/game.d.ts +257 -0
  824. package/dist/session/game.d.ts.map +1 -0
  825. package/dist/session/game.js +2880 -0
  826. package/dist/session/game.js.map +1 -0
  827. package/dist/session/save.d.ts +847 -0
  828. package/dist/session/save.d.ts.map +1 -0
  829. package/dist/session/save.js +1306 -0
  830. package/dist/session/save.js.map +1 -0
  831. package/dist/sound/engine.d.ts +146 -0
  832. package/dist/sound/engine.d.ts.map +1 -0
  833. package/dist/sound/engine.js +332 -0
  834. package/dist/sound/engine.js.map +1 -0
  835. package/dist/sound/index.d.ts +13 -0
  836. package/dist/sound/index.d.ts.map +1 -0
  837. package/dist/sound/index.js +13 -0
  838. package/dist/sound/index.js.map +1 -0
  839. package/dist/sound/sound-prefs-data.d.ts +10 -0
  840. package/dist/sound/sound-prefs-data.d.ts.map +1 -0
  841. package/dist/sound/sound-prefs-data.js +165 -0
  842. package/dist/sound/sound-prefs-data.js.map +1 -0
  843. package/dist/sound/types.d.ts +64 -0
  844. package/dist/sound/types.d.ts.map +1 -0
  845. package/dist/sound/types.js +23 -0
  846. package/dist/sound/types.js.map +1 -0
  847. package/dist/store/bind.d.ts +43 -0
  848. package/dist/store/bind.d.ts.map +1 -0
  849. package/dist/store/bind.js +130 -0
  850. package/dist/store/bind.js.map +1 -0
  851. package/dist/store/price.d.ts +27 -0
  852. package/dist/store/price.d.ts.map +1 -0
  853. package/dist/store/price.js +81 -0
  854. package/dist/store/price.js.map +1 -0
  855. package/dist/store/store-cmd.d.ts +51 -0
  856. package/dist/store/store-cmd.d.ts.map +1 -0
  857. package/dist/store/store-cmd.js +73 -0
  858. package/dist/store/store-cmd.js.map +1 -0
  859. package/dist/store/store.d.ts +156 -0
  860. package/dist/store/store.d.ts.map +1 -0
  861. package/dist/store/store.js +616 -0
  862. package/dist/store/store.js.map +1 -0
  863. package/dist/store/transact.d.ts +198 -0
  864. package/dist/store/transact.d.ts.map +1 -0
  865. package/dist/store/transact.js +383 -0
  866. package/dist/store/transact.js.map +1 -0
  867. package/dist/store/types.d.ts +101 -0
  868. package/dist/store/types.d.ts.map +1 -0
  869. package/dist/store/types.js +14 -0
  870. package/dist/store/types.js.map +1 -0
  871. package/dist/version.d.ts +25 -0
  872. package/dist/version.d.ts.map +1 -0
  873. package/dist/version.js +25 -0
  874. package/dist/version.js.map +1 -0
  875. package/dist/visuals/engine.d.ts +223 -0
  876. package/dist/visuals/engine.d.ts.map +1 -0
  877. package/dist/visuals/engine.js +357 -0
  878. package/dist/visuals/engine.js.map +1 -0
  879. package/dist/visuals/glyph-table.d.ts +112 -0
  880. package/dist/visuals/glyph-table.d.ts.map +1 -0
  881. package/dist/visuals/glyph-table.js +156 -0
  882. package/dist/visuals/glyph-table.js.map +1 -0
  883. package/dist/visuals/grafmode-data.d.ts +4 -0
  884. package/dist/visuals/grafmode-data.d.ts.map +1 -0
  885. package/dist/visuals/grafmode-data.js +88 -0
  886. package/dist/visuals/grafmode-data.js.map +1 -0
  887. package/dist/visuals/grafmode.d.ts +83 -0
  888. package/dist/visuals/grafmode.d.ts.map +1 -0
  889. package/dist/visuals/grafmode.js +82 -0
  890. package/dist/visuals/grafmode.js.map +1 -0
  891. package/dist/visuals/index.d.ts +19 -0
  892. package/dist/visuals/index.d.ts.map +1 -0
  893. package/dist/visuals/index.js +19 -0
  894. package/dist/visuals/index.js.map +1 -0
  895. package/dist/visuals/map-text.d.ts +79 -0
  896. package/dist/visuals/map-text.d.ts.map +1 -0
  897. package/dist/visuals/map-text.js +122 -0
  898. package/dist/visuals/map-text.js.map +1 -0
  899. package/dist/visuals/pref-expr.d.ts +56 -0
  900. package/dist/visuals/pref-expr.d.ts.map +1 -0
  901. package/dist/visuals/pref-expr.js +173 -0
  902. package/dist/visuals/pref-expr.js.map +1 -0
  903. package/dist/visuals/prefs.d.ts +280 -0
  904. package/dist/visuals/prefs.d.ts.map +1 -0
  905. package/dist/visuals/prefs.js +835 -0
  906. package/dist/visuals/prefs.js.map +1 -0
  907. package/dist/visuals/tile-prefs.d.ts +132 -0
  908. package/dist/visuals/tile-prefs.d.ts.map +1 -0
  909. package/dist/visuals/tile-prefs.js +105 -0
  910. package/dist/visuals/tile-prefs.js.map +1 -0
  911. package/dist/world/chunk.d.ts +195 -0
  912. package/dist/world/chunk.d.ts.map +1 -0
  913. package/dist/world/chunk.js +422 -0
  914. package/dist/world/chunk.js.map +1 -0
  915. package/dist/world/feature.d.ts +86 -0
  916. package/dist/world/feature.d.ts.map +1 -0
  917. package/dist/world/feature.js +153 -0
  918. package/dist/world/feature.js.map +1 -0
  919. package/dist/world/flow.d.ts +33 -0
  920. package/dist/world/flow.d.ts.map +1 -0
  921. package/dist/world/flow.js +115 -0
  922. package/dist/world/flow.js.map +1 -0
  923. package/dist/world/project.d.ts +176 -0
  924. package/dist/world/project.d.ts.map +1 -0
  925. package/dist/world/project.js +543 -0
  926. package/dist/world/project.js.map +1 -0
  927. package/dist/world/projection.d.ts +100 -0
  928. package/dist/world/projection.d.ts.map +1 -0
  929. package/dist/world/projection.js +152 -0
  930. package/dist/world/projection.js.map +1 -0
  931. package/dist/world/scatter.d.ts +25 -0
  932. package/dist/world/scatter.d.ts.map +1 -0
  933. package/dist/world/scatter.js +54 -0
  934. package/dist/world/scatter.js.map +1 -0
  935. package/dist/world/trap.d.ts +84 -0
  936. package/dist/world/trap.d.ts.map +1 -0
  937. package/dist/world/trap.js +106 -0
  938. package/dist/world/trap.js.map +1 -0
  939. package/dist/world/view.d.ts +60 -0
  940. package/dist/world/view.d.ts.map +1 -0
  941. package/dist/world/view.js +436 -0
  942. package/dist/world/view.js.map +1 -0
  943. package/dist/z-queue.d.ts +133 -0
  944. package/dist/z-queue.d.ts.map +1 -0
  945. package/dist/z-queue.js +283 -0
  946. package/dist/z-queue.js.map +1 -0
  947. package/package.json +75 -0
  948. package/src/agent/act.ts +114 -0
  949. package/src/agent/controller.ts +109 -0
  950. package/src/agent/events.ts +47 -0
  951. package/src/agent/index.ts +36 -0
  952. package/src/agent/perceive.ts +440 -0
  953. package/src/agent/types.ts +464 -0
  954. package/src/bitflag.ts +536 -0
  955. package/src/cmd.ts +547 -0
  956. package/src/color.ts +267 -0
  957. package/src/combat/brand-slay.ts +360 -0
  958. package/src/combat/hit.ts +471 -0
  959. package/src/combat/index.ts +15 -0
  960. package/src/combat/melee.ts +728 -0
  961. package/src/combat/mon-melee.ts +1153 -0
  962. package/src/combat/ranged.ts +397 -0
  963. package/src/constants.ts +324 -0
  964. package/src/dice.ts +467 -0
  965. package/src/effects/effect-choice.ts +32 -0
  966. package/src/effects/effect-info.ts +859 -0
  967. package/src/effects/effect.ts +560 -0
  968. package/src/effects/handlers.ts +452 -0
  969. package/src/effects/interpreter.ts +603 -0
  970. package/src/events.ts +317 -0
  971. package/src/expression.ts +360 -0
  972. package/src/game/cave-cmd.ts +1147 -0
  973. package/src/game/char-sheet.ts +557 -0
  974. package/src/game/chest.ts +348 -0
  975. package/src/game/context.ts +1218 -0
  976. package/src/game/curse-tick.ts +130 -0
  977. package/src/game/describe.ts +62 -0
  978. package/src/game/display.ts +838 -0
  979. package/src/game/dump-level.ts +114 -0
  980. package/src/game/effect-attack.ts +746 -0
  981. package/src/game/effect-detect.ts +542 -0
  982. package/src/game/effect-env.ts +252 -0
  983. package/src/game/effect-game-env.ts +86 -0
  984. package/src/game/effect-general.ts +1122 -0
  985. package/src/game/effect-item.ts +999 -0
  986. package/src/game/effect-melee.ts +557 -0
  987. package/src/game/effect-mon-origin.ts +196 -0
  988. package/src/game/effect-monster.ts +310 -0
  989. package/src/game/effect-summon.ts +161 -0
  990. package/src/game/effect-teleport.ts +645 -0
  991. package/src/game/effect-terrain.ts +881 -0
  992. package/src/game/energy.ts +61 -0
  993. package/src/game/equip-cmp.ts +476 -0
  994. package/src/game/floor.ts +524 -0
  995. package/src/game/gear.ts +1352 -0
  996. package/src/game/harness.ts +270 -0
  997. package/src/game/history.ts +78 -0
  998. package/src/game/ignore-cmd.ts +68 -0
  999. package/src/game/inscription-confirm.ts +115 -0
  1000. package/src/game/known.ts +960 -0
  1001. package/src/game/loop.ts +671 -0
  1002. package/src/game/lore-color.ts +108 -0
  1003. package/src/game/mon-cast.ts +409 -0
  1004. package/src/game/mon-cmd.ts +767 -0
  1005. package/src/game/mon-death.ts +459 -0
  1006. package/src/game/mon-group.ts +368 -0
  1007. package/src/game/mon-list.ts +213 -0
  1008. package/src/game/mon-message.ts +359 -0
  1009. package/src/game/mon-place.ts +1012 -0
  1010. package/src/game/mon-ranged.ts +405 -0
  1011. package/src/game/mon-shape.ts +161 -0
  1012. package/src/game/mon-side.ts +511 -0
  1013. package/src/game/monster-turn.ts +1750 -0
  1014. package/src/game/obj-cmd.ts +1970 -0
  1015. package/src/game/obj-list.ts +302 -0
  1016. package/src/game/object-inspect.ts +162 -0
  1017. package/src/game/pickup.ts +483 -0
  1018. package/src/game/player-path.ts +1434 -0
  1019. package/src/game/player-side.ts +555 -0
  1020. package/src/game/player-turn.ts +852 -0
  1021. package/src/game/project-cast.ts +766 -0
  1022. package/src/game/project-feat.ts +386 -0
  1023. package/src/game/project-monster.ts +407 -0
  1024. package/src/game/project-obj.ts +298 -0
  1025. package/src/game/project-player.ts +236 -0
  1026. package/src/game/quest.ts +248 -0
  1027. package/src/game/ranged-cmd.ts +417 -0
  1028. package/src/game/scheduler.ts +150 -0
  1029. package/src/game/spell-cmd.ts +404 -0
  1030. package/src/game/spoil.ts +562 -0
  1031. package/src/game/steal.ts +169 -0
  1032. package/src/game/take-hit-hooks.ts +152 -0
  1033. package/src/game/target-loop.ts +501 -0
  1034. package/src/game/target.ts +424 -0
  1035. package/src/game/thrust.ts +174 -0
  1036. package/src/game/trap.ts +791 -0
  1037. package/src/game/ui-entry.ts +2075 -0
  1038. package/src/game/wizard.ts +1760 -0
  1039. package/src/game/world.ts +786 -0
  1040. package/src/gen/cave.ts +2858 -0
  1041. package/src/gen/gen-monster.ts +592 -0
  1042. package/src/gen/generate.ts +523 -0
  1043. package/src/gen/room.ts +2213 -0
  1044. package/src/gen/util.ts +1958 -0
  1045. package/src/generated/dun-profiles.ts +30 -0
  1046. package/src/generated/effects.ts +241 -0
  1047. package/src/generated/elements.ts +62 -0
  1048. package/src/generated/equip-slots.ts +36 -0
  1049. package/src/generated/history-types.ts +34 -0
  1050. package/src/generated/ignore-types.ts +66 -0
  1051. package/src/generated/index.ts +33 -0
  1052. package/src/generated/kind-flags.ts +44 -0
  1053. package/src/generated/message.ts +320 -0
  1054. package/src/generated/mon-message.ts +138 -0
  1055. package/src/generated/mon-race-flags.ts +182 -0
  1056. package/src/generated/mon-spells.ts +198 -0
  1057. package/src/generated/mon-temp-flags.ts +34 -0
  1058. package/src/generated/mon-timed.ts +34 -0
  1059. package/src/generated/object-flags.ts +95 -0
  1060. package/src/generated/object-modifiers.ts +43 -0
  1061. package/src/generated/options.ts +104 -0
  1062. package/src/generated/origins.ts +64 -0
  1063. package/src/generated/parser-errors.ts +140 -0
  1064. package/src/generated/player-flags.ts +48 -0
  1065. package/src/generated/player-timed.ts +118 -0
  1066. package/src/generated/projections.ts +103 -0
  1067. package/src/generated/randart-properties.ts +202 -0
  1068. package/src/generated/room-flags.ts +21 -0
  1069. package/src/generated/rooms.ts +50 -0
  1070. package/src/generated/square-flags.ts +56 -0
  1071. package/src/generated/stats.ts +22 -0
  1072. package/src/generated/terrain-flags.ts +76 -0
  1073. package/src/generated/terrain.ts +62 -0
  1074. package/src/generated/trap-flags.ts +42 -0
  1075. package/src/generated/tvals.ts +84 -0
  1076. package/src/generated/ui-entry-renderers.ts +24 -0
  1077. package/src/guard.ts +70 -0
  1078. package/src/host/args.ts +334 -0
  1079. package/src/host/bridge.ts +193 -0
  1080. package/src/host/index.ts +18 -0
  1081. package/src/host/io.ts +239 -0
  1082. package/src/host/memory.ts +134 -0
  1083. package/src/host/raw.ts +190 -0
  1084. package/src/index.ts +250 -0
  1085. package/src/loc.ts +157 -0
  1086. package/src/mod/hooks.ts +278 -0
  1087. package/src/mod/ids.ts +390 -0
  1088. package/src/mod/registry-host.ts +258 -0
  1089. package/src/mod/save-blocks.ts +787 -0
  1090. package/src/mod/vocabulary.ts +0 -0
  1091. package/src/mon/bind.ts +899 -0
  1092. package/src/mon/desc.ts +212 -0
  1093. package/src/mon/knowledge-groups.ts +164 -0
  1094. package/src/mon/lore-describe.ts +1414 -0
  1095. package/src/mon/lore.ts +306 -0
  1096. package/src/mon/make.ts +422 -0
  1097. package/src/mon/monster.ts +161 -0
  1098. package/src/mon/predicate.ts +220 -0
  1099. package/src/mon/project-mon.ts +855 -0
  1100. package/src/mon/spell.ts +418 -0
  1101. package/src/mon/steal.ts +246 -0
  1102. package/src/mon/summon.ts +145 -0
  1103. package/src/mon/take-hit.ts +195 -0
  1104. package/src/mon/timed.ts +300 -0
  1105. package/src/mon/types.ts +286 -0
  1106. package/src/msg.ts +146 -0
  1107. package/src/obj/artifact-fake.ts +63 -0
  1108. package/src/obj/artifact-known.ts +69 -0
  1109. package/src/obj/bind.ts +1345 -0
  1110. package/src/obj/chest.ts +249 -0
  1111. package/src/obj/desc.ts +699 -0
  1112. package/src/obj/effects-info.ts +349 -0
  1113. package/src/obj/flavor.ts +256 -0
  1114. package/src/obj/ignore.ts +387 -0
  1115. package/src/obj/knowledge.ts +1577 -0
  1116. package/src/obj/known-object.ts +718 -0
  1117. package/src/obj/make.ts +1367 -0
  1118. package/src/obj/object-info.ts +1737 -0
  1119. package/src/obj/object.ts +1296 -0
  1120. package/src/obj/power.ts +674 -0
  1121. package/src/obj/randart-build.ts +1705 -0
  1122. package/src/obj/randart-data.ts +1344 -0
  1123. package/src/obj/randart.ts +552 -0
  1124. package/src/obj/randname.ts +128 -0
  1125. package/src/obj/recharge.ts +62 -0
  1126. package/src/obj/types.ts +559 -0
  1127. package/src/obj/value.ts +215 -0
  1128. package/src/player/abilities.ts +142 -0
  1129. package/src/player/best-digger.ts +118 -0
  1130. package/src/player/bind.ts +1021 -0
  1131. package/src/player/birth.ts +794 -0
  1132. package/src/player/calcs.ts +1522 -0
  1133. package/src/player/combat-regen.ts +33 -0
  1134. package/src/player/exp.ts +275 -0
  1135. package/src/player/history.ts +211 -0
  1136. package/src/player/options.ts +244 -0
  1137. package/src/player/player.ts +356 -0
  1138. package/src/player/shape-lore.ts +250 -0
  1139. package/src/player/spell.ts +627 -0
  1140. package/src/player/take-hit.ts +173 -0
  1141. package/src/player/timed.ts +482 -0
  1142. package/src/player/types.ts +415 -0
  1143. package/src/rational.ts +388 -0
  1144. package/src/rng.ts +476 -0
  1145. package/src/save/buffer.ts +287 -0
  1146. package/src/save/compress.ts +132 -0
  1147. package/src/save/description.ts +70 -0
  1148. package/src/save/integrity.ts +133 -0
  1149. package/src/score/display.ts +125 -0
  1150. package/src/score/score.ts +341 -0
  1151. package/src/score/types.ts +104 -0
  1152. package/src/session/boot.ts +338 -0
  1153. package/src/session/game.ts +3712 -0
  1154. package/src/session/save.ts +2074 -0
  1155. package/src/sound/engine.ts +375 -0
  1156. package/src/sound/index.ts +13 -0
  1157. package/src/sound/sound-prefs-data.ts +173 -0
  1158. package/src/sound/types.ts +68 -0
  1159. package/src/store/bind.ts +145 -0
  1160. package/src/store/price.ts +97 -0
  1161. package/src/store/store-cmd.ts +73 -0
  1162. package/src/store/store.ts +723 -0
  1163. package/src/store/transact.ts +644 -0
  1164. package/src/store/types.ts +110 -0
  1165. package/src/version.ts +26 -0
  1166. package/src/visuals/engine.ts +444 -0
  1167. package/src/visuals/glyph-table.ts +191 -0
  1168. package/src/visuals/grafmode-data.ts +90 -0
  1169. package/src/visuals/grafmode.ts +123 -0
  1170. package/src/visuals/index.ts +19 -0
  1171. package/src/visuals/map-text.ts +152 -0
  1172. package/src/visuals/pref-expr.ts +182 -0
  1173. package/src/visuals/prefs.ts +981 -0
  1174. package/src/visuals/tile-prefs.ts +183 -0
  1175. package/src/world/chunk.ts +531 -0
  1176. package/src/world/feature.ts +215 -0
  1177. package/src/world/flow.ts +128 -0
  1178. package/src/world/project.ts +687 -0
  1179. package/src/world/projection.ts +228 -0
  1180. package/src/world/scatter.ts +72 -0
  1181. package/src/world/trap.ts +155 -0
  1182. package/src/world/view.ts +513 -0
  1183. package/src/z-queue.ts +300 -0
@@ -0,0 +1,1218 @@
1
+ /**
2
+ * The mutable game state the turn loop operates on, plus the square-occupancy
3
+ * helpers the AI and player turn read.
4
+ *
5
+ * struct player upstream carries grid/energy/speed/total_energy; the port's
6
+ * Player (player/player.ts) deliberately omits the world/UI-only members, so
7
+ * this module holds them in a PlayerActor wrapper alongside the Player. Live
8
+ * monsters live in a flat array indexed by midx (index 0 unused, matching
9
+ * cave_monster(cave, i) for i >= 1); Chunk.mon(grid) stores the occupant
10
+ * (0 empty, > 0 a monster's midx, < 0 the player) exactly as upstream's
11
+ * square(c, grid)->mon.
12
+ *
13
+ * The loop couples to the outside world only through injected hooks: a
14
+ * command provider (so it never blocks on real input) and an FOV-update hook
15
+ * (called after the player moves, as game code calls update_view).
16
+ */
17
+
18
+ import { MON_TMD, RF, TMD } from "../generated/index.js";
19
+ import type { GameEvents } from "../events.js";
20
+ import type { MessageLog, MessageType } from "../msg.js";
21
+ import type { Loc } from "../loc.js";
22
+ import { distance, locEq } from "../loc.js";
23
+ import { los } from "../world/view.js";
24
+ import type { Connector } from "../gen/util.js";
25
+ import type { Rng } from "../rng.js";
26
+ import type { Chunk } from "../world/chunk.js";
27
+ import type { Player } from "../player/player.js";
28
+ import type { Monster } from "../mon/monster.js";
29
+ import type { MeleeAttack, PlayerCombatState } from "../combat/melee.js";
30
+ import type { DefenderState } from "../combat/mon-melee.js";
31
+ import type { GameObject } from "../obj/object.js";
32
+ import type { Effect } from "../effects/effect.js";
33
+ import type { Brand, Slay } from "../obj/types.js";
34
+ import type { FlavorAwareDeps, FlavorKnowledge } from "../obj/knowledge.js";
35
+ import type { Gear } from "./gear.js";
36
+ import type { Store } from "../store/store.js";
37
+ import { NORMAL_ENERGY } from "./energy.js";
38
+ /* Value import is safe: mon-group's imports from this module are type-only,
39
+ * so there is no runtime cycle. */
40
+ import { monsterRemoveFromGroups } from "./mon-group.js";
41
+ import {
42
+ becomeAware,
43
+ moveMimickedObject,
44
+ updateMon,
45
+ } from "./known.js";
46
+ import {
47
+ monsterIsCamouflaged,
48
+ monsterIsInView,
49
+ monsterIsMimicking,
50
+ } from "../mon/predicate.js";
51
+
52
+ /**
53
+ * z_info fields the turn loop and monster AI read (defaults are the shipped
54
+ * constants.txt values). Kept as a plain record so tests can override any
55
+ * single field.
56
+ */
57
+ export interface GameConstants {
58
+ /** z_info->move_energy. */
59
+ moveEnergy: number;
60
+ /** z_info->max_sight (flee_range = max_sight + flee-range). */
61
+ maxSight: number;
62
+ /** z_info->max_range (the projectable / targeting range bound). */
63
+ maxRange: number;
64
+ /** z_info->flee_range. */
65
+ fleeRange: number;
66
+ /** z_info->turn_range (nearby monsters won't run away). */
67
+ turnRange: number;
68
+ /** z_info->repro_monster_max (mon-gen:repro-max): breeder cap per level. */
69
+ reproMonsterMax: number;
70
+ /** z_info->repro_monster_rate (mon-play:mult-rate): 1/(k*rate) breed chance. */
71
+ reproMonsterRate: number;
72
+ /** z_info->glyph_hardness (mon-play:break-glyph): monster glyph-break roll. */
73
+ glyphHardness: number;
74
+ /** z_info->day_length (is_daytime; the town day/night cycle). */
75
+ dayLength: number;
76
+ /** z_info->food_value. */
77
+ foodValue: number;
78
+ /** PY_FOOD_STARVE / _FAINT / _WEAK / _HUNGRY (food_value-scaled grade maxima). */
79
+ foodStarve: number;
80
+ foodFaint: number;
81
+ foodWeak: number;
82
+ /** PY_FOOD_HUNGRY (Hungry grade max, food_value-scaled): fast-metabolism cutoff. */
83
+ foodHungry: number;
84
+ /** z_info->alloc_monster_chance (mon-gen:chance): 1/N ambient spawn chance. */
85
+ allocMonsterChance: number;
86
+ /** z_info->store_turns (store:turns): dungeon turns per store day. */
87
+ storeTurns: number;
88
+ /** z_info->life_drain_percent (mon-play:life-drain): exp-drain scaling. */
89
+ lifeDrainPercent: number;
90
+ /** z_info->level_monster_max (level-max:monsters): monster-list capacity. */
91
+ levelMonsterMax: number;
92
+ /** z_info->floor_size (obj:floor-size): max objects in one floor pile. */
93
+ floorSize: number;
94
+ /** z_info->max_depth (world:max-depth): the trapdoor legality bound. */
95
+ maxDepth: number;
96
+ /** z_info->stair_skip (world:stair-skip): deep-descent increment scale. */
97
+ stairSkip: number;
98
+ }
99
+
100
+ /** The shipped constants.txt values, food thresholds scaled by food_value. */
101
+ export const DEFAULT_GAME_CONSTANTS: GameConstants = {
102
+ moveEnergy: NORMAL_ENERGY,
103
+ maxSight: 20,
104
+ maxRange: 20,
105
+ fleeRange: 5,
106
+ turnRange: 5,
107
+ reproMonsterMax: 100,
108
+ reproMonsterRate: 8,
109
+ glyphHardness: 550,
110
+ dayLength: 10000,
111
+ foodValue: 100,
112
+ foodStarve: 100,
113
+ foodFaint: 400,
114
+ foodWeak: 800,
115
+ foodHungry: 1500,
116
+ allocMonsterChance: 500,
117
+ storeTurns: 1000,
118
+ lifeDrainPercent: 2,
119
+ levelMonsterMax: 1024,
120
+ floorSize: 23,
121
+ maxDepth: 128,
122
+ stairSkip: 1,
123
+ };
124
+
125
+ /**
126
+ * The player's world/turn-loop state (the struct player members the port's
127
+ * Player omits), plus the combat/defence views combat needs. `combat` backs
128
+ * py_attack (player-attack.c p->state) and `defense` backs make_attack_normal
129
+ * (p->state.ac + p->state.to_a); calc_bonuses that would derive them is
130
+ * deferred (player/calcs.ts), so they are supplied explicitly.
131
+ */
132
+ export interface PlayerActor {
133
+ player: Player;
134
+ /** p->grid. */
135
+ grid: Loc;
136
+ /** p->energy. */
137
+ energy: number;
138
+ /** p->state.speed (net speed after effects; 110 = normal). */
139
+ speed: number;
140
+ /** p->total_energy (cumulative energy spent). */
141
+ totalEnergy: number;
142
+ /** player-attack.c reads this as p->state. */
143
+ combat: PlayerCombatState;
144
+ /** make_attack_normal reads ac + to_a from this. */
145
+ defense: DefenderState;
146
+ /** The wielded melee weapon, or null for unarmed (py_attack). */
147
+ weapon: GameObject | null;
148
+ /** p->state.skills[SKILL_STEALTH]; the AI's hearing math reads it. */
149
+ stealth: number;
150
+ /** p->state.cur_light (calc_light): the derived light radius. */
151
+ light: number;
152
+ /** state.pflags PF_UNLIGHT: the derived unlight status. */
153
+ unlight: boolean;
154
+ }
155
+
156
+ /**
157
+ * struct monster_group (mon-group.c): a pack of monsters sharing a leader.
158
+ * `members` is the member midx list; its head is the most recently added
159
+ * member, mirroring upstream's member_list (add prepends).
160
+ */
161
+ export interface MonsterGroup {
162
+ /** The group's index in state.groups. */
163
+ index: number;
164
+ /** midx of the group leader (0 = none). */
165
+ leader: number;
166
+ /** Member midx list, head-first (most recently added). */
167
+ members: number[];
168
+ }
169
+
170
+ /**
171
+ * A dungeon level frozen under birth_levels_persist (#30): the exact per-level
172
+ * field-set changeLevel shuffles, plus the game turn it was frozen at. This is
173
+ * the serializable, depth-keyed generalization of session/game.ts' in-memory
174
+ * arena stash (upstream's cave_store into the chunk_list, generate.c L1017).
175
+ * `turn` is the freeze turn (cave_store stamps chunk->turn, generate.c L1032),
176
+ * read by restore_monsters (mon-move.c L2007) to recover the monsters over the
177
+ * turns elapsed while the level was out of play.
178
+ */
179
+ export interface StoredLevel {
180
+ chunk: Chunk;
181
+ monsters: Array<Monster | null>;
182
+ groups: Array<MonsterGroup | null>;
183
+ floor: Map<number, GameObject[]>;
184
+ traps: Map<number, import("./trap.js").Trap[]>;
185
+ known: import("./known.js").KnownMap;
186
+ decoy: Loc | null;
187
+ turn: number;
188
+ /**
189
+ * chunk->join (generate.c L1203-1214): the level's stair connectors, so a
190
+ * re-entered / adjacent persistent level can align up/down stairs via
191
+ * getJoinInfo. Empty when the level recorded no stairs (or for old saves).
192
+ */
193
+ join: Connector[];
194
+ }
195
+
196
+ /**
197
+ * The full mutable game state. `turn` is the upstream int32 game-turn counter;
198
+ * `monsters` is indexed by midx with index 0 unused. Signals mirror the
199
+ * upstream player->upkeep flags the loop branches on.
200
+ */
201
+ export interface GameState {
202
+ rng: Rng;
203
+ chunk: Chunk;
204
+ actor: PlayerActor;
205
+ /**
206
+ * The player's gear store (obj-gear.c): a handle -> object map, the pack
207
+ * (non-equipped handles) and the equipment[] handles on actor.player.
208
+ * Populated at birth by outfitPlayer (game/gear.ts).
209
+ */
210
+ gear: Gear;
211
+ /** cave_monster(cave, i): live monsters, index 0 unused (null). */
212
+ monsters: Array<Monster | null>;
213
+ /** cave->monster_groups[]: monster packs, index 0 unused (null). */
214
+ groups: Array<MonsterGroup | null>;
215
+ /**
216
+ * Floor object piles (square(c, grid)->obj), keyed by grid index
217
+ * (y * width + x). Each pile is head-first: pile_insert prepends, so
218
+ * pile[0] is the newest drop, exactly as the upstream linked list.
219
+ * Managed by game/floor.ts (floor_carry / drop_near / excise).
220
+ */
221
+ floor: Map<number, GameObject[]>;
222
+ /**
223
+ * Live traps (square(c, grid)->trap), keyed by grid index, newest
224
+ * first. Managed by game/trap.ts (place_trap / hit_trap / locks).
225
+ * The type import is erased, so no runtime cycle with game/trap.
226
+ */
227
+ traps: Map<number, import("./trap.js").Trap[]>;
228
+ /**
229
+ * The player's map knowledge (the upstream player->cave twin, reduced):
230
+ * remembered terrain and floor objects, possibly stale. Managed by
231
+ * game/known.ts (square_memorize / note_spot / detection).
232
+ */
233
+ known: import("./known.js").KnownMap;
234
+ /**
235
+ * The player's target (target.c's file-statics). Managed by
236
+ * game/target.ts (target_set_monster / target_okay / fix / release).
237
+ */
238
+ target: import("./target.js").TargetState;
239
+ /**
240
+ * The player's ignore settings (obj-ignore.c's file-statics: quality tiers,
241
+ * ego ignore, per-kind flags). Defaults to nothing ignored. Persists in the
242
+ * save. Read through state.isIgnored (built by the session with flavor
243
+ * awareness), so worldless code stays decoupled from flavor knowledge.
244
+ */
245
+ ignore: import("../obj/ignore.js").IgnoreSettings;
246
+ /**
247
+ * The per-kind autoinscription registry (obj-ignore.c note_aware/note_unaware,
248
+ * obj/knowledge.ts AutoinscriptionRegistry). Notes registered through the
249
+ * knowledge-menu manager are applied by game/obj-cmd.ts's applyAutoinscription
250
+ * (wired via ObjCmdDeps.autoNote in session/game.ts) and persist in the save.
251
+ * Optional so the worldless harness (game/harness.ts) stays total: absent,
252
+ * autoinscribe is a no-op.
253
+ */
254
+ autoinscribe?: import("../obj/knowledge.js").AutoinscriptionRegistry;
255
+ /**
256
+ * The per-RUNE autoinscription registry (rune_list[i].note, obj-knowledge.c
257
+ * rune_note / rune_set_note). Separate from `autoinscribe`: upstream
258
+ * apply_autoinscription applies BOTH (runes_autoinscribe first,
259
+ * obj-ignore.c:259). Persists in the save (wr_ignore, save.c:586-605).
260
+ * Optional so the worldless harness stays total.
261
+ */
262
+ runeNotes?: import("../obj/knowledge.js").RuneNoteRegistry;
263
+ /**
264
+ * apply_autoinscription (obj-ignore.c:242) as a seam, for the call sites that
265
+ * have no ObjCmdDeps to hand: inven_carry (obj-gear.c:868, every pickup) and
266
+ * store selling (store.c:1977). Wired by the session; absent in the worldless
267
+ * harness, where autoinscription is a no-op.
268
+ */
269
+ autoinscribeObject?: (obj: GameObject) => void;
270
+ /**
271
+ * autoinscribe_ground + autoinscribe_pack, the pair
272
+ * update_player_object_knowledge tail-calls (obj-knowledge.c:1245-1247).
273
+ * Wired by the session; absent in the worldless harness.
274
+ */
275
+ autoinscribeAll?: () => void;
276
+ /**
277
+ * The bound player classes (players.classes), stashed by wireGame so the
278
+ * bookseller's town-book always-line expansion (object_kind_to_book,
279
+ * store.c:208-231) can resolve which spellbooks are town (non-dungeon) books.
280
+ * Absent in the worldless harness; the expansion then no-ops.
281
+ */
282
+ classes?: readonly import("../player/types.js").PlayerClass[];
283
+ /**
284
+ * ignore_item_ok(obj): whether an object is currently ignored. Installed by
285
+ * the session (wireGame) with the flavor-awareness lookup baked in; absent,
286
+ * nothing is ignored.
287
+ */
288
+ isIgnored?: (obj: GameObject) => boolean;
289
+ /**
290
+ * player->upkeep->notice's PN_IGNORE bit: object_flavor_aware's ignore fix
291
+ * (obj-knowledge.c L2279) raises this when a newly-aware kind carries its
292
+ * ignore-when-aware bit over, requesting an ignore_drop() re-check of the
293
+ * pack. Set by FlavorAwareDeps.requestIgnoreNotice (obj/knowledge.ts) at
294
+ * the in-play becomes-aware sites (store/transact.ts, game/obj-cmd.ts).
295
+ * Consuming/clearing this (running ignore_drop, #25 UI) is a shell concern
296
+ * and is not wired yet - ledgered like the rest of the ignore-drop UI.
297
+ */
298
+ noticeIgnore?: boolean;
299
+ /**
300
+ * object_flavor_is_aware(kind): whether the player has identified this
301
+ * kind's flavour. Installed by the session (wireGame) from flavor
302
+ * knowledge, so presentation code (obj-list.c, #25) stays decoupled from
303
+ * the flavor store the same way isIgnored does; absent, treated as aware.
304
+ */
305
+ isAware?: (kind: import("../obj/types.js").ObjectKind) => boolean;
306
+ /**
307
+ * obj->kind->flavor != NULL: whether flavor_init assigned this kind a
308
+ * flavour. Installed by the session (wireGame) from the per-game
309
+ * FlavorAssignment; absent, presentation falls back to the tval-only test.
310
+ */
311
+ hasFlavor?: (kind: import("../obj/types.js").ObjectKind) => boolean;
312
+ /**
313
+ * obj->kind->flavor->text: the flavour adjective ("Smoky") or scroll title
314
+ * shown for an unaware flavoured object. Installed by wireGame from the
315
+ * FlavorAssignment; absent, no '#' modstr is produced.
316
+ */
317
+ flavorText?: (kind: import("../obj/types.js").ObjectKind) => string;
318
+ /**
319
+ * object_kind_attr / object_kind_char (ui-object.c:97-112): the assigned
320
+ * flavour's display glyph (d_char) and colour NAME (d_attr) for a flavoured
321
+ * kind, so the map renders an unidentified potion/etc. in its flavour colour
322
+ * (use_flavor_glyph) rather than the kind's black placeholder. Installed by
323
+ * wireGame from the FlavorAssignment; absent, the base kind glyph is used.
324
+ */
325
+ flavorGlyph?: (
326
+ kind: import("../obj/types.js").ObjectKind,
327
+ ) => import("../obj/flavor.js").AssignedFlavor | undefined;
328
+ /**
329
+ * The player option store (option.c op_ptr->opt / hitpoint_warn). Built by
330
+ * the session (startGame / loadGame) from OPTION_ENTRIES defaults and the
331
+ * birth-option choices; persists in the save. Optional so worldless tests
332
+ * (game/harness.ts) stay total - each deferred seam reads it as
333
+ * `dep ?? state.options?.get(name) ?? <shipped default>`, so an absent store
334
+ * reproduces the shipped defaults exactly.
335
+ */
336
+ options?: import("../player/options.js").OptionState;
337
+ /**
338
+ * aup_info[] (obj-make.c): the shared per-artifact created flags. The
339
+ * session owns the single per-game instance and threads it into every
340
+ * MakeDeps so no artifact spawns twice; it is serialized in the save.
341
+ * Optional so the worldless harness (game/harness.ts) stays total.
342
+ */
343
+ artifacts?: import("../obj/make.js").ArtifactState;
344
+ /**
345
+ * kind->everseen / ego->everseen (object_kind/ego_item; save.c L397/L533):
346
+ * the per-game "ever seen" flags for object kinds and egos, marked the first
347
+ * time the player sees an item whose name they know (obj-desc.c L633-637) and
348
+ * for each bought start item (player-birth.c L658). Read by the object/ego
349
+ * knowledge browsers; installed by wireGame; serialized in the save. Optional
350
+ * so the worldless harness stays total (absent = nothing ever seen).
351
+ */
352
+ everseen?: import("../obj/knowledge.js").EverseenKnowledge;
353
+ /**
354
+ * The per-game flavor-awareness store (FlavorKnowledge). Installed by wireGame
355
+ * so the game-layer knowledge sweep (game/known.ts updatePlayerObjectKnowledge,
356
+ * the port of update_player_object_knowledge) can flip a kind aware when a
357
+ * rune-learn completes a carried jewel's non-curse runes. Absent in the
358
+ * worldless harness, where the sweep is a no-op (no flavor store to mutate).
359
+ */
360
+ flavorKnown?: FlavorKnowledge;
361
+ /**
362
+ * The in-play FlavorAwareDeps object_flavor_aware needs (the ignore-fix
363
+ * side-channel). Installed by wireGame alongside flavorKnown; absent, the
364
+ * sweep passes the no-op deps.
365
+ */
366
+ flavorAwareDeps?: FlavorAwareDeps;
367
+ /**
368
+ * The live derived player state (upstream p->state), the result of the last
369
+ * calc_bonuses. update_mon (game/known.ts) reads its OF flag set (telepathy /
370
+ * see-invisible) and see_infra to compute monster visibility. Reassigned by
371
+ * the session on every refreshDerived (equip / level / timed change); absent
372
+ * in the worldless harness, where update_mon falls back to the bare race
373
+ * infravision and an empty flag set.
374
+ */
375
+ playerState?: import("../player/calcs.js").PlayerState;
376
+ /**
377
+ * player->upkeep->health_who (health_track reduced to the tracked
378
+ * monster; the health-bar redraw rides presentation, #25).
379
+ */
380
+ healthWho?: Monster | null;
381
+ /**
382
+ * Monster memory (upstream l_list), keyed by race.ridx and created
383
+ * lazily by getLore (mon/lore.ts). Persists across levels and in the
384
+ * save.
385
+ */
386
+ lore: import("../mon/lore.js").LoreStore;
387
+ /** turn (game-world.c): the game-turn counter. */
388
+ turn: number;
389
+ /**
390
+ * cave->num_repro (cave.h): the count of RF_MULTIPLY breeders on the current
391
+ * level, the denominator gate of monster_turn_multiply's cap. Reset and
392
+ * recounted by countMonsterRaces on level load, bumped by placeMonsterLive
393
+ * and dropped by deleteMonster. Absent is treated as 0.
394
+ */
395
+ numRepro?: number;
396
+ /**
397
+ * daycount (game-world.c): the number of store turnovers accrued while in
398
+ * the dungeon; the town stores restock this many days on return. Persists in
399
+ * the save. Absent is treated as 0.
400
+ */
401
+ daycount?: number;
402
+ /**
403
+ * player->resting_turn (player.h:554, u32; save.c:507): the cumulative count
404
+ * of player turns spent resting, shown on the character sheet (ui-player.c:836)
405
+ * and reset only at birth (player-birth.c:449). DISTINCT from resting.turnsRested
406
+ * (the per-session file-static player_turns_rested that gates the x2 regen):
407
+ * resting_turn accumulates for the character's whole life. Bumped once per rested
408
+ * turn (player-util.c:1487). Persists in the save; absent is treated as 0.
409
+ * The live producer (the rest command) lives outside this module - see the
410
+ * WIRING-NEEDED note in session/save.ts.
411
+ */
412
+ restingTurn?: number;
413
+ /**
414
+ * player->skip_cmd_coercion (player.h:560, u8; save.c:490): the bloodlust
415
+ * command-coercion skip state (0/1/2) - set when a bloodlust-forced command was
416
+ * cancelled so the next command is not re-coerced (cmd-core.c:367-385) and
417
+ * decremented by the world clock (game-world.c:856-901). Persists in the save;
418
+ * absent is treated as 0. Live producer is outside this module (WIRING-NEEDED).
419
+ */
420
+ skipCmdCoercion?: number;
421
+ /**
422
+ * player->unignoring (player.h:558, u8; save.c:491): the temporary "show
423
+ * ignored items" toggle (ui-object.c:1841; consulted by obj-ignore.c:624-640
424
+ * and the status line ui-display.c:1282). Persists in the save; absent is
425
+ * treated as 0 (ignoring active). Live producer is outside this module
426
+ * (the UI toggle - WIRING-NEEDED).
427
+ */
428
+ unignoring?: number;
429
+ /**
430
+ * player->opts.name_suffix (option.h:68, u8; save.c:432): the numeric suffix
431
+ * appended to the character name for the high-score table when names collide.
432
+ * Set at birth. Persists in the save; absent is treated as 0. Live producer is
433
+ * outside this module (the birth/score path - WIRING-NEEDED).
434
+ */
435
+ nameSuffix?: number;
436
+ /**
437
+ * The rolling message log (message.c file-statics; msg.ts MessageLog),
438
+ * persisted in the savefile (wr_messages/rd_messages, save.c:339-353 /
439
+ * load.c:471-495). Upstream is a global; the port holds the live instance
440
+ * here so it can be serialized. Absent in the worldless harness and in saves
441
+ * written before message persistence, which load with an empty log. The live
442
+ * append path (routing msg()/msgt() into this log) lives outside this module
443
+ * (session wiring - WIRING-NEEDED).
444
+ */
445
+ messages?: MessageLog;
446
+ z: GameConstants;
447
+ /** Object domain tables for player melee brands/slays (index 0 = none). */
448
+ brands: readonly (Brand | null)[];
449
+ slays: readonly (Slay | null)[];
450
+ /**
451
+ * Rune-learning environment (obj-knowledge.c learn-by-use): registry
452
+ * tables plus equipment access. Built by the session (wireGame); the
453
+ * harness supplies an inert default so worldless tests stay total.
454
+ */
455
+ runeEnv: import("../obj/knowledge.js").RuneEnv;
456
+
457
+ /**
458
+ * player->wizard (player.h): the session wizard-mode flag. Client/runtime
459
+ * toggle (not saved as such); the web shell sets it from ^W. Gates the
460
+ * cheat-death escape together with OPT(cheat_live). Absent = false.
461
+ */
462
+ wizard?: boolean;
463
+ /**
464
+ * A fatal wizard/cheat_live blow that is waiting for the shell's in-terminal
465
+ * get_check("Die? ") answer. The callback resumes the same live death chain;
466
+ * it is deliberately runtime-only and is not part of save data.
467
+ */
468
+ pendingDeath?: {
469
+ killer: string;
470
+ resolve: (die: boolean) => void;
471
+ } | undefined;
472
+
473
+ /* --- upkeep signals (player->upkeep) --- */
474
+ playing: boolean;
475
+ /** player->is_dead. */
476
+ isDead: boolean;
477
+ /** player->upkeep->generate_level (a stairs/recall level change). */
478
+ generateLevel: boolean;
479
+ /**
480
+ * The depth the pending level change targets (dungeon_change_level's
481
+ * argument). Set with generateLevel by stairs / trapdoors / deep
482
+ * descent; consumed by the session's changeLevel.
483
+ */
484
+ targetDepth?: number;
485
+ /**
486
+ * choose_profile's NOSCORE_JUMPING request (generate.c L824-836): the answer
487
+ * to the wizard jump command's "Profile name (eg classic): ". The NEXT
488
+ * generation consumes it - the session clears it as it passes it on, matching
489
+ * the C's one-shot `p->noscore &= ~(NOSCORE_JUMPING)`. An unknown name falls
490
+ * through to the ordinary depth-based selection.
491
+ */
492
+ jumpProfileName?: string | undefined;
493
+ /**
494
+ * player->upkeep->create_up_stair / create_down_stair (cmd-cave.c:90-91,
495
+ * 137-138): the arrival staircase the NEXT generated level must lay under the
496
+ * player, so a down-stair lands you on an up-stair and vice versa
497
+ * (birth_connect_stairs). Set only by the stair commands - "up" mirrors
498
+ * create_up_stair (set on descent), "down" mirrors create_down_stair (set on
499
+ * ascent). new_player_spot lays it and player_place clears it; recall/arena
500
+ * level changes leave it unset (no arrival stair), exactly as upstream.
501
+ */
502
+ arrivalStair?: "up" | "down" | null;
503
+ /**
504
+ * player->upkeep->arena_level: the player is in (or headed to) single
505
+ * combat. Set by EF_SINGLE_COMBAT; cleared by the arena exit.
506
+ */
507
+ arenaLevel?: boolean;
508
+ /** player->old_grid: where to stand again after the arena. */
509
+ oldGrid?: Loc;
510
+
511
+ /**
512
+ * The running engine's live state (player-path.c). Created lazily by the
513
+ * run action (game/player-path.ts); absent until the player first runs.
514
+ */
515
+ run?: RunState;
516
+
517
+ /**
518
+ * player->upkeep->resting + the file-static player_turns_rested
519
+ * (player-util.c:1417,1472). count mirrors upkeep->resting (>0 = timed turns
520
+ * left, or a REST_ special: COMPLETE=-2, ALL_POINTS=-1, SOME_POINTS=-3);
521
+ * turnsRested gates the x2 regen. Set/tracked by the web rest command
522
+ * (packages/web main.ts driveRest); absent when not resting.
523
+ */
524
+ resting?: { count: number; turnsRested: number };
525
+
526
+ /* --- injected hooks --- */
527
+ /**
528
+ * cmdq: the internal command queue (cmd-core.c). Self-continuing commands
529
+ * (running re-queues CMD_RUN) push here; processPlayer drains it before
530
+ * nextCommand so a run advances without new input. disturb() flushes it.
531
+ */
532
+ cmdQueue?: PlayerCommand[];
533
+ /** cmdq_pop: the next queued player command, or null when input is needed. */
534
+ nextCommand: () => PlayerCommand | null;
535
+ /**
536
+ * check_for_player_interrupt's keyboard poll (ui-game.c:645), hosted. Called
537
+ * from the loop at upstream's EVENT_CHECK_INTERRUPT site while a run, a
538
+ * repeated command or a rest is driving the game - see
539
+ * checkForPlayerInterrupt in game/loop.ts for the contract and why "pause"
540
+ * exists. Absent: the loop never stops for input, as before.
541
+ */
542
+ checkInterrupt?: () => InterruptResponse;
543
+ /** update_view: refresh player FOV after the player moves. */
544
+ updateFov?: (state: GameState) => void;
545
+ /** Renderer-neutral EF_SELECT chooser; the host owns the menu renderer. */
546
+ effectChooser?: (first: Effect | null, count: number) => number;
547
+ /**
548
+ * make_ranged_attack: a monster attempts a spell / breath on its turn,
549
+ * returning true if it spent the turn casting. Installed by
550
+ * installMonsterCasting (game/mon-ranged.ts); absent, monsters never cast.
551
+ */
552
+ monsterCast?: (mon: Monster, state: GameState) => boolean;
553
+ /**
554
+ * multiply_monster (mon-make.c L983): a breeder tries to spawn a copy in an
555
+ * adjacent empty grid, returning true on success. Installed by wireGame
556
+ * (session/game.ts) from game/mon-place.ts multiplyMonster; absent, breeders
557
+ * never actually reproduce (monster_turn_multiply still draws its cap /
558
+ * chance rolls, so the RNG stream is unchanged when it is wired).
559
+ */
560
+ monsterMultiply?: (mon: Monster) => boolean;
561
+ /**
562
+ * square_door_power (cave-square.c): the lock strength on a closed door
563
+ * (0 = unlocked). Door locks are the "door lock" trap (#21), so this seams
564
+ * back the trap system; installed by wireGame. Absent, every door reads as
565
+ * unlocked - the RNG-free path monster_turn_can_move already takes when no
566
+ * trap system is live.
567
+ */
568
+ doorLockPower?: (grid: Loc) => number;
569
+ /** square_set_door_lock: set a closed door's lock strength (trap #21 seam). */
570
+ setDoorLock?: (grid: Loc, power: number) => void;
571
+ /**
572
+ * player_best_digger (player-util.c L744) + the do_cmd_tunnel_aux /
573
+ * compute_rubble_penalty swap: the DIGGING skill the dig should use, having
574
+ * temporarily wielded the pack's best digger and recomputed calc_bonuses.
575
+ * Installed by wireGame (it closes over the live calc_bonuses options).
576
+ * RNG-free (input only). Absent (worldless harnesses), digging falls back to
577
+ * the wielded state's DIGGING skill, as before.
578
+ */
579
+ bestDiggerDigging?: () => number;
580
+ /**
581
+ * square_open_door / square_smash_door remove the "door lock" trap before
582
+ * changing the feature; this seams that removal back to the trap system.
583
+ * Absent, the (harmless, feature-gated) lock trap is simply left in place.
584
+ */
585
+ removeDoorLock?: (grid: Loc) => void;
586
+ /**
587
+ * make_attack_normal's blow-effect environment (game/mon-side.ts): binds a
588
+ * MonBlowEnv to an attacking monster so combat/mon-melee.ts applies the full
589
+ * status / stat / theft / terrain consequences of a melee blow in upstream
590
+ * RNG order. Installed by wireGame; absent, monster melee falls back to the
591
+ * worldless stub-log intents (the physical HP slice only).
592
+ */
593
+ monBlowEnv?: (mon: Monster) => import("../combat/mon-melee.js").MonBlowEnv;
594
+ /**
595
+ * do_cmd_mon_command: while TMD_COMMAND runs, player commands drive the
596
+ * commanded monster instead (upstream swaps the command list,
597
+ * cmd-core.c L333). Installed by installMonCommand (game/mon-cmd.ts);
598
+ * returns the energy spent.
599
+ */
600
+ monCommand?: (state: GameState, cmd: PlayerCommand) => number;
601
+ /**
602
+ * do_autopickup after a step: returns the energy the pickup cost (picked
603
+ * * move_energy / 10, capped). Installed by installPickup (game/pickup.ts);
604
+ * upstream queues CMD_AUTOPICKUP instead - the port folds the identical
605
+ * cost into the step because the command provider is injected.
606
+ */
607
+ autoPickup?: (state: GameState) => number;
608
+ /**
609
+ * Runs after the player steps onto a new grid (move_player's trap /
610
+ * terrain consequences). Installed by installTraps (game/trap.ts).
611
+ */
612
+ onPlayerMoved?: (state: GameState, grid: Loc) => void;
613
+ /**
614
+ * player_leaving (mon-util.c:503-515): fires when the player leaves a grid
615
+ * (delayed traps, decoy range). Installed by installTraps; called from
616
+ * movePlayer so every monster_swap path matches C.
617
+ */
618
+ onPlayerLeaving?: (state: GameState, oldGrid: Loc, newGrid: Loc) => void;
619
+ /**
620
+ * Terrain-only town layout (chunk_write "Town", gen-chunk.c:46 / generate.c
621
+ * L1371-1373). Stored when leaving depth 0 without birth_levels_persist so
622
+ * town_gen can reload the same shops/stairs. Cleared when consumed on re-entry.
623
+ */
624
+ townChunk?: import("../world/chunk.js").Chunk | null;
625
+ /**
626
+ * The walk-into-a-wall seam: consulted by walkAction (game/player-turn.ts)
627
+ * when a walk is blocked, BEFORE the faithful no-energy bump.
628
+ *
629
+ * `null` means NO mod took the walk over, and is the ONLY value that falls
630
+ * through to the bump. A number is the energy a mod spent - **including 0**,
631
+ * which is a mod consuming the keypress without costing the player a turn.
632
+ * Those two are different answers on purpose; collapsing zero into "declined"
633
+ * is the defect this signature exists to prevent, and it would make the hook
634
+ * interface document a case the engine cannot express.
635
+ *
636
+ * Installed by the session (movementAutoDig, game/cave-cmd.ts), which returns
637
+ * null having drawn NO RNG unless a mod supplied the walkBlockedByDiggable
638
+ * hook - so an absent hook keeps movement byte-identical to faithful 4.2.6.
639
+ *
640
+ * Core names no mod and reads no flag here. Which mod is asking, and why, is
641
+ * not core's business.
642
+ */
643
+ autoDigStep?: (state: GameState, grid: Loc) => number | null;
644
+ /**
645
+ * player_kill_monster's reward slice: runs when the PLAYER kills a
646
+ * monster, before it is deleted (experience now; drops/lore/quests join
647
+ * it with their subsystems). Installed by the session (wireGame).
648
+ */
649
+ onPlayerKill?: (mon: Monster) => void;
650
+ /**
651
+ * become_aware (mon-util.c L711, game/known.ts): reveal a camouflaged
652
+ * mimic - clears MFLAG_CAMOUFLAGE, learns RF_UNAWARE, and (once object-mimic
653
+ * placement is ported) drops the fake floor item. Installed by the session
654
+ * (wireGame) and threaded into every existing becomeAware? hook config
655
+ * (mon/take-hit.ts, game/project-monster.ts, game/mon-ranged.ts) plus the
656
+ * direct player/monster melee call sites (game/effect-melee.ts,
657
+ * game/mon-cmd.ts) and the player-adjacent bump paths (game/player-turn.ts
658
+ * walkAction, game/cave-cmd.ts attackBlocker). Absent, camouflaged monsters
659
+ * are attacked instead of unmasked - matching pre-#31 behaviour.
660
+ */
661
+ becomeAware?: (mon: Monster) => void;
662
+ /**
663
+ * object_touch's history_find_artifact call (obj-knowledge.c L971): fires
664
+ * when an artifact enters the pack for the first time. Installed by the
665
+ * session (wireGame); pickup.ts's playerPickupAux calls it, keeping the
666
+ * hook alive across a later installPickup re-registration (which only
667
+ * replaces the message-hook env, not this state-level slot).
668
+ */
669
+ onArtifactFound?: (art: import("../obj/types.js").Artifact) => void;
670
+ /**
671
+ * history_lose_artifact (player-history.c L246): fires when a known artifact
672
+ * is lost - destroyed by an effect (effect-handler-attack/general.c),
673
+ * abandoned on a regenerated level (generate.c), or discarded by a store the
674
+ * player sold it to (store.c do_cmd_sell / store_delete_random / store_maint).
675
+ * Installed by the session (wireGame); marks the artifact's history entry
676
+ * "Missed", or logs a fresh one.
677
+ */
678
+ onArtifactLost?: (art: import("../obj/types.js").Artifact) => void;
679
+ /**
680
+ * py_attack's message slice: runs after the player melees a monster, with
681
+ * the full blow-by-blow result (hits, damage, crit HitType, and whether the
682
+ * monster died). The combat code returns only HitType keys - the text is a UI
683
+ * concern (combat/melee.ts) - so a shell installs this to render faithful
684
+ * "You hit/miss/slay the X" messages. Called before the monster is deleted.
685
+ */
686
+ onMelee?: (mon: Monster, result: MeleeAttack) => void;
687
+ /**
688
+ * Monster-AI override hook (W2.2 mod seam). Consulted at the very top of
689
+ * monsterTurn (monster-turn.ts): returning true takes the monster's whole
690
+ * turn over (the ported AI is skipped for that monster this turn); returning
691
+ * false falls through to the faithful AI. Absent by default, so core
692
+ * behaviour is byte-identical. Installed by a trusted in-process plugin via
693
+ * ModRegistryHost.monsters.setTurnHook (mod/registry-host.ts).
694
+ */
695
+ monsterTurnHook?: (mon: Monster, state: GameState) => boolean;
696
+ /**
697
+ * Named boolean "mod rule" flags: the player's per-patch choices, resolved by
698
+ * the HOST from each enabled mod's manifest `rules` against their saved Fixes
699
+ * & tweaks selections.
700
+ *
701
+ * OPAQUE TO CORE. Core stores this (it is save state, and a save has to record
702
+ * which patches a character was played with) and never branches on it. Every
703
+ * flag name here belongs to a mod, so a core function reading one would be core
704
+ * implementing that mod - which is exactly what the ModHooks seam below exists
705
+ * to stop. The mod itself reads its own flags when it decides which hooks to
706
+ * install; by the time core sees anything, the decision is already a function
707
+ * or an absent field.
708
+ */
709
+ modRules?: Record<string, boolean>;
710
+ /**
711
+ * The behaviour a mod supplies (mod/hooks.ts).
712
+ *
713
+ * ABSENT by default, and absent is the whole contract: with no mod loaded there
714
+ * is no object, no optional call is made, and core runs the faithful 4.2.6 path
715
+ * that is the only path in the branch. Composed by the host in load order from
716
+ * every enabled mod's contributions (composeModHooks), so core holds one object
717
+ * and knows nothing about mod identity, ordering or enablement.
718
+ */
719
+ modHooks?: import("../mod/hooks.js").ModHooks;
720
+ /**
721
+ * PU_BONUS | PU_HP | PU_MANA: recompute the derived state from the
722
+ * current gear (equipment commands call this after changing what is
723
+ * worn). Installed by the session (wireGame).
724
+ */
725
+ updateBonuses?: () => void;
726
+ /** game-world.c:947 pack_overflow(NULL), installed by the live session with
727
+ * its full object/calc_inventory dependencies. */
728
+ overflowPack?: () => void;
729
+ /**
730
+ * state->stat_ind: the six internal stat indices from the last
731
+ * calc_bonuses, kept live (updateBonuses refreshes it in place). The
732
+ * casting math (spell_chance / spell_cast) reads it, and a shell reads it
733
+ * to show live fail chances; absent only before the first bonus calc.
734
+ */
735
+ statInd?: readonly number[];
736
+ /**
737
+ * cave->decoy: the grid of the player's active decoy glyph (EF_GLYPH with
738
+ * GLYPH_DECOY), or absent/null when none is deployed. Level state, like
739
+ * traps; cleared when the decoy trap is destroyed or the level changes.
740
+ */
741
+ decoy?: Loc | null;
742
+ /**
743
+ * birth_levels_persist (#30) frozen-level cache, keyed by depth. The standard
744
+ * dungeon has exactly one level per depth, so `depth` (a number) is the
745
+ * faithful identity for upstream's level NAME key (chunk_find_name of
746
+ * level_by_depth(depth)->name, generate.c L1414); town is depth 0. Populated
747
+ * only while the option is on; the whole persist path in changeLevel is gated
748
+ * on the option, so default play never reads or writes it. Serialized in the
749
+ * save (session/save.ts); absent / empty means no frozen levels.
750
+ */
751
+ levelCache?: Map<number, StoredLevel>;
752
+ /**
753
+ * chunk->join for the level currently in play (generate.c L1203-1214),
754
+ * captured from generateLevel / restored from the frozen cache. Frozen into
755
+ * StoredLevel.join on level change and persisted (session/save.ts) so a
756
+ * first-visit persistent level can seed its stairs from adjacent levels.
757
+ * Only meaningful under birth_levels_persist; undefined otherwise.
758
+ */
759
+ currentJoins?: Connector[];
760
+ /**
761
+ * The preset target-item reference for an item-choosing effect (the port of
762
+ * cmd_get_item's "tgtitem" command argument, cmd-core.c L1056). Set by the
763
+ * object / spell command from cmd.args.tgtitem just before effect_do, read by
764
+ * the getItem seam (session/game.ts resolveTargetItem), and cleared after the
765
+ * run. Absent means the shell did not pre-resolve a pick, so the choosing
766
+ * handler aborts (the upstream cancel path). One-shot: the getItem seam clears
767
+ * it once consumed so a two-prompt effect cannot reuse the same object.
768
+ */
769
+ itemTarget?: ItemTargetRef | null;
770
+ /**
771
+ * The unfulfilled item request left behind when a choosing handler ran with no
772
+ * (or a filter-failing) preset target - the shell's defensive fallback reads
773
+ * it to re-prompt. Absent in the normal probe/pre-resolution flow.
774
+ */
775
+ itemRequest?: import("./effect-item.js").ItemRequest | null;
776
+ /**
777
+ * The preset curse index for EF_REMOVE_CURSE's get_curse selection (the port
778
+ * of cmd_get_arg_choice on a multi-curse item). Set from cmd.args.tgtcurse;
779
+ * read by the chooseCurse seam; cleared after the run. Absent picks the first
780
+ * removable curse (upstream get_curse's default), never a random one.
781
+ */
782
+ curseTarget?: number | null;
783
+ /**
784
+ * The world-event message sink (the recall yank, the deep-descent floor
785
+ * opening). Presentation (#25) installs it; absent, the messages drop.
786
+ */
787
+ msg?: (text: string, type?: MessageType) => void;
788
+ /**
789
+ * sound(msgt): play the sound bound to a MSG_* type (message.c sound()).
790
+ * A front end wires it to its audio engine (the web build emits the core
791
+ * EVENT_SOUND onto its sound bus); absent, sound is silent. The engine's
792
+ * own message->sound map and dedup ride #26; this is only the emit seam.
793
+ */
794
+ sound?: (msgType: number) => void;
795
+ /**
796
+ * The equipped-item curse effect countdown (game/curse-tick.ts
797
+ * processCurseTimeouts), run once per game turn at the tail of
798
+ * decrease_timeouts. The session installs it with the curses registry + the
799
+ * effect stack; absent (worldless callers, or no cursed item equipped) the
800
+ * curse loop is a no-op and draws no RNG, exactly as when it was deferred.
801
+ */
802
+ curseTick?: () => void;
803
+ /**
804
+ * The game event bus (events.ts), when a host attaches one. Core-to-anything
805
+ * seam: the host routes messages/sound through it and mods subscribe (the
806
+ * capability-gated agent/events.ts subscribeEvents). Absent in the worldless
807
+ * harness; core never requires it.
808
+ */
809
+ events?: GameEvents;
810
+ /**
811
+ * The live town stores (store.c `stores`), indexed however the session
812
+ * instantiates them; a shell looks a store up by its entrance feature. Set
813
+ * when the town level is generated; absent in the dungeon.
814
+ */
815
+ stores?: Store[];
816
+ /**
817
+ * process_world upkeep environment (game/world.ts): the bound timed-effect
818
+ * table, take_hit / timed hooks, the ambient-spawn and cave-illuminate
819
+ * hooks, and exp deps the once-every-ten-turns world clock needs. Installed
820
+ * by the session (wireGame) and the test harness. Absent, decrease_timeouts
821
+ * falls back to raw mutation and the damage-over-time / digestion / recharge
822
+ * upkeep is skipped (the ambient-spawn roll is still drawn unconditionally).
823
+ */
824
+ world?: import("./world.js").WorldClockEnv;
825
+ }
826
+
827
+ /**
828
+ * A reference to an item-choosing effect's pre-resolved target object: a gear
829
+ * handle (a pack, equipped or quiver object - all live in gear.store) or an
830
+ * index into the floor pile under the player. The shell resolves the pick
831
+ * asynchronously and rides it on the command's args.tgtitem; the getItem seam
832
+ * turns it back into the live object.
833
+ */
834
+ export type ItemTargetRef = { handle: number } | { floor: number };
835
+
836
+ /**
837
+ * What the host's keyboard poll wants the loop to do at upstream's
838
+ * EVENT_CHECK_INTERRUPT point (game-world.c:937).
839
+ *
840
+ * - "go": nothing was pressed; keep driving the run / repeat / rest (the C's
841
+ * EVT_NONE from its non-waiting inkey_ex).
842
+ * - "cancel": a key arrived: flush input, disturb, "Cancelled." (ui-game.c:660).
843
+ * - "pause": the host cannot answer synchronously and needs its event loop; the
844
+ * loop returns LOOP_STATUS.PAUSE with the continuation still queued.
845
+ */
846
+ export type InterruptResponse = "go" | "cancel" | "pause";
847
+
848
+ /** One queued player command (a keyed action plus optional direction/args). */
849
+ export interface PlayerCommand {
850
+ /** The action-registry key (e.g. "walk", "hold", "descend"). */
851
+ code: string;
852
+ /** Keypad direction 1..9 for movement commands. */
853
+ dir?: number;
854
+ /**
855
+ * Set by the move-command wrapper (installCaveCommands' bump-open) once it has
856
+ * already run player_confuse_dir on `dir`: walkAction then uses `dir` as-is
857
+ * rather than re-rolling confusion, so the RNG is drawn exactly once per move
858
+ * (cmd-cave.c L1299-1302, matching do_cmd_walk).
859
+ */
860
+ confusedApplied?: boolean;
861
+ /** Free-form arguments a mod-registered action may read. */
862
+ args?: Readonly<Record<string, unknown>>;
863
+ /**
864
+ * cmd-core.c process_command auto-repeat budget (nrepeats): the number of
865
+ * further attempts a repeatable command (tunnel / open / close / disarm /
866
+ * alter / lock) may make before it stops on its own. Absent on a fresh
867
+ * keypress (seeded to CMD_AUTO_REPEAT); each self-requeue decrements it. See
868
+ * queueCommandRepeat.
869
+ */
870
+ repeatRemaining?: number;
871
+ }
872
+
873
+ /**
874
+ * cmd-core.c game_cmds: the auto_repeat_n value (99) shared by every repeatable
875
+ * action command - open, close, tunnel, disarm, alter (and the lock alias).
876
+ */
877
+ export const CMD_AUTO_REPEAT = 99;
878
+
879
+ /**
880
+ * cmd-core.c process_command auto-repeat, the port of `cmd_set_repeat(99)` plus
881
+ * the per-command `if (!more) disturb(player)` (do_cmd_tunnel and friends): a
882
+ * repeatable command whose _aux reports "may continue" (a failed-but-hopeful
883
+ * attempt - still chipping at a wall, still picking a lock) re-queues itself on
884
+ * state.cmdQueue so the player keeps trying on later game turns without pressing
885
+ * the key again, bounded at CMD_AUTO_REPEAT like upstream. When the aux reports
886
+ * done (success, or no hope), nothing is re-queued, which is what upstream's
887
+ * `disturb(player)` achieves for repetition (the player is not running or
888
+ * resting mid-action, so disturb's other effects are moot here). processPlayer
889
+ * drains cmdQueue before asking for input and a full turn passes between
890
+ * attempts, so monsters act between digs; any disturb() during those turns
891
+ * flushes cmdQueue and stops the repeat, exactly as upstream disturb cancels
892
+ * command repetition.
893
+ */
894
+ export function queueCommandRepeat(
895
+ state: GameState,
896
+ cmd: PlayerCommand,
897
+ more: boolean,
898
+ ): void {
899
+ if (!more) return;
900
+ const remaining = cmd.repeatRemaining ?? CMD_AUTO_REPEAT;
901
+ if (remaining <= 0) return;
902
+ if (!state.cmdQueue) state.cmdQueue = [];
903
+ state.cmdQueue.push({ ...cmd, repeatRemaining: remaining - 1 });
904
+ }
905
+
906
+ /**
907
+ * The running engine's state (player-path.c file-statics plus the
908
+ * player->upkeep running counter). Created lazily by the run action; a
909
+ * `running` of 0 means the player is not running. `firstStep` mirrors
910
+ * upstream's running_firststep (the disturb-suppressed first step).
911
+ */
912
+ export interface RunState {
913
+ /** run_cur_dir: the direction we are moving. */
914
+ curDir: number;
915
+ /** run_old_dir: the direction we are considered to have come from. */
916
+ oldDir: number;
917
+ /** run_open_area: in the open on at least one side. */
918
+ openArea: boolean;
919
+ /** run_break_right: wall on the right, stop if it opens. */
920
+ breakRight: boolean;
921
+ /** run_break_left: wall on the left, stop if it opens. */
922
+ breakLeft: boolean;
923
+ /** player->upkeep->running: steps remaining (0 = not running). */
924
+ running: number;
925
+ /** player->upkeep->running_firststep. */
926
+ firstStep: boolean;
927
+ /**
928
+ * player->upkeep->steps: a pathfinding path as forward keypad directions
929
+ * in reverse order (index stepCount-1 is the next step); absent for a
930
+ * plain run. Freed by disturb().
931
+ */
932
+ steps?: number[];
933
+ /** player->upkeep->step_count: steps of `steps` left to take. */
934
+ stepCount: number;
935
+ /** player->upkeep->path_dest: the travel destination (kept across disturb). */
936
+ pathDest?: Loc;
937
+ }
938
+
939
+ /* modRuleEnabled used to live here: the single reader for state.modRules, which
940
+ * core functions consulted as `if (modRuleEnabled(state, "bugfix.x"))`. It is
941
+ * GONE, deliberately and permanently. Core does not read a mod's flags - flag
942
+ * names belong to mods, so a core function reading one is core implementing that
943
+ * mod. Behaviour arrives through GameState.modHooks (mod/hooks.ts) instead.
944
+ *
945
+ * Deleted rather than left unused: with zero callers it was the last trace of the
946
+ * old contract, and a helper that exists is a helper the next core function will
947
+ * reach for. The HOST still resolves the choice map (it is save state, and the
948
+ * Fixes & tweaks menu is built from it) - that reading lives in the host. */
949
+
950
+ /**
951
+ * player_resting_is_special (player-util.c:1382): the conditional REST_ modes,
952
+ * which rest until a condition is met rather than for a fixed count.
953
+ * REST_COMPLETE = -2, REST_ALL_POINTS = -1, REST_SOME_POINTS = -3
954
+ * (player-util.h:53-55).
955
+ *
956
+ * This and playerIsResting live here, next to state.resting, because three
957
+ * separate copies of them had grown up around the port - the rest command's, the
958
+ * turn loop's, and display.ts's inline -1/-2/-3 tests - and a predicate with
959
+ * three bodies only agrees by luck.
960
+ */
961
+ export function playerRestingIsSpecial(count: number): boolean {
962
+ return count === -1 || count === -2 || count === -3;
963
+ }
964
+
965
+ /**
966
+ * player_is_resting (player-util.c:1397): upkeep->resting > 0 or one of the
967
+ * conditional modes. Absent state.resting is upkeep->resting == 0.
968
+ */
969
+ export function playerIsResting(state: GameState): boolean {
970
+ const r = state.resting;
971
+ if (!r) return false;
972
+ return r.count > 0 || playerRestingIsSpecial(r.count);
973
+ }
974
+
975
+ /** player_resting_count (player-util.c:1406) = upkeep->resting. */
976
+ export function playerRestingCount(state: GameState): number {
977
+ return state.resting?.count ?? 0;
978
+ }
979
+
980
+ /** cave_monster_max(cave): one past the highest occupied monster slot. */
981
+ export function monsterMax(state: GameState): number {
982
+ return state.monsters.length;
983
+ }
984
+
985
+ /** cave_monster(cave, i): the monster in slot i, or null. */
986
+ export function monsterAt(state: GameState, i: number): Monster | null {
987
+ return state.monsters[i] ?? null;
988
+ }
989
+
990
+ /**
991
+ * mon_pop (mon-make.c L646): the index of a free monster slot, or 0 if the
992
+ * list is full. Its one upstream caller (place_new_monster_one, L1016) must
993
+ * check for 0.
994
+ *
995
+ * The order here is the whole point and the port had it backwards. BELOW
996
+ * level_monster_max upstream always APPENDS - it takes cave_monster_max(c) and
997
+ * grows the array - and only once the array is at the cap does it scan for a
998
+ * hole left by a dead monster. placeMonsterLive used to scan for the first hole
999
+ * every time, which assigns different midx values from the first monster death
1000
+ * onward, and midx is turn order (process_monsters walks
1001
+ * cave_monster_max(cave) - 1 down to 1, mon-move.c:1899). Holes are removed by
1002
+ * compact_monsters' excise pass, not by allocation.
1003
+ *
1004
+ * `characterDungeon` is upstream's character_dungeon: during generation there
1005
+ * is no player to warn.
1006
+ */
1007
+ export function monPop(state: GameState, characterDungeon = true): number {
1008
+ /* c->mon_max starts at 1 on a fresh chunk: slot 0 is never a monster. */
1009
+ if (state.monsters.length === 0) state.monsters.push(null);
1010
+
1011
+ /* Normal allocation. */
1012
+ if (monsterMax(state) < state.z.levelMonsterMax) {
1013
+ /* Get the next hole, and expand the array (c->mon_max++). mon_cnt is
1014
+ * derived here (caveMonsterCount), so there is no counter to bump. */
1015
+ const midx = monsterMax(state);
1016
+ state.monsters.push(null);
1017
+ return midx;
1018
+ }
1019
+
1020
+ /* Recycle dead monsters if we've run out of room. */
1021
+ for (let midx = 1; midx < monsterMax(state); midx++) {
1022
+ if (!state.monsters[midx]) return midx;
1023
+ }
1024
+
1025
+ /* Warn the player if no index is available. */
1026
+ if (characterDungeon) state.msg?.("Too many monsters!");
1027
+
1028
+ /* Try not to crash. */
1029
+ return 0;
1030
+ }
1031
+
1032
+ /**
1033
+ * Add a monster to the state and mark its grid occupied, assigning the next
1034
+ * free midx. Mirrors the midx/square bookkeeping place_new_monster does.
1035
+ *
1036
+ * This is the LOADING path (place_new_monster_one's `loading` branch,
1037
+ * mon-make.c L1011-1014): a monster read back from a save keeps its stored slot
1038
+ * and mon_max just grows past it, so appending in stored order is the same
1039
+ * assignment. Live placement goes through monPop instead.
1040
+ */
1041
+ export function addMonster(state: GameState, mon: Monster): number {
1042
+ if (state.monsters.length === 0) state.monsters.push(null);
1043
+ const midx = state.monsters.length;
1044
+ mon.midx = midx;
1045
+ state.monsters.push(mon);
1046
+ state.chunk.setMon(mon.grid, midx);
1047
+ return midx;
1048
+ }
1049
+
1050
+ /** square_monster(c, grid): the monster occupying a grid, or null. */
1051
+ export function squareMonster(state: GameState, grid: Loc): Monster | null {
1052
+ if (!state.chunk.inBounds(grid)) return null;
1053
+ const idx = state.chunk.mon(grid);
1054
+ return idx > 0 ? (state.monsters[idx] ?? null) : null;
1055
+ }
1056
+
1057
+ /** square_isplayer(c, grid): the player occupies this grid. */
1058
+ export function squareIsPlayer(state: GameState, grid: Loc): boolean {
1059
+ return locEq(grid, state.actor.grid);
1060
+ }
1061
+
1062
+ /**
1063
+ * square_isempty reduced to the loop's needs: passable feature, no monster
1064
+ * and not the player. (Player-trap / web / object refinements DEFERRED.)
1065
+ */
1066
+ export function squareIsEmpty(state: GameState, grid: Loc): boolean {
1067
+ if (!state.chunk.inBounds(grid)) return false;
1068
+ if (!state.chunk.isPassable(grid)) return false;
1069
+ if (state.chunk.mon(grid) !== 0) return false;
1070
+ return !squareIsPlayer(state, grid);
1071
+ }
1072
+
1073
+ /**
1074
+ * monster_swap (mon-util.c:566-677): swap mon markers at two grids, update
1075
+ * monster grids, and when the player is involved set actor.grid and fire
1076
+ * player_leaving (mon-util.c:609-625 / 656-672) so TRF_DELAY traps run.
1077
+ * Used by thrust, mon AI steps, and teleports that trade places.
1078
+ */
1079
+ export function monsterSwap(state: GameState, grid1: Loc, grid2: Loc): void {
1080
+ const c = state.chunk;
1081
+ const m1 = c.mon(grid1);
1082
+ const m2 = c.mon(grid2);
1083
+ /* Snapshot player grid before the swap (mon-util.c:570). */
1084
+ const pgrid = state.actor.grid;
1085
+ c.setMon(grid1, m2);
1086
+ c.setMon(grid2, m1);
1087
+ const mon1 = m1 > 0 ? state.monsters[m1] ?? null : null;
1088
+ const mon2 = m2 > 0 ? state.monsters[m2] ?? null : null;
1089
+
1090
+ /* mon-util.c L566-677: swap visibility, camouflage/mimicry, lighting,
1091
+ * distances, monster redraw and square-light updates as one operation. */
1092
+ let lightChanged = false;
1093
+ const moved = (
1094
+ mon: Monster | null,
1095
+ from: Loc,
1096
+ to: Loc,
1097
+ other: number,
1098
+ ): void => {
1099
+ if (!mon) return;
1100
+ if (monsterIsCamouflaged(mon)) {
1101
+ const witnessed =
1102
+ monsterIsInView(mon) ||
1103
+ (other >= 0 ? los(c, state.actor.grid, to) : los(c, from, to));
1104
+ if (witnessed) {
1105
+ (state.becomeAware ?? ((m: Monster) => becomeAware(state, m)))(mon);
1106
+ } else if (monsterIsMimicking(mon)) {
1107
+ moveMimickedObject(state, mon, from, to);
1108
+ }
1109
+ }
1110
+ /* C assigns mon->grid only after the camouflage witness/mimic update
1111
+ * (mon-util.c L591-606 and L636-651). */
1112
+ mon.grid = to;
1113
+ updateMon(state, mon, true);
1114
+ if (mon.race.light !== 0) lightChanged = true;
1115
+ };
1116
+ moved(mon1, grid1, grid2, m2);
1117
+ moved(mon2, grid2, grid1, m1);
1118
+ /* The player half of the swap runs AFTER the monster moves so the camouflage
1119
+ * witness above still sees the player's pre-swap position, as the C does.
1120
+ * Player at grid1 -> grid2 (mon-util.c:609-612). */
1121
+ if (m1 < 0) {
1122
+ state.actor.grid = grid2;
1123
+ state.onPlayerLeaving?.(state, pgrid, state.actor.grid);
1124
+ } else if (m2 < 0) {
1125
+ /* Player at grid2 -> grid1 (mon-util.c:656-659). */
1126
+ state.actor.grid = grid1;
1127
+ state.onPlayerLeaving?.(state, pgrid, state.actor.grid);
1128
+ }
1129
+ updateMonsterDistances(state);
1130
+ if (lightChanged) state.updateFov?.(state);
1131
+ }
1132
+
1133
+ /**
1134
+ * delete_monster_idx (mon-make.c): remove the monster from its groups
1135
+ * (leader succession / group split happen here), forget its racial
1136
+ * occurrence, clear its square and free its slot. The held-object drop,
1137
+ * mimic and targeting/redraw bookkeeping are DEFERRED with their subsystems
1138
+ * (floor objects, lore); the caller runs monster_death (drops) beforehand.
1139
+ */
1140
+ export function deleteMonster(state: GameState, midx: number): void {
1141
+ const mon = state.monsters[midx];
1142
+ if (!mon) return;
1143
+ monsterRemoveFromGroups(state, mon);
1144
+ /* If the monster was the target, forget it (target_set_monster(NULL),
1145
+ * inlined to keep this module below game/target.ts): a fixed target
1146
+ * keeps its grid for the rest of the spell, otherwise fully reset. */
1147
+ const t = state.target;
1148
+ if (t.midx === midx) {
1149
+ t.midx = 0;
1150
+ if (!t.fixed) {
1151
+ t.set = false;
1152
+ t.grid = { x: 0, y: 0 };
1153
+ }
1154
+ }
1155
+ /* If the monster was tracked, forget it (health_track(NULL)). */
1156
+ if (state.healthWho === mon) state.healthWho = null;
1157
+ /* A commanded monster dying releases the player (mon-make.c L345). */
1158
+ if (mon.mTimed[MON_TMD.COMMAND]) {
1159
+ state.actor.player.timed[TMD.COMMAND] = 0;
1160
+ }
1161
+ /* Decrease the racial counter (clamped: test-harness monsters register
1162
+ * without counting, so a naked decrement could go negative). */
1163
+ const race = mon.originalRace ?? mon.race;
1164
+ if (race.curNum > 0) race.curNum--;
1165
+ /* Count the number of "reproducers" (mon-make.c L328): the current race's
1166
+ * MULTIPLY flag decides, clamped for the same harness reason as curNum. */
1167
+ if (mon.race.flags.has(RF.MULTIPLY) && (state.numRepro ?? 0) > 0) {
1168
+ state.numRepro = (state.numRepro ?? 0) - 1;
1169
+ }
1170
+ state.chunk.setMon(mon.grid, 0);
1171
+ state.monsters[midx] = null;
1172
+ }
1173
+
1174
+ /**
1175
+ * Mark the player's starting grid occupied (square(c, grid)->mon = -1) and
1176
+ * set actor.grid, mirroring how the player is placed on a fresh level.
1177
+ */
1178
+ export function placePlayer(state: GameState, grid: Loc): void {
1179
+ state.actor.grid = grid;
1180
+ state.chunk.setMon(grid, -1);
1181
+ }
1182
+
1183
+ /**
1184
+ * Move the player to a new grid, updating the square-occupancy marker
1185
+ * (clear the old grid, mark the new one with the player sentinel -1).
1186
+ * Fires player_leaving on the old grid (mon-util.c:612 / 659 via
1187
+ * monster_swap) so TRF_DELAY traps run before the post-move enter hooks.
1188
+ */
1189
+ export function movePlayer(state: GameState, grid: Loc): void {
1190
+ const old = state.actor.grid;
1191
+ if (old.x === grid.x && old.y === grid.y) return;
1192
+ state.chunk.setMon(old, 0);
1193
+ state.actor.grid = grid;
1194
+ state.chunk.setMon(grid, -1);
1195
+ state.onPlayerLeaving?.(state, old, grid);
1196
+ }
1197
+
1198
+ /**
1199
+ * The mon_take_hit arena branch (mon-util.c L1290) for the game-layer
1200
+ * kill sites: a lethal player blow in single combat signals the level
1201
+ * change (the arena exit finishes the monster) instead of killing.
1202
+ * Returns true when the death was intercepted (skip the kill).
1203
+ */
1204
+ export function arenaInterceptDeath(state: GameState, mon: Monster): boolean {
1205
+ if (!state.arenaLevel) return false;
1206
+ state.generateLevel = true;
1207
+ state.healthWho = mon;
1208
+ return true;
1209
+ }
1210
+
1211
+ /** Refresh mon->cdis for every live monster (update_mon does this upstream). */
1212
+ export function updateMonsterDistances(state: GameState): void {
1213
+ for (let i = 1; i < state.monsters.length; i++) {
1214
+ const mon = state.monsters[i];
1215
+ if (!mon) continue;
1216
+ mon.cdis = distance(mon.grid, state.actor.grid);
1217
+ }
1218
+ }