rpg-event-generator 1.3.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (431) hide show
  1. package/README.md +507 -7
  2. package/demo.js +153 -4
  3. package/dist/index.js +394 -11
  4. package/package.json +16 -3
  5. package/scripts/event-economy.js +388 -0
  6. package/scripts/export-templates.js +289 -0
  7. package/scripts/generate-templates.js +407 -0
  8. package/templates/cyberpunk/event_100.json +43 -0
  9. package/templates/cyberpunk/event_11.json +42 -0
  10. package/templates/cyberpunk/event_14.json +42 -0
  11. package/templates/cyberpunk/event_15.json +43 -0
  12. package/templates/cyberpunk/event_16.json +43 -0
  13. package/templates/cyberpunk/event_18.json +44 -0
  14. package/templates/cyberpunk/event_2.json +42 -0
  15. package/templates/cyberpunk/event_26.json +42 -0
  16. package/templates/cyberpunk/event_27.json +43 -0
  17. package/templates/cyberpunk/event_3.json +43 -0
  18. package/templates/cyberpunk/event_30.json +42 -0
  19. package/templates/cyberpunk/event_32.json +42 -0
  20. package/templates/cyberpunk/event_36.json +43 -0
  21. package/templates/cyberpunk/event_37.json +42 -0
  22. package/templates/cyberpunk/event_39.json +42 -0
  23. package/templates/cyberpunk/event_4.json +42 -0
  24. package/templates/cyberpunk/event_40.json +42 -0
  25. package/templates/cyberpunk/event_42.json +43 -0
  26. package/templates/cyberpunk/event_46.json +43 -0
  27. package/templates/cyberpunk/event_49.json +44 -0
  28. package/templates/cyberpunk/event_5.json +44 -0
  29. package/templates/cyberpunk/event_50.json +42 -0
  30. package/templates/cyberpunk/event_51.json +42 -0
  31. package/templates/cyberpunk/event_54.json +43 -0
  32. package/templates/cyberpunk/event_55.json +44 -0
  33. package/templates/cyberpunk/event_57.json +42 -0
  34. package/templates/cyberpunk/event_58.json +42 -0
  35. package/templates/cyberpunk/event_61.json +43 -0
  36. package/templates/cyberpunk/event_62.json +43 -0
  37. package/templates/cyberpunk/event_64.json +42 -0
  38. package/templates/cyberpunk/event_65.json +42 -0
  39. package/templates/cyberpunk/event_66.json +42 -0
  40. package/templates/cyberpunk/event_68.json +43 -0
  41. package/templates/cyberpunk/event_69.json +43 -0
  42. package/templates/cyberpunk/event_71.json +42 -0
  43. package/templates/cyberpunk/event_72.json +42 -0
  44. package/templates/cyberpunk/event_73.json +42 -0
  45. package/templates/cyberpunk/event_74.json +42 -0
  46. package/templates/cyberpunk/event_75.json +44 -0
  47. package/templates/cyberpunk/event_76.json +43 -0
  48. package/templates/cyberpunk/event_78.json +43 -0
  49. package/templates/cyberpunk/event_79.json +42 -0
  50. package/templates/cyberpunk/event_8.json +42 -0
  51. package/templates/cyberpunk/event_80.json +43 -0
  52. package/templates/cyberpunk/event_81.json +43 -0
  53. package/templates/cyberpunk/event_83.json +44 -0
  54. package/templates/cyberpunk/event_84.json +43 -0
  55. package/templates/cyberpunk/event_86.json +44 -0
  56. package/templates/cyberpunk/event_88.json +43 -0
  57. package/templates/cyberpunk/event_9.json +42 -0
  58. package/templates/cyberpunk/event_91.json +42 -0
  59. package/templates/cyberpunk/event_92.json +43 -0
  60. package/templates/cyberpunk/event_93.json +42 -0
  61. package/templates/cyberpunk/event_95.json +42 -0
  62. package/templates/cyberpunk/event_96.json +43 -0
  63. package/templates/cyberpunk/event_97.json +43 -0
  64. package/templates/cyberpunk/event_98.json +42 -0
  65. package/templates/cyberpunk/event_99.json +42 -0
  66. package/templates/fantasy/event_1.json +44 -0
  67. package/templates/fantasy/event_10.json +43 -0
  68. package/templates/fantasy/event_11.json +43 -0
  69. package/templates/fantasy/event_12.json +42 -0
  70. package/templates/fantasy/event_13.json +43 -0
  71. package/templates/fantasy/event_16.json +44 -0
  72. package/templates/fantasy/event_20.json +42 -0
  73. package/templates/fantasy/event_21.json +42 -0
  74. package/templates/fantasy/event_22.json +42 -0
  75. package/templates/fantasy/event_23.json +42 -0
  76. package/templates/fantasy/event_24.json +43 -0
  77. package/templates/fantasy/event_27.json +43 -0
  78. package/templates/fantasy/event_29.json +43 -0
  79. package/templates/fantasy/event_3.json +42 -0
  80. package/templates/fantasy/event_30.json +43 -0
  81. package/templates/fantasy/event_31.json +42 -0
  82. package/templates/fantasy/event_33.json +42 -0
  83. package/templates/fantasy/event_34.json +43 -0
  84. package/templates/fantasy/event_36.json +43 -0
  85. package/templates/fantasy/event_38.json +43 -0
  86. package/templates/fantasy/event_39.json +42 -0
  87. package/templates/fantasy/event_4.json +44 -0
  88. package/templates/fantasy/event_41.json +43 -0
  89. package/templates/fantasy/event_44.json +42 -0
  90. package/templates/fantasy/event_45.json +42 -0
  91. package/templates/fantasy/event_46.json +42 -0
  92. package/templates/fantasy/event_47.json +42 -0
  93. package/templates/fantasy/event_48.json +42 -0
  94. package/templates/fantasy/event_5.json +42 -0
  95. package/templates/fantasy/event_50.json +44 -0
  96. package/templates/fantasy/event_51.json +43 -0
  97. package/templates/fantasy/event_54.json +43 -0
  98. package/templates/fantasy/event_55.json +43 -0
  99. package/templates/fantasy/event_57.json +44 -0
  100. package/templates/fantasy/event_58.json +44 -0
  101. package/templates/fantasy/event_6.json +42 -0
  102. package/templates/fantasy/event_64.json +42 -0
  103. package/templates/fantasy/event_68.json +42 -0
  104. package/templates/fantasy/event_69.json +43 -0
  105. package/templates/fantasy/event_70.json +42 -0
  106. package/templates/fantasy/event_71.json +42 -0
  107. package/templates/fantasy/event_72.json +43 -0
  108. package/templates/fantasy/event_73.json +42 -0
  109. package/templates/fantasy/event_76.json +43 -0
  110. package/templates/fantasy/event_77.json +43 -0
  111. package/templates/fantasy/event_79.json +42 -0
  112. package/templates/fantasy/event_88.json +42 -0
  113. package/templates/fantasy/event_9.json +44 -0
  114. package/templates/fantasy/event_90.json +43 -0
  115. package/templates/fantasy/event_91.json +42 -0
  116. package/templates/fantasy/event_92.json +42 -0
  117. package/templates/fantasy/event_94.json +43 -0
  118. package/templates/fantasy/event_96.json +42 -0
  119. package/templates/fantasy/event_97.json +42 -0
  120. package/templates/fantasy/event_98.json +42 -0
  121. package/templates/fantasy/event_99.json +42 -0
  122. package/templates/historical/event_1.json +44 -0
  123. package/templates/historical/event_10.json +42 -0
  124. package/templates/historical/event_11.json +44 -0
  125. package/templates/historical/event_14.json +44 -0
  126. package/templates/historical/event_17.json +44 -0
  127. package/templates/historical/event_2.json +43 -0
  128. package/templates/historical/event_20.json +43 -0
  129. package/templates/historical/event_21.json +44 -0
  130. package/templates/historical/event_22.json +43 -0
  131. package/templates/historical/event_25.json +43 -0
  132. package/templates/historical/event_26.json +42 -0
  133. package/templates/historical/event_3.json +43 -0
  134. package/templates/historical/event_30.json +42 -0
  135. package/templates/historical/event_33.json +44 -0
  136. package/templates/historical/event_34.json +42 -0
  137. package/templates/historical/event_39.json +42 -0
  138. package/templates/historical/event_4.json +44 -0
  139. package/templates/historical/event_40.json +42 -0
  140. package/templates/historical/event_42.json +42 -0
  141. package/templates/historical/event_44.json +43 -0
  142. package/templates/historical/event_45.json +43 -0
  143. package/templates/historical/event_48.json +42 -0
  144. package/templates/historical/event_50.json +42 -0
  145. package/templates/historical/event_52.json +42 -0
  146. package/templates/historical/event_53.json +44 -0
  147. package/templates/historical/event_54.json +44 -0
  148. package/templates/historical/event_56.json +42 -0
  149. package/templates/historical/event_57.json +42 -0
  150. package/templates/historical/event_59.json +42 -0
  151. package/templates/historical/event_60.json +43 -0
  152. package/templates/historical/event_61.json +42 -0
  153. package/templates/historical/event_62.json +44 -0
  154. package/templates/historical/event_63.json +42 -0
  155. package/templates/historical/event_64.json +43 -0
  156. package/templates/historical/event_65.json +44 -0
  157. package/templates/historical/event_66.json +42 -0
  158. package/templates/historical/event_67.json +43 -0
  159. package/templates/historical/event_69.json +43 -0
  160. package/templates/historical/event_7.json +42 -0
  161. package/templates/historical/event_70.json +42 -0
  162. package/templates/historical/event_71.json +43 -0
  163. package/templates/historical/event_74.json +42 -0
  164. package/templates/historical/event_75.json +43 -0
  165. package/templates/historical/event_79.json +42 -0
  166. package/templates/historical/event_8.json +44 -0
  167. package/templates/historical/event_80.json +43 -0
  168. package/templates/historical/event_82.json +42 -0
  169. package/templates/historical/event_87.json +43 -0
  170. package/templates/historical/event_89.json +43 -0
  171. package/templates/historical/event_9.json +43 -0
  172. package/templates/historical/event_90.json +44 -0
  173. package/templates/historical/event_91.json +42 -0
  174. package/templates/historical/event_92.json +43 -0
  175. package/templates/historical/event_94.json +42 -0
  176. package/templates/historical/event_97.json +42 -0
  177. package/templates/horror/event_1.json +42 -0
  178. package/templates/horror/event_100.json +42 -0
  179. package/templates/horror/event_12.json +42 -0
  180. package/templates/horror/event_13.json +43 -0
  181. package/templates/horror/event_14.json +44 -0
  182. package/templates/horror/event_15.json +42 -0
  183. package/templates/horror/event_16.json +43 -0
  184. package/templates/horror/event_17.json +43 -0
  185. package/templates/horror/event_18.json +42 -0
  186. package/templates/horror/event_2.json +44 -0
  187. package/templates/horror/event_20.json +43 -0
  188. package/templates/horror/event_23.json +42 -0
  189. package/templates/horror/event_27.json +43 -0
  190. package/templates/horror/event_28.json +42 -0
  191. package/templates/horror/event_29.json +42 -0
  192. package/templates/horror/event_3.json +42 -0
  193. package/templates/horror/event_30.json +42 -0
  194. package/templates/horror/event_32.json +42 -0
  195. package/templates/horror/event_34.json +42 -0
  196. package/templates/horror/event_35.json +43 -0
  197. package/templates/horror/event_36.json +43 -0
  198. package/templates/horror/event_37.json +43 -0
  199. package/templates/horror/event_38.json +44 -0
  200. package/templates/horror/event_39.json +42 -0
  201. package/templates/horror/event_40.json +42 -0
  202. package/templates/horror/event_41.json +42 -0
  203. package/templates/horror/event_42.json +43 -0
  204. package/templates/horror/event_43.json +43 -0
  205. package/templates/horror/event_45.json +42 -0
  206. package/templates/horror/event_46.json +44 -0
  207. package/templates/horror/event_47.json +42 -0
  208. package/templates/horror/event_50.json +43 -0
  209. package/templates/horror/event_52.json +44 -0
  210. package/templates/horror/event_53.json +43 -0
  211. package/templates/horror/event_55.json +43 -0
  212. package/templates/horror/event_56.json +44 -0
  213. package/templates/horror/event_58.json +42 -0
  214. package/templates/horror/event_59.json +42 -0
  215. package/templates/horror/event_60.json +43 -0
  216. package/templates/horror/event_61.json +44 -0
  217. package/templates/horror/event_62.json +42 -0
  218. package/templates/horror/event_63.json +43 -0
  219. package/templates/horror/event_65.json +42 -0
  220. package/templates/horror/event_67.json +43 -0
  221. package/templates/horror/event_68.json +44 -0
  222. package/templates/horror/event_72.json +42 -0
  223. package/templates/horror/event_73.json +44 -0
  224. package/templates/horror/event_74.json +43 -0
  225. package/templates/horror/event_77.json +42 -0
  226. package/templates/horror/event_79.json +43 -0
  227. package/templates/horror/event_8.json +42 -0
  228. package/templates/horror/event_82.json +43 -0
  229. package/templates/horror/event_83.json +42 -0
  230. package/templates/horror/event_84.json +42 -0
  231. package/templates/horror/event_86.json +43 -0
  232. package/templates/horror/event_88.json +42 -0
  233. package/templates/horror/event_89.json +43 -0
  234. package/templates/horror/event_9.json +43 -0
  235. package/templates/horror/event_90.json +44 -0
  236. package/templates/horror/event_91.json +43 -0
  237. package/templates/horror/event_93.json +42 -0
  238. package/templates/horror/event_95.json +42 -0
  239. package/templates/horror/event_96.json +43 -0
  240. package/templates/horror/event_99.json +42 -0
  241. package/templates/index.json +445 -5
  242. package/templates/modern/event_10.json +42 -0
  243. package/templates/modern/event_100.json +43 -0
  244. package/templates/modern/event_11.json +44 -0
  245. package/templates/modern/event_13.json +42 -0
  246. package/templates/modern/event_15.json +43 -0
  247. package/templates/modern/event_16.json +42 -0
  248. package/templates/modern/event_17.json +42 -0
  249. package/templates/modern/event_19.json +43 -0
  250. package/templates/modern/event_2.json +42 -0
  251. package/templates/modern/event_20.json +42 -0
  252. package/templates/modern/event_21.json +43 -0
  253. package/templates/modern/event_22.json +43 -0
  254. package/templates/modern/event_23.json +43 -0
  255. package/templates/modern/event_25.json +43 -0
  256. package/templates/modern/event_27.json +42 -0
  257. package/templates/modern/event_28.json +42 -0
  258. package/templates/modern/event_31.json +42 -0
  259. package/templates/modern/event_32.json +43 -0
  260. package/templates/modern/event_34.json +44 -0
  261. package/templates/modern/event_35.json +42 -0
  262. package/templates/modern/event_36.json +44 -0
  263. package/templates/modern/event_37.json +42 -0
  264. package/templates/modern/event_39.json +42 -0
  265. package/templates/modern/event_4.json +42 -0
  266. package/templates/modern/event_41.json +42 -0
  267. package/templates/modern/event_42.json +44 -0
  268. package/templates/modern/event_43.json +42 -0
  269. package/templates/modern/event_44.json +44 -0
  270. package/templates/modern/event_45.json +44 -0
  271. package/templates/modern/event_46.json +44 -0
  272. package/templates/modern/event_47.json +43 -0
  273. package/templates/modern/event_48.json +42 -0
  274. package/templates/modern/event_49.json +43 -0
  275. package/templates/modern/event_5.json +43 -0
  276. package/templates/modern/event_51.json +42 -0
  277. package/templates/modern/event_52.json +42 -0
  278. package/templates/modern/event_55.json +43 -0
  279. package/templates/modern/event_56.json +42 -0
  280. package/templates/modern/event_57.json +42 -0
  281. package/templates/modern/event_59.json +42 -0
  282. package/templates/modern/event_6.json +43 -0
  283. package/templates/modern/event_60.json +43 -0
  284. package/templates/modern/event_61.json +42 -0
  285. package/templates/modern/event_63.json +42 -0
  286. package/templates/modern/event_64.json +42 -0
  287. package/templates/modern/event_66.json +42 -0
  288. package/templates/modern/event_67.json +42 -0
  289. package/templates/modern/event_69.json +42 -0
  290. package/templates/modern/event_7.json +43 -0
  291. package/templates/modern/event_70.json +42 -0
  292. package/templates/modern/event_72.json +43 -0
  293. package/templates/modern/event_74.json +43 -0
  294. package/templates/modern/event_78.json +42 -0
  295. package/templates/modern/event_8.json +42 -0
  296. package/templates/modern/event_80.json +44 -0
  297. package/templates/modern/event_81.json +43 -0
  298. package/templates/modern/event_82.json +42 -0
  299. package/templates/modern/event_83.json +42 -0
  300. package/templates/modern/event_84.json +44 -0
  301. package/templates/modern/event_85.json +42 -0
  302. package/templates/modern/event_86.json +42 -0
  303. package/templates/modern/event_87.json +44 -0
  304. package/templates/modern/event_89.json +42 -0
  305. package/templates/modern/event_94.json +42 -0
  306. package/templates/modern/event_97.json +43 -0
  307. package/templates/modern/event_98.json +42 -0
  308. package/templates/modern/event_99.json +44 -0
  309. package/templates/schema.json +87 -0
  310. package/templates/sci-fi/event_1.json +42 -0
  311. package/templates/sci-fi/event_11.json +43 -0
  312. package/templates/sci-fi/event_13.json +43 -0
  313. package/templates/sci-fi/event_15.json +43 -0
  314. package/templates/sci-fi/event_18.json +42 -0
  315. package/templates/sci-fi/event_19.json +43 -0
  316. package/templates/sci-fi/event_2.json +44 -0
  317. package/templates/sci-fi/event_22.json +42 -0
  318. package/templates/sci-fi/event_23.json +42 -0
  319. package/templates/sci-fi/event_24.json +43 -0
  320. package/templates/sci-fi/event_25.json +42 -0
  321. package/templates/sci-fi/event_27.json +43 -0
  322. package/templates/sci-fi/event_28.json +43 -0
  323. package/templates/sci-fi/event_30.json +43 -0
  324. package/templates/sci-fi/event_31.json +42 -0
  325. package/templates/sci-fi/event_32.json +42 -0
  326. package/templates/sci-fi/event_33.json +44 -0
  327. package/templates/sci-fi/event_34.json +42 -0
  328. package/templates/sci-fi/event_35.json +42 -0
  329. package/templates/sci-fi/event_36.json +42 -0
  330. package/templates/sci-fi/event_37.json +44 -0
  331. package/templates/sci-fi/event_39.json +43 -0
  332. package/templates/sci-fi/event_4.json +43 -0
  333. package/templates/sci-fi/event_41.json +42 -0
  334. package/templates/sci-fi/event_45.json +42 -0
  335. package/templates/sci-fi/event_47.json +43 -0
  336. package/templates/sci-fi/event_48.json +42 -0
  337. package/templates/sci-fi/event_50.json +43 -0
  338. package/templates/sci-fi/event_51.json +42 -0
  339. package/templates/sci-fi/event_53.json +42 -0
  340. package/templates/sci-fi/event_54.json +43 -0
  341. package/templates/sci-fi/event_55.json +42 -0
  342. package/templates/sci-fi/event_56.json +43 -0
  343. package/templates/sci-fi/event_59.json +42 -0
  344. package/templates/sci-fi/event_6.json +42 -0
  345. package/templates/sci-fi/event_60.json +43 -0
  346. package/templates/sci-fi/event_64.json +44 -0
  347. package/templates/sci-fi/event_65.json +43 -0
  348. package/templates/sci-fi/event_67.json +42 -0
  349. package/templates/sci-fi/event_7.json +42 -0
  350. package/templates/sci-fi/event_72.json +42 -0
  351. package/templates/sci-fi/event_73.json +43 -0
  352. package/templates/sci-fi/event_74.json +44 -0
  353. package/templates/sci-fi/event_75.json +43 -0
  354. package/templates/sci-fi/event_78.json +42 -0
  355. package/templates/sci-fi/event_80.json +42 -0
  356. package/templates/sci-fi/event_82.json +43 -0
  357. package/templates/sci-fi/event_83.json +44 -0
  358. package/templates/sci-fi/event_85.json +42 -0
  359. package/templates/sci-fi/event_87.json +42 -0
  360. package/templates/sci-fi/event_89.json +42 -0
  361. package/templates/sci-fi/event_9.json +42 -0
  362. package/templates/sci-fi/event_90.json +43 -0
  363. package/templates/sci-fi/event_92.json +44 -0
  364. package/templates/sci-fi/event_93.json +42 -0
  365. package/templates/sci-fi/event_94.json +42 -0
  366. package/templates/sci-fi/event_95.json +43 -0
  367. package/templates/sci-fi/event_96.json +43 -0
  368. package/templates/sci-fi/event_97.json +42 -0
  369. package/templates/space-opera/event_1.json +44 -0
  370. package/templates/space-opera/event_10.json +42 -0
  371. package/templates/space-opera/event_100.json +42 -0
  372. package/templates/space-opera/event_12.json +42 -0
  373. package/templates/space-opera/event_13.json +44 -0
  374. package/templates/space-opera/event_14.json +43 -0
  375. package/templates/space-opera/event_15.json +43 -0
  376. package/templates/space-opera/event_17.json +42 -0
  377. package/templates/space-opera/event_18.json +43 -0
  378. package/templates/space-opera/event_19.json +42 -0
  379. package/templates/space-opera/event_20.json +43 -0
  380. package/templates/space-opera/event_21.json +42 -0
  381. package/templates/space-opera/event_24.json +44 -0
  382. package/templates/space-opera/event_25.json +42 -0
  383. package/templates/space-opera/event_26.json +43 -0
  384. package/templates/space-opera/event_27.json +43 -0
  385. package/templates/space-opera/event_28.json +43 -0
  386. package/templates/space-opera/event_29.json +44 -0
  387. package/templates/space-opera/event_31.json +42 -0
  388. package/templates/space-opera/event_32.json +42 -0
  389. package/templates/space-opera/event_33.json +42 -0
  390. package/templates/space-opera/event_35.json +42 -0
  391. package/templates/space-opera/event_36.json +44 -0
  392. package/templates/space-opera/event_38.json +43 -0
  393. package/templates/space-opera/event_40.json +42 -0
  394. package/templates/space-opera/event_41.json +42 -0
  395. package/templates/space-opera/event_43.json +43 -0
  396. package/templates/space-opera/event_44.json +42 -0
  397. package/templates/space-opera/event_47.json +42 -0
  398. package/templates/space-opera/event_48.json +43 -0
  399. package/templates/space-opera/event_49.json +44 -0
  400. package/templates/space-opera/event_5.json +44 -0
  401. package/templates/space-opera/event_50.json +42 -0
  402. package/templates/space-opera/event_51.json +42 -0
  403. package/templates/space-opera/event_52.json +42 -0
  404. package/templates/space-opera/event_53.json +43 -0
  405. package/templates/space-opera/event_55.json +42 -0
  406. package/templates/space-opera/event_58.json +43 -0
  407. package/templates/space-opera/event_6.json +43 -0
  408. package/templates/space-opera/event_60.json +44 -0
  409. package/templates/space-opera/event_61.json +42 -0
  410. package/templates/space-opera/event_62.json +43 -0
  411. package/templates/space-opera/event_65.json +42 -0
  412. package/templates/space-opera/event_67.json +42 -0
  413. package/templates/space-opera/event_68.json +43 -0
  414. package/templates/space-opera/event_69.json +42 -0
  415. package/templates/space-opera/event_7.json +44 -0
  416. package/templates/space-opera/event_71.json +44 -0
  417. package/templates/space-opera/event_73.json +42 -0
  418. package/templates/space-opera/event_74.json +42 -0
  419. package/templates/space-opera/event_77.json +43 -0
  420. package/templates/space-opera/event_78.json +43 -0
  421. package/templates/space-opera/event_8.json +43 -0
  422. package/templates/space-opera/event_81.json +42 -0
  423. package/templates/space-opera/event_82.json +42 -0
  424. package/templates/space-opera/event_83.json +43 -0
  425. package/templates/space-opera/event_85.json +42 -0
  426. package/templates/space-opera/event_87.json +42 -0
  427. package/templates/space-opera/event_88.json +42 -0
  428. package/templates/space-opera/event_90.json +42 -0
  429. package/templates/space-opera/event_93.json +43 -0
  430. package/templates/space-opera/event_97.json +42 -0
  431. package/templates/space-opera/event_98.json +43 -0
