@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.
- package/.env +1 -0
- package/CodeSnippets/StoryScriptSnippets.code-snippets +573 -0
- package/LICENSE.txt +21 -0
- package/LiveTemplates/StoryScript.xml +271 -0
- package/README.md +9 -2
- package/baseViteConfig.js +112 -0
- package/clientFiles/currentGameName.js +1 -0
- package/clientFiles/gitignore +12 -0
- package/clientFiles/tsconfig.json +34 -0
- package/clientFiles/vite.config.ts +14 -0
- package/clientFiles/vitest.config.ts +29 -0
- package/dist/src/Engine/Actions/index.d.ts +2 -0
- package/dist/src/Engine/Actions/open.d.ts +6 -0
- package/dist/src/Engine/Actions/openWithKey.d.ts +7 -0
- package/dist/src/Engine/EntityCreatorFunctions.d.ts +18 -0
- package/dist/src/Engine/Interfaces/action.d.ts +37 -0
- package/dist/src/Engine/Interfaces/autoplayStep.d.ts +11 -0
- package/dist/src/Engine/Interfaces/barrier.d.ts +16 -0
- package/dist/src/Engine/Interfaces/barrierAction.d.ts +19 -0
- package/dist/src/Engine/Interfaces/character.d.ts +48 -0
- package/dist/src/Engine/Interfaces/combatSetup.d.ts +9 -0
- package/dist/src/Engine/Interfaces/combatTurn.d.ts +37 -0
- package/dist/src/Engine/Interfaces/combatWinnings.d.ts +6 -0
- package/dist/src/Engine/Interfaces/combinations/activeCombination.d.ts +14 -0
- package/dist/src/Engine/Interfaces/combinations/combinable.d.ts +18 -0
- package/dist/src/Engine/Interfaces/combinations/combinationAction.d.ts +41 -0
- package/dist/src/Engine/Interfaces/combinations/combinationMatchResult.d.ts +14 -0
- package/dist/src/Engine/Interfaces/combinations/combinations.d.ts +17 -0
- package/dist/src/Engine/Interfaces/combinations/combine.d.ts +22 -0
- package/dist/src/Engine/Interfaces/combinations/combineResult.d.ts +18 -0
- package/dist/src/Engine/Interfaces/combinations/gameCombinations.d.ts +40 -0
- package/dist/src/Engine/Interfaces/compiledLocation.d.ts +33 -0
- package/dist/src/Engine/Interfaces/conversations/conversation.d.ts +44 -0
- package/dist/src/Engine/Interfaces/conversations/conversationLogEntry.d.ts +13 -0
- package/dist/src/Engine/Interfaces/conversations/conversationNode.d.ts +22 -0
- package/dist/src/Engine/Interfaces/conversations/conversationReply.d.ts +49 -0
- package/dist/src/Engine/Interfaces/createCharacter/createCharacter.d.ts +20 -0
- package/dist/src/Engine/Interfaces/createCharacter/createCharacterAttribute.d.ts +18 -0
- package/dist/src/Engine/Interfaces/createCharacter/createCharacterAttributeEntry.d.ts +18 -0
- package/dist/src/Engine/Interfaces/createCharacter/createCharacterQuestion.d.ts +18 -0
- package/dist/src/Engine/Interfaces/createCharacter/createCharacterQuestionEntry.d.ts +22 -0
- package/dist/src/Engine/Interfaces/createCharacter/createCharacterStep.d.ts +40 -0
- package/dist/src/Engine/Interfaces/customCursor.d.ts +8 -0
- package/dist/src/Engine/Interfaces/defaultEquipment.d.ts +19 -0
- package/dist/src/Engine/Interfaces/definitions.d.ts +40 -0
- package/dist/src/Engine/Interfaces/destination.d.ts +31 -0
- package/dist/src/Engine/Interfaces/dynamicStyle.d.ts +10 -0
- package/dist/src/Engine/Interfaces/enemy.d.ts +46 -0
- package/dist/src/Engine/Interfaces/enumerations/actionStatus.d.ts +18 -0
- package/dist/src/Engine/Interfaces/enumerations/actionType.d.ts +9 -0
- package/dist/src/Engine/Interfaces/enumerations/equipmentType.d.ts +51 -0
- package/dist/src/Engine/Interfaces/enumerations/gameState.d.ts +11 -0
- package/dist/src/Engine/Interfaces/enumerations/playState.d.ts +10 -0
- package/dist/src/Engine/Interfaces/enumerations/targetType.d.ts +9 -0
- package/dist/src/Engine/Interfaces/equipment.d.ts +43 -0
- package/dist/src/Engine/Interfaces/feature.d.ts +37 -0
- package/dist/src/Engine/Interfaces/featureCollection.d.ts +7 -0
- package/dist/src/Engine/Interfaces/game.d.ts +148 -0
- package/dist/src/Engine/Interfaces/gameEvents.d.ts +7 -0
- package/dist/src/Engine/Interfaces/groupableItem.d.ts +32 -0
- package/dist/src/Engine/Interfaces/helpers.d.ts +50 -0
- package/dist/src/Engine/Interfaces/index.d.ts +78 -0
- package/dist/src/Engine/Interfaces/interfaceTexts.d.ts +140 -0
- package/dist/src/Engine/Interfaces/item.d.ts +96 -0
- package/dist/src/Engine/Interfaces/key.d.ts +16 -0
- package/dist/src/Engine/Interfaces/location.d.ts +78 -0
- package/dist/src/Engine/Interfaces/maps/map.d.ts +45 -0
- package/dist/src/Engine/Interfaces/maps/mapLocation.d.ts +23 -0
- package/dist/src/Engine/Interfaces/party.d.ts +33 -0
- package/dist/src/Engine/Interfaces/person.d.ts +25 -0
- package/dist/src/Engine/Interfaces/quest.d.ts +51 -0
- package/dist/src/Engine/Interfaces/rules/characterRules.d.ts +84 -0
- package/dist/src/Engine/Interfaces/rules/combatRules.d.ts +46 -0
- package/dist/src/Engine/Interfaces/rules/combinationRules.d.ts +15 -0
- package/dist/src/Engine/Interfaces/rules/demoMode.d.ts +15 -0
- package/dist/src/Engine/Interfaces/rules/encounterRules.d.ts +4 -0
- package/dist/src/Engine/Interfaces/rules/explorationRules.d.ts +42 -0
- package/dist/src/Engine/Interfaces/rules/generalRules.d.ts +62 -0
- package/dist/src/Engine/Interfaces/rules/rules.d.ts +31 -0
- package/dist/src/Engine/Interfaces/rules/setupRules.d.ts +56 -0
- package/dist/src/Engine/Interfaces/rules/titleScreen.d.ts +16 -0
- package/dist/src/Engine/Interfaces/saveGame.d.ts +33 -0
- package/dist/src/Engine/Interfaces/scoreEntry.d.ts +13 -0
- package/dist/src/Engine/Interfaces/services/autoplayService.d.ts +19 -0
- package/dist/src/Engine/Interfaces/services/characterService.d.ts +17 -0
- package/dist/src/Engine/Interfaces/services/combatService.d.ts +26 -0
- package/dist/src/Engine/Interfaces/services/combinationService.d.ts +9 -0
- package/dist/src/Engine/Interfaces/services/commandService.d.ts +64 -0
- package/dist/src/Engine/Interfaces/services/conversationService.d.ts +5 -0
- package/dist/src/Engine/Interfaces/services/dataSerializer.d.ts +4 -0
- package/dist/src/Engine/Interfaces/services/dataService.d.ts +33 -0
- package/dist/src/Engine/Interfaces/services/dataSynchronizer.d.ts +3 -0
- package/dist/src/Engine/Interfaces/services/gameService.d.ts +10 -0
- package/dist/src/Engine/Interfaces/services/index.d.ts +16 -0
- package/dist/src/Engine/Interfaces/services/itemService.d.ts +14 -0
- package/dist/src/Engine/Interfaces/services/localStorageService.d.ts +6 -0
- package/dist/src/Engine/Interfaces/services/locationService.d.ts +8 -0
- package/dist/src/Engine/Interfaces/services/soundService.d.ts +5 -0
- package/dist/src/Engine/Interfaces/services/tradeService.d.ts +9 -0
- package/dist/src/Engine/Interfaces/soundPlayer.d.ts +30 -0
- package/dist/src/Engine/Interfaces/sprite.d.ts +23 -0
- package/dist/src/Engine/Interfaces/stateList.d.ts +9 -0
- package/dist/src/Engine/Interfaces/statistics.d.ts +13 -0
- package/dist/src/Engine/Interfaces/stock.d.ts +39 -0
- package/dist/src/Engine/Interfaces/trade.d.ts +62 -0
- package/dist/src/Engine/ServiceFactory.d.ts +52 -0
- package/dist/src/Engine/Services/AutoplayService.d.ts +11 -0
- package/dist/src/Engine/Services/CharacterService.d.ts +21 -0
- package/dist/src/Engine/Services/CombatService.d.ts +16 -0
- package/dist/src/Engine/Services/CombinationService.d.ts +15 -0
- package/dist/src/Engine/Services/CommandService.d.ts +24 -0
- package/dist/src/Engine/Services/ConversationService.d.ts +26 -0
- package/dist/src/Engine/Services/DataSerializer.d.ts +17 -0
- package/dist/src/Engine/Services/DataService.d.ts +16 -0
- package/dist/src/Engine/Services/DataSynchronizer.d.ts +12 -0
- package/dist/src/Engine/Services/GameService.d.ts +28 -0
- package/dist/src/Engine/Services/HelperService.d.ts +18 -0
- package/dist/src/Engine/Services/ItemService.d.ts +21 -0
- package/dist/src/Engine/Services/LocalStorageService.d.ts +7 -0
- package/dist/src/Engine/Services/LocationService.d.ts +25 -0
- package/dist/src/Engine/Services/SoundService.d.ts +13 -0
- package/dist/src/Engine/Services/TradeService.d.ts +17 -0
- package/dist/src/Engine/Services/index.d.ts +17 -0
- package/dist/src/Engine/Services/serializationData.d.ts +8 -0
- package/dist/src/Engine/Services/sharedFunctions.d.ts +21 -0
- package/dist/src/Engine/arrayAndFunctionExtensions.d.ts +3 -0
- package/dist/src/Engine/defaultTexts.d.ts +7 -0
- package/dist/src/Engine/gameEvents.d.ts +10 -0
- package/dist/src/Engine/index.d.ts +8 -0
- package/dist/src/Engine/stateProperties.d.ts +6 -0
- package/dist/src/Engine/utilityFunctions.d.ts +25 -0
- package/dist/src/UI/Composables/CustomCursor.d.ts +2 -0
- package/dist/src/UI/Composables/LocationMap.d.ts +26 -0
- package/dist/src/UI/Composables/Sound.d.ts +7 -0
- package/dist/src/UI/Composables/TextFeatures.d.ts +8 -0
- package/dist/src/UI/Composables/VisualFeatures.d.ts +7 -0
- package/dist/src/UI/Composables/index.d.ts +7 -0
- package/dist/src/UI/Composables/playStateWatch.d.ts +2 -0
- package/dist/src/UI/StateStore.d.ts +14256 -0
- package/dist/src/UI/error.d.ts +6 -0
- package/dist/src/UI/helpers.d.ts +3 -0
- package/dist/src/UI/index.d.ts +6 -0
- package/dist/src/UI/main.d.ts +1 -0
- package/dist/src/UI/startup.d.ts +2 -0
- package/dist/src/constants.d.ts +17 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/storyscript.css +9566 -0
- package/dist/storyscript.js +9659 -0
- package/dist/storyscript.js.map +1 -0
- package/dist/storyscript.mjs +9569 -0
- package/dist/storyscript.mjs.map +1 -0
- package/electron.cjs +44 -0
- package/index.html +14 -0
- package/package.json +118 -4
- package/scripts/cli.js +268 -0
- package/scripts/createAsset.js +117 -0
- package/scripts/createGame.js +40 -0
- package/scripts/helpers.js +21 -0
- package/scripts/postbuild.js +179 -0
- package/scripts/setupTesting.js +17 -0
- package/shims-vue.d.ts +1 -0
- package/src/Engine/Actions/index.ts +2 -0
- package/src/Engine/Actions/open.ts +12 -0
- package/src/Engine/Actions/openWithKey.ts +23 -0
- package/src/Engine/EntityCreatorFunctions.ts +602 -0
- package/src/Engine/Interfaces/action.ts +43 -0
- package/src/Engine/Interfaces/autoplayStep.ts +13 -0
- package/src/Engine/Interfaces/barrier.ts +18 -0
- package/src/Engine/Interfaces/barrierAction.ts +21 -0
- package/src/Engine/Interfaces/character.ts +58 -0
- package/src/Engine/Interfaces/combatSetup.ts +10 -0
- package/src/Engine/Interfaces/combatTurn.ts +45 -0
- package/src/Engine/Interfaces/combatWinnings.ts +7 -0
- package/src/Engine/Interfaces/combinations/activeCombination.ts +16 -0
- package/src/Engine/Interfaces/combinations/combinable.ts +21 -0
- package/src/Engine/Interfaces/combinations/combinationAction.ts +45 -0
- package/src/Engine/Interfaces/combinations/combinationMatchResult.ts +16 -0
- package/src/Engine/Interfaces/combinations/combinations.ts +19 -0
- package/src/Engine/Interfaces/combinations/combine.ts +25 -0
- package/src/Engine/Interfaces/combinations/combineResult.ts +21 -0
- package/src/Engine/Interfaces/combinations/gameCombinations.ts +48 -0
- package/src/Engine/Interfaces/compiledLocation.ts +37 -0
- package/src/Engine/Interfaces/conversations/conversation.ts +47 -0
- package/src/Engine/Interfaces/conversations/conversationLogEntry.ts +14 -0
- package/src/Engine/Interfaces/conversations/conversationNode.ts +26 -0
- package/src/Engine/Interfaces/conversations/conversationReply.ts +59 -0
- package/src/Engine/Interfaces/createCharacter/createCharacter.ts +23 -0
- package/src/Engine/Interfaces/createCharacter/createCharacterAttribute.ts +21 -0
- package/src/Engine/Interfaces/createCharacter/createCharacterAttributeEntry.ts +21 -0
- package/src/Engine/Interfaces/createCharacter/createCharacterQuestion.ts +21 -0
- package/src/Engine/Interfaces/createCharacter/createCharacterQuestionEntry.ts +25 -0
- package/src/Engine/Interfaces/createCharacter/createCharacterStep.ts +47 -0
- package/src/Engine/Interfaces/customCursor.ts +5 -0
- package/src/Engine/Interfaces/defaultEquipment.ts +32 -0
- package/src/Engine/Interfaces/definitions.ts +48 -0
- package/src/Engine/Interfaces/destination.ts +37 -0
- package/src/Engine/Interfaces/dynamicStyle.ts +11 -0
- package/src/Engine/Interfaces/enemy.ts +54 -0
- package/src/Engine/Interfaces/enumerations/actionStatus.ts +20 -0
- package/src/Engine/Interfaces/enumerations/actionType.ts +9 -0
- package/src/Engine/Interfaces/enumerations/equipmentType.ts +61 -0
- package/src/Engine/Interfaces/enumerations/gameState.ts +11 -0
- package/src/Engine/Interfaces/enumerations/playState.ts +10 -0
- package/src/Engine/Interfaces/enumerations/targetType.ts +9 -0
- package/src/Engine/Interfaces/equipment.ts +44 -0
- package/src/Engine/Interfaces/feature.ts +43 -0
- package/src/Engine/Interfaces/featureCollection.ts +8 -0
- package/src/Engine/Interfaces/game.ts +201 -0
- package/src/Engine/Interfaces/gameEvents.ts +11 -0
- package/src/Engine/Interfaces/groupableItem.ts +37 -0
- package/src/Engine/Interfaces/helpers.ts +55 -0
- package/src/Engine/Interfaces/index.ts +158 -0
- package/src/Engine/Interfaces/interfaceTexts.ts +142 -0
- package/src/Engine/Interfaces/item.ts +111 -0
- package/src/Engine/Interfaces/key.ts +18 -0
- package/src/Engine/Interfaces/location.ts +92 -0
- package/src/Engine/Interfaces/maps/map.ts +55 -0
- package/src/Engine/Interfaces/maps/mapLocation.ts +28 -0
- package/src/Engine/Interfaces/party.ts +40 -0
- package/src/Engine/Interfaces/person.ts +29 -0
- package/src/Engine/Interfaces/quest.ts +60 -0
- package/src/Engine/Interfaces/rules/characterRules.ts +96 -0
- package/src/Engine/Interfaces/rules/combatRules.ts +52 -0
- package/src/Engine/Interfaces/rules/combinationRules.ts +17 -0
- package/src/Engine/Interfaces/rules/demoMode.ts +18 -0
- package/src/Engine/Interfaces/rules/encounterRules.ts +5 -0
- package/src/Engine/Interfaces/rules/explorationRules.ts +47 -0
- package/src/Engine/Interfaces/rules/generalRules.ts +80 -0
- package/src/Engine/Interfaces/rules/rules.ts +46 -0
- package/src/Engine/Interfaces/rules/setupRules.ts +65 -0
- package/src/Engine/Interfaces/rules/titleScreen.ts +19 -0
- package/src/Engine/Interfaces/saveGame.ts +39 -0
- package/src/Engine/Interfaces/scoreEntry.ts +14 -0
- package/src/Engine/Interfaces/services/autoplayService.ts +23 -0
- package/src/Engine/Interfaces/services/characterService.ts +35 -0
- package/src/Engine/Interfaces/services/combatService.ts +30 -0
- package/src/Engine/Interfaces/services/combinationService.ts +10 -0
- package/src/Engine/Interfaces/services/commandService.ts +75 -0
- package/src/Engine/Interfaces/services/conversationService.ts +7 -0
- package/src/Engine/Interfaces/services/dataSerializer.ts +4 -0
- package/src/Engine/Interfaces/services/dataService.ts +39 -0
- package/src/Engine/Interfaces/services/dataSynchronizer.ts +9 -0
- package/src/Engine/Interfaces/services/gameService.ts +17 -0
- package/src/Engine/Interfaces/services/index.ts +33 -0
- package/src/Engine/Interfaces/services/itemService.ts +25 -0
- package/src/Engine/Interfaces/services/localStorageService.ts +6 -0
- package/src/Engine/Interfaces/services/locationService.ts +13 -0
- package/src/Engine/Interfaces/services/soundService.ts +7 -0
- package/src/Engine/Interfaces/services/tradeService.ts +15 -0
- package/src/Engine/Interfaces/soundPlayer.ts +30 -0
- package/src/Engine/Interfaces/sprite.ts +27 -0
- package/src/Engine/Interfaces/stateList.ts +13 -0
- package/src/Engine/Interfaces/statistics.ts +14 -0
- package/src/Engine/Interfaces/stock.ts +46 -0
- package/src/Engine/Interfaces/trade.ts +72 -0
- package/src/Engine/ServiceFactory.ts +167 -0
- package/src/Engine/Services/AutoplayService.ts +59 -0
- package/src/Engine/Services/CharacterService.ts +291 -0
- package/src/Engine/Services/CombatService.ts +266 -0
- package/src/Engine/Services/CombinationService.ts +197 -0
- package/src/Engine/Services/CommandService.ts +197 -0
- package/src/Engine/Services/ConversationService.ts +406 -0
- package/src/Engine/Services/DataSerializer.ts +326 -0
- package/src/Engine/Services/DataService.ts +93 -0
- package/src/Engine/Services/DataSynchronizer.ts +216 -0
- package/src/Engine/Services/GameService.ts +554 -0
- package/src/Engine/Services/HelperService.ts +94 -0
- package/src/Engine/Services/ItemService.ts +294 -0
- package/src/Engine/Services/LocalStorageService.ts +24 -0
- package/src/Engine/Services/LocationService.ts +380 -0
- package/src/Engine/Services/SoundService.ts +54 -0
- package/src/Engine/Services/TradeService.ts +176 -0
- package/src/Engine/Services/index.ts +17 -0
- package/src/Engine/Services/serializationData.ts +8 -0
- package/src/Engine/Services/sharedFunctions.ts +296 -0
- package/src/Engine/arrayAndFunctionExtensions.ts +269 -0
- package/src/Engine/defaultTexts.ts +162 -0
- package/src/Engine/gameEvents.ts +51 -0
- package/src/Engine/index.ts +9 -0
- package/src/Engine/stateProperties.ts +9 -0
- package/src/Engine/utilityFunctions.ts +238 -0
- package/src/Games/_GameTemplate/character.ts +31 -0
- package/src/Games/_GameTemplate/customTexts.ts +8 -0
- package/src/Games/_GameTemplate/interfaces/action.ts +5 -0
- package/src/Games/_GameTemplate/interfaces/combatSetup.ts +7 -0
- package/src/Games/_GameTemplate/interfaces/combatTurn.ts +8 -0
- package/src/Games/_GameTemplate/interfaces/destination.ts +5 -0
- package/src/Games/_GameTemplate/interfaces/enemy.ts +11 -0
- package/src/Games/_GameTemplate/interfaces/equipment.ts +5 -0
- package/src/Games/_GameTemplate/interfaces/feature.ts +9 -0
- package/src/Games/_GameTemplate/interfaces/game.ts +22 -0
- package/src/Games/_GameTemplate/interfaces/interfaceTexts.ts +5 -0
- package/src/Games/_GameTemplate/interfaces/item.ts +18 -0
- package/src/Games/_GameTemplate/interfaces/key.ts +10 -0
- package/src/Games/_GameTemplate/interfaces/location.ts +22 -0
- package/src/Games/_GameTemplate/interfaces/map.ts +16 -0
- package/src/Games/_GameTemplate/interfaces/party.ts +8 -0
- package/src/Games/_GameTemplate/interfaces/person.ts +11 -0
- package/src/Games/_GameTemplate/interfaces/quest.ts +9 -0
- package/src/Games/_GameTemplate/locations/Start.html +5 -0
- package/src/Games/_GameTemplate/locations/start.ts +12 -0
- package/src/Games/_GameTemplate/rules.ts +60 -0
- package/src/Games/_GameTemplate/types.ts +55 -0
- package/src/Games/_GameTemplate/ui/styles/game.css +3 -0
- package/src/Games/_GameTemplate/webroot/favicon.ico +0 -0
- package/src/Games/_GameTemplate/webroot/gameinfo.json +10 -0
- package/src/Games/_GameTemplate/webroot/logo192.png +0 -0
- package/src/Games/_GameTemplate/webroot/logo512.png +0 -0
- package/src/Tests/Games/_GameTemplate/specs/rules.test.ts +9 -0
- package/src/UI/Components/AppShell.vue +43 -0
- package/src/UI/Components/Autoplay.vue +32 -0
- package/src/UI/Components/Combinations.vue +37 -0
- package/src/UI/Components/Common/Collapsible.vue +50 -0
- package/src/UI/Components/Common/ModalDialog.vue +54 -0
- package/src/UI/Components/Common/Sprite.vue +53 -0
- package/src/UI/Components/Description.vue +23 -0
- package/src/UI/Components/Encounter/Combat/Combat.vue +89 -0
- package/src/UI/Components/Encounter/Combat/CombatActions.vue +26 -0
- package/src/UI/Components/Encounter/Combat/CombatParticipant.vue +22 -0
- package/src/UI/Components/Encounter/Combat/CombatTargetSelect.vue +55 -0
- package/src/UI/Components/Encounter/Combat/CombatWin.vue +33 -0
- package/src/UI/Components/Encounter/Conversation.vue +66 -0
- package/src/UI/Components/Encounter/Encounter.vue +39 -0
- package/src/UI/Components/Encounter/Enemy.vue +30 -0
- package/src/UI/Components/Encounter/Trade/Stock.vue +58 -0
- package/src/UI/Components/Encounter/Trade/Trade.vue +24 -0
- package/src/UI/Components/Exploration/ActionLog.vue +17 -0
- package/src/UI/Components/Exploration/Destination.vue +66 -0
- package/src/UI/Components/Exploration/Exploration.vue +67 -0
- package/src/UI/Components/Exploration/Ground.vue +22 -0
- package/src/UI/Components/Exploration/LocationMap.vue +42 -0
- package/src/UI/Components/Exploration/LocationText.vue +39 -0
- package/src/UI/Components/Exploration/LocationVisual.vue +38 -0
- package/src/UI/Components/GameContainer.vue +49 -0
- package/src/UI/Components/GameMenu.vue +111 -0
- package/src/UI/Components/GameState/GameOver.vue +20 -0
- package/src/UI/Components/GameState/HighScores.vue +22 -0
- package/src/UI/Components/GameState/Intro.vue +17 -0
- package/src/UI/Components/GameState/TitleScreen.vue +42 -0
- package/src/UI/Components/GameState/Victory.vue +28 -0
- package/src/UI/Components/Navigation.vue +94 -0
- package/src/UI/Components/Party/Backpack.vue +68 -0
- package/src/UI/Components/Party/BuildCharacter.vue +64 -0
- package/src/UI/Components/Party/CharacterSheet.vue +57 -0
- package/src/UI/Components/Party/CreateCharacter.vue +46 -0
- package/src/UI/Components/Party/Equipment.vue +48 -0
- package/src/UI/Components/Party/EquipmentSlot.vue +31 -0
- package/src/UI/Components/Party/LevelUp.vue +27 -0
- package/src/UI/Components/Party/Party.vue +29 -0
- package/src/UI/Components/Party/Quests.vue +48 -0
- package/src/UI/Components/Sound.vue +42 -0
- package/src/UI/Composables/CustomCursor.ts +60 -0
- package/src/UI/Composables/LocationMap.ts +315 -0
- package/src/UI/Composables/Sound.ts +111 -0
- package/src/UI/Composables/TextFeatures.ts +148 -0
- package/src/UI/Composables/VisualFeatures.ts +220 -0
- package/src/UI/Composables/index.ts +15 -0
- package/src/UI/Composables/playStateWatch.ts +31 -0
- package/src/UI/StateStore.ts +237 -0
- package/src/UI/error.ts +6 -0
- package/src/UI/helpers.ts +62 -0
- package/src/UI/index.ts +13 -0
- package/src/UI/main.ts +62 -0
- package/src/UI/startup.ts +58 -0
- package/src/UI/styles/bootstrap-storyscript.scss +31 -0
- package/src/UI/styles/empty.css +3 -0
- package/src/UI/styles/lookinglass.png +0 -0
- package/src/UI/styles/storyscript.css +735 -0
- package/typeExtensions.d.ts +25 -0
- package/vite-env.d.ts +1 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import {StateProperties} from "./stateProperties";
|
|
2
|
+
import {compareString, getId, getKeyPropertyNames, isDataRecord, propertyMatch} from "./utilityFunctions";
|
|
3
|
+
import {TypeProperty} from 'src/constants';
|
|
4
|
+
|
|
5
|
+
const deletedCollection: string = '_deleted';
|
|
6
|
+
|
|
7
|
+
if (Function.prototype.proxy === undefined) {
|
|
8
|
+
// This code has to be outside the addFunctionExtensions to have the correct function scope for the proxy.
|
|
9
|
+
Function.prototype.proxy = function (proxyFunction: Function, ...params: any[]) {
|
|
10
|
+
const originalFunction = this;
|
|
11
|
+
|
|
12
|
+
return (function () {
|
|
13
|
+
// Creating an object to attach the function to is a workaround to not
|
|
14
|
+
// trigger the TypeScript error TS2683: 'this' implicitly has type 'any'.
|
|
15
|
+
const func = {
|
|
16
|
+
func: function () {
|
|
17
|
+
const args = [].slice.call(arguments);
|
|
18
|
+
|
|
19
|
+
if (originalFunction) {
|
|
20
|
+
args.splice(0, 0, this);
|
|
21
|
+
args.splice(1, 0, originalFunction);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return proxyFunction.apply(this, args.concat(...params));
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
func.func.isProxy = true;
|
|
29
|
+
return func.func;
|
|
30
|
+
})();
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function addFunctionExtensions() {
|
|
35
|
+
/* v8 ignore start */
|
|
36
|
+
if (Function.prototype.name === undefined) {
|
|
37
|
+
// This is only used by legacy browsers
|
|
38
|
+
Object.defineProperty(Function.prototype, 'name', {
|
|
39
|
+
get: function () {
|
|
40
|
+
return /function ([^(]*)/.exec(this + '')[1];
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/* v8 ignore stop */
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function addUniqueId(entity: any) {
|
|
48
|
+
if (entity[TypeProperty] && !entity[StateProperties.Id]) {
|
|
49
|
+
entity[StateProperties.Id] = crypto.randomUUID();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function addArrayExtensions() {
|
|
54
|
+
if ((<any>Array.prototype).get === undefined) {
|
|
55
|
+
Object.defineProperty(Array.prototype, 'get', {
|
|
56
|
+
enumerable: false,
|
|
57
|
+
value: function (id: any) {
|
|
58
|
+
let result: any;
|
|
59
|
+
|
|
60
|
+
if (id) {
|
|
61
|
+
result = find(id, this, false)[0];
|
|
62
|
+
} else {
|
|
63
|
+
result = this[0];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if ((<any>Array.prototype).all === undefined) {
|
|
72
|
+
Object.defineProperty(Array.prototype, 'all', {
|
|
73
|
+
enumerable: false,
|
|
74
|
+
value: function (id: any) {
|
|
75
|
+
return find(id, this, false).filter(r => !r[StateProperties.Deleted]);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if ((<any>Array.prototype).getDeleted === undefined) {
|
|
81
|
+
Object.defineProperty(Array.prototype, 'getDeleted', {
|
|
82
|
+
enumerable: false,
|
|
83
|
+
value: function () {
|
|
84
|
+
return this[deletedCollection] ?? [];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if ((<any>Array.prototype).add === undefined) {
|
|
90
|
+
Object.defineProperty(Array.prototype, 'add', {
|
|
91
|
+
enumerable: false,
|
|
92
|
+
writable: true,
|
|
93
|
+
value: function (entity: any) {
|
|
94
|
+
if (entity === undefined) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
let deleted: any;
|
|
99
|
+
|
|
100
|
+
// Add a unique id to identify the add record if it doesn't have one yet, so we can
|
|
101
|
+
// match it to a delete record when appropriate. Otherwise, try and get a matching
|
|
102
|
+
// delete record to see whether the record originally came from this array.
|
|
103
|
+
if (entity[StateProperties.Id]) {
|
|
104
|
+
deleted = this.getDeleted()?.find((e: {
|
|
105
|
+
[StateProperties.Id]: string;
|
|
106
|
+
}) => e[StateProperties.Id] === entity[StateProperties.Id]);
|
|
107
|
+
} else {
|
|
108
|
+
addUniqueId(entity);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// If an existing delete record is found, the item was originally removed from this array.
|
|
112
|
+
// Remove the deleted record, the added flag and unique id so the original situation is
|
|
113
|
+
// restored. Otherwise, add the added flag.
|
|
114
|
+
if (deleted) {
|
|
115
|
+
const deletedItems = this[deletedCollection];
|
|
116
|
+
deletedItems.splice(deletedItems.indexOf(deleted), 1);
|
|
117
|
+
delete entity[StateProperties.Id];
|
|
118
|
+
delete entity[StateProperties.Added];
|
|
119
|
+
} else if (isDataRecord(entity)) {
|
|
120
|
+
entity[1][StateProperties.Added] = true;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
entity[StateProperties.Added] = true;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
Array.prototype.push.call(this, entity);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if ((<any>Array.prototype).delete === undefined) {
|
|
132
|
+
Object.defineProperty(Array.prototype, 'delete', {
|
|
133
|
+
enumerable: false,
|
|
134
|
+
writable: true,
|
|
135
|
+
value: function (item: any) {
|
|
136
|
+
if (item === undefined) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const collection = this;
|
|
141
|
+
const firstCollectionItem = collection[0];
|
|
142
|
+
|
|
143
|
+
if (firstCollectionItem
|
|
144
|
+
&& Array.isArray(firstCollectionItem)
|
|
145
|
+
&& firstCollectionItem.length === 2
|
|
146
|
+
&& typeof firstCollectionItem[0] === 'string') {
|
|
147
|
+
item = collection.get(item);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const index = findIndex(collection, item);
|
|
151
|
+
|
|
152
|
+
if (index === -1) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// When an id was passed in, replace the item with the actual entity so we
|
|
157
|
+
// have the information we need to create the deletion record.
|
|
158
|
+
if (typeof item === 'string') {
|
|
159
|
+
item = collection[index];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
Array.prototype.splice.call(this, index, 1);
|
|
163
|
+
collection[deletedCollection] = collection[deletedCollection] || [];
|
|
164
|
+
|
|
165
|
+
// If a deletion record is deleted, simply move it to the deleted collection.
|
|
166
|
+
if (item[StateProperties.Deleted]) {
|
|
167
|
+
collection[deletedCollection].push(item);
|
|
168
|
+
return item;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Only add a deletion record when the item is removed from the array and the
|
|
172
|
+
// item does not have the 'added' flag. Otherwise, it came from another array
|
|
173
|
+
// that has the deletion record for this item.
|
|
174
|
+
if (!item[StateProperties.Added]) {
|
|
175
|
+
// Add a unique id to the item to track it if it doesn't have one yet.
|
|
176
|
+
addUniqueId(item);
|
|
177
|
+
|
|
178
|
+
const {first, second} = getKeyPropertyNames(item);
|
|
179
|
+
let keyProps: { [x: string]: any; };
|
|
180
|
+
|
|
181
|
+
if (first && second) {
|
|
182
|
+
keyProps = {[first]: item[first], [second]: item[second]};
|
|
183
|
+
} else if (first) {
|
|
184
|
+
keyProps = {[first]: item[first]}
|
|
185
|
+
} else {
|
|
186
|
+
keyProps = {[second]: item[second]};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (item[StateProperties.Id]) {
|
|
190
|
+
collection[deletedCollection].push({
|
|
191
|
+
...keyProps,
|
|
192
|
+
[StateProperties.Deleted]: true,
|
|
193
|
+
[StateProperties.Id]: item[StateProperties.Id]
|
|
194
|
+
});
|
|
195
|
+
} else {
|
|
196
|
+
collection[deletedCollection].push({
|
|
197
|
+
...keyProps,
|
|
198
|
+
[StateProperties.Deleted]: true
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return item;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if ((<any>Array.prototype).clear === undefined) {
|
|
209
|
+
Object.defineProperty(Array.prototype, 'clear', {
|
|
210
|
+
enumerable: false,
|
|
211
|
+
value: function () {
|
|
212
|
+
const collection = [...this];
|
|
213
|
+
|
|
214
|
+
collection.forEach(e => {
|
|
215
|
+
this.delete(e);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function findIndex(collection: any[], item: any) {
|
|
223
|
+
let entry: any;
|
|
224
|
+
|
|
225
|
+
if (isDataRecord(item)) {
|
|
226
|
+
entry = collection.find(e => e[0] === item[0]);
|
|
227
|
+
} else {
|
|
228
|
+
entry = find(item, collection, false)[0];
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
let index: number;
|
|
232
|
+
|
|
233
|
+
if (entry === undefined) {
|
|
234
|
+
index = collection.indexOf(item);
|
|
235
|
+
} else {
|
|
236
|
+
index = collection.indexOf(entry);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return index;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function find(id: any, array: any[], usePropertyMatch: boolean): any[] {
|
|
243
|
+
if (typeof id === 'object') {
|
|
244
|
+
let result = Array.prototype.filter.call(array, (x: any) => x === id);
|
|
245
|
+
|
|
246
|
+
if (result.length === 0 && usePropertyMatch) {
|
|
247
|
+
result = Array.prototype.filter.call(array, p => propertyMatch(id, p));
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return result;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
id = getId(id);
|
|
254
|
+
|
|
255
|
+
return Array.prototype.filter.call(array, (x: { id: string, target: Function | string } | Function) => {
|
|
256
|
+
let currentId: string | Function;
|
|
257
|
+
|
|
258
|
+
if (typeof x === 'function') {
|
|
259
|
+
currentId = x;
|
|
260
|
+
} else if (Array.isArray(x) && x.length === 2) {
|
|
261
|
+
currentId = x[0];
|
|
262
|
+
|
|
263
|
+
} else {
|
|
264
|
+
currentId = x.target ?? x.id;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return compareString(getId(currentId), id) || (x[StateProperties.Id] && compareString(x[StateProperties.Id], id));
|
|
268
|
+
});
|
|
269
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import {IInterfaceTexts} from 'storyScript';
|
|
2
|
+
|
|
3
|
+
export class DefaultTexts {
|
|
4
|
+
texts: IInterfaceTexts = {
|
|
5
|
+
equipmentHeader: 'Equipment',
|
|
6
|
+
head: 'Head',
|
|
7
|
+
amulet: 'Amulet',
|
|
8
|
+
rightHand: 'Right hand',
|
|
9
|
+
leftHand: 'Left hand',
|
|
10
|
+
body: 'Body',
|
|
11
|
+
legs: 'Legs',
|
|
12
|
+
feet: 'Feet',
|
|
13
|
+
backpack: 'Backpack',
|
|
14
|
+
equip: 'Equip',
|
|
15
|
+
use: 'Use',
|
|
16
|
+
groupItem: 'Group',
|
|
17
|
+
splitItemGroup: 'Split',
|
|
18
|
+
drop: 'Drop',
|
|
19
|
+
enemies: 'Enemies',
|
|
20
|
+
enemyHitpoints: 'Health: {0} / {1}',
|
|
21
|
+
enemyCombatName: "{0} {1}",
|
|
22
|
+
characterHitpoints: 'Health: {0} / {1}',
|
|
23
|
+
fight: 'Fight!',
|
|
24
|
+
noWeapon: 'No weapon!',
|
|
25
|
+
attack: 'Attack ',
|
|
26
|
+
attackWith: 'with ',
|
|
27
|
+
aid: 'Aid',
|
|
28
|
+
aidWith: 'with ',
|
|
29
|
+
useCombatItem: 'Use item',
|
|
30
|
+
newGame: 'New game',
|
|
31
|
+
firstCharacter: 'Create your first character',
|
|
32
|
+
secondCharacter: 'Create your second character',
|
|
33
|
+
thirdCharacter: 'Create your third character',
|
|
34
|
+
nthCharacter: 'Create your {0}th character',
|
|
35
|
+
nextCharacter: 'Next character',
|
|
36
|
+
nextQuestion: 'Next question',
|
|
37
|
+
startAdventure: 'Start adventure',
|
|
38
|
+
actions: 'Actions',
|
|
39
|
+
destinations: 'Destinations',
|
|
40
|
+
back: 'Back: ',
|
|
41
|
+
onTheGround: 'On the ground',
|
|
42
|
+
youLost: 'You lost...',
|
|
43
|
+
questFailed: 'You have failed your quest!',
|
|
44
|
+
finalScore: 'Your score: ',
|
|
45
|
+
tryAgain: 'Try again',
|
|
46
|
+
highScores: 'High Scores',
|
|
47
|
+
youWon: 'You won!',
|
|
48
|
+
congratulations: 'Congratulations! You have won the game!',
|
|
49
|
+
playAgain: 'Play again',
|
|
50
|
+
startOver: 'Start over',
|
|
51
|
+
resetWorld: 'Reset world',
|
|
52
|
+
gameName: 'Game template',
|
|
53
|
+
save: 'Save',
|
|
54
|
+
saveGame: 'Save game',
|
|
55
|
+
load: 'Load',
|
|
56
|
+
loadGame: 'Load game',
|
|
57
|
+
loading: 'Loading...',
|
|
58
|
+
youAreHere: 'You are at {0}',
|
|
59
|
+
messages: 'Messages',
|
|
60
|
+
hitpoints: 'Health',
|
|
61
|
+
currency: 'Money',
|
|
62
|
+
partyCurrency: 'Money:',
|
|
63
|
+
trade: 'Trade with {0}',
|
|
64
|
+
talk: 'Talk to {0}',
|
|
65
|
+
examine: 'Examine {0}',
|
|
66
|
+
encounters: 'Encounters',
|
|
67
|
+
closeModal: 'Close',
|
|
68
|
+
combatTitle: 'Combat',
|
|
69
|
+
combatRound: 'Combat round {0}',
|
|
70
|
+
value: 'value',
|
|
71
|
+
traderCurrency: 'Trader money: {0} {1}',
|
|
72
|
+
startCombat: 'Start combat',
|
|
73
|
+
combatWin: 'You are victorious!',
|
|
74
|
+
enemiesToFight: 'You face these foes: ',
|
|
75
|
+
useInCombat: 'Use {0}',
|
|
76
|
+
noCombatAction: 'No Combat Actions',
|
|
77
|
+
view: 'View',
|
|
78
|
+
quests: 'Quests',
|
|
79
|
+
currentQuests: 'Current',
|
|
80
|
+
completedQuests: 'Completed',
|
|
81
|
+
hands: 'Hands',
|
|
82
|
+
leftRing: 'Left ring',
|
|
83
|
+
rightRing: 'Right ring',
|
|
84
|
+
yourName: 'Name',
|
|
85
|
+
combinations: 'Combinations',
|
|
86
|
+
tryCombination: 'Try',
|
|
87
|
+
noCombination: 'You {2} the {0} {3} the {1}. Nothing happens.',
|
|
88
|
+
noCombinationNoTool: 'You {1} {2} the {0}. Nothing happens.',
|
|
89
|
+
levelUp: 'Level up',
|
|
90
|
+
completeLevelUp: 'Accept',
|
|
91
|
+
levelUpDescription: 'You reached level {0}.',
|
|
92
|
+
newSaveGame: 'New save game',
|
|
93
|
+
existingSaveGames: 'Saved games',
|
|
94
|
+
overwriteSaveGame: 'Overwrite saved game {0}?',
|
|
95
|
+
loadSaveGame: 'Load saved game {0}?',
|
|
96
|
+
characterSheet: 'Character sheet',
|
|
97
|
+
skipIntro: 'Skip intro',
|
|
98
|
+
mainMenu: 'Main menu',
|
|
99
|
+
mainMenuShort: 'Menu',
|
|
100
|
+
confirmRestart: 'Really restart?',
|
|
101
|
+
restartCancelled: 'No',
|
|
102
|
+
restartConfirmed: 'Yes',
|
|
103
|
+
cancel: 'Cancel',
|
|
104
|
+
confirmAction: 'Ok',
|
|
105
|
+
cancelAction: 'Cancel',
|
|
106
|
+
stockItemDisplayText: '{0}: {1} {2}',
|
|
107
|
+
buyConfirmationText: 'Are you sure you want to buy the {0} for {1} {2}?',
|
|
108
|
+
confirmBuy: 'Ok',
|
|
109
|
+
cancelBuy: 'Cancel',
|
|
110
|
+
sellConfirmationText: 'Are you sure you want to sell the {0} for {1} {2}?',
|
|
111
|
+
confirmSell: 'Ok',
|
|
112
|
+
cancelSell: 'Cancel',
|
|
113
|
+
currencyWon: 'Currency gained: {0}',
|
|
114
|
+
itemsTaken: 'Items taken',
|
|
115
|
+
enemiesDefeated: 'Enemies defeated',
|
|
116
|
+
backToGame: 'Back to the game',
|
|
117
|
+
conversationEnded: 'Your conversation has ended.',
|
|
118
|
+
openFullScreenMap: '>',
|
|
119
|
+
closeFullScreenMap: '<',
|
|
120
|
+
pressToShowMarkers: 'Press {0} to show location markers',
|
|
121
|
+
touchToShowMarkers: 'Press here to show location markers',
|
|
122
|
+
startGame: 'Start',
|
|
123
|
+
continueGame: 'Continue',
|
|
124
|
+
autoplayText: "Auto-playing",
|
|
125
|
+
noPlayWarning: "Please interact with the page to allow media playback!"
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
format = format;
|
|
129
|
+
|
|
130
|
+
titleCase = (text: string): string => text.substring(0, 1).toUpperCase() + text.substring(1);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function format(template: string, tokens: string | string[]): string {
|
|
134
|
+
if (template && tokens) {
|
|
135
|
+
if (!Array.isArray(tokens)) {
|
|
136
|
+
tokens = [tokens];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
tokens.forEach((t, i) => {
|
|
140
|
+
if (t === undefined) {
|
|
141
|
+
(<string[]>tokens)[i] = "{undefined}";
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
146
|
+
const pattern = '[ ]{0,1}\\{' + i + '\\}[ ]{0,1}';
|
|
147
|
+
const match = new RegExp(pattern).exec(template);
|
|
148
|
+
|
|
149
|
+
if (match) {
|
|
150
|
+
const matchReplacement = match[0].replace('{' + i + '}', '');
|
|
151
|
+
|
|
152
|
+
if (tokens[i].trim && tokens[i].trim().length == 0 && matchReplacement.length > 1) {
|
|
153
|
+
template = template.replace(match[0], ' ');
|
|
154
|
+
} else {
|
|
155
|
+
template = template.replace('{' + i + '}', tokens[i]);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return template;
|
|
162
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {IGame, IGameEvents}from 'storyScript';
|
|
2
|
+
|
|
3
|
+
export class GameEvents implements IGameEvents {
|
|
4
|
+
private readonly _eventHandlers = new Map<string, ((game: IGame, eventArguments: any) => void)[]>();
|
|
5
|
+
private _game: IGame;
|
|
6
|
+
|
|
7
|
+
register = (eventName: string): void => {
|
|
8
|
+
if (this._eventHandlers.has(eventName)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
this._eventHandlers.set(eventName, []);
|
|
13
|
+
}
|
|
14
|
+
subscribe = (eventName: string | string[], handler: (game: IGame, eventArguments: any) => void, throwIfUnknown?: boolean): void => {
|
|
15
|
+
const eventNames = Array.isArray(eventName) ? eventName : [eventName];
|
|
16
|
+
|
|
17
|
+
eventNames.forEach(e => {
|
|
18
|
+
if (!this._eventHandlers.has(e)) {
|
|
19
|
+
if (throwIfUnknown === undefined || throwIfUnknown) {
|
|
20
|
+
throw new Error(`Event ${e} has not been registered!`);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
this._eventHandlers.set(e, []);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const handlers = this._eventHandlers.get(e);
|
|
28
|
+
handlers.push(handler);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
publish = (eventName: string, eventData?: any): void => {
|
|
33
|
+
if (!this._eventHandlers.has(eventName)) {
|
|
34
|
+
throw new Error(`Event ${eventName} has not been registered!`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const handlers = this._eventHandlers.get(eventName);
|
|
38
|
+
|
|
39
|
+
if (this._game) {
|
|
40
|
+
handlers.forEach(handler => handler(this._game, eventData));
|
|
41
|
+
} else {
|
|
42
|
+
console.log(`setGame has not been called for gameEvents, or it was called without passing in a game object!`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
setGame = (game: IGame): void => {
|
|
47
|
+
this._game = game;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const gameEvents = new GameEvents();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import {addArrayExtensions, addFunctionExtensions} from './arrayAndFunctionExtensions';
|
|
2
|
+
import {ServiceFactory} from "./ServiceFactory";
|
|
3
|
+
|
|
4
|
+
export {addArrayExtensions, addFunctionExtensions, ServiceFactory};
|
|
5
|
+
export * from './Interfaces/index';
|
|
6
|
+
export {gameEvents} from './gameEvents';
|
|
7
|
+
export * from './defaultTexts';
|
|
8
|
+
export * from './Services/sharedFunctions';
|
|
9
|
+
export * from './utilityFunctions';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const enum StateProperties {
|
|
2
|
+
Id = 'ss_uniqueId',
|
|
3
|
+
Added = 'ss_added',
|
|
4
|
+
Deleted = 'ss_deleted',
|
|
5
|
+
|
|
6
|
+
// A marker to see that actions have been performed and should not be repeated.
|
|
7
|
+
// This is used for e.g. initializing trader stock on a first visit.
|
|
8
|
+
Triggered = 'ss_triggered'
|
|
9
|
+
}
|