briyah 1.4.1 → 2.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/README.md +1092 -849
- package/data/common/config/markup +1 -1
- package/data/common/prompts/character/progress_character.json +5 -5
- package/data/common/prompts/illustrator/describe_scene.json +11 -3
- package/data/common/prompts/perceive.json +2 -2
- package/data/common/prompts/room_moderator/moderate.json +34 -34
- package/data/common/prompts/story_moderator/moderate.json +62 -62
- package/data/packs/dnd5e/agents/battle-master.json +6 -0
- package/data/packs/dnd5e/agents/campaign-designer.json +6 -0
- package/data/packs/dnd5e/agents/character-creator.json +6 -0
- package/data/packs/dnd5e/agents/dungeon-master.json +6 -0
- package/data/packs/dnd5e/agents/player.json +13 -0
- package/data/packs/dnd5e/agents/table-moderator.json +6 -0
- package/data/{common/artifacts/dnd5e/dungeon_master-procedure.md → packs/dnd5e/artifacts/battle_master-combat.md} +31 -131
- package/data/packs/dnd5e/artifacts/dungeon_master-procedure.md +192 -0
- package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/manifest.json +8 -2
- package/data/packs/dnd5e/pack.json +6 -0
- package/data/packs/dnd5e/prompts/battle_master/defaults_config.json +23 -0
- package/data/packs/dnd5e/prompts/battle_master/perceive.json +33 -0
- package/data/packs/dnd5e/prompts/battle_master/perceive.prompt +378 -0
- package/data/{common → packs/dnd5e}/prompts/character_creator/defaults_config.json +1 -1
- package/data/{common → packs/dnd5e}/prompts/character_creator/perceive.prompt +29 -0
- package/data/{common → packs/dnd5e}/prompts/dnd_player/perceive.prompt +40 -22
- package/data/{common → packs/dnd5e}/prompts/dnd_room_moderator/moderate.json +34 -34
- package/data/{common → packs/dnd5e}/prompts/dnd_room_moderator/moderate.prompt +14 -3
- package/data/{common → packs/dnd5e}/prompts/dungeon_master/defaults_config.json +1 -0
- package/data/{common → packs/dnd5e}/prompts/dungeon_master/perceive.prompt +122 -115
- package/data/packs/dnd5e/prompts/dungeon_master/system_instruction.prompt +0 -0
- package/data/packs/dnd5e/rooms/table.json +16 -0
- package/dist-sdk/server/src/ai/LLM/base-ai.service.js +4 -13
- package/dist-sdk/server/src/ai/LLM/deepseek.service.d.ts +2 -1
- package/dist-sdk/server/src/ai/LLM/deepseek.service.js +65 -77
- package/dist-sdk/server/src/ai/agent-config.d.ts +2 -0
- package/dist-sdk/server/src/ai/agent-store.service.js +8 -0
- package/dist-sdk/server/src/ai/agent.d.ts +6 -0
- package/dist-sdk/server/src/ai/agent.js +25 -2
- package/dist-sdk/server/src/ai/artifact.service.d.ts +3 -1
- package/dist-sdk/server/src/ai/artifact.service.js +12 -5
- package/dist-sdk/server/src/ai/pack-artifacts.d.ts +3 -3
- package/dist-sdk/server/src/ai/pack-artifacts.js +21 -15
- package/dist-sdk/server/src/app/user-service-factory.js +9 -1
- package/dist-sdk/server/src/app.controller.d.ts +11 -11
- package/dist-sdk/server/src/app.controller.js +178 -88
- package/dist-sdk/server/src/app.service.d.ts +36 -8
- package/dist-sdk/server/src/app.service.js +147 -91
- package/dist-sdk/server/src/common/errors.d.ts +0 -3
- package/dist-sdk/server/src/common/errors.js +1 -11
- package/dist-sdk/server/src/config/prompt-resolver.d.ts +39 -0
- package/dist-sdk/server/src/config/prompt-resolver.js +189 -0
- package/dist-sdk/server/src/config/user-config.service.d.ts +17 -0
- package/dist-sdk/server/src/config/user-config.service.js +103 -0
- package/dist-sdk/server/src/config/user-paths.service.d.ts +4 -4
- package/dist-sdk/server/src/config/user-paths.service.js +12 -16
- package/dist-sdk/server/src/packs/pack-instantiation.service.d.ts +35 -0
- package/dist-sdk/server/src/packs/pack-instantiation.service.js +154 -0
- package/dist-sdk/server/src/packs/pack-manifest.d.ts +52 -0
- package/dist-sdk/server/src/packs/pack-manifest.js +256 -0
- package/dist-sdk/server/src/packs/pack.service.d.ts +24 -0
- package/dist-sdk/server/src/packs/pack.service.js +151 -0
- package/dist-sdk/server/src/room/room-config.d.ts +5 -0
- package/dist-sdk/server/src/room/room-store.service.d.ts +3 -0
- package/dist-sdk/server/src/room/room-store.service.js +41 -5
- package/dist-sdk/server/src/room/room.d.ts +10 -2
- package/dist-sdk/server/src/room/room.js +37 -6
- package/dist-sdk/server/src/sdk/briyah.d.ts +2 -0
- package/dist-sdk/server/src/sdk/briyah.js +45 -8
- package/dist-sdk/server/src/sdk/index.d.ts +8 -3
- package/dist-sdk/server/src/sdk/index.js +6 -2
- package/dist-sdk/server/src/shared/shared.module.js +0 -3
- package/dist-sdk/server/src/story/story.service.d.ts +2 -2
- package/dist-sdk/server/src/story/story.service.js +2 -2
- package/dist-sdk/server/src/tools/packs/dnd5e/data/kits.d.ts +17 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/kits.js +54 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/races.d.ts +3 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/races.js +6 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/srd.d.ts +2 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/srd.js +4 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/backgrounds.d.ts +1 -1
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/backgrounds.js +6 -3
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.d.ts +3 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.js +45 -5
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.d.ts +27 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.js +103 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/foes.d.ts +7 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/foes.js +83 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/kits.d.ts +19 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/kits.js +130 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.d.ts +2 -1
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.js +13 -2
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/rules.d.ts +6 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/rules.js +16 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.d.ts +10 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.js +82 -1
- package/dist-sdk/server/src/tools/packs/dnd5e/index.js +2 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/check.tool.js +51 -6
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/dice.tools.js +19 -9
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/encounter.tool.d.ts +2 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/encounter.tool.js +134 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/monster.tool.js +31 -13
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.d.ts +2 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.js +25 -8
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.js +70 -4
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.js +27 -0
- package/dist-sdk/server/src/tools/packs/index.d.ts +1 -2
- package/dist-sdk/server/src/tools/packs/index.js +5 -11
- package/dist-sdk/shared/types/app.types.d.ts +72 -13
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/highlight.css +8 -1
- package/docs/assets/icons.js +1 -1
- package/docs/assets/icons.svg +1 -1
- package/docs/assets/main.js +4 -4
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +18 -3
- package/docs/classes/Agent.html +702 -37
- package/docs/classes/Briyah.html +250 -33
- package/docs/classes/BriyahConfigService.html +117 -10
- package/docs/classes/NativeToolRegistry.html +156 -11
- package/docs/classes/PackInstantiationService.html +146 -0
- package/docs/classes/PackService.html +247 -0
- package/docs/classes/Room.html +1196 -74
- package/docs/classes/RoomMessage.html +260 -29
- package/docs/enums/MessageAction.html +123 -3
- package/docs/functions/availableToolPacks.html +41 -2
- package/docs/functions/dnd5eTools.html +42 -3
- package/docs/functions/installToolPacks.html +48 -0
- package/docs/functions/registerToolPacks.html +54 -6
- package/docs/hierarchy.html +42 -1
- package/docs/index.html +218 -30
- package/docs/interfaces/AgentCreationOptions.html +125 -0
- package/docs/interfaces/AgentInfo.html +188 -3
- package/docs/interfaces/AgentMessagesResponse.html +71 -2
- package/docs/interfaces/AppService.html +2799 -466
- package/docs/interfaces/Artifact.html +81 -4
- package/docs/interfaces/ArtifactMetadata.html +104 -3
- package/docs/interfaces/ArtifactWriteOptions.html +75 -6
- package/docs/interfaces/AttachDocumentResponse.html +61 -2
- package/docs/interfaces/BriyahConfigOptions.html +107 -10
- package/docs/interfaces/ChapterInfo.html +61 -2
- package/docs/interfaces/Character.html +81 -2
- package/docs/interfaces/CreateAgentResponse.html +56 -2
- package/docs/interfaces/CreateRoomResponse.html +61 -2
- package/docs/interfaces/CreateStoryResponse.html +56 -2
- package/docs/interfaces/FileList.html +56 -2
- package/docs/interfaces/FileMetadata.html +84 -3
- package/docs/interfaces/IConfigService.html +76 -3
- package/docs/interfaces/InstantiateModels.html +64 -0
- package/docs/interfaces/InstantiateRoomResult.html +70 -0
- package/docs/interfaces/LoadedPack.html +131 -0
- package/docs/interfaces/LoggingOptions.html +86 -7
- package/docs/interfaces/Message.html +80 -2
- package/docs/interfaces/ModelChoice.html +73 -0
- package/docs/interfaces/ModelInfo.html +71 -2
- package/docs/interfaces/NativeToolDefinition.html +96 -9
- package/docs/interfaces/PackAgentTemplate.html +101 -0
- package/docs/interfaces/PackRoomTemplate.html +108 -0
- package/docs/interfaces/PackView.html +172 -0
- package/docs/interfaces/PreparedPromptResponse.html +61 -2
- package/docs/interfaces/ProcessTextResponse.html +81 -2
- package/docs/interfaces/PromptFile.html +69 -2
- package/docs/interfaces/PromptFileContent.html +75 -2
- package/docs/interfaces/PromptFilesResponse.html +56 -2
- package/docs/interfaces/PromptFolder.html +79 -2
- package/docs/interfaces/PromptFolderDefaults.html +155 -0
- package/docs/interfaces/PromptFolderDefaultsResponse.html +66 -0
- package/docs/interfaces/PromptFoldersResponse.html +56 -2
- package/docs/interfaces/RoomDetails.html +133 -4
- package/docs/interfaces/RoomInfo.html +84 -2
- package/docs/interfaces/RoomMessageUpdate.html +91 -2
- package/docs/interfaces/RoomMessagesResponse.html +61 -2
- package/docs/interfaces/SendMessageResult.html +61 -2
- package/docs/interfaces/StoryErrorEvent.html +76 -4
- package/docs/interfaces/StoryIdea.html +71 -2
- package/docs/interfaces/StoryInfo.html +173 -3
- package/docs/interfaces/StoryIntroduceCharacterEvent.html +71 -4
- package/docs/interfaces/StoryProgressChapterEvent.html +64 -3
- package/docs/interfaces/StoryState.html +99 -6
- package/docs/interfaces/StoryStateEvent.html +69 -3
- package/docs/interfaces/ToolArtifact.html +81 -4
- package/docs/interfaces/ToolCaller.html +75 -6
- package/docs/interfaces/ToolDefinition.html +76 -2
- package/docs/interfaces/ToolHelpers.html +91 -6
- package/docs/interfaces/ToolParameter.html +71 -2
- package/docs/interfaces/ToolRoomAccess.html +200 -24
- package/docs/interfaces/ToolSummary.html +71 -2
- package/docs/interfaces/ToolsResponse.html +66 -2
- package/docs/interfaces/Transaction.html +96 -2
- package/docs/interfaces/TransactionHistoryResponse.html +61 -2
- package/docs/modules.html +53 -1
- package/docs/types/PackOrigin.html +34 -0
- package/docs/types/PromptScope.html +34 -1
- package/docs/types/RoomTurnMode.html +42 -0
- package/docs/types/ToolContext.html +36 -2
- package/docs/types/ToolRunResult.html +34 -1
- package/package.json +139 -139
- package/src/tools/packs/dnd5e/README.md +162 -26
- package/dist-sdk/server/src/library/library.service.d.ts +0 -14
- package/dist-sdk/server/src/library/library.service.js +0 -165
- package/docs/functions/enabledToolPacks.html +0 -2
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/campaign_designer-setting.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/character_creator-basics.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-barbarian.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-bard.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-cleric.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-druid.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-fighter.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-monk.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-paladin.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-ranger.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-rogue.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-sorcerer.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-warlock.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-wizard.md +0 -0
- /package/data/{common/prompts/campaign_designer → packs/dnd5e/prompts/battle_master}/system_instruction.prompt +0 -0
- /package/data/{common → packs/dnd5e}/prompts/campaign_designer/defaults_config.json +0 -0
- /package/data/{common → packs/dnd5e}/prompts/campaign_designer/perceive.json +0 -0
- /package/data/{common → packs/dnd5e}/prompts/campaign_designer/perceive.prompt +0 -0
- /package/data/{common/prompts/character_creator → packs/dnd5e/prompts/campaign_designer}/system_instruction.prompt +0 -0
- /package/data/{common → packs/dnd5e}/prompts/character_creator/perceive.json +0 -0
- /package/data/{common/prompts/dnd_player → packs/dnd5e/prompts/character_creator}/system_instruction.prompt +0 -0
- /package/data/{common → packs/dnd5e}/prompts/dnd_player/defaults_config.json +0 -0
- /package/data/{common → packs/dnd5e}/prompts/dnd_player/perceive.json +0 -0
- /package/data/{common/prompts/dnd_room_moderator → packs/dnd5e/prompts/dnd_player}/system_instruction.prompt +0 -0
- /package/data/{common → packs/dnd5e}/prompts/dnd_room_moderator/defaults_config.json +0 -0
- /package/data/{common/prompts/dungeon_master → packs/dnd5e/prompts/dnd_room_moderator}/system_instruction.prompt +0 -0
- /package/data/{common → packs/dnd5e}/prompts/dungeon_master/compact_agent.prompt +0 -0
- /package/data/{common → packs/dnd5e}/prompts/dungeon_master/perceive.json +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TOOL_KITS = exports.TOOL_CATEGORY_LABEL = exports.TOOLS_RULE = void 0;
|
|
4
|
+
exports.TOOLS_RULE = 'A tool helps you to do something you could not otherwise do, such as craft or repair an item, forge a document, or pick a lock. Proficiency with a tool adds your proficiency bonus to any ability check you make using it. ' +
|
|
5
|
+
'Tool use is not tied to a single ability, since proficiency with a tool represents broader knowledge of its use: the DM chooses the ability the check uses from the situation. Picking a lock with thieves\' tools is a Dexterity check; identifying a poison with a poisoner\'s kit is an Intelligence check. ' +
|
|
6
|
+
'Tools fall into artisan\'s tools, gaming sets, musical instruments, and a handful named on their own — a disguise kit, a forgery kit, a herbalism kit, navigator\'s tools, a poisoner\'s kit and thieves\' tools. Vehicles are a proficiency in a kind of vehicle rather than in a named object.';
|
|
7
|
+
exports.TOOL_CATEGORY_LABEL = {
|
|
8
|
+
artisan: "artisan's tools",
|
|
9
|
+
gaming: 'gaming set',
|
|
10
|
+
instrument: 'musical instrument',
|
|
11
|
+
other: 'tool',
|
|
12
|
+
vehicle: 'vehicle',
|
|
13
|
+
};
|
|
14
|
+
exports.TOOL_KITS = {
|
|
15
|
+
'alchemists supplies': { name: "Alchemist's supplies", category: 'artisan' },
|
|
16
|
+
'brewers supplies': { name: "Brewer's supplies", category: 'artisan' },
|
|
17
|
+
'calligraphers supplies': { name: "Calligrapher's supplies", category: 'artisan' },
|
|
18
|
+
'carpenters tools': { name: "Carpenter's tools", category: 'artisan' },
|
|
19
|
+
'cartographers tools': { name: "Cartographer's tools", category: 'artisan' },
|
|
20
|
+
'cobblers tools': { name: "Cobbler's tools", category: 'artisan' },
|
|
21
|
+
'cooks utensils': { name: "Cook's utensils", category: 'artisan' },
|
|
22
|
+
'glassblowers tools': { name: "Glassblower's tools", category: 'artisan' },
|
|
23
|
+
'jewelers tools': { name: "Jeweler's tools", category: 'artisan' },
|
|
24
|
+
'leatherworkers tools': { name: "Leatherworker's tools", category: 'artisan' },
|
|
25
|
+
'masons tools': { name: "Mason's tools", category: 'artisan' },
|
|
26
|
+
'painters supplies': { name: "Painter's supplies", category: 'artisan' },
|
|
27
|
+
'potters tools': { name: "Potter's tools", category: 'artisan' },
|
|
28
|
+
'smiths tools': { name: "Smith's tools", category: 'artisan' },
|
|
29
|
+
'tinkers tools': { name: "Tinker's tools", category: 'artisan' },
|
|
30
|
+
'weavers tools': { name: "Weaver's tools", category: 'artisan' },
|
|
31
|
+
'woodcarvers tools': { name: "Woodcarver's tools", category: 'artisan' },
|
|
32
|
+
'dice set': { name: 'Dice set', category: 'gaming' },
|
|
33
|
+
'dragonchess set': { name: 'Dragonchess set', category: 'gaming' },
|
|
34
|
+
'playing card set': { name: 'Playing card set', category: 'gaming' },
|
|
35
|
+
'threedragon ante set': { name: 'Three-Dragon Ante set', category: 'gaming' },
|
|
36
|
+
bagpipes: { name: 'Bagpipes', category: 'instrument' },
|
|
37
|
+
drum: { name: 'Drum', category: 'instrument' },
|
|
38
|
+
dulcimer: { name: 'Dulcimer', category: 'instrument' },
|
|
39
|
+
flute: { name: 'Flute', category: 'instrument' },
|
|
40
|
+
lute: { name: 'Lute', category: 'instrument' },
|
|
41
|
+
lyre: { name: 'Lyre', category: 'instrument' },
|
|
42
|
+
horn: { name: 'Horn', category: 'instrument' },
|
|
43
|
+
'pan flute': { name: 'Pan flute', category: 'instrument' },
|
|
44
|
+
shawm: { name: 'Shawm', category: 'instrument' },
|
|
45
|
+
viol: { name: 'Viol', category: 'instrument' },
|
|
46
|
+
'disguise kit': { name: 'Disguise kit', category: 'other' },
|
|
47
|
+
'forgery kit': { name: 'Forgery kit', category: 'other' },
|
|
48
|
+
'herbalism kit': { name: 'Herbalism kit', category: 'other' },
|
|
49
|
+
'navigators tools': { name: "Navigator's tools", category: 'other' },
|
|
50
|
+
'poisoners kit': { name: "Poisoner's kit", category: 'other' },
|
|
51
|
+
'thieves tools': { name: "Thieves' tools", category: 'other' },
|
|
52
|
+
'land vehicles': { name: 'Land vehicles', category: 'vehicle' },
|
|
53
|
+
'water vehicles': { name: 'Water vehicles', category: 'vehicle' },
|
|
54
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AbilityKey } from './srd';
|
|
2
|
+
import type { ToolGrant } from './kits';
|
|
2
3
|
export interface RaceTrait {
|
|
3
4
|
n: string;
|
|
4
5
|
text: string;
|
|
@@ -13,6 +14,7 @@ export interface SubraceRules {
|
|
|
13
14
|
abil: Partial<Record<AbilityKey, number>>;
|
|
14
15
|
skills?: string[];
|
|
15
16
|
weapons?: string[];
|
|
17
|
+
tools?: ToolGrant;
|
|
16
18
|
languageChoices?: number;
|
|
17
19
|
hpPerLevel?: number;
|
|
18
20
|
traits: RaceTrait[];
|
|
@@ -28,6 +30,7 @@ export interface RaceRules {
|
|
|
28
30
|
skills?: string[];
|
|
29
31
|
skillChoices?: number;
|
|
30
32
|
weapons?: string[];
|
|
33
|
+
tools?: ToolGrant;
|
|
31
34
|
languages: string[];
|
|
32
35
|
languageChoices?: number;
|
|
33
36
|
ignoresHeavyArmorSpeed?: boolean;
|
|
@@ -18,6 +18,11 @@ exports.RACES = {
|
|
|
18
18
|
darkvision: 60,
|
|
19
19
|
resist: ['poison'],
|
|
20
20
|
weapons: ['battleaxe', 'handaxe', 'light hammer', 'warhammer'],
|
|
21
|
+
tools: {
|
|
22
|
+
choices: [
|
|
23
|
+
{ count: 1, options: ["Smith's tools", "Brewer's supplies", "Mason's tools"] },
|
|
24
|
+
],
|
|
25
|
+
},
|
|
21
26
|
languages: ['Common', 'Dwarvish'],
|
|
22
27
|
ignoresHeavyArmorSpeed: true,
|
|
23
28
|
traits: [
|
|
@@ -176,6 +181,7 @@ exports.RACES = {
|
|
|
176
181
|
'rock gnome': {
|
|
177
182
|
name: 'Rock Gnome',
|
|
178
183
|
abil: { con: 1 },
|
|
184
|
+
tools: { fixed: ["Tinker's tools"] },
|
|
179
185
|
traits: [
|
|
180
186
|
{
|
|
181
187
|
n: "Artificer's Lore",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ToolGrant } from './kits';
|
|
1
2
|
export declare const SRD_ATTRIBUTION = "This work includes material from the System Reference Document 5.1 by Wizards of the Coast LLC, available under the Creative Commons Attribution 4.0 International License.";
|
|
2
3
|
export type AbilityKey = 'str' | 'dex' | 'con' | 'int' | 'wis' | 'cha';
|
|
3
4
|
export declare const ABILITIES: AbilityKey[];
|
|
@@ -12,6 +13,7 @@ export interface ClassRules {
|
|
|
12
13
|
saves: AbilityKey[];
|
|
13
14
|
skillChoices: number;
|
|
14
15
|
skillList: string[];
|
|
16
|
+
tools?: ToolGrant;
|
|
15
17
|
caster: CasterType;
|
|
16
18
|
spellAbility?: AbilityKey;
|
|
17
19
|
shortRestFeatures?: string[];
|
|
@@ -57,6 +57,7 @@ exports.CLASSES = {
|
|
|
57
57
|
saves: ['dex', 'cha'],
|
|
58
58
|
skillChoices: 3,
|
|
59
59
|
skillList: [],
|
|
60
|
+
tools: { choices: [{ count: 3, from: ['instrument'] }] },
|
|
60
61
|
caster: 'full',
|
|
61
62
|
spellAbility: 'cha',
|
|
62
63
|
shortRestFeatures: ['bardic_inspiration'],
|
|
@@ -92,6 +93,7 @@ exports.CLASSES = {
|
|
|
92
93
|
'religion',
|
|
93
94
|
'survival',
|
|
94
95
|
],
|
|
96
|
+
tools: { fixed: ['Herbalism kit'] },
|
|
95
97
|
caster: 'full',
|
|
96
98
|
spellAbility: 'wis',
|
|
97
99
|
shortRestFeatures: ['wild_shape'],
|
|
@@ -126,6 +128,7 @@ exports.CLASSES = {
|
|
|
126
128
|
saves: ['str', 'dex'],
|
|
127
129
|
skillChoices: 2,
|
|
128
130
|
skillList: ['acrobatics', 'athletics', 'history', 'insight', 'religion', 'stealth'],
|
|
131
|
+
tools: { choices: [{ count: 1, from: ['artisan', 'instrument'] }] },
|
|
129
132
|
caster: 'none',
|
|
130
133
|
shortRestFeatures: ['ki'],
|
|
131
134
|
subclassLevel: 3,
|
|
@@ -184,6 +187,7 @@ exports.CLASSES = {
|
|
|
184
187
|
'sleight of hand',
|
|
185
188
|
'stealth',
|
|
186
189
|
],
|
|
190
|
+
tools: { fixed: ["Thieves' tools"] },
|
|
187
191
|
caster: 'none',
|
|
188
192
|
subclassLevel: 3,
|
|
189
193
|
subclassLabel: 'Roguish Archetype',
|
|
@@ -15,6 +15,6 @@ export interface BackgroundApplication {
|
|
|
15
15
|
equipment: string[];
|
|
16
16
|
coin: string[];
|
|
17
17
|
}
|
|
18
|
-
export declare function applyBackground(state: SheetState, withEquipment?: boolean): BackgroundApplication;
|
|
18
|
+
export declare function applyBackground(state: SheetState, withEquipment?: boolean, consumedTools?: Set<string>): BackgroundApplication;
|
|
19
19
|
export declare function backgroundFeature(state: SheetState): BackgroundRules['feature'] | undefined;
|
|
20
20
|
export declare function describeBackground(background: BackgroundRules): string;
|
|
@@ -9,6 +9,7 @@ exports.describeBackground = describeBackground;
|
|
|
9
9
|
const backgrounds_1 = require("../data/backgrounds");
|
|
10
10
|
const srd_1 = require("../data/srd");
|
|
11
11
|
const coerce_1 = require("./coerce");
|
|
12
|
+
const kits_1 = require("./kits");
|
|
12
13
|
let backgroundIndexCache = null;
|
|
13
14
|
function backgroundIndex() {
|
|
14
15
|
if (!backgroundIndexCache) {
|
|
@@ -40,7 +41,7 @@ function resolveBackground(name) {
|
|
|
40
41
|
function backgroundNames() {
|
|
41
42
|
return Object.values(backgrounds_1.BACKGROUNDS).map((background) => background.name).sort();
|
|
42
43
|
}
|
|
43
|
-
function applyBackground(state, withEquipment = true) {
|
|
44
|
+
function applyBackground(state, withEquipment = true, consumedTools = new Set()) {
|
|
44
45
|
const { background } = resolveBackground(state.bg || '');
|
|
45
46
|
const result = {
|
|
46
47
|
known: false,
|
|
@@ -67,9 +68,11 @@ function applyBackground(state, withEquipment = true) {
|
|
|
67
68
|
state.skillProf.push(skill);
|
|
68
69
|
result.changes.push(`proficient in ${skill}`);
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
const tools = (0, kits_1.grantTools)(state, { fixed: background.tools }, background.name, consumedTools);
|
|
72
|
+
for (const tool of tools.added) {
|
|
73
|
+
result.changes.push(`proficient with ${tool}`);
|
|
72
74
|
}
|
|
75
|
+
result.outstanding.push(...tools.outstanding);
|
|
73
76
|
if (background.languageChoices) {
|
|
74
77
|
result.outstanding.push(`${background.languageChoices} language${background.languageChoices === 1 ? '' : 's'} of the player's choice`);
|
|
75
78
|
}
|
|
@@ -2,6 +2,7 @@ import { AbilityKey } from '../data/srd';
|
|
|
2
2
|
import { Rng } from './dice';
|
|
3
3
|
import { RaceApplication } from './races';
|
|
4
4
|
import { BackgroundApplication } from './backgrounds';
|
|
5
|
+
import { ToolGrantResult } from './kits';
|
|
5
6
|
import { AttackEntry, InventoryItem, SheetState } from './sheet';
|
|
6
7
|
export interface Refusal {
|
|
7
8
|
violation: string;
|
|
@@ -32,6 +33,7 @@ export interface CharacterSpec {
|
|
|
32
33
|
abilities?: Partial<Record<AbilityKey, number>>;
|
|
33
34
|
skills?: string[];
|
|
34
35
|
expertise?: string[];
|
|
36
|
+
tools?: string[];
|
|
35
37
|
equipment?: string[];
|
|
36
38
|
attacks?: AttackEntry[];
|
|
37
39
|
spells?: string[];
|
|
@@ -54,6 +56,7 @@ export declare const STANDARD_ARRAY: number[];
|
|
|
54
56
|
export declare function buildCharacter(name: string, spec: CharacterSpec, owner?: string): SheetState;
|
|
55
57
|
export declare function lastRaceResult(): RaceApplication;
|
|
56
58
|
export declare function lastBackgroundResult(): BackgroundApplication;
|
|
59
|
+
export declare function lastClassToolResult(): ToolGrantResult;
|
|
57
60
|
export declare function parseItemEntry(entry: string): InventoryItem;
|
|
58
61
|
export declare function applyClassFeatureUses(state: SheetState): void;
|
|
59
62
|
export declare function recomputeDerived(state: SheetState): void;
|
|
@@ -39,6 +39,7 @@ exports.isSuccess = isSuccess;
|
|
|
39
39
|
exports.buildCharacter = buildCharacter;
|
|
40
40
|
exports.lastRaceResult = lastRaceResult;
|
|
41
41
|
exports.lastBackgroundResult = lastBackgroundResult;
|
|
42
|
+
exports.lastClassToolResult = lastClassToolResult;
|
|
42
43
|
exports.parseItemEntry = parseItemEntry;
|
|
43
44
|
exports.applyClassFeatureUses = applyClassFeatureUses;
|
|
44
45
|
exports.recomputeDerived = recomputeDerived;
|
|
@@ -66,6 +67,7 @@ const rules = __importStar(require("./rules"));
|
|
|
66
67
|
const weapons_1 = require("./weapons");
|
|
67
68
|
const races_1 = require("./races");
|
|
68
69
|
const backgrounds_1 = require("./backgrounds");
|
|
70
|
+
const kits_1 = require("./kits");
|
|
69
71
|
const spells_1 = require("./spells");
|
|
70
72
|
const feats_1 = require("./feats");
|
|
71
73
|
const sheet_1 = require("./sheet");
|
|
@@ -106,6 +108,7 @@ function buildCharacter(name, spec, owner) {
|
|
|
106
108
|
abil[ability] = Number.isFinite(supplied) ? (0, sheet_1.clamp)(supplied, 1, 30) : exports.STANDARD_ARRAY[index];
|
|
107
109
|
});
|
|
108
110
|
const inv = (spec.equipment || []).map(parseItemEntry);
|
|
111
|
+
const expertise = splitExpertise(spec.expertise);
|
|
109
112
|
const state = {
|
|
110
113
|
v: sheet_1.SHEET_STATE_VERSION,
|
|
111
114
|
rev: 1,
|
|
@@ -118,7 +121,9 @@ function buildCharacter(name, spec, owner) {
|
|
|
118
121
|
abil,
|
|
119
122
|
saveProf: [...srd_1.CLASSES[primaryKey].saves],
|
|
120
123
|
skillProf: normalizeSkillList(spec.skills),
|
|
121
|
-
skillExp:
|
|
124
|
+
skillExp: expertise.skills,
|
|
125
|
+
toolProf: (0, kits_1.canonicalToolNames)([...(spec.tools || []), ...expertise.tools]),
|
|
126
|
+
toolExp: expertise.tools,
|
|
122
127
|
hp: { max: 1, cur: 1, temp: 0 },
|
|
123
128
|
hd: {},
|
|
124
129
|
ac: 10,
|
|
@@ -139,12 +144,14 @@ function buildCharacter(name, spec, owner) {
|
|
|
139
144
|
coin: spec.coin || { gp: 10 },
|
|
140
145
|
xp: Math.max(Number(spec.xp) || 0, 0),
|
|
141
146
|
};
|
|
147
|
+
const consumedTools = new Set();
|
|
142
148
|
const race = spec.applyRacialBonuses === false
|
|
143
|
-
? { increases: {}, outstanding: [], problems: [] }
|
|
144
|
-
: (0, races_1.applyRace)(state, spec.raceAbilityChoices);
|
|
149
|
+
? { increases: {}, tools: [], outstanding: [], problems: [] }
|
|
150
|
+
: (0, races_1.applyRace)(state, spec.raceAbilityChoices, consumedTools);
|
|
151
|
+
const classTools = (0, kits_1.grantTools)(state, srd_1.CLASSES[primaryKey].tools, srd_1.CLASSES[primaryKey].name, consumedTools);
|
|
145
152
|
recomputeDerived(state);
|
|
146
153
|
applyClassFeatureUses(state);
|
|
147
|
-
const background = (0, backgrounds_1.applyBackground)(state, spec.backgroundEquipment !== false);
|
|
154
|
+
const background = (0, backgrounds_1.applyBackground)(state, spec.backgroundEquipment !== false, consumedTools);
|
|
148
155
|
if (background.equipment.length > 0) {
|
|
149
156
|
const added = addItems(state, background.equipment);
|
|
150
157
|
if (added.length > 0)
|
|
@@ -176,9 +183,15 @@ function buildCharacter(name, spec, owner) {
|
|
|
176
183
|
}
|
|
177
184
|
lastRaceApplication = race;
|
|
178
185
|
lastBackgroundApplication = background;
|
|
186
|
+
lastClassToolApplication = classTools;
|
|
179
187
|
return state;
|
|
180
188
|
}
|
|
181
|
-
let lastRaceApplication = {
|
|
189
|
+
let lastRaceApplication = {
|
|
190
|
+
increases: {},
|
|
191
|
+
tools: [],
|
|
192
|
+
outstanding: [],
|
|
193
|
+
problems: [],
|
|
194
|
+
};
|
|
182
195
|
function lastRaceResult() {
|
|
183
196
|
return lastRaceApplication;
|
|
184
197
|
}
|
|
@@ -192,6 +205,10 @@ let lastBackgroundApplication = {
|
|
|
192
205
|
function lastBackgroundResult() {
|
|
193
206
|
return lastBackgroundApplication;
|
|
194
207
|
}
|
|
208
|
+
let lastClassToolApplication = { added: [], outstanding: [] };
|
|
209
|
+
function lastClassToolResult() {
|
|
210
|
+
return lastClassToolApplication;
|
|
211
|
+
}
|
|
195
212
|
function equipStartingArmor(state) {
|
|
196
213
|
const dex = rules.abilityModifier(state, 'dex');
|
|
197
214
|
let best;
|
|
@@ -228,6 +245,22 @@ function normalizeSkillList(skills) {
|
|
|
228
245
|
.map((s) => String(s).trim().toLowerCase())
|
|
229
246
|
.filter((s) => srd_1.SKILL_ABILITY[s] !== undefined);
|
|
230
247
|
}
|
|
248
|
+
function splitExpertise(entries) {
|
|
249
|
+
if (!Array.isArray(entries))
|
|
250
|
+
return { skills: [], tools: [] };
|
|
251
|
+
const skills = [];
|
|
252
|
+
const tools = [];
|
|
253
|
+
for (const entry of entries) {
|
|
254
|
+
const text = String(entry).trim();
|
|
255
|
+
if (srd_1.SKILL_ABILITY[text.toLowerCase()] !== undefined) {
|
|
256
|
+
skills.push(text.toLowerCase());
|
|
257
|
+
}
|
|
258
|
+
else if ((0, kits_1.resolveTool)(text).tool) {
|
|
259
|
+
tools.push((0, kits_1.canonicalToolName)(text));
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return { skills, tools };
|
|
263
|
+
}
|
|
231
264
|
function featureUseMaximum(state, max, classLevel) {
|
|
232
265
|
if ('fixed' in max)
|
|
233
266
|
return max.fixed;
|
|
@@ -263,6 +296,8 @@ function applyClassFeatureUses(state) {
|
|
|
263
296
|
}
|
|
264
297
|
}
|
|
265
298
|
function recomputeDerived(state) {
|
|
299
|
+
if (state.foe)
|
|
300
|
+
return;
|
|
266
301
|
const con = rules.abilityModifier(state, 'con');
|
|
267
302
|
let maxHp = 0;
|
|
268
303
|
let totalLevels = 0;
|
|
@@ -415,6 +450,11 @@ function applyDamage(state, raw, options, details) {
|
|
|
415
450
|
state.hp.cur = Math.max(before - remaining, 0);
|
|
416
451
|
const overflow = remaining - before;
|
|
417
452
|
if (state.hp.cur === 0) {
|
|
453
|
+
if (state.foe) {
|
|
454
|
+
state.deathSaves = { s: 0, f: 3 };
|
|
455
|
+
state.stable = false;
|
|
456
|
+
return done(state, `${state.name} takes ${remaining}${typeNote} damage and dies.`, details);
|
|
457
|
+
}
|
|
418
458
|
if (overflow >= rules.effectiveMaxHp(state)) {
|
|
419
459
|
return instantDeath(state, remaining, typeNote, details, overflow);
|
|
420
460
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const ENCOUNTER_STATE_VERSION = 1;
|
|
2
|
+
export interface Combatant {
|
|
3
|
+
name: string;
|
|
4
|
+
init: number;
|
|
5
|
+
foe?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface EncounterState {
|
|
8
|
+
v: number;
|
|
9
|
+
name: string;
|
|
10
|
+
round: number;
|
|
11
|
+
turn: number;
|
|
12
|
+
order: Combatant[];
|
|
13
|
+
}
|
|
14
|
+
export declare class EncounterError extends Error {
|
|
15
|
+
readonly violation: string;
|
|
16
|
+
constructor(violation: string, message: string);
|
|
17
|
+
}
|
|
18
|
+
export declare function newEncounter(name: string, order: Combatant[]): EncounterState;
|
|
19
|
+
export declare function parseEncounter(body: string | undefined): EncounterState | null;
|
|
20
|
+
export declare function currentCombatant(state: EncounterState): Combatant;
|
|
21
|
+
export declare function advanceTurn(state: EncounterState, skip?: (combatant: Combatant) => boolean): {
|
|
22
|
+
combatant: Combatant;
|
|
23
|
+
newRound: boolean;
|
|
24
|
+
skipped: string[];
|
|
25
|
+
};
|
|
26
|
+
export declare function removeCombatant(state: EncounterState, name: string): boolean;
|
|
27
|
+
export declare function renderEncounter(state: EncounterState, dead?: string[]): string;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EncounterError = exports.ENCOUNTER_STATE_VERSION = void 0;
|
|
4
|
+
exports.newEncounter = newEncounter;
|
|
5
|
+
exports.parseEncounter = parseEncounter;
|
|
6
|
+
exports.currentCombatant = currentCombatant;
|
|
7
|
+
exports.advanceTurn = advanceTurn;
|
|
8
|
+
exports.removeCombatant = removeCombatant;
|
|
9
|
+
exports.renderEncounter = renderEncounter;
|
|
10
|
+
const STATE_FENCE_TAG = 'briyah-state';
|
|
11
|
+
exports.ENCOUNTER_STATE_VERSION = 1;
|
|
12
|
+
class EncounterError extends Error {
|
|
13
|
+
violation;
|
|
14
|
+
constructor(violation, message) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = 'EncounterError';
|
|
17
|
+
this.violation = violation;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.EncounterError = EncounterError;
|
|
21
|
+
function newEncounter(name, order) {
|
|
22
|
+
return { v: exports.ENCOUNTER_STATE_VERSION, name, round: 1, turn: 0, order };
|
|
23
|
+
}
|
|
24
|
+
function parseEncounter(body) {
|
|
25
|
+
if (!body || !body.trim())
|
|
26
|
+
return null;
|
|
27
|
+
const lines = body.split('\n');
|
|
28
|
+
const open = lines.findIndex((line) => line.trim() === '```' + STATE_FENCE_TAG);
|
|
29
|
+
if (open === -1) {
|
|
30
|
+
throw new EncounterError('encounter_corrupt', `The "Encounter" artifact has no "${STATE_FENCE_TAG}" block, so the turn order cannot be read. Roll initiative again to start a fresh one.`);
|
|
31
|
+
}
|
|
32
|
+
const closeOffset = lines.slice(open + 1).findIndex((line) => line.trim() === '```');
|
|
33
|
+
if (closeOffset === -1) {
|
|
34
|
+
throw new EncounterError('encounter_corrupt', 'The "Encounter" artifact\'s state block is not closed.');
|
|
35
|
+
}
|
|
36
|
+
let parsed;
|
|
37
|
+
try {
|
|
38
|
+
parsed = JSON.parse(lines.slice(open + 1, open + 1 + closeOffset).join('\n'));
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
throw new EncounterError('encounter_corrupt', `The "Encounter" artifact's state block is not valid JSON (${e.message}).`);
|
|
42
|
+
}
|
|
43
|
+
const order = Array.isArray(parsed?.order)
|
|
44
|
+
? parsed.order
|
|
45
|
+
.filter((entry) => entry && entry.name)
|
|
46
|
+
.map((entry) => ({
|
|
47
|
+
name: String(entry.name),
|
|
48
|
+
init: Number(entry.init) || 0,
|
|
49
|
+
foe: entry.foe === true ? true : undefined,
|
|
50
|
+
}))
|
|
51
|
+
: [];
|
|
52
|
+
if (order.length === 0)
|
|
53
|
+
return null;
|
|
54
|
+
const round = Math.max(Number(parsed.round) || 1, 1);
|
|
55
|
+
const turn = Math.min(Math.max(Number(parsed.turn) || 0, 0), order.length - 1);
|
|
56
|
+
return { v: exports.ENCOUNTER_STATE_VERSION, name: String(parsed.name || 'Encounter'), round, turn, order };
|
|
57
|
+
}
|
|
58
|
+
function currentCombatant(state) {
|
|
59
|
+
return state.order[state.turn];
|
|
60
|
+
}
|
|
61
|
+
function advanceTurn(state, skip = () => false) {
|
|
62
|
+
const skipped = [];
|
|
63
|
+
let newRound = false;
|
|
64
|
+
for (let step = 0; step < state.order.length; step++) {
|
|
65
|
+
state.turn += 1;
|
|
66
|
+
if (state.turn >= state.order.length) {
|
|
67
|
+
state.turn = 0;
|
|
68
|
+
state.round += 1;
|
|
69
|
+
newRound = true;
|
|
70
|
+
}
|
|
71
|
+
const candidate = state.order[state.turn];
|
|
72
|
+
if (!skip(candidate))
|
|
73
|
+
return { combatant: candidate, newRound, skipped };
|
|
74
|
+
skipped.push(candidate.name);
|
|
75
|
+
}
|
|
76
|
+
return { combatant: state.order[state.turn], newRound, skipped };
|
|
77
|
+
}
|
|
78
|
+
function removeCombatant(state, name) {
|
|
79
|
+
const index = state.order.findIndex((entry) => entry.name.toLowerCase() === name.trim().toLowerCase());
|
|
80
|
+
if (index === -1)
|
|
81
|
+
return false;
|
|
82
|
+
state.order.splice(index, 1);
|
|
83
|
+
if (state.order.length === 0) {
|
|
84
|
+
state.turn = 0;
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
if (index < state.turn)
|
|
88
|
+
state.turn -= 1;
|
|
89
|
+
if (state.turn >= state.order.length)
|
|
90
|
+
state.turn = 0;
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
function renderEncounter(state, dead = []) {
|
|
94
|
+
const down = new Set(dead.map((name) => name.toLowerCase()));
|
|
95
|
+
const lines = [`# ${state.name}`, '', `**Round ${state.round}**`, ''];
|
|
96
|
+
state.order.forEach((combatant, index) => {
|
|
97
|
+
const mark = index === state.turn ? ' ←' : index < state.turn ? ' ✓' : '';
|
|
98
|
+
const status = down.has(combatant.name.toLowerCase()) ? ' — down' : '';
|
|
99
|
+
lines.push(`${index + 1}. ${combatant.name} — ${combatant.init}${mark}${status}`);
|
|
100
|
+
});
|
|
101
|
+
lines.push('', '```' + STATE_FENCE_TAG, JSON.stringify(state), '```', '');
|
|
102
|
+
return lines.join('\n');
|
|
103
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MonsterBlock } from '../data/monsters';
|
|
2
|
+
import { SheetState } from './sheet';
|
|
3
|
+
import { Rng } from './dice';
|
|
4
|
+
export declare const FOE_LABELS = "ABCDEFGHIJKL";
|
|
5
|
+
export declare function foeNames(blockName: string, count: number): string[];
|
|
6
|
+
export declare function rollFoeHitPoints(block: MonsterBlock, rng?: Rng): number;
|
|
7
|
+
export declare function buildFoe(block: MonsterBlock, name: string, hp: number, owner?: string): SheetState;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FOE_LABELS = void 0;
|
|
4
|
+
exports.foeNames = foeNames;
|
|
5
|
+
exports.rollFoeHitPoints = rollFoeHitPoints;
|
|
6
|
+
exports.buildFoe = buildFoe;
|
|
7
|
+
const srd_1 = require("../data/srd");
|
|
8
|
+
const sheet_1 = require("./sheet");
|
|
9
|
+
const dice_1 = require("./dice");
|
|
10
|
+
exports.FOE_LABELS = 'ABCDEFGHIJKL';
|
|
11
|
+
function foeNames(blockName, count) {
|
|
12
|
+
if (count <= 1)
|
|
13
|
+
return [blockName];
|
|
14
|
+
return Array.from({ length: count }, (_, i) => `${blockName} ${exports.FOE_LABELS[i]}`);
|
|
15
|
+
}
|
|
16
|
+
function rollFoeHitPoints(block, rng = dice_1.defaultRng) {
|
|
17
|
+
if (!block.hpDice)
|
|
18
|
+
return Math.max(block.hp, 1);
|
|
19
|
+
return Math.max((0, dice_1.rollOne)(block.hpDice, rng).total, 1);
|
|
20
|
+
}
|
|
21
|
+
function buildFoe(block, name, hp, owner) {
|
|
22
|
+
const abil = {};
|
|
23
|
+
for (const ability of srd_1.ABILITIES) {
|
|
24
|
+
const score = Number(block.abil?.[ability]);
|
|
25
|
+
abil[ability] = Number.isFinite(score) ? score : 10;
|
|
26
|
+
}
|
|
27
|
+
const attacks = (block.attacks || []).map((attack) => {
|
|
28
|
+
const entry = {
|
|
29
|
+
n: String(attack.n),
|
|
30
|
+
atk: Number(attack.atk) || 0,
|
|
31
|
+
dmg: String(attack.dmg),
|
|
32
|
+
};
|
|
33
|
+
if (attack.type)
|
|
34
|
+
entry.type = attack.type;
|
|
35
|
+
if (attack.reach)
|
|
36
|
+
entry.range = String(attack.reach);
|
|
37
|
+
return entry;
|
|
38
|
+
});
|
|
39
|
+
const saveBonus = {};
|
|
40
|
+
for (const ability of srd_1.ABILITIES) {
|
|
41
|
+
const value = Number(block.saves?.[ability]);
|
|
42
|
+
if (Number.isFinite(value))
|
|
43
|
+
saveBonus[ability] = value;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
v: sheet_1.SHEET_STATE_VERSION,
|
|
47
|
+
rev: 1,
|
|
48
|
+
name,
|
|
49
|
+
owner,
|
|
50
|
+
foe: true,
|
|
51
|
+
race: [block.size, block.kind].filter(Boolean).join(' ') || undefined,
|
|
52
|
+
class: [],
|
|
53
|
+
abil,
|
|
54
|
+
saveProf: [],
|
|
55
|
+
skillProf: Object.keys(block.skills || {}).map((skill) => skill.toLowerCase()),
|
|
56
|
+
skillExp: [],
|
|
57
|
+
toolProf: [],
|
|
58
|
+
toolExp: [],
|
|
59
|
+
saveBonus: Object.keys(saveBonus).length > 0 ? saveBonus : undefined,
|
|
60
|
+
hp: { max: Math.max(hp, 1), cur: Math.max(hp, 1), temp: 0 },
|
|
61
|
+
hd: {},
|
|
62
|
+
ac: Number(block.ac) || 10,
|
|
63
|
+
speed: parseWalkingSpeed(block.speed),
|
|
64
|
+
initBonus: Math.floor((abil.dex - 10) / 2),
|
|
65
|
+
slots: {},
|
|
66
|
+
uses: {},
|
|
67
|
+
attacks,
|
|
68
|
+
cond: [],
|
|
69
|
+
exh: 0,
|
|
70
|
+
deathSaves: { s: 0, f: 0 },
|
|
71
|
+
stable: false,
|
|
72
|
+
resist: (block.resist || []).map((word) => String(word).toLowerCase()),
|
|
73
|
+
immune: (block.immune || []).map((word) => String(word).toLowerCase()),
|
|
74
|
+
vuln: (block.vuln || []).map((word) => String(word).toLowerCase()),
|
|
75
|
+
inv: [],
|
|
76
|
+
coin: {},
|
|
77
|
+
xp: 0,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function parseWalkingSpeed(speed) {
|
|
81
|
+
const match = /^\s*(\d+)\s*ft/i.exec(String(speed || ''));
|
|
82
|
+
return match ? Number(match[1]) : 30;
|
|
83
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ToolCategory, ToolGrant, ToolKit } from '../data/kits';
|
|
2
|
+
import type { SheetState } from './sheet';
|
|
3
|
+
export interface ToolLookup {
|
|
4
|
+
tool?: ToolKit;
|
|
5
|
+
ambiguous?: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function resolveTool(name: string): ToolLookup;
|
|
8
|
+
export declare function canonicalToolName(name: string): string;
|
|
9
|
+
export declare function toolNames(): string[];
|
|
10
|
+
export declare function toolsInCategory(category: ToolCategory): string[];
|
|
11
|
+
export declare function canonicalToolNames(names: string[] | undefined): string[];
|
|
12
|
+
export declare function hasToolProficiency(state: SheetState, name: string): boolean;
|
|
13
|
+
export declare function hasToolExpertise(state: SheetState, name: string): boolean;
|
|
14
|
+
export declare function addToolProficiency(state: SheetState, name: string): boolean;
|
|
15
|
+
export interface ToolGrantResult {
|
|
16
|
+
added: string[];
|
|
17
|
+
outstanding: string[];
|
|
18
|
+
}
|
|
19
|
+
export declare function grantTools(state: SheetState, grant: ToolGrant | undefined, source: string, consumed?: Set<string>): ToolGrantResult;
|