@@ -0,0 +1,289 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Cross-Platform Template Export System for RPG Event Generator v2.0.0
5
+ * Exports templates in formats compatible with different game engines
6
+ */
7
+
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+
11
+ const CONFIG = {
12
+ inputDir: path.join(__dirname, '..', 'templates'),
13
+ outputDir: path.join(__dirname, '..', 'exports'),
14
+ formats: ['unity', 'godot', 'json', 'typescript']
15
+ };
16
+
17
+ if (!fs.existsSync(CONFIG.outputDir)) {
18
+ fs.mkdirSync(CONFIG.outputDir, { recursive: true });
19
+ }
20
+
21
+ const formatConverters = {
22
+ /**
23
+ * Unity ScriptableObject format
24
+ */
25
+ unity: (template, filename) => {
26
+ const className = toPascalCase(filename.replace('.json', ''));
27
+ const choices = template.choices.map((choice, index) => `
28
+ public Choice choice${index + 1} = new Choice() {
29
+ text = "${choice.text}",
30
+ consequence = "${choice.consequence}",
31
+ effects = new Dictionary<string, float>() {
32
+ ${Object.entries(choice.effect).map(([key, value]) => `{"${key}", ${value}}`).join(',\n ')}
33
+ }
34
+ };`).join('');
35
+
36
+ return `[CreateAssetMenu(fileName = "${className}", menuName = "RPG Events/${className}")]
37
+ public class ${className} : EventTemplate
38
+ {
39
+ public string title = "${template.title}";
40
+ public string narrative = @"${template.narrative}";
41
+ public string type = "${template.type}";
42
+ public string difficulty = "${template.difficulty}";
43
+ public string[] tags = { ${template.tags.map(tag => `"${tag}"`).join(', ')} };
44
+ public Dictionary<string, string> contextRequirements = new Dictionary<string, string>() {
45
+ ${Object.entries(template.context_requirements || {}).map(([key, value]) => `{"${key}", "${value}"}`).join(',\n ')}
46
+ };${choices}
47
+
48
+ public override void ExecuteEvent()
49
+ {
50
+ // Event execution logic here
51
+ Debug.Log($"Executing event: {title}");
52
+ }
53
+ }`;
54
+ },
55
+
56
+ /**
57
+ * Godot Resource format (GDScript)
58
+ */
59
+ godot: (template, filename) => {
60
+ const className = toPascalCase(filename.replace('.json', ''));
61
+ const choices = template.choices.map((choice, index) => `
62
+ var choice_${index + 1} = {
63
+ "text": "${choice.text}",
64
+ "consequence": "${choice.consequence}",
65
+ "effect": {
66
+ ${Object.entries(choice.effect).map(([key, value]) => `"${key}": ${value}`).join(',\n ')}
67
+ }
68
+ }`).join('');
69
+
70
+ return `extends Resource
71
+ class_name ${className}
72
+
73
+ export var title: String = "${template.title}"
74
+ export var narrative: String = """${template.narrative}"""
75
+ export var type: String = "${template.type}"
76
+ export var difficulty: String = "${template.difficulty}"
77
+ export var tags: Array = ${JSON.stringify(template.tags)}
78
+ export var context_requirements: Dictionary = ${JSON.stringify(template.context_requirements || {})}${choices}
79
+
80
+ func execute_event():
81
+ # Event execution logic here
82
+ print("Executing event: " + title)
83
+ return choices`;
84
+ },
85
+
86
+ /**
87
+ * TypeScript interface format
88
+ */
89
+ typescript: (template, filename) => {
90
+ const interfaceName = toPascalCase(filename.replace('.json', ''));
91
+ const choices = template.choices.map((choice, index) => `
92
+ choice${index + 1}: {
93
+ text: "${choice.text}",
94
+ consequence: "${choice.consequence}",
95
+ effect: {
96
+ ${Object.entries(choice.effect).map(([key, value]) => `${key}: ${typeof value === 'string' ? `"${value}"` : value}`).join(',\n ')}
97
+ }
98
+ }`).join(',');
99
+
100
+ return `export interface ${interfaceName} {
101
+ title: "${template.title}";
102
+ narrative: "${template.narrative}";
103
+ type: "${template.type}";
104
+ difficulty: "${template.difficulty}";
105
+ tags: ${JSON.stringify(template.tags)};${choices}
106
+ contextRequirements: ${JSON.stringify(template.context_requirements || {})};
107
+ }
108
+
109
+ export const ${toCamelCase(interfaceName)}: ${interfaceName} = {
110
+ title: "${template.title}",
111
+ narrative: "${template.narrative}",
112
+ type: "${template.type}",
113
+ difficulty: "${template.difficulty}",
114
+ tags: ${JSON.stringify(template.tags)},${template.choices.map((choice, index) => `
115
+ choice${index + 1}: {
116
+ text: "${choice.text}",
117
+ consequence: "${choice.consequence}",
118
+ effect: {
119
+ ${Object.entries(choice.effect).map(([key, value]) => `${key}: ${typeof value === 'string' ? `"${value}"` : value}`).join(',\n ')}
120
+ }
121
+ }`).join(',')}
122
+ contextRequirements: ${JSON.stringify(template.context_requirements || {})}
123
+ };`;
124
+ },
125
+
126
+ /**
127
+ * Clean JSON format (default)
128
+ */
129
+ json: (template, filename) => {
130
+ return JSON.stringify(template, null, 2);
131
+ }
132
+ };
133
+
134
+ function toPascalCase(str) {
135
+ return str
136
+ .replace(/[-_](.)/g, (_, letter) => letter.toUpperCase())
137
+ .replace(/^(.)/, (_, letter) => letter.toUpperCase());
138
+ }
139
+
140
+ function toCamelCase(str) {
141
+ return str
142
+ .replace(/[-_](.)/g, (_, letter) => letter.toUpperCase())
143
+ .replace(/^(.)/, (_, letter) => letter.toLowerCase());
144
+ }
145
+
146
+ function exportTemplates(format = 'json', genre = null) {
147
+ console.log(`🚀 Starting template export in ${format.toUpperCase()} format...`);
148
+
149
+ const genres = genre ? [genre] : fs.readdirSync(CONFIG.inputDir).filter(dir =>
150
+ fs.statSync(path.join(CONFIG.inputDir, dir)).isDirectory()
151
+ );
152
+
153
+ let exportedCount = 0;
154
+
155
+ genres.forEach(genreDir => {
156
+ const genrePath = path.join(CONFIG.inputDir, genreDir);
157
+ if (!fs.statSync(genrePath).isDirectory()) return;
158
+
159
+ const outputGenreDir = path.join(CONFIG.outputDir, format, genreDir);
160
+ if (!fs.existsSync(outputGenreDir)) {
161
+ fs.mkdirSync(outputGenreDir, { recursive: true });
162
+ }
163
+
164
+ const templateFiles = fs.readdirSync(genrePath).filter(file =>
165
+ file.endsWith('.json') && !file.includes('index')
166
+ );
167
+
168
+ templateFiles.forEach(filename => {
169
+ try {
170
+ const templatePath = path.join(genrePath, filename);
171
+ const template = JSON.parse(fs.readFileSync(templatePath, 'utf8'));
172
+
173
+ const converter = formatConverters[format];
174
+ if (!converter) {
175
+ console.error(`❌ Unknown format: ${format}`);
176
+ return;
177
+ }
178
+
179
+ const convertedContent = converter(template, filename);
180
+
181
+ let outputFilename;
182
+ switch (format) {
183
+ case 'unity':
184
+ outputFilename = filename.replace('.json', '.cs');
185
+ break;
186
+ case 'godot':
187
+ outputFilename = filename.replace('.json', '.gd');
188
+ break;
189
+ case 'typescript':
190
+ outputFilename = filename.replace('.json', '.ts');
191
+ break;
192
+ default:
193
+ outputFilename = filename;
194
+ }
195
+
196
+ const outputPath = path.join(outputGenreDir, outputFilename);
197
+ fs.writeFileSync(outputPath, convertedContent);
198
+
199
+ exportedCount++;
200
+ } catch (error) {
201
+ console.error(`❌ Error exporting ${filename}:`, error.message);
202
+ }
203
+ });
204
+ });
205
+
206
+ console.log(`✅ Successfully exported ${exportedCount} templates in ${format.toUpperCase()} format!`);
207
+ console.log(`📁 Output directory: ${path.join(CONFIG.outputDir, format)}`);
208
+ }
209
+
210
+ function exportIndexFiles() {
211
+ console.log(`📋 Generating index files for all formats...`);
212
+
213
+ CONFIG.formats.forEach(format => {
214
+ const formatDir = path.join(CONFIG.outputDir, format);
215
+
216
+ if (!fs.existsSync(formatDir)) {
217
+ fs.mkdirSync(formatDir, { recursive: true });
218
+ }
219
+
220
+ if (format === 'json') {
221
+ const sourceIndex = path.join(CONFIG.inputDir, 'index.json');
222
+ const destIndex = path.join(formatDir, 'index.json');
223
+ if (fs.existsSync(sourceIndex)) {
224
+ fs.copyFileSync(sourceIndex, destIndex);
225
+ }
226
+ } else {
227
+ const indexContent = generateIndexForFormat(format);
228
+ fs.writeFileSync(path.join(formatDir, 'index.txt'), indexContent);
229
+ }
230
+ });
231
+
232
+ console.log(`✅ Index files generated for all formats`);
233
+ }
234
+
235
+ function generateIndexForFormat(format) {
236
+ const genres = fs.readdirSync(CONFIG.inputDir).filter(dir =>
237
+ fs.statSync(path.join(CONFIG.inputDir, dir)).isDirectory()
238
+ );
239
+
240
+ let content = `RPG Event Generator v2.0.0 - ${format.toUpperCase()} Export Index\n`;
241
+ content += '='.repeat(50) + '\n\n';
242
+
243
+ genres.forEach(genre => {
244
+ const genrePath = path.join(CONFIG.outputDir, format, genre);
245
+ if (fs.existsSync(genrePath)) {
246
+ const files = fs.readdirSync(genrePath).filter(file =>
247
+ file.endsWith(getExtensionForFormat(format))
248
+ );
249
+
250
+ content += `${genre.toUpperCase()} (${files.length} templates):\n`;
251
+ files.forEach(file => {
252
+ content += ` - ${file}\n`;
253
+ });
254
+ content += '\n';
255
+ }
256
+ });
257
+
258
+ return content;
259
+ }
260
+
261
+ function getExtensionForFormat(format) {
262
+ switch (format) {
263
+ case 'unity': return '.cs';
264
+ case 'godot': return '.gd';
265
+ case 'typescript': return '.ts';
266
+ default: return '.json';
267
+ }
268
+ }
269
+
270
+ function main() {
271
+ const args = process.argv.slice(2);
272
+ const format = args[0] || 'json';
273
+ const genre = args[1] || null;
274
+
275
+ if (!CONFIG.formats.includes(format)) {
276
+ console.error(`❌ Unsupported format: ${format}`);
277
+ console.log(`📋 Supported formats: ${CONFIG.formats.join(', ')}`);
278
+ process.exit(1);
279
+ }
280
+
281
+ exportTemplates(format, genre);
282
+ exportIndexFiles();
283
+ }
284
+
285
+ if (require.main === module) {
286
+ main();
287
+ }
288
+
289
+ module.exports = { exportTemplates, exportIndexFiles };
@@ -0,0 +1,407 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Template Generation System for RPG Event Generator v2.0.0
5
+ * Generates thousands of diverse, high-quality event templates
6
+ */
7
+
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+
11
+ const CONFIG = {
12
+ outputDir: path.join(__dirname, '..', 'templates'),
13
+ targetCount: 100, // Start with 100 for Phase 1a
14
+ genres: ['fantasy', 'sci-fi', 'horror', 'historical', 'modern', 'cyberpunk', 'space-opera']
15
+ };
16
+
17
+ const GENRE_MAPPING = {
18
+ 'sci-fi': 'sci-fi',
19
+ 'space-opera': 'space-opera',
20
+ 'cyberpunk': 'cyberpunk',
21
+ 'fantasy': 'fantasy',
22
+ 'horror': 'horror',
23
+ 'historical': 'historical',
24
+ 'modern': 'modern'
25
+ };
26
+
27
+ const EVENT_TYPES = {
28
+ COMBAT: ['AMBUSH', 'DUEL', 'BATTLE', 'SIEGE', 'GUERRILLA', 'NAVAL'],
29
+ SOCIAL: ['BANQUET', 'BETRAYAL', 'ROMANCE', 'DIPLOMACY', 'NEGOTIATION', 'ALLIANCE'],
30
+ EXPLORATION: ['RUINS', 'CAVE', 'FOREST', 'MOUNTAIN', 'DESERT', 'ISLAND'],
31
+ ECONOMIC: ['TRADE', 'BARGAIN', 'BLACK_MARKET', 'AUCTION', 'HEIST', 'CONTRACT'],
32
+ MYSTERY: ['INVESTIGATION', 'CRYPTIC_MESSAGE', 'ANCIENT_ARTIFACT', 'STRANGE_OCCURRENCE'],
33
+ SUPERNATURAL: ['CURSE', 'POSSESSION', 'PROPHECY', 'MAGICAL_CREATURE', 'RITUAL'],
34
+ POLITICAL: ['COUP', 'ELECTION', 'ASSASSINATION', 'TREATY', 'CORRUPTION'],
35
+ TECHNOLOGICAL: ['HACK', 'MALFUNCTION', 'INVENTION', 'AI_REBELLION', 'CYBER_ATTACK'],
36
+ HORROR: ['HAUNTING', 'MONSTER', 'MADNESS', 'CULT', 'UNDEAD'],
37
+ QUEST: ['RETRIEVAL', 'ESCORT', 'DELIVERY', 'RESCUE', 'HUNT']
38
+ };
39
+
40
+ const LOCATIONS = {
41
+ fantasy: ['castle', 'village', 'forest', 'mountain', 'dungeon', 'tavern', 'market'],
42
+ 'sci-fi': ['spaceship', 'space-station', 'alien-planet', 'megacity', 'laboratory'],
43
+ horror: ['mansion', 'graveyard', 'abandoned-mine', 'cursed-forest', 'haunted-town'],
44
+ historical: ['palace', 'battlefield', 'trading-post', 'colonial-town', 'ancient-ruins'],
45
+ modern: ['city', 'suburb', 'office', 'mall', 'apartment', 'park'],
46
+ cyberpunk: ['megacity', 'underground', 'corporate-tower', 'neon-district'],
47
+ 'space-opera': ['starship', 'alien-world', 'space-station', 'wormhole']
48
+ };
49
+
50
+ const CAREERS = ['warrior', 'mage', 'merchant', 'noble', 'thief', 'priest', 'scholar', 'explorer', 'diplomat'];
51
+
52
+ function generateTitle(type, genre, location) {
53
+ const templates = {
54
+ COMBAT: [
55
+ `Desperate ${type} at ${capitalize(location)}`,
56
+ `${type} in the ${capitalize(location)}`,
57
+ `Sudden ${type} Encounter`,
58
+ `The ${type} of ${capitalize(location)}`
59
+ ],
60
+ SOCIAL: [
61
+ `Unexpected ${type} Meeting`,
62
+ `${type} at Court`,
63
+ `Social ${type} in ${capitalize(location)}`,
64
+ `The ${type} Gathering`
65
+ ],
66
+ EXPLORATION: [
67
+ `Discovery in ${capitalize(location)}`,
68
+ `Exploring the ${capitalize(location)}`,
69
+ `Ancient ${capitalize(location)} Secrets`,
70
+ `${capitalize(location)} Exploration`
71
+ ],
72
+ ECONOMIC: [
73
+ `${type} Deal Gone Wrong`,
74
+ `Economic ${type} Opportunity`,
75
+ `The ${type} of ${capitalize(location)}`,
76
+ `${type} Negotiations`
77
+ ],
78
+ MYSTERY: [
79
+ `The Mystery of ${capitalize(location)}`,
80
+ `Cryptic ${type} Message`,
81
+ `${type} Investigation`,
82
+ `Strange ${capitalize(location)} Occurrence`
83
+ ],
84
+ SUPERNATURAL: [
85
+ `${type} in ${capitalize(location)}`,
86
+ `Supernatural ${type} Event`,
87
+ `The ${type} Manifestation`,
88
+ `${capitalize(location)} ${type}`
89
+ ],
90
+ POLITICAL: [
91
+ `Political ${type} Crisis`,
92
+ `${type} in ${capitalize(location)}`,
93
+ `The ${type} Conspiracy`,
94
+ `${capitalize(location)} Intrigue`
95
+ ],
96
+ TECHNOLOGICAL: [
97
+ `${type} Malfunction`,
98
+ `Technological ${type} Crisis`,
99
+ `${type} Breakthrough`,
100
+ `The ${type} System`
101
+ ],
102
+ HORROR: [
103
+ `Terrifying ${type} in ${capitalize(location)}`,
104
+ `${type} Horror`,
105
+ `The ${capitalize(location)} ${type}`,
106
+ `${type} Nightmare`
107
+ ],
108
+ QUEST: [
109
+ `${type} Mission`,
110
+ `The ${type} Quest`,
111
+ `${type} for Hire`,
112
+ `${capitalize(location)} ${type}`
113
+ ]
114
+ };
115
+
116
+ const category = Object.keys(EVENT_TYPES).find(cat => EVENT_TYPES[cat].includes(type)) || 'QUEST';
117
+ const options = templates[category] || templates.QUEST;
118
+ return capitalize(options[Math.floor(Math.random() * options.length)]);
119
+ }
120
+
121
+ function capitalize(str) {
122
+ return str.split(' ').map(word => {
123
+ const lowerWords = ['at', 'in', 'the', 'of', 'and', 'or', 'but', 'for', 'to', 'with', 'by', 'on', 'as', 'a', 'an'];
124
+ if (lowerWords.includes(word.toLowerCase())) {
125
+ return word.toLowerCase();
126
+ }
127
+ return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
128
+ }).join(' ');
129
+ }
130
+
131
+ function generateNarrative(title, type, genre, location, difficulty) {
132
+ const templates = {
133
+ fantasy: [
134
+ `As you traverse the ${location}, you stumble upon ${title.toLowerCase()}. The air grows thick with magic and mystery.`,
135
+ `Legends speak of ${title.toLowerCase()} in the ${location}. Today, you face this ancient challenge.`,
136
+ `The ${location} holds many secrets. Today you discover ${title.toLowerCase()}, testing your mettle as a hero.`,
137
+ `Ancient runes glow as ${title.toLowerCase()} unfolds in the ${location}, awakening powers long dormant.`,
138
+ `Crystal chimes echo through the ${location} as ${title.toLowerCase()} demands your attention.`
139
+ ],
140
+ 'sci-fi': [
141
+ `Your scanners detect unusual readings from ${title.toLowerCase()} in ${location}. The future of your mission hangs in the balance.`,
142
+ `In the vast expanse of space, ${title.toLowerCase()} presents itself as both opportunity and danger.`,
143
+ `Technological marvels surround you in ${location}. Suddenly, ${title.toLowerCase()} demands your immediate attention.`,
144
+ `Holographic displays flicker as ${title.toLowerCase()} emerges from the digital void in ${location}.`,
145
+ `Quantum fluctuations herald ${title.toLowerCase()} aboard your vessel in ${location}.`
146
+ ],
147
+ horror: [
148
+ `Shadows whisper secrets in the ${location}. ${title.toLowerCase()} emerges from the darkness, chilling your very soul.`,
149
+ `The ${location} has always been cursed. Now ${title.toLowerCase()} proves the legends true.`,
150
+ `Terror grips your heart as ${title.toLowerCase()} manifests in the foreboding ${location}.`,
151
+ `Eerie silence falls over the ${location} as ${title.toLowerCase()} begins its terrifying work.`,
152
+ `Cold sweat beads on your brow as ${title.toLowerCase()} reveals itself in the ${location}.`
153
+ ],
154
+ historical: [
155
+ `In the annals of history, ${title.toLowerCase()} in ${location} will be remembered as a pivotal moment.`,
156
+ `The ${location} bears witness to ${title.toLowerCase()}, where politics and destiny collide.`,
157
+ `Ancient traditions meet modern challenges in ${title.toLowerCase()} at the ${location}.`,
158
+ `Royal decrees echo through the ${location} as ${title.toLowerCase()} unfolds before your eyes.`,
159
+ `The weight of history presses upon you as ${title.toLowerCase()} occurs in the ${location}.`
160
+ ],
161
+ cyberpunk: [
162
+ `Neon lights reflect off rain-slicked streets as ${title.toLowerCase()} unfolds in the ${location}.`,
163
+ `Corporate towers loom overhead while ${title.toLowerCase()} demands your attention in ${location}.`,
164
+ `The net comes alive with data streams heralding ${title.toLowerCase()} in the ${location}.`,
165
+ `Chrome and circuitry surround you as ${title.toLowerCase()} emerges from the digital shadows.`,
166
+ `Megacity sprawl provides the backdrop for ${title.toLowerCase()} in ${location}.`
167
+ ],
168
+ modern: [
169
+ `City lights illuminate ${title.toLowerCase()} as it unfolds in the bustling ${location}.`,
170
+ `Digital notifications ping as ${title.toLowerCase()} interrupts your day in ${location}.`,
171
+ `Contemporary life takes an unexpected turn with ${title.toLowerCase()} in the ${location}.`,
172
+ `Social media buzzes with rumors of ${title.toLowerCase()} occurring right now in ${location}.`,
173
+ `Modern conveniences fail you as ${title.toLowerCase()} demands immediate attention.`
174
+ ],
175
+ 'space-opera': [
176
+ `Star fields twinkle as ${title.toLowerCase()} erupts across multiple systems from ${location}.`,
177
+ `Imperial fleets maneuver while ${title.toLowerCase()} threatens galactic peace in ${location}.`,
178
+ `Alien artifacts pulse with energy as ${title.toLowerCase()} unfolds in the ${location}.`,
179
+ `Faster-than-light communications carry news of ${title.toLowerCase()} throughout the galaxy.`,
180
+ `Cosmic forces align as ${title.toLowerCase()} manifests in the legendary ${location}.`
181
+ ]
182
+ };
183
+
184
+ const mappedGenre = GENRE_MAPPING[genre] || 'fantasy';
185
+ const genreTemplates = templates[mappedGenre] || templates.fantasy;
186
+ return genreTemplates[Math.floor(Math.random() * genreTemplates.length)];
187
+ }
188
+
189
+ function generateChoices(type, difficulty) {
190
+ const choiceTemplates = {
191
+ COMBAT: [
192
+ { text: "Fight bravely and face the challenge head-on", effect: { risk: 20, reward: 30 }, consequence: "brave_combat" },
193
+ { text: "Use strategy and cunning to outmaneuver your opponent", effect: { strategy: 15, risk: 10 }, consequence: "strategic_combat" },
194
+ { text: "Attempt to flee and live to fight another day", effect: { cowardice: 10, safety: 15 }, consequence: "retreat_combat" }
195
+ ],
196
+ SOCIAL: [
197
+ { text: "Use diplomacy and charm to navigate the situation", effect: { influence: 20, reputation: 10 }, consequence: "diplomatic_social" },
198
+ { text: "Assert your authority and take command", effect: { influence: 15, risk: 25 }, consequence: "authoritative_social" },
199
+ { text: "Observe quietly and gather information", effect: { knowledge: 15, influence: -5 }, consequence: "observant_social" }
200
+ ],
201
+ EXPLORATION: [
202
+ { text: "Carefully investigate and document your findings", effect: { knowledge: 20, time: 1 }, consequence: "thorough_exploration" },
203
+ { text: "Quickly search for valuables and depart", effect: { gold: 15, risk: 10 }, consequence: "quick_exploration" },
204
+ { text: "Set up camp and study the area thoroughly", effect: { knowledge: 25, time: 2 }, consequence: "extended_exploration" }
205
+ ],
206
+ ECONOMIC: [
207
+ { text: "Negotiate shrewdly for the best deal", effect: { gold: 25, reputation: 5 }, consequence: "shrewd_negotiation" },
208
+ { text: "Take the straightforward approach", effect: { gold: 15, risk: 5 }, consequence: "straightforward_deal" },
209
+ { text: "Walk away and seek better opportunities", effect: { gold: -10, opportunity: 20 }, consequence: "walk_away_deal" }
210
+ ]
211
+ };
212
+
213
+ const category = Object.keys(EVENT_TYPES).find(cat => EVENT_TYPES[cat].includes(type)) || 'QUEST';
214
+ const choices = choiceTemplates[category] || choiceTemplates.EXPLORATION;
215
+
216
+ const adjustedChoices = choices.map(choice => ({
217
+ ...choice,
218
+ effect: adjustForDifficulty(choice.effect, difficulty)
219
+ }));
220
+
221
+ return adjustedChoices;
222
+ }
223
+
224
+ function adjustForDifficulty(effect, difficulty) {
225
+ const multipliers = {
226
+ easy: { reward: 1.5, risk: 0.5, gold: 1.3 },
227
+ normal: { reward: 1.0, risk: 1.0, gold: 1.0 },
228
+ hard: { reward: 0.7, risk: 1.4, gold: 0.8 },
229
+ legendary: { reward: 0.5, risk: 2.0, gold: 0.6 }
230
+ };
231
+
232
+ const mult = multipliers[difficulty] || multipliers.normal;
233
+ const adjusted = {};
234
+
235
+ for (const [key, value] of Object.entries(effect)) {
236
+ if (typeof value === 'number') {
237
+ if (key.includes('risk')) {
238
+ adjusted[key] = Math.round(value * mult.risk);
239
+ } else if (key.includes('gold')) {
240
+ adjusted[key] = Math.round(value * mult.gold);
241
+ } else if (key.includes('reward')) {
242
+ adjusted[key] = Math.round(value * mult.reward);
243
+ } else {
244
+ adjusted[key] = value;
245
+ }
246
+ } else {
247
+ adjusted[key] = value;
248
+ }
249
+ }
250
+
251
+ return adjusted;
252
+ }
253
+
254
+ function generateTags(type, genre, location) {
255
+ const baseTags = [genre, location.toLowerCase().replace(/-/g, '')];
256
+
257
+ const typeTags = {
258
+ COMBAT: ['battle', 'fight', 'combat', 'danger'],
259
+ SOCIAL: ['people', 'conversation', 'relationship', 'diplomacy'],
260
+ EXPLORATION: ['discovery', 'search', 'investigation', 'travel'],
261
+ ECONOMIC: ['trade', 'money', 'business', 'commerce'],
262
+ MYSTERY: ['puzzle', 'investigation', 'clue', 'secret'],
263
+ SUPERNATURAL: ['magic', 'supernatural', 'mystical', 'otherworldly'],
264
+ POLITICAL: ['politics', 'power', 'authority', 'government'],
265
+ TECHNOLOGICAL: ['technology', 'science', 'innovation', 'mechanical'],
266
+ HORROR: ['fear', 'terror', 'horror', 'nightmare'],
267
+ QUEST: ['adventure', 'mission', 'task', 'objective']
268
+ };
269
+
270
+ const category = Object.keys(EVENT_TYPES).find(cat => EVENT_TYPES[cat].includes(type)) || 'QUEST';
271
+ const categoryTags = typeTags[category] || typeTags.QUEST;
272
+
273
+ return [...baseTags, ...categoryTags.slice(0, 2), type.toLowerCase()];
274
+ }
275
+
276
+ function generateContextRequirements(genre, location, difficulty) {
277
+ const requirements = {
278
+ location: location
279
+ };
280
+
281
+ if (difficulty === 'legendary' && Math.random() > 0.5) {
282
+ requirements.career = CAREERS[Math.floor(Math.random() * CAREERS.length)];
283
+ }
284
+
285
+ if (difficulty === 'hard') {
286
+ requirements.min_level = Math.floor(Math.random() * 5) + 3;
287
+ } else if (difficulty === 'legendary') {
288
+ requirements.min_level = Math.floor(Math.random() * 10) + 10;
289
+ }
290
+
291
+ return requirements;
292
+ }
293
+
294
+ function generateTemplate(id, genre) {
295
+ const type = Object.values(EVENT_TYPES).flat()[Math.floor(Math.random() * Object.values(EVENT_TYPES).flat().length)];
296
+ const location = LOCATIONS[genre][Math.floor(Math.random() * LOCATIONS[genre].length)];
297
+ const difficulty = ['easy', 'normal', 'hard', 'legendary'][Math.floor(Math.random() * 4)];
298
+
299
+ const title = generateTitle(type, genre, location);
300
+ const narrative = generateNarrative(title, type, genre, location, difficulty);
301
+ const choices = generateChoices(type, difficulty);
302
+ const tags = generateTags(type, genre, location);
303
+ const contextRequirements = generateContextRequirements(genre, location, difficulty);
304
+
305
+ return {
306
+ title,
307
+ narrative,
308
+ choices,
309
+ difficulty,
310
+ type,
311
+ tags,
312
+ context_requirements: contextRequirements
313
+ };
314
+ }
315
+
316
+ function generateTemplates() {
317
+ console.log(`🎲 Starting template generation for ${CONFIG.targetCount} templates...`);
318
+
319
+ const templates = {};
320
+ let generated = 0;
321
+
322
+ CONFIG.genres.forEach(genre => {
323
+ const genreDir = path.join(CONFIG.outputDir, genre);
324
+ if (!fs.existsSync(genreDir)) {
325
+ fs.mkdirSync(genreDir, { recursive: true });
326
+ }
327
+ templates[genre] = [];
328
+ });
329
+
330
+ while (generated < CONFIG.targetCount) {
331
+ const genre = CONFIG.genres[Math.floor(Math.random() * CONFIG.genres.length)];
332
+ const template = generateTemplate(generated + 1, genre);
333
+
334
+ // Save individual template file
335
+ const filename = `event_${generated + 1}.json`;
336
+ const filepath = path.join(CONFIG.outputDir, genre, filename);
337
+ fs.writeFileSync(filepath, JSON.stringify(template, null, 2));
338
+
339
+ templates[genre].push(filename.replace('.json', ''));
340
+ generated++;
341
+
342
+ if (generated % 10 === 0) {
343
+ console.log(`📝 Generated ${generated} templates...`);
344
+ }
345
+ }
346
+
347
+ // Update index.json with all templates
348
+ const indexPath = path.join(CONFIG.outputDir, 'index.json');
349
+
350
+ // Read existing index or create new one
351
+ let indexData;
352
+ if (fs.existsSync(indexPath)) {
353
+ indexData = JSON.parse(fs.readFileSync(indexPath, 'utf8'));
354
+ } else {
355
+ indexData = {
356
+ version: "2.0.0",
357
+ genres: {},
358
+ totalTemplates: 0
359
+ };
360
+ }
361
+
362
+ // Get all existing templates from file system
363
+ const allGenres = fs.readdirSync(CONFIG.outputDir).filter(dir =>
364
+ fs.statSync(path.join(CONFIG.outputDir, dir)).isDirectory()
365
+ );
366
+
367
+ let totalCount = 0;
368
+
369
+ allGenres.forEach(genre => {
370
+ const genrePath = path.join(CONFIG.outputDir, genre);
371
+ const templateFiles = fs.readdirSync(genrePath).filter(file =>
372
+ file.endsWith('.json') && !file.includes('index')
373
+ );
374
+
375
+ const templateIds = templateFiles.map(file => file.replace('.json', ''));
376
+
377
+ if (!indexData.genres[genre]) {
378
+ indexData.genres[genre] = {
379
+ name: genre.charAt(0).toUpperCase() + genre.slice(1).replace('-', ' '),
380
+ description: genre === 'fantasy' ? 'Magical worlds, dragons, wizards, and epic quests' :
381
+ genre === 'sci-fi' ? 'Space exploration, advanced technology, alien encounters' :
382
+ genre === 'horror' ? 'Supernatural terror, psychological horror, dark secrets' :
383
+ genre === 'historical' ? 'Medieval politics, exploration, court intrigue' :
384
+ `Events in the ${genre} genre`,
385
+ templates: []
386
+ };
387
+ }
388
+
389
+ indexData.genres[genre].templates = templateIds;
390
+ totalCount += templateIds.length;
391
+ });
392
+
393
+ indexData.totalTemplates = totalCount;
394
+ indexData.version = "2.0.0";
395
+
396
+ fs.writeFileSync(indexPath, JSON.stringify(indexData, null, 2));
397
+
398
+ console.log(`✅ Successfully generated ${generated} templates across ${CONFIG.genres.length} genres!`);
399
+ console.log(`📁 Templates saved to ${CONFIG.outputDir}`);
400
+ }
401
+
402
+ // Run generation if called directly
403
+ if (require.main === module) {
404
+ generateTemplates();
405
+ }
406
+
407
+ module.exports = { generateTemplates, generateTemplate };