@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,794 @@
1
+ /**
2
+ * Character birth, ported from reference/src/player-birth.c (Angband 4.2.6):
3
+ * the point-buy stat cost table and buy/sell semantics, the classic stat
4
+ * roller (get_stats / do_cmd_roll_stats), history-chart generation, the
5
+ * age/height/weight rolls, starting gold, and the level-1 hitpoint math from
6
+ * player_generate.
7
+ *
8
+ * generatePlayer is a pure pipeline (race, class, options, rng) ->
9
+ * PlayerBirthResult. It uses the classic roller (the do_cmd_roll_stats path)
10
+ * for reproducible stats from a seeded Rng, or a supplied stat array (either a
11
+ * point-buy allocation or a standard-roller result).
12
+ *
13
+ * Also ported here (player-birth.c): generate_stats (the point-buy auto-spend
14
+ * heuristic that seeds the recommended per-class spread) and the Roman-numeral
15
+ * dynastic-suffix helpers (int_to_roman / roman_to_int / find_roman_suffix_start,
16
+ * used by do_cmd_birth_init when death -> new character reuses the savefile),
17
+ * plus the acceptance-flow engine helpers options_init_cheat, flavor_set_all_aware
18
+ * and the message-recall separator banner.
19
+ *
20
+ * DEFERRED (see parity/ledger/player-birth.yaml):
21
+ * - starting inventory objects (returned as tval/sval kind-name refs only)
22
+ * calc_mana runs in the session layer after birth (session/game.ts calls
23
+ * calcMana), so msp/csp are left at 0 here and populated there.
24
+ */
25
+
26
+ import type { Rng } from "../rng.js";
27
+ import { HIST, STAT } from "../generated/index.js";
28
+ import { TMD } from "../generated/index.js";
29
+ import {
30
+ calcBlows,
31
+ calcHitpoints,
32
+ calcSkills,
33
+ calcStatIndices,
34
+ modifyStatValue,
35
+ statUseToIndex,
36
+ } from "./calcs.js";
37
+ import { blankPlayer } from "./player.js";
38
+ import type { Player } from "./player.js";
39
+ import type { OptionState } from "./options.js";
40
+ import { historyAddFull } from "./history.js";
41
+ import { rollHp } from "./exp.js";
42
+ import { STAT_MAX } from "./types.js";
43
+ import type {
44
+ HistoryChart,
45
+ PlayerBody,
46
+ PlayerClass,
47
+ PlayerRace,
48
+ StartItem,
49
+ } from "./types.js";
50
+ import type { FlavorKnowledge } from "../obj/knowledge.js";
51
+ import type { ObjectKind } from "../obj/types.js";
52
+
53
+ /** z_info->start_gold (constants.txt). */
54
+ export const START_GOLD = 600;
55
+
56
+ /**
57
+ * birth_stat_costs[18 + 1] (player-birth.c): the point cost of a base stat at
58
+ * each value 0..18. Buying a stat from v to v+1 costs birth_stat_costs[v + 1].
59
+ */
60
+ export const BIRTH_STAT_COSTS: readonly number[] = [
61
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 4,
62
+ ];
63
+
64
+ /** MAX_BIRTH_POINTS = 3 * (1+1+1+1+1+1+2) (player-birth.c). */
65
+ export const MAX_BIRTH_POINTS = 20;
66
+
67
+ /** Base value every stat starts at during point-buy. */
68
+ export const BIRTH_STAT_BASE = 10;
69
+
70
+ /** Default PY_FOOD_FULL: the FOOD "Fed" grade max (90) times food_value (100). */
71
+ export const PY_FOOD_FULL_DEFAULT = 90 * 100;
72
+
73
+ /* ------------------------------------------------------------------ */
74
+ /* Point-buy (player-birth.c reset_stats / buy_stat / sell_stat) */
75
+ /* ------------------------------------------------------------------ */
76
+
77
+ /** Mutable point-buy state (the stats[]/points arrays in player-birth.c). */
78
+ export interface StatBuyState {
79
+ stats: number[];
80
+ pointsSpent: number[];
81
+ pointsLeft: number;
82
+ }
83
+
84
+ /** reset_stats: all stats at base 10, no points spent, full pool available. */
85
+ export function resetStats(): StatBuyState {
86
+ return {
87
+ stats: new Array<number>(STAT_MAX).fill(BIRTH_STAT_BASE),
88
+ pointsSpent: new Array<number>(STAT_MAX).fill(0),
89
+ pointsLeft: MAX_BIRTH_POINTS,
90
+ };
91
+ }
92
+
93
+ /** Cost to raise a stat currently at `value` by one point (below 18 only). */
94
+ export function statIncreaseCost(value: number): number {
95
+ return BIRTH_STAT_COSTS[value + 1] ?? 0;
96
+ }
97
+
98
+ /**
99
+ * buy_stat: raise stat `choice` by one if it is below 18 and enough points
100
+ * remain. Returns whether the purchase happened.
101
+ */
102
+ export function buyStat(state: StatBuyState, choice: number): boolean {
103
+ if (choice < 0 || choice >= STAT_MAX) return false;
104
+ const cur = state.stats[choice] ?? 0;
105
+ if (cur >= 18) return false;
106
+ const cost = statIncreaseCost(cur);
107
+ if (cost > state.pointsLeft) return false;
108
+ state.stats[choice] = cur + 1;
109
+ state.pointsSpent[choice] = (state.pointsSpent[choice] ?? 0) + cost;
110
+ state.pointsLeft -= cost;
111
+ return true;
112
+ }
113
+
114
+ /**
115
+ * sell_stat: lower stat `choice` by one if it is above the base of 10,
116
+ * refunding birth_stat_costs[value]. Returns whether the sale happened.
117
+ */
118
+ export function sellStat(state: StatBuyState, choice: number): boolean {
119
+ if (choice < 0 || choice >= STAT_MAX) return false;
120
+ const cur = state.stats[choice] ?? 0;
121
+ if (cur <= BIRTH_STAT_BASE) return false;
122
+ const refund = BIRTH_STAT_COSTS[cur] ?? 0;
123
+ state.stats[choice] = cur - 1;
124
+ state.pointsSpent[choice] = (state.pointsSpent[choice] ?? 0) - refund;
125
+ state.pointsLeft += refund;
126
+ return true;
127
+ }
128
+
129
+ /**
130
+ * Total point cost to raise a single stat from `from` to `to` (to <= 18),
131
+ * i.e. sum of birth_stat_costs[v] for v in (from, to]. Convenience wrapper
132
+ * over the buy_stat cost table.
133
+ */
134
+ export function pointBuyCost(from: number, to: number): number {
135
+ let total = 0;
136
+ for (let v = from; v < to; v++) total += statIncreaseCost(v);
137
+ return total;
138
+ }
139
+
140
+ /** recalculate_stats gold: start_gold + 50 * points_left. */
141
+ export function birthGold(pointsLeft: number): number {
142
+ return START_GOLD + 50 * pointsLeft;
143
+ }
144
+
145
+ /**
146
+ * generate_stats (player-birth.c:816-973): pick a reasonable set of point-buy
147
+ * starting stats for a race/class following the upstream 5-step heuristic, and
148
+ * return the resulting StatBuyState (stats/pointsSpent/pointsLeft). Draws NO
149
+ * RNG. Invoked by do_cmd_choose_race/class (player-birth.c:1101,1112) to seed
150
+ * the recommended per-class spread the point-buy screen starts from.
151
+ *
152
+ * Faithful to the C, step by step:
153
+ * 0. buy base STR up to 17 (a pure caster then skips straight to step 3);
154
+ * 1. buy DEX up to 17, tracking the best num_blows breakpoint (dex_break);
155
+ * 2. sell DEX back down to that breakpoint (drop DEX that buys no extra blow);
156
+ * 3. spend up to half the remaining pool on the spell-stat and CON (a warrior
157
+ * may spend all of it; a non-caster caps the spell-stat at base 16);
158
+ * 4. dump any leftover points on DEX, then the non-spell stats, in order.
159
+ *
160
+ * num_blows is recomputed after each DEX buy exactly as buy_stat(update=true)
161
+ * -> recalculate_stats -> get_bonuses would: calc_blows over the race/class
162
+ * modified STR/DEX indices with NO wielded weapon (obj == NULL), since the
163
+ * player is not outfitted until do_cmd_accept_character. percentDamage mirrors
164
+ * OPT(player, birth_percent_damage) (default off), which only raises the blow
165
+ * floor to two and never changes the breakpoint search.
166
+ */
167
+ export function generateStats(
168
+ race: PlayerRace,
169
+ cls: PlayerClass,
170
+ percentDamage = false,
171
+ ): StatBuyState {
172
+ const buy = resetStats();
173
+ const maxed = new Array<boolean>(STAT_MAX).fill(false);
174
+
175
+ /* spell_stat: the realm stat of the class's first book, or 0 if no magic. */
176
+ const spellStat = cls.magic.totalSpells
177
+ ? (cls.magic.books[0]?.realm.stat ?? 0)
178
+ : 0;
179
+ const caster = cls.maxAttacks < 5;
180
+ const warrior = cls.maxAttacks > 5;
181
+
182
+ let blows = 10;
183
+ let dexBreak = 10;
184
+
185
+ /* player->state.num_blows (100x) for the current allocation: calc_blows over
186
+ * the modified STR/DEX indices, unarmed (weaponWeight null). */
187
+ const numBlows = (): number => {
188
+ const strAdd =
189
+ (race.statAdj[STAT.STR] ?? 0) + (cls.statAdj[STAT.STR] ?? 0);
190
+ const dexAdd =
191
+ (race.statAdj[STAT.DEX] ?? 0) + (cls.statAdj[STAT.DEX] ?? 0);
192
+ const strInd = statUseToIndex(
193
+ modifyStatValue(buy.stats[STAT.STR] ?? 0, strAdd),
194
+ );
195
+ const dexInd = statUseToIndex(
196
+ modifyStatValue(buy.stats[STAT.DEX] ?? 0, dexAdd),
197
+ );
198
+ return calcBlows(cls, null, strInd, dexInd, 0, percentDamage);
199
+ };
200
+
201
+ let step = 0;
202
+ while (buy.pointsLeft > 0 && step >= 0) {
203
+ switch (step) {
204
+ /* Step 0: buy base STR 17. */
205
+ case 0: {
206
+ if (!maxed[STAT.STR] && (buy.stats[STAT.STR] ?? 0) < 17) {
207
+ if (!buyStat(buy, STAT.STR)) maxed[STAT.STR] = true;
208
+ } else {
209
+ step++;
210
+ /* If pure caster skip to step 3. */
211
+ if (caster) step = 3;
212
+ }
213
+ break;
214
+ }
215
+
216
+ /* Step 1: buy base DEX 17, recording the best blow breakpoint. */
217
+ case 1: {
218
+ if (!maxed[STAT.DEX] && (buy.stats[STAT.DEX] ?? 0) < 17) {
219
+ if (!buyStat(buy, STAT.DEX)) maxed[STAT.DEX] = true;
220
+ const nb = Math.trunc(numBlows() / 10);
221
+ if (nb > blows) {
222
+ blows = nb;
223
+ dexBreak = buy.stats[STAT.DEX] ?? 0;
224
+ }
225
+ } else {
226
+ step++;
227
+ }
228
+ break;
229
+ }
230
+
231
+ /* Step 2: sell back DEX that isn't getting us an extra blow. */
232
+ case 2: {
233
+ while ((buy.stats[STAT.DEX] ?? 0) > dexBreak) {
234
+ sellStat(buy, STAT.DEX);
235
+ maxed[STAT.DEX] = false;
236
+ }
237
+ step++;
238
+ break;
239
+ }
240
+
241
+ /*
242
+ * Step 3: spend up to half the remaining points on each of the spell-stat
243
+ * and CON, capped at base 16 unless a pure class [caster or warrior].
244
+ */
245
+ case 3: {
246
+ let pointsTrigger = Math.trunc(buy.pointsLeft / 2);
247
+
248
+ if (warrior) {
249
+ pointsTrigger = buy.pointsLeft;
250
+ } else {
251
+ while (
252
+ !maxed[spellStat] &&
253
+ (caster || (buy.stats[spellStat] ?? 0) < 18) &&
254
+ (buy.pointsSpent[spellStat] ?? 0) < pointsTrigger
255
+ ) {
256
+ if (!buyStat(buy, spellStat)) maxed[spellStat] = true;
257
+ if ((buy.pointsSpent[spellStat] ?? 0) > pointsTrigger) {
258
+ sellStat(buy, spellStat);
259
+ maxed[spellStat] = true;
260
+ }
261
+ }
262
+ }
263
+
264
+ while (
265
+ !maxed[STAT.CON] &&
266
+ (buy.stats[STAT.CON] ?? 0) < 16 &&
267
+ (buy.pointsSpent[STAT.CON] ?? 0) < pointsTrigger
268
+ ) {
269
+ if (!buyStat(buy, STAT.CON)) maxed[STAT.CON] = true;
270
+ if ((buy.pointsSpent[STAT.CON] ?? 0) > pointsTrigger) {
271
+ sellStat(buy, STAT.CON);
272
+ maxed[STAT.CON] = true;
273
+ }
274
+ }
275
+
276
+ step++;
277
+ break;
278
+ }
279
+
280
+ /*
281
+ * Step 4: spend any remaining points as far as possible, in order, on
282
+ * DEX and then the non-spell stat.
283
+ */
284
+ case 4: {
285
+ let nextStat: number;
286
+ if (!maxed[STAT.DEX]) {
287
+ nextStat = STAT.DEX;
288
+ } else if (!maxed[STAT.INT] && spellStat !== STAT.INT) {
289
+ nextStat = STAT.INT;
290
+ } else if (!maxed[STAT.WIS] && spellStat !== STAT.WIS) {
291
+ nextStat = STAT.WIS;
292
+ } else {
293
+ step++;
294
+ break;
295
+ }
296
+
297
+ /* Buy until we can't buy any more. */
298
+ while (buyStat(buy, nextStat)) {
299
+ /* keep buying this stat */
300
+ }
301
+ maxed[nextStat] = true;
302
+ break;
303
+ }
304
+
305
+ default: {
306
+ step = -1;
307
+ break;
308
+ }
309
+ }
310
+ }
311
+
312
+ return buy;
313
+ }
314
+
315
+ /* ------------------------------------------------------------------ */
316
+ /* Classic roller (player-birth.c get_stats) */
317
+ /* ------------------------------------------------------------------ */
318
+
319
+ /**
320
+ * get_stats: roll each stat as 5 + 1d3 + 1d4 + 1d5, re-rolling the whole set
321
+ * until the 15-dice total lands strictly between 7*STAT_MAX and 9*STAT_MAX.
322
+ * Returns the natural stat_max array (values 8..17), indexed by STAT.
323
+ */
324
+ export function rollStats(rng: Rng): number[] {
325
+ const dice = new Array<number>(3 * STAT_MAX).fill(0);
326
+ for (;;) {
327
+ let sum = 0;
328
+ for (let i = 0; i < 3 * STAT_MAX; i++) {
329
+ const d = rng.randint1(3 + (i % 3));
330
+ dice[i] = d;
331
+ sum += d;
332
+ }
333
+ if (sum > 7 * STAT_MAX && sum < 9 * STAT_MAX) break;
334
+ }
335
+ const stats = new Array<number>(STAT_MAX).fill(0);
336
+ for (let i = 0; i < STAT_MAX; i++) {
337
+ stats[i] =
338
+ 5 + (dice[3 * i] ?? 0) + (dice[3 * i + 1] ?? 0) + (dice[3 * i + 2] ?? 0);
339
+ }
340
+ return stats;
341
+ }
342
+
343
+ /* ------------------------------------------------------------------ */
344
+ /* History, age/height/weight, gold (player-birth.c) */
345
+ /* ------------------------------------------------------------------ */
346
+
347
+ /**
348
+ * get_history: walk the history graph from `chart`, at each node rolling
349
+ * randint1(100) and taking the first entry whose cumulative roll threshold is
350
+ * >= the roll, appending its text and moving to the successor chart. Returns
351
+ * the concatenated history string (empty when chart is null).
352
+ */
353
+ export function generateHistory(chart: HistoryChart | null, rng: Rng): string {
354
+ let res = "";
355
+ let node: HistoryChart | null = chart;
356
+ while (node) {
357
+ const roll = rng.randint1(100);
358
+ let chosen = node.entries[node.entries.length - 1] ?? null;
359
+ for (const entry of node.entries) {
360
+ if (roll <= entry.roll) {
361
+ chosen = entry;
362
+ break;
363
+ }
364
+ }
365
+ if (!chosen) break;
366
+ res += chosen.text;
367
+ node = chosen.succ;
368
+ }
369
+ return res;
370
+ }
371
+
372
+ /** get_ahw result: rolled age, height and weight. */
373
+ export interface Ahw {
374
+ age: number;
375
+ ht: number;
376
+ wt: number;
377
+ }
378
+
379
+ /**
380
+ * get_ahw: age = b_age + 1d(m_age); height and weight are normal rolls about
381
+ * the racial base with the racial modifier as the spread.
382
+ */
383
+ export function rollAhw(race: PlayerRace, rng: Rng): Ahw {
384
+ const age = race.baseAge + rng.randint1(race.modAge);
385
+ const ht = rng.randNormal(race.baseHeight, race.modHeight);
386
+ const wt = rng.randNormal(race.baseWeight, race.modWeight);
387
+ return { age, ht, wt };
388
+ }
389
+
390
+ /* ------------------------------------------------------------------ */
391
+ /* Full birth pipeline */
392
+ /* ------------------------------------------------------------------ */
393
+
394
+ /** A starting-inventory entry, kept as object kind-name refs (deferred). */
395
+ export interface StartItemRef {
396
+ tval: string;
397
+ sval: string;
398
+ min: number;
399
+ max: number;
400
+ eopts: string[];
401
+ }
402
+
403
+ /** Inputs to generatePlayer that come from the registry / birth choices. */
404
+ export interface PlayerBirthOptions {
405
+ /** The race's equipment body (registry.bodies[race.body]). */
406
+ body: PlayerBody;
407
+ /** The race's starting history chart (registry.historyChart(race)). */
408
+ historyChart: HistoryChart | null;
409
+ /** Starting timed[FOOD] ceiling; defaults to PY_FOOD_FULL_DEFAULT. */
410
+ foodFull?: number;
411
+ /**
412
+ * Point-based allocated base stats (STAT_MAX values, each in
413
+ * [BIRTH_STAT_BASE, 18]), the ui-birth.c BR_POINTBASED result. When present,
414
+ * these stats are applied faithfully through the point-buy primitives
415
+ * (reset_stats + buy_stat) and the classic roller is NOT run, so the stat
416
+ * stage draws ZERO RNG and the leftover-point gold bonus (get_money) is
417
+ * honoured. Omit for the classic roller (rollStats). Values below the base of
418
+ * 10 are clamped up to the base; values above 18 are capped by buy_stat.
419
+ */
420
+ stats?: readonly number[];
421
+ /**
422
+ * A standard-roller result (do_cmd_roll_stats, player-birth.c:1159-1193): the
423
+ * STAT_MAX natural stat values are applied VERBATIM - no point-buy clamp, no
424
+ * cost accounting, no RNG. Mutually exclusive with `stats`; `rolledStats`
425
+ * wins if both are given. Like the classic roller the roller leaves zero
426
+ * leftover points, so get_money awards exactly start_gold. Use this to thread
427
+ * a stat set the shell's roller UI rolled and the player accepted, keeping the
428
+ * downstream draws (rollHp / ahw / history) byte-identical to the other paths.
429
+ */
430
+ rolledStats?: readonly number[];
431
+ /**
432
+ * An edited character background (do_cmd_choose_history, player-birth.c:1219-
433
+ * 1230): when present it REPLACES the get_history result stored on the player.
434
+ * The history walk is still run against `historyChart` so the RNG draw order
435
+ * is unchanged (get_history has already consumed its draws by the time
436
+ * do_cmd_choose_history overwrites the text upstream); only the final string
437
+ * is overridden.
438
+ */
439
+ historyOverride?: string;
440
+ }
441
+
442
+ /** Result of the birth pipeline: the new player plus deferred references. */
443
+ export interface PlayerBirthResult {
444
+ player: Player;
445
+ /** Class starting inventory, unresolved (object binding deferred). */
446
+ startingKit: StartItemRef[];
447
+ /** The generated history text (also stored on player.history). */
448
+ history: string;
449
+ }
450
+
451
+ /**
452
+ * generate_player pipeline (player_generate + get_stats + get_ahw +
453
+ * get_history + get_money, with level-1 hitpoints from calc_hitpoints).
454
+ *
455
+ * The RNG is consumed in this order: stat rolls, then age/height/weight, then
456
+ * the history walk, matching the do_cmd_roll_stats sequence (get_bonuses,
457
+ * which does not consume the RNG, sits between stats and ahw upstream).
458
+ */
459
+ export function generatePlayer(
460
+ race: PlayerRace,
461
+ cls: PlayerClass,
462
+ options: PlayerBirthOptions,
463
+ rng: Rng,
464
+ ): PlayerBirthResult {
465
+ const player = blankPlayer(race, cls, options.body);
466
+
467
+ /*
468
+ * Stats: point-based (a given allocation, drawing ZERO RNG) or the classic
469
+ * roller. For point-based we replay the allocation through reset_stats +
470
+ * buy_stat so the resulting stats match ui-birth.c's point-buy exactly. The
471
+ * leftover-point pool no longer affects gold (get_money resets au to
472
+ * start_gold at accept, see below). For the classic path the RNG draw is the
473
+ * unchanged rollStats sequence.
474
+ */
475
+ let statMax: number[];
476
+ if (options.rolledStats) {
477
+ /* Standard roller: the accepted natural stats are applied verbatim (no
478
+ * point-buy clamp, no RNG). do_cmd_roll_stats zeroes the points
479
+ * (player-birth.c:1183-1187) and get_money awards start_gold either way. */
480
+ statMax = new Array<number>(STAT_MAX)
481
+ .fill(0)
482
+ .map((_, i) => options.rolledStats?.[i] ?? 0);
483
+ } else if (options.stats) {
484
+ const buy = resetStats();
485
+ for (let i = 0; i < STAT_MAX; i++) {
486
+ const target = options.stats[i] ?? BIRTH_STAT_BASE;
487
+ while ((buy.stats[i] ?? 0) < target && buyStat(buy, i)) {
488
+ /* raise this stat one point at a time, up to the target */
489
+ }
490
+ }
491
+ statMax = buy.stats;
492
+ } else {
493
+ statMax = rollStats(rng);
494
+ }
495
+ for (let i = 0; i < STAT_MAX; i++) {
496
+ player.statMax[i] = statMax[i] ?? 0;
497
+ player.statCur[i] = statMax[i] ?? 0;
498
+ player.statBirth[i] = statMax[i] ?? 0;
499
+ player.statMap[i] = i;
500
+ }
501
+
502
+ /* Level 1, experience factor and hitdice (player_generate). */
503
+ player.lev = 1;
504
+ player.maxLev = 1;
505
+ player.exp = 0;
506
+ player.maxExp = 0;
507
+ player.expFrac = 0;
508
+ player.expFactor = race.expFactor + cls.expFactor;
509
+ player.hitdie = race.hitdie + cls.hitdie;
510
+ player.playerHp[0] = player.hitdie;
511
+ /* roll_hp: the cumulative hitdice for levels 2..50, banded 3/8..5/8. */
512
+ rollHp(player, rng);
513
+
514
+ /* Stat indices into adj_* tables, then level-1 hitpoints. */
515
+ const statInd = calcStatIndices(race, cls, player.statCur);
516
+ const conAdd = (race.statAdj[STAT.CON] ?? 0) + (cls.statAdj[STAT.CON] ?? 0);
517
+ const conInd = statUseToIndex(
518
+ modifyStatValue(player.statCur[STAT.CON] ?? 0, conAdd),
519
+ );
520
+ player.mhp = calcHitpoints(player.playerHp[0] ?? 0, 1, conInd);
521
+ player.chp = player.mhp;
522
+ player.chpFrac = 0;
523
+ /* Mana: calcMana runs in the session layer after birth; born at 0 here. */
524
+ player.msp = 0;
525
+ player.csp = 0;
526
+ player.cspFrac = 0;
527
+
528
+ /* Non-equipment level-based skills. */
529
+ player.skills = calcSkills(race, cls, 1, statInd);
530
+
531
+ /* Age / height / weight. */
532
+ const ahw = rollAhw(race, rng);
533
+ player.age = ahw.age;
534
+ player.ht = ahw.ht;
535
+ player.wt = ahw.wt;
536
+ player.htBirth = ahw.ht;
537
+ player.wtBirth = ahw.wt;
538
+
539
+ /* Well fed to start (player_generate). */
540
+ const foodFull = options.foodFull ?? PY_FOOD_FULL_DEFAULT;
541
+ player.timed[TMD.FOOD] = foodFull - 1;
542
+
543
+ /* History. The get_history walk always runs (so the RNG stream is identical
544
+ * across paths); an edited background (do_cmd_choose_history) then overrides
545
+ * the resulting text, exactly as upstream replaces player->history. */
546
+ const rolledHistory = generateHistory(options.historyChart, rng);
547
+ const history = options.historyOverride ?? rolledHistory;
548
+ player.history = history;
549
+
550
+ /* Starting gold. do_cmd_accept_character (player-birth.c:1255) calls
551
+ * get_money AFTER the interactive point-buy screen, and get_money (L392)
552
+ * unconditionally sets au = au_birth = z_info->start_gold, DISCARDING the
553
+ * "start_gold + 50 * points_left" preview that recalculate_stats (L693)
554
+ * showed during birth. So every accepted character starts with exactly
555
+ * START_GOLD regardless of leftover points. birthGold(pointsLeft) is kept
556
+ * for the point-buy screen's live gold preview only, never the final value. */
557
+ player.au = START_GOLD;
558
+ player.auBirth = START_GOLD;
559
+
560
+ /* do_cmd_accept_character (player-birth.c L1241-1242): history_clear then
561
+ * history_add(HIST_PLAYER_BIRTH). blankPlayer already leaves player.hist
562
+ * empty, so the clear is a no-op here; stamped with the constants true of
563
+ * every character at birth (town, level 1, turn 0). */
564
+ historyAddFull(
565
+ player,
566
+ 1 << HIST.PLAYER_BIRTH,
567
+ 0,
568
+ 0,
569
+ 1,
570
+ 0,
571
+ "Began the quest to destroy Morgoth.",
572
+ );
573
+
574
+ const startingKit: StartItemRef[] = cls.startItems.map((s: StartItem) => ({
575
+ tval: s.tval,
576
+ sval: s.sval,
577
+ min: s.min,
578
+ max: s.max,
579
+ eopts: [...s.eopts],
580
+ }));
581
+
582
+ return { player, startingKit, history };
583
+ }
584
+
585
+ /* ------------------------------------------------------------------ */
586
+ /* Acceptance-flow engine helpers (do_cmd_accept_character) */
587
+ /* ------------------------------------------------------------------ */
588
+
589
+ /**
590
+ * The birth message-recall separator banner (player-birth.c:1245-1249): five
591
+ * lines pushed into the message log at do_cmd_accept_character so the new
592
+ * character's messages start below a visible divider. Emit each verbatim (in
593
+ * order) through the shell's message sink at acceptance. Exact strings and
594
+ * order are load-bearing (upstream message_add) - do not trim the padded
595
+ * spaces.
596
+ */
597
+ export const BIRTH_MESSAGE_RECALL_BANNER: readonly string[] = [
598
+ " ",
599
+ " ",
600
+ "====================",
601
+ " ",
602
+ " ",
603
+ ];
604
+
605
+ /**
606
+ * options_init_cheat (option.c:175-185): clear every cheat option and its
607
+ * score twin at character acceptance so a fresh character starts un-flagged.
608
+ * Upstream clears opt[i] and opt[i+1] (the score option that immediately
609
+ * follows each cheat option); the port models the twin by name (cheat_X ->
610
+ * score_X), matching OptionState's own coupling.
611
+ */
612
+ export function optionsInitCheat(options: OptionState): void {
613
+ for (const name of options.names()) {
614
+ if (!options.isCheat(name)) continue;
615
+ options.set(name, false);
616
+ /* cheat_X -> score_X (the adjacent score option upstream clears). */
617
+ const twin = "score" + name.slice("cheat".length);
618
+ options.set(twin, false);
619
+ }
620
+ }
621
+
622
+ /**
623
+ * flavor_set_all_aware (obj-util.c:252-266): mark every flavoured object kind
624
+ * aware, so a birth_know_flavors character auto-identifies consumables on
625
+ * sight. Upstream sets kind->aware for every kind with a kind->flavor; the port
626
+ * keeps the per-game flavour assignment out of the immutable kind records, so
627
+ * the caller supplies `hasFlavor` (state.hasFlavor / flavorAssignment.hasFlavor)
628
+ * to decide which kinds were flavoured this game.
629
+ */
630
+ export function flavorSetAllAware(
631
+ flavor: FlavorKnowledge,
632
+ kinds: readonly ObjectKind[],
633
+ hasFlavor: (kind: ObjectKind) => boolean,
634
+ ): void {
635
+ for (const kind of kinds) {
636
+ if (hasFlavor(kind)) flavor.setAware(kind);
637
+ }
638
+ }
639
+
640
+ /* ------------------------------------------------------------------ */
641
+ /* Roman-numeral dynastic suffixes (player-birth.c:1329-1481) */
642
+ /* ------------------------------------------------------------------ */
643
+
644
+ /** int_to_roman symbol labels, largest first (player-birth.c:1371-1373). */
645
+ const ROMAN_LABELS: readonly string[] = [
646
+ "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I",
647
+ ];
648
+ /** int_to_roman symbol values, aligned with ROMAN_LABELS. */
649
+ const ROMAN_VALUES: readonly number[] = [
650
+ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1,
651
+ ];
652
+ /** The seven single roman characters, high to low (roman_to_int chr1). */
653
+ const ROMAN_CHR1 = "MDCLXVI";
654
+ /** roman_to_int chr2: the subtractive follow chars per chr1 index. */
655
+ const ROMAN_CHR2: readonly (string | null)[] = [
656
+ null, null, "DM", null, "LC", null, "VX",
657
+ ];
658
+ /** roman_to_int token values per [chr1 index][chr2 index]. */
659
+ const ROMAN_TOKEN_VALS: readonly (readonly number[])[] = [
660
+ [1000],
661
+ [500],
662
+ [100, 400, 900],
663
+ [50],
664
+ [10, 40, 90],
665
+ [5],
666
+ [1, 4, 9],
667
+ ];
668
+
669
+ /**
670
+ * int_to_roman (player-birth.c:1368-1413): the upper-case roman numeral for a
671
+ * positive integer, or null when none exists (n < 1) or the result would not
672
+ * fit in `bufSize` characters (upstream returns 0 and an empty buffer). The
673
+ * default bufSize is large enough that only n < 1 fails.
674
+ */
675
+ export function intToRoman(n: number, bufSize = 64): string | null {
676
+ if (n < 1) return null;
677
+ let out = "";
678
+ let rem = n;
679
+ while (rem > 0) {
680
+ let i = 0;
681
+ while (rem < (ROMAN_VALUES[i] ?? 0)) i++;
682
+ const label = ROMAN_LABELS[i] ?? "";
683
+ /* No room in buffer (label + trailing NUL), so abort (L1393-1395). */
684
+ if (out.length + label.length + 1 > bufSize) break;
685
+ out += label;
686
+ rem -= ROMAN_VALUES[i] ?? 0;
687
+ }
688
+ /* Ran out of space and aborted (L1404-1410). */
689
+ if (rem > 0) return null;
690
+ return out;
691
+ }
692
+
693
+ /**
694
+ * roman_to_int (player-birth.c:1428-1481): the integer value of a roman
695
+ * numeral, or -1 when the string is empty or contains a non-roman character.
696
+ * The upstream quirk of parsing certain nonsense strings (e.g. "IVXCCCVIII")
697
+ * is preserved deliberately.
698
+ */
699
+ export function romanToInt(roman: string): number {
700
+ if (roman.length === 0) return -1;
701
+ let n = 0;
702
+ for (let i = 0; i < roman.length; i++) {
703
+ const c1 = roman[i] ?? "";
704
+ const c2 = roman[i + 1];
705
+ const c1i = ROMAN_CHR1.indexOf(c1);
706
+ if (c1i < 0) return -1;
707
+ let c2i = 0;
708
+ const follow = ROMAN_CHR2[c1i];
709
+ if (follow && c2 !== undefined) {
710
+ const p = follow.indexOf(c2);
711
+ if (p >= 0) {
712
+ c2i = p + 1;
713
+ /* Two-char token, so skip a char on the next pass. */
714
+ i++;
715
+ }
716
+ }
717
+ n += ROMAN_TOKEN_VALS[c1i]?.[c2i] ?? 0;
718
+ }
719
+ return n;
720
+ }
721
+
722
+ /**
723
+ * find_roman_suffix_start (player-birth.c:1336-1354): the index within `buf`
724
+ * where a trailing roman-numeral suffix begins (the character after the last
725
+ * space), or null when there is no space or the characters after it are not all
726
+ * roman symbols. A trailing space yields an index at the end of the string
727
+ * (an empty suffix), matching the C pointer-to-NUL behaviour.
728
+ */
729
+ export function findRomanSuffixStart(buf: string): number | null {
730
+ const sp = buf.lastIndexOf(" ");
731
+ if (sp < 0) return null;
732
+ const start = sp + 1;
733
+ for (let p = start; p < buf.length; p++) {
734
+ if (!ROMAN_CHR1.includes(buf[p] ?? "")) return null;
735
+ }
736
+ return start;
737
+ }
738
+
739
+ /**
740
+ * player_safe_name (player.c:389-420): the character name reduced to a filename.
741
+ * Every character that is not a letter or digit becomes '_', and with
742
+ * `stripSuffix` a trailing roman-numeral dynasty suffix is dropped along with
743
+ * the space before it (so "Bob III" dumps as "Bob", not "Bob_III").
744
+ *
745
+ * Lives here because it is the only caller of find_roman_suffix_start outside
746
+ * the birth flow. `safelen` is the C's buffer size; the result is truncated to
747
+ * it exactly as the C's `limit = MIN(limit, safelen)` does.
748
+ *
749
+ * A name that is entirely stripped yields "" - upstream then writes ".txt",
750
+ * which the port keeps rather than inventing a placeholder.
751
+ */
752
+ export function playerSafeName(name: string, safelen: number, stripSuffix: boolean): string {
753
+ let limit = name.length;
754
+ if (stripSuffix) {
755
+ const suffix = findRomanSuffixStart(name);
756
+ if (suffix !== null) limit = suffix - 1; /* -1 for preceding space */
757
+ }
758
+ if (limit > safelen) limit = safelen;
759
+ let out = "";
760
+ for (let i = 0; i < limit; i++) {
761
+ const c = name[i] ?? "";
762
+ out += /^[A-Za-z0-9]$/u.test(c) ? c : "_";
763
+ }
764
+ return out;
765
+ }
766
+
767
+ /**
768
+ * The dynastic-suffix increment from player_birth (player-birth.c:1060-1073):
769
+ * when a previous character exists (`player->ht_birth`, the same condition that
770
+ * enables quickstart), a name that already carries a roman-numeral suffix has
771
+ * that suffix bumped by one (Name II -> Name III) BEFORE the birth menus run,
772
+ * so the name prompt offers the next generation by default. Returns the new
773
+ * full name; a name with no roman suffix is returned unchanged, and one whose
774
+ * incremented suffix will not fit is returned unchanged after reporting
775
+ * "Sorry, could not deal with suffix" (L1071).
776
+ *
777
+ * `bufSize` is PLAYER_NAME_LEN (option.h:23 = 32) by default. `msg` is the
778
+ * message sink; omitted, the failure is silent (the worldless-test shape).
779
+ */
780
+ export function incrementNameSuffix(
781
+ fullName: string,
782
+ bufSize = 32,
783
+ msg?: (text: string) => void,
784
+ ): string {
785
+ const start = findRomanSuffixStart(fullName);
786
+ if (start === null) return fullName;
787
+ const suffix = fullName.slice(start);
788
+ const roman = intToRoman(romanToInt(suffix) + 1, bufSize - start);
789
+ if (roman === null) {
790
+ msg?.("Sorry, could not deal with suffix");
791
+ return fullName;
792
+ }
793
+ return fullName.slice(0, start) + roman;
794
+ }