@strixit/storyscript 0.0.0-stage → 1.0.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 (370) hide show
  1. package/.env +1 -0
  2. package/CodeSnippets/StoryScriptSnippets.code-snippets +573 -0
  3. package/LICENSE.txt +21 -0
  4. package/LiveTemplates/StoryScript.xml +271 -0
  5. package/README.md +9 -2
  6. package/baseViteConfig.js +112 -0
  7. package/clientFiles/currentGameName.js +1 -0
  8. package/clientFiles/gitignore +12 -0
  9. package/clientFiles/tsconfig.json +34 -0
  10. package/clientFiles/vite.config.ts +14 -0
  11. package/clientFiles/vitest.config.ts +29 -0
  12. package/dist/src/Engine/Actions/index.d.ts +2 -0
  13. package/dist/src/Engine/Actions/open.d.ts +6 -0
  14. package/dist/src/Engine/Actions/openWithKey.d.ts +7 -0
  15. package/dist/src/Engine/EntityCreatorFunctions.d.ts +18 -0
  16. package/dist/src/Engine/Interfaces/action.d.ts +37 -0
  17. package/dist/src/Engine/Interfaces/autoplayStep.d.ts +11 -0
  18. package/dist/src/Engine/Interfaces/barrier.d.ts +16 -0
  19. package/dist/src/Engine/Interfaces/barrierAction.d.ts +19 -0
  20. package/dist/src/Engine/Interfaces/character.d.ts +48 -0
  21. package/dist/src/Engine/Interfaces/combatSetup.d.ts +9 -0
  22. package/dist/src/Engine/Interfaces/combatTurn.d.ts +37 -0
  23. package/dist/src/Engine/Interfaces/combatWinnings.d.ts +6 -0
  24. package/dist/src/Engine/Interfaces/combinations/activeCombination.d.ts +14 -0
  25. package/dist/src/Engine/Interfaces/combinations/combinable.d.ts +18 -0
  26. package/dist/src/Engine/Interfaces/combinations/combinationAction.d.ts +41 -0
  27. package/dist/src/Engine/Interfaces/combinations/combinationMatchResult.d.ts +14 -0
  28. package/dist/src/Engine/Interfaces/combinations/combinations.d.ts +17 -0
  29. package/dist/src/Engine/Interfaces/combinations/combine.d.ts +22 -0
  30. package/dist/src/Engine/Interfaces/combinations/combineResult.d.ts +18 -0
  31. package/dist/src/Engine/Interfaces/combinations/gameCombinations.d.ts +40 -0
  32. package/dist/src/Engine/Interfaces/compiledLocation.d.ts +33 -0
  33. package/dist/src/Engine/Interfaces/conversations/conversation.d.ts +44 -0
  34. package/dist/src/Engine/Interfaces/conversations/conversationLogEntry.d.ts +13 -0
  35. package/dist/src/Engine/Interfaces/conversations/conversationNode.d.ts +22 -0
  36. package/dist/src/Engine/Interfaces/conversations/conversationReply.d.ts +49 -0
  37. package/dist/src/Engine/Interfaces/createCharacter/createCharacter.d.ts +20 -0
  38. package/dist/src/Engine/Interfaces/createCharacter/createCharacterAttribute.d.ts +18 -0
  39. package/dist/src/Engine/Interfaces/createCharacter/createCharacterAttributeEntry.d.ts +18 -0
  40. package/dist/src/Engine/Interfaces/createCharacter/createCharacterQuestion.d.ts +18 -0
  41. package/dist/src/Engine/Interfaces/createCharacter/createCharacterQuestionEntry.d.ts +22 -0
  42. package/dist/src/Engine/Interfaces/createCharacter/createCharacterStep.d.ts +40 -0
  43. package/dist/src/Engine/Interfaces/customCursor.d.ts +8 -0
  44. package/dist/src/Engine/Interfaces/defaultEquipment.d.ts +19 -0
  45. package/dist/src/Engine/Interfaces/definitions.d.ts +40 -0
  46. package/dist/src/Engine/Interfaces/destination.d.ts +31 -0
  47. package/dist/src/Engine/Interfaces/dynamicStyle.d.ts +10 -0
  48. package/dist/src/Engine/Interfaces/enemy.d.ts +46 -0
  49. package/dist/src/Engine/Interfaces/enumerations/actionStatus.d.ts +18 -0
  50. package/dist/src/Engine/Interfaces/enumerations/actionType.d.ts +9 -0
  51. package/dist/src/Engine/Interfaces/enumerations/equipmentType.d.ts +51 -0
  52. package/dist/src/Engine/Interfaces/enumerations/gameState.d.ts +11 -0
  53. package/dist/src/Engine/Interfaces/enumerations/playState.d.ts +10 -0
  54. package/dist/src/Engine/Interfaces/enumerations/targetType.d.ts +9 -0
  55. package/dist/src/Engine/Interfaces/equipment.d.ts +43 -0
  56. package/dist/src/Engine/Interfaces/feature.d.ts +37 -0
  57. package/dist/src/Engine/Interfaces/featureCollection.d.ts +7 -0
  58. package/dist/src/Engine/Interfaces/game.d.ts +148 -0
  59. package/dist/src/Engine/Interfaces/gameEvents.d.ts +7 -0
  60. package/dist/src/Engine/Interfaces/groupableItem.d.ts +32 -0
  61. package/dist/src/Engine/Interfaces/helpers.d.ts +50 -0
  62. package/dist/src/Engine/Interfaces/index.d.ts +78 -0
  63. package/dist/src/Engine/Interfaces/interfaceTexts.d.ts +140 -0
  64. package/dist/src/Engine/Interfaces/item.d.ts +96 -0
  65. package/dist/src/Engine/Interfaces/key.d.ts +16 -0
  66. package/dist/src/Engine/Interfaces/location.d.ts +78 -0
  67. package/dist/src/Engine/Interfaces/maps/map.d.ts +45 -0
  68. package/dist/src/Engine/Interfaces/maps/mapLocation.d.ts +23 -0
  69. package/dist/src/Engine/Interfaces/party.d.ts +33 -0
  70. package/dist/src/Engine/Interfaces/person.d.ts +25 -0
  71. package/dist/src/Engine/Interfaces/quest.d.ts +51 -0
  72. package/dist/src/Engine/Interfaces/rules/characterRules.d.ts +84 -0
  73. package/dist/src/Engine/Interfaces/rules/combatRules.d.ts +46 -0
  74. package/dist/src/Engine/Interfaces/rules/combinationRules.d.ts +15 -0
  75. package/dist/src/Engine/Interfaces/rules/demoMode.d.ts +15 -0
  76. package/dist/src/Engine/Interfaces/rules/encounterRules.d.ts +4 -0
  77. package/dist/src/Engine/Interfaces/rules/explorationRules.d.ts +42 -0
  78. package/dist/src/Engine/Interfaces/rules/generalRules.d.ts +62 -0
  79. package/dist/src/Engine/Interfaces/rules/rules.d.ts +31 -0
  80. package/dist/src/Engine/Interfaces/rules/setupRules.d.ts +56 -0
  81. package/dist/src/Engine/Interfaces/rules/titleScreen.d.ts +16 -0
  82. package/dist/src/Engine/Interfaces/saveGame.d.ts +33 -0
  83. package/dist/src/Engine/Interfaces/scoreEntry.d.ts +13 -0
  84. package/dist/src/Engine/Interfaces/services/autoplayService.d.ts +19 -0
  85. package/dist/src/Engine/Interfaces/services/characterService.d.ts +17 -0
  86. package/dist/src/Engine/Interfaces/services/combatService.d.ts +26 -0
  87. package/dist/src/Engine/Interfaces/services/combinationService.d.ts +9 -0
  88. package/dist/src/Engine/Interfaces/services/commandService.d.ts +64 -0
  89. package/dist/src/Engine/Interfaces/services/conversationService.d.ts +5 -0
  90. package/dist/src/Engine/Interfaces/services/dataSerializer.d.ts +4 -0
  91. package/dist/src/Engine/Interfaces/services/dataService.d.ts +33 -0
  92. package/dist/src/Engine/Interfaces/services/dataSynchronizer.d.ts +3 -0
  93. package/dist/src/Engine/Interfaces/services/gameService.d.ts +10 -0
  94. package/dist/src/Engine/Interfaces/services/index.d.ts +16 -0
  95. package/dist/src/Engine/Interfaces/services/itemService.d.ts +14 -0
  96. package/dist/src/Engine/Interfaces/services/localStorageService.d.ts +6 -0
  97. package/dist/src/Engine/Interfaces/services/locationService.d.ts +8 -0
  98. package/dist/src/Engine/Interfaces/services/soundService.d.ts +5 -0
  99. package/dist/src/Engine/Interfaces/services/tradeService.d.ts +9 -0
  100. package/dist/src/Engine/Interfaces/soundPlayer.d.ts +30 -0
  101. package/dist/src/Engine/Interfaces/sprite.d.ts +23 -0
  102. package/dist/src/Engine/Interfaces/stateList.d.ts +9 -0
  103. package/dist/src/Engine/Interfaces/statistics.d.ts +13 -0
  104. package/dist/src/Engine/Interfaces/stock.d.ts +39 -0
  105. package/dist/src/Engine/Interfaces/trade.d.ts +62 -0
  106. package/dist/src/Engine/ServiceFactory.d.ts +52 -0
  107. package/dist/src/Engine/Services/AutoplayService.d.ts +11 -0
  108. package/dist/src/Engine/Services/CharacterService.d.ts +21 -0
  109. package/dist/src/Engine/Services/CombatService.d.ts +16 -0
  110. package/dist/src/Engine/Services/CombinationService.d.ts +15 -0
  111. package/dist/src/Engine/Services/CommandService.d.ts +24 -0
  112. package/dist/src/Engine/Services/ConversationService.d.ts +26 -0
  113. package/dist/src/Engine/Services/DataSerializer.d.ts +17 -0
  114. package/dist/src/Engine/Services/DataService.d.ts +16 -0
  115. package/dist/src/Engine/Services/DataSynchronizer.d.ts +12 -0
  116. package/dist/src/Engine/Services/GameService.d.ts +28 -0
  117. package/dist/src/Engine/Services/HelperService.d.ts +18 -0
  118. package/dist/src/Engine/Services/ItemService.d.ts +21 -0
  119. package/dist/src/Engine/Services/LocalStorageService.d.ts +7 -0
  120. package/dist/src/Engine/Services/LocationService.d.ts +25 -0
  121. package/dist/src/Engine/Services/SoundService.d.ts +13 -0
  122. package/dist/src/Engine/Services/TradeService.d.ts +17 -0
  123. package/dist/src/Engine/Services/index.d.ts +17 -0
  124. package/dist/src/Engine/Services/serializationData.d.ts +8 -0
  125. package/dist/src/Engine/Services/sharedFunctions.d.ts +21 -0
  126. package/dist/src/Engine/arrayAndFunctionExtensions.d.ts +3 -0
  127. package/dist/src/Engine/defaultTexts.d.ts +7 -0
  128. package/dist/src/Engine/gameEvents.d.ts +10 -0
  129. package/dist/src/Engine/index.d.ts +8 -0
  130. package/dist/src/Engine/stateProperties.d.ts +6 -0
  131. package/dist/src/Engine/utilityFunctions.d.ts +25 -0
  132. package/dist/src/UI/Composables/CustomCursor.d.ts +2 -0
  133. package/dist/src/UI/Composables/LocationMap.d.ts +26 -0
  134. package/dist/src/UI/Composables/Sound.d.ts +7 -0
  135. package/dist/src/UI/Composables/TextFeatures.d.ts +8 -0
  136. package/dist/src/UI/Composables/VisualFeatures.d.ts +7 -0
  137. package/dist/src/UI/Composables/index.d.ts +7 -0
  138. package/dist/src/UI/Composables/playStateWatch.d.ts +2 -0
  139. package/dist/src/UI/StateStore.d.ts +14256 -0
  140. package/dist/src/UI/error.d.ts +6 -0
  141. package/dist/src/UI/helpers.d.ts +3 -0
  142. package/dist/src/UI/index.d.ts +6 -0
  143. package/dist/src/UI/main.d.ts +1 -0
  144. package/dist/src/UI/startup.d.ts +2 -0
  145. package/dist/src/constants.d.ts +17 -0
  146. package/dist/src/index.d.ts +3 -0
  147. package/dist/storyscript.css +9566 -0
  148. package/dist/storyscript.js +9659 -0
  149. package/dist/storyscript.js.map +1 -0
  150. package/dist/storyscript.mjs +9569 -0
  151. package/dist/storyscript.mjs.map +1 -0
  152. package/electron.cjs +44 -0
  153. package/index.html +14 -0
  154. package/package.json +118 -4
  155. package/scripts/cli.js +268 -0
  156. package/scripts/createAsset.js +117 -0
  157. package/scripts/createGame.js +40 -0
  158. package/scripts/helpers.js +21 -0
  159. package/scripts/postbuild.js +179 -0
  160. package/scripts/setupTesting.js +17 -0
  161. package/shims-vue.d.ts +1 -0
  162. package/src/Engine/Actions/index.ts +2 -0
  163. package/src/Engine/Actions/open.ts +12 -0
  164. package/src/Engine/Actions/openWithKey.ts +23 -0
  165. package/src/Engine/EntityCreatorFunctions.ts +602 -0
  166. package/src/Engine/Interfaces/action.ts +43 -0
  167. package/src/Engine/Interfaces/autoplayStep.ts +13 -0
  168. package/src/Engine/Interfaces/barrier.ts +18 -0
  169. package/src/Engine/Interfaces/barrierAction.ts +21 -0
  170. package/src/Engine/Interfaces/character.ts +58 -0
  171. package/src/Engine/Interfaces/combatSetup.ts +10 -0
  172. package/src/Engine/Interfaces/combatTurn.ts +45 -0
  173. package/src/Engine/Interfaces/combatWinnings.ts +7 -0
  174. package/src/Engine/Interfaces/combinations/activeCombination.ts +16 -0
  175. package/src/Engine/Interfaces/combinations/combinable.ts +21 -0
  176. package/src/Engine/Interfaces/combinations/combinationAction.ts +45 -0
  177. package/src/Engine/Interfaces/combinations/combinationMatchResult.ts +16 -0
  178. package/src/Engine/Interfaces/combinations/combinations.ts +19 -0
  179. package/src/Engine/Interfaces/combinations/combine.ts +25 -0
  180. package/src/Engine/Interfaces/combinations/combineResult.ts +21 -0
  181. package/src/Engine/Interfaces/combinations/gameCombinations.ts +48 -0
  182. package/src/Engine/Interfaces/compiledLocation.ts +37 -0
  183. package/src/Engine/Interfaces/conversations/conversation.ts +47 -0
  184. package/src/Engine/Interfaces/conversations/conversationLogEntry.ts +14 -0
  185. package/src/Engine/Interfaces/conversations/conversationNode.ts +26 -0
  186. package/src/Engine/Interfaces/conversations/conversationReply.ts +59 -0
  187. package/src/Engine/Interfaces/createCharacter/createCharacter.ts +23 -0
  188. package/src/Engine/Interfaces/createCharacter/createCharacterAttribute.ts +21 -0
  189. package/src/Engine/Interfaces/createCharacter/createCharacterAttributeEntry.ts +21 -0
  190. package/src/Engine/Interfaces/createCharacter/createCharacterQuestion.ts +21 -0
  191. package/src/Engine/Interfaces/createCharacter/createCharacterQuestionEntry.ts +25 -0
  192. package/src/Engine/Interfaces/createCharacter/createCharacterStep.ts +47 -0
  193. package/src/Engine/Interfaces/customCursor.ts +5 -0
  194. package/src/Engine/Interfaces/defaultEquipment.ts +32 -0
  195. package/src/Engine/Interfaces/definitions.ts +48 -0
  196. package/src/Engine/Interfaces/destination.ts +37 -0
  197. package/src/Engine/Interfaces/dynamicStyle.ts +11 -0
  198. package/src/Engine/Interfaces/enemy.ts +54 -0
  199. package/src/Engine/Interfaces/enumerations/actionStatus.ts +20 -0
  200. package/src/Engine/Interfaces/enumerations/actionType.ts +9 -0
  201. package/src/Engine/Interfaces/enumerations/equipmentType.ts +61 -0
  202. package/src/Engine/Interfaces/enumerations/gameState.ts +11 -0
  203. package/src/Engine/Interfaces/enumerations/playState.ts +10 -0
  204. package/src/Engine/Interfaces/enumerations/targetType.ts +9 -0
  205. package/src/Engine/Interfaces/equipment.ts +44 -0
  206. package/src/Engine/Interfaces/feature.ts +43 -0
  207. package/src/Engine/Interfaces/featureCollection.ts +8 -0
  208. package/src/Engine/Interfaces/game.ts +201 -0
  209. package/src/Engine/Interfaces/gameEvents.ts +11 -0
  210. package/src/Engine/Interfaces/groupableItem.ts +37 -0
  211. package/src/Engine/Interfaces/helpers.ts +55 -0
  212. package/src/Engine/Interfaces/index.ts +158 -0
  213. package/src/Engine/Interfaces/interfaceTexts.ts +142 -0
  214. package/src/Engine/Interfaces/item.ts +111 -0
  215. package/src/Engine/Interfaces/key.ts +18 -0
  216. package/src/Engine/Interfaces/location.ts +92 -0
  217. package/src/Engine/Interfaces/maps/map.ts +55 -0
  218. package/src/Engine/Interfaces/maps/mapLocation.ts +28 -0
  219. package/src/Engine/Interfaces/party.ts +40 -0
  220. package/src/Engine/Interfaces/person.ts +29 -0
  221. package/src/Engine/Interfaces/quest.ts +60 -0
  222. package/src/Engine/Interfaces/rules/characterRules.ts +96 -0
  223. package/src/Engine/Interfaces/rules/combatRules.ts +52 -0
  224. package/src/Engine/Interfaces/rules/combinationRules.ts +17 -0
  225. package/src/Engine/Interfaces/rules/demoMode.ts +18 -0
  226. package/src/Engine/Interfaces/rules/encounterRules.ts +5 -0
  227. package/src/Engine/Interfaces/rules/explorationRules.ts +47 -0
  228. package/src/Engine/Interfaces/rules/generalRules.ts +80 -0
  229. package/src/Engine/Interfaces/rules/rules.ts +46 -0
  230. package/src/Engine/Interfaces/rules/setupRules.ts +65 -0
  231. package/src/Engine/Interfaces/rules/titleScreen.ts +19 -0
  232. package/src/Engine/Interfaces/saveGame.ts +39 -0
  233. package/src/Engine/Interfaces/scoreEntry.ts +14 -0
  234. package/src/Engine/Interfaces/services/autoplayService.ts +23 -0
  235. package/src/Engine/Interfaces/services/characterService.ts +35 -0
  236. package/src/Engine/Interfaces/services/combatService.ts +30 -0
  237. package/src/Engine/Interfaces/services/combinationService.ts +10 -0
  238. package/src/Engine/Interfaces/services/commandService.ts +75 -0
  239. package/src/Engine/Interfaces/services/conversationService.ts +7 -0
  240. package/src/Engine/Interfaces/services/dataSerializer.ts +4 -0
  241. package/src/Engine/Interfaces/services/dataService.ts +39 -0
  242. package/src/Engine/Interfaces/services/dataSynchronizer.ts +9 -0
  243. package/src/Engine/Interfaces/services/gameService.ts +17 -0
  244. package/src/Engine/Interfaces/services/index.ts +33 -0
  245. package/src/Engine/Interfaces/services/itemService.ts +25 -0
  246. package/src/Engine/Interfaces/services/localStorageService.ts +6 -0
  247. package/src/Engine/Interfaces/services/locationService.ts +13 -0
  248. package/src/Engine/Interfaces/services/soundService.ts +7 -0
  249. package/src/Engine/Interfaces/services/tradeService.ts +15 -0
  250. package/src/Engine/Interfaces/soundPlayer.ts +30 -0
  251. package/src/Engine/Interfaces/sprite.ts +27 -0
  252. package/src/Engine/Interfaces/stateList.ts +13 -0
  253. package/src/Engine/Interfaces/statistics.ts +14 -0
  254. package/src/Engine/Interfaces/stock.ts +46 -0
  255. package/src/Engine/Interfaces/trade.ts +72 -0
  256. package/src/Engine/ServiceFactory.ts +167 -0
  257. package/src/Engine/Services/AutoplayService.ts +59 -0
  258. package/src/Engine/Services/CharacterService.ts +291 -0
  259. package/src/Engine/Services/CombatService.ts +266 -0
  260. package/src/Engine/Services/CombinationService.ts +197 -0
  261. package/src/Engine/Services/CommandService.ts +197 -0
  262. package/src/Engine/Services/ConversationService.ts +406 -0
  263. package/src/Engine/Services/DataSerializer.ts +326 -0
  264. package/src/Engine/Services/DataService.ts +93 -0
  265. package/src/Engine/Services/DataSynchronizer.ts +216 -0
  266. package/src/Engine/Services/GameService.ts +554 -0
  267. package/src/Engine/Services/HelperService.ts +94 -0
  268. package/src/Engine/Services/ItemService.ts +294 -0
  269. package/src/Engine/Services/LocalStorageService.ts +24 -0
  270. package/src/Engine/Services/LocationService.ts +380 -0
  271. package/src/Engine/Services/SoundService.ts +54 -0
  272. package/src/Engine/Services/TradeService.ts +176 -0
  273. package/src/Engine/Services/index.ts +17 -0
  274. package/src/Engine/Services/serializationData.ts +8 -0
  275. package/src/Engine/Services/sharedFunctions.ts +296 -0
  276. package/src/Engine/arrayAndFunctionExtensions.ts +269 -0
  277. package/src/Engine/defaultTexts.ts +162 -0
  278. package/src/Engine/gameEvents.ts +51 -0
  279. package/src/Engine/index.ts +9 -0
  280. package/src/Engine/stateProperties.ts +9 -0
  281. package/src/Engine/utilityFunctions.ts +238 -0
  282. package/src/Games/_GameTemplate/character.ts +31 -0
  283. package/src/Games/_GameTemplate/customTexts.ts +8 -0
  284. package/src/Games/_GameTemplate/interfaces/action.ts +5 -0
  285. package/src/Games/_GameTemplate/interfaces/combatSetup.ts +7 -0
  286. package/src/Games/_GameTemplate/interfaces/combatTurn.ts +8 -0
  287. package/src/Games/_GameTemplate/interfaces/destination.ts +5 -0
  288. package/src/Games/_GameTemplate/interfaces/enemy.ts +11 -0
  289. package/src/Games/_GameTemplate/interfaces/equipment.ts +5 -0
  290. package/src/Games/_GameTemplate/interfaces/feature.ts +9 -0
  291. package/src/Games/_GameTemplate/interfaces/game.ts +22 -0
  292. package/src/Games/_GameTemplate/interfaces/interfaceTexts.ts +5 -0
  293. package/src/Games/_GameTemplate/interfaces/item.ts +18 -0
  294. package/src/Games/_GameTemplate/interfaces/key.ts +10 -0
  295. package/src/Games/_GameTemplate/interfaces/location.ts +22 -0
  296. package/src/Games/_GameTemplate/interfaces/map.ts +16 -0
  297. package/src/Games/_GameTemplate/interfaces/party.ts +8 -0
  298. package/src/Games/_GameTemplate/interfaces/person.ts +11 -0
  299. package/src/Games/_GameTemplate/interfaces/quest.ts +9 -0
  300. package/src/Games/_GameTemplate/locations/Start.html +5 -0
  301. package/src/Games/_GameTemplate/locations/start.ts +12 -0
  302. package/src/Games/_GameTemplate/rules.ts +60 -0
  303. package/src/Games/_GameTemplate/types.ts +55 -0
  304. package/src/Games/_GameTemplate/ui/styles/game.css +3 -0
  305. package/src/Games/_GameTemplate/webroot/favicon.ico +0 -0
  306. package/src/Games/_GameTemplate/webroot/gameinfo.json +10 -0
  307. package/src/Games/_GameTemplate/webroot/logo192.png +0 -0
  308. package/src/Games/_GameTemplate/webroot/logo512.png +0 -0
  309. package/src/Tests/Games/_GameTemplate/specs/rules.test.ts +9 -0
  310. package/src/UI/Components/AppShell.vue +43 -0
  311. package/src/UI/Components/Autoplay.vue +32 -0
  312. package/src/UI/Components/Combinations.vue +37 -0
  313. package/src/UI/Components/Common/Collapsible.vue +50 -0
  314. package/src/UI/Components/Common/ModalDialog.vue +54 -0
  315. package/src/UI/Components/Common/Sprite.vue +53 -0
  316. package/src/UI/Components/Description.vue +23 -0
  317. package/src/UI/Components/Encounter/Combat/Combat.vue +89 -0
  318. package/src/UI/Components/Encounter/Combat/CombatActions.vue +26 -0
  319. package/src/UI/Components/Encounter/Combat/CombatParticipant.vue +22 -0
  320. package/src/UI/Components/Encounter/Combat/CombatTargetSelect.vue +55 -0
  321. package/src/UI/Components/Encounter/Combat/CombatWin.vue +33 -0
  322. package/src/UI/Components/Encounter/Conversation.vue +66 -0
  323. package/src/UI/Components/Encounter/Encounter.vue +39 -0
  324. package/src/UI/Components/Encounter/Enemy.vue +30 -0
  325. package/src/UI/Components/Encounter/Trade/Stock.vue +58 -0
  326. package/src/UI/Components/Encounter/Trade/Trade.vue +24 -0
  327. package/src/UI/Components/Exploration/ActionLog.vue +17 -0
  328. package/src/UI/Components/Exploration/Destination.vue +66 -0
  329. package/src/UI/Components/Exploration/Exploration.vue +67 -0
  330. package/src/UI/Components/Exploration/Ground.vue +22 -0
  331. package/src/UI/Components/Exploration/LocationMap.vue +42 -0
  332. package/src/UI/Components/Exploration/LocationText.vue +39 -0
  333. package/src/UI/Components/Exploration/LocationVisual.vue +38 -0
  334. package/src/UI/Components/GameContainer.vue +49 -0
  335. package/src/UI/Components/GameMenu.vue +111 -0
  336. package/src/UI/Components/GameState/GameOver.vue +20 -0
  337. package/src/UI/Components/GameState/HighScores.vue +22 -0
  338. package/src/UI/Components/GameState/Intro.vue +17 -0
  339. package/src/UI/Components/GameState/TitleScreen.vue +42 -0
  340. package/src/UI/Components/GameState/Victory.vue +28 -0
  341. package/src/UI/Components/Navigation.vue +94 -0
  342. package/src/UI/Components/Party/Backpack.vue +68 -0
  343. package/src/UI/Components/Party/BuildCharacter.vue +64 -0
  344. package/src/UI/Components/Party/CharacterSheet.vue +57 -0
  345. package/src/UI/Components/Party/CreateCharacter.vue +46 -0
  346. package/src/UI/Components/Party/Equipment.vue +48 -0
  347. package/src/UI/Components/Party/EquipmentSlot.vue +31 -0
  348. package/src/UI/Components/Party/LevelUp.vue +27 -0
  349. package/src/UI/Components/Party/Party.vue +29 -0
  350. package/src/UI/Components/Party/Quests.vue +48 -0
  351. package/src/UI/Components/Sound.vue +42 -0
  352. package/src/UI/Composables/CustomCursor.ts +60 -0
  353. package/src/UI/Composables/LocationMap.ts +315 -0
  354. package/src/UI/Composables/Sound.ts +111 -0
  355. package/src/UI/Composables/TextFeatures.ts +148 -0
  356. package/src/UI/Composables/VisualFeatures.ts +220 -0
  357. package/src/UI/Composables/index.ts +15 -0
  358. package/src/UI/Composables/playStateWatch.ts +31 -0
  359. package/src/UI/StateStore.ts +237 -0
  360. package/src/UI/error.ts +6 -0
  361. package/src/UI/helpers.ts +62 -0
  362. package/src/UI/index.ts +13 -0
  363. package/src/UI/main.ts +62 -0
  364. package/src/UI/startup.ts +58 -0
  365. package/src/UI/styles/bootstrap-storyscript.scss +31 -0
  366. package/src/UI/styles/empty.css +3 -0
  367. package/src/UI/styles/lookinglass.png +0 -0
  368. package/src/UI/styles/storyscript.css +735 -0
  369. package/typeExtensions.d.ts +25 -0
  370. package/vite-env.d.ts +1 -0
package/electron.cjs ADDED
@@ -0,0 +1,44 @@
1
+ const path = require('path');
2
+ const { app, BrowserWindow } = require('electron');
3
+
4
+ let win;
5
+
6
+ function createWindow () {
7
+ let distPath = path.resolve(__dirname, './dist');
8
+
9
+ // Create the browser window.
10
+ win = new BrowserWindow({
11
+ width: 1024,
12
+ height: 768,
13
+ icon: `file://${distPath}/logo192.png`
14
+ })
15
+
16
+ win.loadURL(`file://${distPath}/index.html`)
17
+
18
+ // uncomment below to open the DevTools.
19
+ // win.webContents.openDevTools()
20
+
21
+ // Event when the window is closed.
22
+ win.on('closed', function () {
23
+ win = null
24
+ })
25
+ }
26
+
27
+ // Create window on electron intialization
28
+ app.on('ready', createWindow)
29
+
30
+ // Quit when all windows are closed.
31
+ app.on('window-all-closed', function () {
32
+
33
+ // On macOS specific close process
34
+ if (process.platform !== 'darwin') {
35
+ app.quit()
36
+ }
37
+ })
38
+
39
+ app.on('activate', function () {
40
+ // macOS specific close process
41
+ if (win === null) {
42
+ createWindow()
43
+ }
44
+ })
package/index.html ADDED
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <link href="/favicon.ico" rel="icon"/>
7
+ <title>%STORYSCRIPT_GAME_NAME%</title>
8
+ <meta name="description" content="%STORYSCRIPT_GAME_DESCRIPTION%">
9
+ </head>
10
+ <body>
11
+ <div class="app" id="app"></div>
12
+ <script src="/src/UI/main.ts" type="module"></script>
13
+ </body>
14
+ </html>
package/package.json CHANGED
@@ -1,6 +1,120 @@
1
1
  {
2
2
  "name": "@strixit/storyscript",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "publishConfig": {
4
+ "access": "public"
5
+ },
6
+ "description": "StoryScript is an engine to create games for the web. Games that run anywhere, online or offline, on any device, and work well with both mouse and touch control. You play your games while you build them! Your changes are shown immediately, allowing you to shape your world as you move through it.",
7
+ "version": "1.0.0",
8
+ "author": "Rutger Schurgers",
9
+ "homepage": "https://www.storyscript.nl",
10
+ "license": "MIT",
11
+ "private": false,
12
+ "type": "module",
13
+ "main": "./electron.cjs",
14
+ "module": "./dist/storyscript.mjs",
15
+ "build": {
16
+ "appId": "storyscript.id",
17
+ "files": [
18
+ "./electron.cjs",
19
+ "dist/**/*"
20
+ ],
21
+ "win": {
22
+ "target": "portable",
23
+ "icon": "dist/icon.ico"
24
+ }
25
+ },
26
+ "types": "./dist/src/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "import": "./dist/storyscript.mjs",
30
+ "types": "./dist/src/index.d.ts"
31
+ },
32
+ "./styles": "./dist/storyscript.css",
33
+ "./vite-config": "./dist/baseViteConfig.js"
34
+ },
35
+ "bin": {
36
+ "storyscript": "./scripts/cli.js"
37
+ },
38
+ "files": [
39
+ "CodeSnippets/StoryScriptSnippets.code-snippets",
40
+ "LiveTemplates",
41
+ "clientFiles",
42
+ "scripts/cli.js",
43
+ "scripts/createGame.js",
44
+ "scripts/createAsset.js",
45
+ "scripts/setupTesting.js",
46
+ "scripts/postbuild.js",
47
+ "scripts/helpers.js",
48
+ "src/Engine",
49
+ "src/UI",
50
+ "src/Games/_GameTemplate",
51
+ "src/Tests/Games/_GameTemplate",
52
+ "dist/**/*.d.ts",
53
+ "!dist/**/Games",
54
+ "!dist/**/Tests",
55
+ "dist/storyscript.*",
56
+ "baseViteConfig.js",
57
+ "typeExtensions.d.ts",
58
+ "shims-vue.d.ts",
59
+ "vite-env.d.ts",
60
+ "index.html",
61
+ "electron.cjs",
62
+ ".env"
63
+ ],
64
+ "scripts": {
65
+ "create-game": "node scripts/createGame.js",
66
+ "sca": "node scripts/createAsset.js action",
67
+ "scl": "node scripts/createAsset.js location",
68
+ "scf": "node scripts/createAsset.js feature",
69
+ "sce": "node scripts/createAsset.js enemy",
70
+ "scp": "node scripts/createAsset.js person",
71
+ "sci": "node scripts/createAsset.js item",
72
+ "sck": "node scripts/createAsset.js key",
73
+ "scq": "node scripts/createAsset.js quest",
74
+ "scm": "node scripts/createAsset.js map",
75
+ "start": "vite",
76
+ "test": "node ./src/Tests/beforeTests.js && node scripts/setupTesting.js && vitest --ui",
77
+ "publish": "tsc && vite build",
78
+ "publish:package": "tsc && VITE_BUILD_LIB=true vite build",
79
+ "electron-start": "vite build && electron .",
80
+ "electron-publish": "vite build && electron-builder",
81
+ "pack:test": "node scripts/pack-and-test.js",
82
+ "pack": "npm run publish:package && npm pack"
83
+ },
84
+ "dependencies": {
85
+ "@types/node": "^26.6.4",
86
+ "@vitejs/plugin-vue": "^6.0.9",
87
+ "@vue/language-server": "^3.3.12",
88
+ "@vueuse/components": "^15.0.0",
89
+ "@vueuse/core": "^15.0.0",
90
+ "archiver": "^8.0.0",
91
+ "fs-extra": "^11.4.1",
92
+ "jsonfile": "^6.2.1",
93
+ "pinia": "^4.0.3",
94
+ "sass-embedded": "^1.105.1",
95
+ "sharp": "^0.35.5",
96
+ "typescript": "^6.0.3",
97
+ "vite": "^8.3.4",
98
+ "vite-plugin-checker": "^0.14.5",
99
+ "vite-plugin-pwa": "^2.0.0",
100
+ "vite-plugin-static-copy": "^4.1.1",
101
+ "vue": "^3.5.43",
102
+ "vue-tsc": "^3.3.12",
103
+ "which": "^7.0.0"
104
+ },
105
+ "devDependencies": {
106
+ "@vitest/coverage-v8": "^5.0.3",
107
+ "@vitest/ui": "^5.0.3",
108
+ "bootstrap": "^5.3.8",
109
+ "jsdom": "^30.1.1",
110
+ "vitest": "^5.0.3",
111
+ "vite-plugin-dts": "^5.1.2",
112
+ "electron": "^44.7.0",
113
+ "electron-builder": "^26.15.3",
114
+ "rollup-plugin-visualizer": "^7.1.1"
115
+ },
116
+ "allowScripts": {
117
+ "@parcel/watcher@2.6.0": true,
118
+ "electron-winstaller@5.4.0": true
119
+ }
120
+ }
package/scripts/cli.js ADDED
@@ -0,0 +1,268 @@
1
+ #!/usr/bin/env node
2
+
3
+ import path from 'path';
4
+ import fs from 'fs-extra';
5
+ import {fileURLToPath} from 'url';
6
+ import {spawn} from 'child_process';
7
+ import {setJsonFileProperty} from "./helpers.js";
8
+ import {createInterface} from 'readline';
9
+
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = path.dirname(__filename);
12
+
13
+ const command = process.argv[2];
14
+ const args = process.argv.slice(3);
15
+ const projectRoot = process.cwd();
16
+
17
+ const packageDir = path.resolve(__dirname, '..');
18
+ const flagFile = path.join(packageDir, '.setup-complete');
19
+
20
+ const filesToCopy = [
21
+ ['CodeSnippets/StoryScriptSnippets.code-snippets', '.vscode/StoryScriptSnippets.code-snippets', true],
22
+ ['clientFiles/tsconfig.json', 'tsconfig.json', true],
23
+ ['clientFiles/vite.config.ts', 'vite.config.ts', true],
24
+ ['clientFiles/gitignore', '.gitignore', false],
25
+ ['clientFiles/currentGameName.js', 'currentGameName.js', false],
26
+ ['src/UI/Components', true],
27
+ ['src/UI/main.ts', true],
28
+ ['index.html', true],
29
+ ['typeExtensions.d.ts', true],
30
+ ['shims-vue.d.ts', true],
31
+ ['vite-env.d.ts', true],
32
+ ['.env', false]
33
+ ];
34
+
35
+ const getGameNameInput = () => {
36
+ const rl = createInterface({
37
+ input: process.stdin,
38
+ output: process.stdout
39
+ });
40
+
41
+ return new Promise((resolve) => {
42
+ const prompt = () => {
43
+ rl.question('Enter a valid game name. Start with a letter and use letters, numbers and underscores up to 50 characters: ', (answer) => {
44
+ const gameNameRegex = /^[a-zA-Z][a-zA-Z0-9_]{0,49}$/;
45
+
46
+ if (!gameNameRegex.test(answer)) {
47
+ console.error('❌ That is not a valid game name. Please try again.');
48
+ prompt();
49
+ } else {
50
+ rl.close();
51
+ resolve(answer);
52
+ }
53
+ });
54
+
55
+ };
56
+
57
+ prompt();
58
+ });
59
+ };
60
+
61
+ async function main() {
62
+ if (command === 'setup') {
63
+ await setup();
64
+ } else if (command === 'game') {
65
+ await createGame(args[0]);
66
+ } else if (command === 'start') {
67
+ await executeTask('vite');
68
+ } else if (command === 'start:electron') {
69
+ await electron(true);
70
+ } else if (command === 'test') {
71
+ await runTests();
72
+ } else if (command === 'publish') {
73
+ await executeTask('vite', ['build']);
74
+ } else if (command === 'preview') {
75
+ await executeTask('vite', ['preview']);
76
+ } else if (command === 'publish') {
77
+ await executeTask('vite', ['build']);
78
+ } else if (command === 'publish:electron') {
79
+ await electron(false);
80
+ } else if (/^(location)|(feature)|(map)|(item)|(key)|(enemy)|(person)|(quest)|(action)$/i.test(command)) {
81
+ await createAsset(command, args[0]);
82
+ } else {
83
+ console.log('Usage: storyscript <command>');
84
+ console.log('\nCommands:');
85
+ console.log(' setup Setup StoryScript. Includes creating a new game.');
86
+ console.log(' game [name] Create a new StoryScript game.');
87
+ console.log(' location [name] Create a new StoryScript Location.');
88
+ console.log(' feature [name] Create a new StoryScript stand-alone Feature.');
89
+ console.log(' map [name] Create a new StoryScript Map.');
90
+ console.log(' item [name] Create a new StoryScript Item.');
91
+ console.log(' key [name] Create a new StoryScript Key.');
92
+ console.log(' enemy [name] Create a new StoryScript Enemy.');
93
+ console.log(' person [name] Create a new StoryScript Person.');
94
+ console.log(' quest [name] Create a new StoryScript Quest.');
95
+ console.log(' action [name] Create a new StoryScript stand-alone Action.');
96
+ console.log(' start Start running your game in development mode.');
97
+ console.log(' test Run the tests for your game. This will setup testing if you don\'t have any tests yet.');
98
+ console.log(' publish Build your game for deployment as a web app.');
99
+ console.log(' preview preview your published web app game.');
100
+ console.log(' start:electron Start running your game in electron. This will setup electron if you don\'t have it yet.');
101
+ console.log(' publish:electron Build your game for deployment as an electron executable. This will setup electron if you don\'t have it yet.');
102
+ console.log('\nDon\'t forget that when you use Visual Studio Code Or Rider you have the StoryScript Code Snippets / Live Templates at your disposal. ' +
103
+ 'Check out https://www.storyscript.nl/reference for an overview of all available code snippets.');
104
+ }
105
+ }
106
+
107
+ main().catch(err => {
108
+ console.error(err);
109
+ process.exit(1);
110
+ });
111
+
112
+ async function setup() {
113
+ const isFirstInstall = !fs.existsSync(flagFile);
114
+
115
+ console.log(`🚀 ${isFirstInstall ? 'Setting up StoryScript...' : 'Updating StoryScript...'}`);
116
+ console.log(`📁 Target: ${projectRoot}`);
117
+
118
+ fs.copySync(path.join(packageDir, 'baseViteConfig.js'), path.join(packageDir, 'dist/baseViteConfig.js'));
119
+ fs.copySync(path.join(packageDir, 'scripts/postbuild.js'), path.join(packageDir, 'dist/scripts/postbuild.js'));
120
+ fs.copySync(path.join(packageDir, 'scripts/helpers.js'), path.join(packageDir, 'dist/scripts/helpers.js'));
121
+
122
+ try {
123
+ for (const file of filesToCopy) {
124
+ copyFile(file);
125
+ }
126
+
127
+ if (isFirstInstall) {
128
+ const gameName = await getGameNameInput();
129
+ await createGame(gameName);
130
+ setJsonFileProperty(path.join(projectRoot, 'package.json'), 'type', 'module');
131
+ fs.writeFileSync(flagFile, '');
132
+ }
133
+
134
+ console.log('✅ Setup complete!');
135
+
136
+ if (isFirstInstall) {
137
+ console.log('\nRun this command to start your game:');
138
+ console.log(' npx storyscript start');
139
+ console.log('\n');
140
+ }
141
+
142
+ } catch (err) {
143
+ console.error('❌ Setup failed:', err.message);
144
+ process.exit(1);
145
+ }
146
+ }
147
+
148
+ async function runTests() {
149
+ const scriptPath = path.join(__dirname, 'setupTesting.js');
150
+ copyFile(['clientFiles/vitest.config.ts', 'vitest.config.ts', false]);
151
+ await executeTask('node', [scriptPath]);
152
+ await executeTask('npm', ['install', 'jsdom@latest', '@vitest/ui@latest', '@vitest/coverage-v8@latest', '--save-dev']);
153
+ await executeTask('vitest', ['--ui'], false);
154
+ }
155
+
156
+ async function electron(preview) {
157
+ copyFile(['electron.cjs', false]);
158
+
159
+ const gameName = await getGameName();
160
+
161
+ setJsonFileProperty(path.join(projectRoot, 'package.json'), 'name', gameName);
162
+ setJsonFileProperty(path.join(projectRoot, 'package.json'), 'version', '1.0.0');
163
+ setJsonFileProperty(path.join(projectRoot, 'package.json'), 'main', './electron.cjs');
164
+ setJsonFileProperty(path.join(projectRoot, 'package.json'), 'build', {
165
+ "appId": "storyscript.id",
166
+ "files": [
167
+ "./electron.cjs",
168
+ "dist/**/*"
169
+ ],
170
+ "win": {
171
+ "target": "portable",
172
+ "icon": "dist/icon.ico"
173
+ }
174
+ });
175
+
176
+ await executeTask('npm', ['install', 'electron@latest', 'electron-builder@latest', '--save-dev']);
177
+ await executeTask('vite', ['build']);
178
+
179
+ if (preview) {
180
+ await executeTask('electron', ['.'], false);
181
+ } else {
182
+ await executeTask('electron-builder', [], false);
183
+ }
184
+ }
185
+
186
+ async function createGame(gameName) {
187
+ if (!gameName) {
188
+ console.error('Error: Game name is required');
189
+ console.error('Usage: npx storyscript create-game <gameName>');
190
+ process.exit(1);
191
+ }
192
+
193
+ const scriptPath = path.join(__dirname, 'createGame.js');
194
+ await executeTask('node', [scriptPath, gameName]);
195
+ console.log(`✅ Game "${gameName}" created successfully!`);
196
+ }
197
+
198
+ async function createAsset(commandName, assetName) {
199
+ if (!assetName) {
200
+ console.error('Error: Asset name is required');
201
+ console.error(`Usage: npx storyscript ${commandName} <assetName>`);
202
+ process.exit(1);
203
+ }
204
+
205
+ const scriptPath = path.join(__dirname, 'createAsset.js');
206
+
207
+ await executeTask('node', [scriptPath, commandName, assetName]);
208
+ }
209
+
210
+ async function getGameName() {
211
+ const nameModule = await import(path.resolve(projectRoot, 'currentGameName.js'));
212
+ return nameModule.currentGameName;
213
+ }
214
+
215
+ async function executeTask(command, args, waitForCompletion) {
216
+ if (waitForCompletion === undefined || waitForCompletion) {
217
+ return new Promise((resolve, reject) => {
218
+ const child = spawn(command, args, {
219
+ stdio: 'inherit'
220
+ });
221
+
222
+ child.on('close', (code) => {
223
+ if (code === 0) {
224
+ resolve();
225
+ } else {
226
+ reject(new Error(`Command ${command} failed with code ${code}`));
227
+ }
228
+ });
229
+
230
+ child.on('error', (err) => {
231
+ reject(err);
232
+ });
233
+ });
234
+ }
235
+
236
+ spawn(command, args, {
237
+ stdio: 'inherit'
238
+ });
239
+ }
240
+
241
+ function copyFile(file) {
242
+ const srcFile = file[0];
243
+ const destFile = file.length < 3 ? file[0] : file[1];
244
+ const overWrite = file.length < 3 ? file[1] : file[2];
245
+
246
+ const src = path.join(packageDir, srcFile);
247
+ const dest = path.join(projectRoot, destFile);
248
+
249
+ const stat = fs.statSync(src);
250
+
251
+ if (stat.isDirectory()) {
252
+ fs.cpSync(src, dest, {recursive: true});
253
+ return;
254
+ }
255
+
256
+ if (!fs.existsSync(src)) {
257
+ console.warn(`⚠️ ${srcFile} not found in template`);
258
+ return;
259
+ }
260
+
261
+ if (fs.existsSync(dest)) {
262
+ if (fs.existsSync(dest) && !overWrite) {
263
+ return;
264
+ }
265
+ }
266
+
267
+ fs.copySync(src, dest);
268
+ }
@@ -0,0 +1,117 @@
1
+ import {existsSync, mkdirSync, writeFileSync} from 'fs';
2
+ import pkg from 'jsonfile';
3
+ import {rootFolder} from "./helpers.js";
4
+ import path from "path";
5
+
6
+ const {readFileSync} = pkg;
7
+
8
+ const args = process.argv;
9
+
10
+ const entityNameRegex = /^[a-zA-Z][A-Za-z0-9_]+$/;
11
+ const nameModule = await import(path.resolve(rootFolder, 'currentGameName.js'));
12
+ const gameDir = `${rootFolder}/src/Games/${nameModule.currentGameName}`;
13
+
14
+ const assetType = args[2];
15
+
16
+ if (!assetType) {
17
+ console.log('You need to specify an asset type, e.g. location.');
18
+ process.exit();
19
+ }
20
+
21
+ const assetName = args[3];
22
+
23
+ if (!assetName) {
24
+ console.log('You need to specify an asset name, e.g. \'Cave\'.');
25
+ process.exit();
26
+ }
27
+
28
+ if (!entityNameRegex.exec(assetName)) {
29
+ console.log(`${assetName} is not a valid asset name! The name must start with a letter and contain only letters, numbers and '_'.`);
30
+ process.exit();
31
+ }
32
+
33
+ let baseSnippetKey = assetType.substring(0, 1).toUpperCase() + assetType.substring(1) + 's';
34
+ let snippetKey = baseSnippetKey.endsWith('ys') ? baseSnippetKey.substring(0, baseSnippetKey.length - 2) + 'ies' : baseSnippetKey;
35
+ const assetNameCapital = assetName.substring(0, 1).toUpperCase() + assetName.substring(1);
36
+
37
+ const snippets = readFileSync(path.resolve(rootFolder, '.vscode', 'StoryScriptSnippets.code-snippets'));
38
+
39
+ if (!snippets[snippetKey]) {
40
+ if (!snippets[baseSnippetKey]) {
41
+ console.log(`No asset type ${assetType} exists.`);
42
+ process.exit();
43
+ }
44
+ snippetKey = baseSnippetKey;
45
+ }
46
+
47
+ const descriptionSnippet = snippets['Description'];
48
+
49
+ if (!descriptionSnippet) {
50
+ console.log('The description snippet doesn\'t exist.');
51
+ process.exit();
52
+ }
53
+
54
+ let includeDescription = !process.argv[4] || process.argv[4].toLowerCase() !== 'p';
55
+ includeDescription = (snippetKey === 'Locations' || snippetKey === 'Persons') || ((snippetKey === 'Items' || snippetKey === 'Keys' || snippetKey === 'Enemies') && includeDescription);
56
+
57
+ let conversationSnippet = null;
58
+
59
+ if (snippetKey === 'Persons') {
60
+ conversationSnippet = snippets['Conversation'];
61
+
62
+ if (!conversationSnippet) {
63
+ console.log('The conversation snippet doesn\'t exist.');
64
+ }
65
+ }
66
+
67
+ const snippet = snippets[snippetKey];
68
+
69
+ // Keys go into the items folder.
70
+ const dirName = snippetKey === 'Keys' ? 'Items' : snippetKey;
71
+ const assetDir = `${gameDir}/${dirName.toLowerCase()}`;
72
+ const assetBaseFileName = `${assetDir}/${assetName}`;
73
+
74
+ if (!existsSync(assetDir)) {
75
+ mkdirSync(assetDir);
76
+ }
77
+
78
+ if (!includeDescription) {
79
+ const cleaned = [];
80
+
81
+ snippet.body = Object.keys(snippet.body).forEach(k => {
82
+ const l = snippet.body[k];
83
+ if (!l.match(/import description from \'\.\/\$\{TM_FILENAME_BASE\}\.html?raw';/g) && !l.match(/[\\t]{0,}description:/g)) {
84
+ cleaned.push(l);
85
+ }
86
+ });
87
+
88
+ snippet.body = cleaned;
89
+ }
90
+
91
+ const tsString = snippet.body
92
+ .join('\n')
93
+ .replace(/\${TM_FILENAME_BASE}/g, assetName)
94
+ .replace(/\${TM_FILENAME_BASE\/\(\.\*\)\/\${1:\/capitalize}\/}/g, assetNameCapital)
95
+ .replace(/\$[0-9]{1,}/g, '');
96
+
97
+ // Write ts file
98
+ writeFileSync(assetBaseFileName + '.ts', tsString);
99
+
100
+ if (!includeDescription) {
101
+ process.exit();
102
+ }
103
+
104
+ let htmlString = removePlaceholders(descriptionSnippet);
105
+
106
+ if (conversationSnippet) {
107
+ htmlString = htmlString + '\n' + removePlaceholders(conversationSnippet);
108
+ }
109
+
110
+ // Write html file
111
+ writeFileSync(assetBaseFileName + '.html', htmlString);
112
+
113
+ function removePlaceholders(value) {
114
+ return value.body
115
+ .join('\n')
116
+ .replace(/\$[0-9]{1,}/g, '');
117
+ }
@@ -0,0 +1,40 @@
1
+ import pkg from 'fs-extra';
2
+ import fs from "fs";
3
+ import {fileURLToPath} from "url";
4
+ import path from "path";
5
+ import {rootFolder, setJsonFileProperty} from "./helpers.js";
6
+
7
+ const {copy, writeFile} = pkg;
8
+
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ let __dirname = path.resolve(path.dirname(__filename), '../');
11
+ const gameName = process.argv[2];
12
+
13
+ if (!gameName) {
14
+ console.log('Please specify a game name.');
15
+ process.exit();
16
+ }
17
+
18
+ // Set the game name to the new game.
19
+ await writeFile(path.resolve(rootFolder, 'currentGameName.js'), `export const currentGameName = '${gameName}';`);
20
+
21
+ const gameRoot = `${__dirname}/src/Games/_GameTemplate/`;
22
+ const gameDestination = `${rootFolder}/src/Games/${gameName}`;
23
+
24
+ // Copy the game template.
25
+ await copy(gameRoot, gameDestination);
26
+
27
+ // Add the game name to the game info.
28
+ setJsonFileProperty(path.join(gameDestination, 'webroot', 'gameinfo.json'), 'name', gameName);
29
+
30
+ // Add the components and the resources folders to make sure they are present.
31
+ const componentsPath = `${gameDestination}/ui/components`;
32
+ const resourcesPath = `${gameDestination}/resources`;
33
+
34
+ if (!fs.existsSync(componentsPath)) {
35
+ fs.mkdirSync(componentsPath);
36
+ }
37
+
38
+ if (!fs.existsSync(resourcesPath)) {
39
+ fs.mkdirSync(resourcesPath);
40
+ }
@@ -0,0 +1,21 @@
1
+ import {fileURLToPath} from "url";
2
+ import path from 'path';
3
+ import fs from "fs-extra";
4
+
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ let __dirname = path.dirname(__filename);
7
+ __dirname = __dirname.includes('/node_modules/') ?
8
+ __dirname.split('/node_modules/')[0] : __dirname.includes('/scripts')
9
+ ? __dirname.split('/scripts')[0] :__dirname;
10
+
11
+ export const rootFolder = __dirname;
12
+
13
+ export function setJsonFileProperty(filePath, property, newValue) {
14
+ const rawData = fs.readFileSync(filePath, 'utf8');
15
+ const jsonObject = JSON.parse(rawData);
16
+
17
+ if (!jsonObject[property]) {
18
+ jsonObject[property] = newValue;
19
+ fs.writeFileSync(filePath, JSON.stringify(jsonObject, null, 2), 'utf8');
20
+ }
21
+ }