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,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveTool = resolveTool;
|
|
4
|
+
exports.canonicalToolName = canonicalToolName;
|
|
5
|
+
exports.toolNames = toolNames;
|
|
6
|
+
exports.toolsInCategory = toolsInCategory;
|
|
7
|
+
exports.canonicalToolNames = canonicalToolNames;
|
|
8
|
+
exports.hasToolProficiency = hasToolProficiency;
|
|
9
|
+
exports.hasToolExpertise = hasToolExpertise;
|
|
10
|
+
exports.addToolProficiency = addToolProficiency;
|
|
11
|
+
exports.grantTools = grantTools;
|
|
12
|
+
const kits_1 = require("../data/kits");
|
|
13
|
+
const coerce_1 = require("./coerce");
|
|
14
|
+
function resolveTool(name) {
|
|
15
|
+
const key = (0, coerce_1.nameKey)(name || '');
|
|
16
|
+
if (!key)
|
|
17
|
+
return {};
|
|
18
|
+
const exact = kits_1.TOOL_KITS[key];
|
|
19
|
+
if (exact)
|
|
20
|
+
return { tool: exact };
|
|
21
|
+
const matches = (0, coerce_1.matchNames)(name, Object.keys(kits_1.TOOL_KITS));
|
|
22
|
+
if (matches.length === 1)
|
|
23
|
+
return { tool: kits_1.TOOL_KITS[matches[0]] };
|
|
24
|
+
if (matches.length > 1) {
|
|
25
|
+
return { ambiguous: matches.map((k) => kits_1.TOOL_KITS[k].name).sort() };
|
|
26
|
+
}
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
function canonicalToolName(name) {
|
|
30
|
+
const written = String(name || '').trim();
|
|
31
|
+
const { tool } = resolveTool(written);
|
|
32
|
+
return tool ? tool.name : written;
|
|
33
|
+
}
|
|
34
|
+
function toolNames() {
|
|
35
|
+
return Object.values(kits_1.TOOL_KITS).map((tool) => tool.name).sort();
|
|
36
|
+
}
|
|
37
|
+
function toolsInCategory(category) {
|
|
38
|
+
return Object.values(kits_1.TOOL_KITS)
|
|
39
|
+
.filter((tool) => tool.category === category)
|
|
40
|
+
.map((tool) => tool.name)
|
|
41
|
+
.sort();
|
|
42
|
+
}
|
|
43
|
+
function canonicalToolNames(names) {
|
|
44
|
+
if (!Array.isArray(names))
|
|
45
|
+
return [];
|
|
46
|
+
const seen = new Set();
|
|
47
|
+
const out = [];
|
|
48
|
+
for (const entry of names) {
|
|
49
|
+
const name = canonicalToolName(String(entry));
|
|
50
|
+
if (!name)
|
|
51
|
+
continue;
|
|
52
|
+
const key = (0, coerce_1.nameKey)(name);
|
|
53
|
+
if (seen.has(key))
|
|
54
|
+
continue;
|
|
55
|
+
seen.add(key);
|
|
56
|
+
out.push(name);
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
function hasToolProficiency(state, name) {
|
|
61
|
+
const key = (0, coerce_1.nameKey)(canonicalToolName(name));
|
|
62
|
+
if (!key)
|
|
63
|
+
return false;
|
|
64
|
+
return (state.toolProf || []).some((held) => (0, coerce_1.nameKey)(held) === key);
|
|
65
|
+
}
|
|
66
|
+
function hasToolExpertise(state, name) {
|
|
67
|
+
const key = (0, coerce_1.nameKey)(canonicalToolName(name));
|
|
68
|
+
if (!key)
|
|
69
|
+
return false;
|
|
70
|
+
return (state.toolExp || []).some((held) => (0, coerce_1.nameKey)(held) === key);
|
|
71
|
+
}
|
|
72
|
+
function addToolProficiency(state, name) {
|
|
73
|
+
const canonical = canonicalToolName(name);
|
|
74
|
+
if (!canonical || hasToolProficiency(state, canonical))
|
|
75
|
+
return false;
|
|
76
|
+
state.toolProf = [...(state.toolProf || []), canonical];
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
function satisfiesChoice(held, choice) {
|
|
80
|
+
const key = (0, coerce_1.nameKey)(held);
|
|
81
|
+
if (choice.options) {
|
|
82
|
+
return choice.options.some((option) => (0, coerce_1.nameKey)(option) === key);
|
|
83
|
+
}
|
|
84
|
+
const { tool } = resolveTool(held);
|
|
85
|
+
return Boolean(tool && choice.from?.includes(tool.category));
|
|
86
|
+
}
|
|
87
|
+
function describeChoice(choice, owed) {
|
|
88
|
+
const what = choice.options
|
|
89
|
+
? choice.options.join(', ')
|
|
90
|
+
: (choice.from || [])
|
|
91
|
+
.map((category) => `any ${kits_1.TOOL_CATEGORY_LABEL[category]}`)
|
|
92
|
+
.join(' or ');
|
|
93
|
+
return `${owed} tool proficienc${owed === 1 ? 'y' : 'ies'} of the player's choice: ${what}`;
|
|
94
|
+
}
|
|
95
|
+
function grantTools(state, grant, source, consumed = new Set()) {
|
|
96
|
+
const result = { added: [], outstanding: [] };
|
|
97
|
+
if (!grant)
|
|
98
|
+
return result;
|
|
99
|
+
for (const name of grant.fixed || []) {
|
|
100
|
+
const canonical = canonicalToolName(name);
|
|
101
|
+
if (hasToolProficiency(state, canonical)) {
|
|
102
|
+
result.outstanding.push(`${canonical} was already proficient, so ${source} grants a different tool proficiency of the player's choice instead`);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
addToolProficiency(state, canonical);
|
|
106
|
+
result.added.push(canonical);
|
|
107
|
+
consumed.add((0, coerce_1.nameKey)(canonical));
|
|
108
|
+
}
|
|
109
|
+
for (const choice of grant.choices || []) {
|
|
110
|
+
let owed = choice.count;
|
|
111
|
+
for (const held of state.toolProf || []) {
|
|
112
|
+
if (owed === 0)
|
|
113
|
+
break;
|
|
114
|
+
const key = (0, coerce_1.nameKey)(held);
|
|
115
|
+
if (consumed.has(key) || !satisfiesChoice(held, choice))
|
|
116
|
+
continue;
|
|
117
|
+
consumed.add(key);
|
|
118
|
+
owed -= 1;
|
|
119
|
+
}
|
|
120
|
+
if (owed > 0)
|
|
121
|
+
result.outstanding.push(describeChoice(choice, owed));
|
|
122
|
+
}
|
|
123
|
+
if (result.outstanding.length > 0) {
|
|
124
|
+
const unknown = (state.toolProf || []).filter((held) => !resolveTool(held).tool);
|
|
125
|
+
if (unknown.length > 0) {
|
|
126
|
+
result.outstanding.push(`${unknown.join(', ')} ${unknown.length === 1 ? 'is' : 'are'} not in the SRD tool table, so ${unknown.length === 1 ? 'it was' : 'they were'} not counted against the choices above — ignore this if ${unknown.length === 1 ? 'it is' : 'they are'} what the player picked`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
@@ -15,10 +15,11 @@ export interface RaceApplication {
|
|
|
15
15
|
race?: string;
|
|
16
16
|
subrace?: string;
|
|
17
17
|
increases: Partial<Record<AbilityKey, number>>;
|
|
18
|
+
tools: string[];
|
|
18
19
|
outstanding: string[];
|
|
19
20
|
problems: string[];
|
|
20
21
|
}
|
|
21
|
-
export declare function applyRace(state: SheetState, chosen?: Partial<Record<AbilityKey, number
|
|
22
|
+
export declare function applyRace(state: SheetState, chosen?: Partial<Record<AbilityKey, number>>, consumedTools?: Set<string>): RaceApplication;
|
|
22
23
|
export declare function racialWeaponProficiencies(state: SheetState): string[];
|
|
23
24
|
export declare function racialHpPerLevel(state: SheetState): number;
|
|
24
25
|
export declare function ignoresHeavyArmorSpeed(state: SheetState): boolean;
|
|
@@ -13,6 +13,7 @@ exports.describeRace = describeRace;
|
|
|
13
13
|
const srd_1 = require("../data/srd");
|
|
14
14
|
const races_1 = require("../data/races");
|
|
15
15
|
const coerce_1 = require("./coerce");
|
|
16
|
+
const kits_1 = require("./kits");
|
|
16
17
|
let raceIndexCache = null;
|
|
17
18
|
function raceIndex() {
|
|
18
19
|
if (!raceIndexCache) {
|
|
@@ -74,9 +75,9 @@ function racialAbilityIncreases(lookup) {
|
|
|
74
75
|
}
|
|
75
76
|
return out;
|
|
76
77
|
}
|
|
77
|
-
function applyRace(state, chosen = {}) {
|
|
78
|
+
function applyRace(state, chosen = {}, consumedTools = new Set()) {
|
|
78
79
|
const lookup = resolveRace(state.race || '');
|
|
79
|
-
const result = { increases: {}, outstanding: [], problems: [] };
|
|
80
|
+
const result = { increases: {}, tools: [], outstanding: [], problems: [] };
|
|
80
81
|
if (!lookup.race) {
|
|
81
82
|
if (state.race) {
|
|
82
83
|
result.problems.push(`"${state.race}" is not a race in the SRD, so no racial bonuses were applied. Known races: ${raceNames().join(', ')}.`);
|
|
@@ -133,6 +134,16 @@ function applyRace(state, chosen = {}) {
|
|
|
133
134
|
if (race.skillChoices) {
|
|
134
135
|
result.outstanding.push(`${race.skillChoices} skill proficiencies of the player's choice, from any skill`);
|
|
135
136
|
}
|
|
137
|
+
for (const [grant, from] of [
|
|
138
|
+
[race.tools, race.name],
|
|
139
|
+
[subrace?.tools, subrace?.name],
|
|
140
|
+
]) {
|
|
141
|
+
if (!grant)
|
|
142
|
+
continue;
|
|
143
|
+
const granted = (0, kits_1.grantTools)(state, grant, `the ${from}`, consumedTools);
|
|
144
|
+
result.tools.push(...granted.added);
|
|
145
|
+
result.outstanding.push(...granted.outstanding);
|
|
146
|
+
}
|
|
136
147
|
for (const type of race.resist || []) {
|
|
137
148
|
if (!state.resist.includes(type))
|
|
138
149
|
state.resist.push(type);
|
|
@@ -5,6 +5,12 @@ export declare function proficiencyBonus(state: SheetState): number;
|
|
|
5
5
|
export declare function abilityModifier(state: SheetState, ability: AbilityKey): number;
|
|
6
6
|
export declare function saveModifier(state: SheetState, ability: AbilityKey): number;
|
|
7
7
|
export declare function skillModifier(state: SheetState, skill: string): number;
|
|
8
|
+
export interface ToolCheckModifier {
|
|
9
|
+
modifier: number;
|
|
10
|
+
proficient: boolean;
|
|
11
|
+
expertise: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function toolCheckModifier(state: SheetState, tool: string, ability: AbilityKey): ToolCheckModifier;
|
|
8
14
|
export declare function passivePerception(state: SheetState): number;
|
|
9
15
|
export declare function spellcastingClass(state: SheetState): ClassEntry | undefined;
|
|
10
16
|
export declare function spellSaveDc(state: SheetState): number | null;
|
|
@@ -5,6 +5,7 @@ exports.proficiencyBonus = proficiencyBonus;
|
|
|
5
5
|
exports.abilityModifier = abilityModifier;
|
|
6
6
|
exports.saveModifier = saveModifier;
|
|
7
7
|
exports.skillModifier = skillModifier;
|
|
8
|
+
exports.toolCheckModifier = toolCheckModifier;
|
|
8
9
|
exports.passivePerception = passivePerception;
|
|
9
10
|
exports.spellcastingClass = spellcastingClass;
|
|
10
11
|
exports.spellSaveDc = spellSaveDc;
|
|
@@ -34,6 +35,7 @@ const items_1 = require("./items");
|
|
|
34
35
|
const races_1 = require("./races");
|
|
35
36
|
const encumbrance_1 = require("./encumbrance");
|
|
36
37
|
const coerce_1 = require("./coerce");
|
|
38
|
+
const kits_1 = require("./kits");
|
|
37
39
|
function totalLevel(state) {
|
|
38
40
|
const level = state.class.reduce((sum, entry) => sum + (Number(entry.lvl) || 0), 0);
|
|
39
41
|
return Math.max(level, 1);
|
|
@@ -46,6 +48,9 @@ function abilityModifier(state, ability) {
|
|
|
46
48
|
return Math.floor(((Number(state.abil[ability]) || 10) - 10) / 2);
|
|
47
49
|
}
|
|
48
50
|
function saveModifier(state, ability) {
|
|
51
|
+
const printed = state.saveBonus?.[ability];
|
|
52
|
+
if (typeof printed === 'number' && Number.isFinite(printed))
|
|
53
|
+
return printed;
|
|
49
54
|
const base = abilityModifier(state, ability);
|
|
50
55
|
return state.saveProf.includes(ability) ? base + proficiencyBonus(state) : base;
|
|
51
56
|
}
|
|
@@ -62,6 +67,17 @@ function skillModifier(state, skill) {
|
|
|
62
67
|
return base + prof;
|
|
63
68
|
return base;
|
|
64
69
|
}
|
|
70
|
+
function toolCheckModifier(state, tool, ability) {
|
|
71
|
+
const base = abilityModifier(state, ability);
|
|
72
|
+
const prof = proficiencyBonus(state);
|
|
73
|
+
if ((0, kits_1.hasToolExpertise)(state, tool)) {
|
|
74
|
+
return { modifier: base + prof * 2, proficient: true, expertise: true };
|
|
75
|
+
}
|
|
76
|
+
if ((0, kits_1.hasToolProficiency)(state, tool)) {
|
|
77
|
+
return { modifier: base + prof, proficient: true, expertise: false };
|
|
78
|
+
}
|
|
79
|
+
return { modifier: base, proficient: false, expertise: false };
|
|
80
|
+
}
|
|
65
81
|
function passivePerception(state) {
|
|
66
82
|
return 10 + skillModifier(state, 'perception');
|
|
67
83
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AbilityKey } from '../data/srd';
|
|
2
2
|
export declare const SHEET_STATE_VERSION = 1;
|
|
3
3
|
export declare const SHEET_NAME_PREFIX = "Sheet: ";
|
|
4
|
+
export declare const FOE_NAME_PREFIX = "Foe: ";
|
|
4
5
|
export declare const PARTY_STATUS_ARTIFACT = "Party Status";
|
|
5
6
|
export declare const ENCOUNTER_ARTIFACT = "Encounter";
|
|
6
7
|
export interface ClassEntry {
|
|
@@ -49,6 +50,8 @@ export interface SheetState {
|
|
|
49
50
|
saveProf: AbilityKey[];
|
|
50
51
|
skillProf: string[];
|
|
51
52
|
skillExp: string[];
|
|
53
|
+
toolProf: string[];
|
|
54
|
+
toolExp: string[];
|
|
52
55
|
hp: {
|
|
53
56
|
max: number;
|
|
54
57
|
cur: number;
|
|
@@ -80,6 +83,8 @@ export interface SheetState {
|
|
|
80
83
|
inv: InventoryItem[];
|
|
81
84
|
coin: Record<string, number>;
|
|
82
85
|
xp: number;
|
|
86
|
+
foe?: boolean;
|
|
87
|
+
saveBonus?: Partial<Record<AbilityKey, number>>;
|
|
83
88
|
[key: string]: any;
|
|
84
89
|
}
|
|
85
90
|
export declare class SheetError extends Error {
|
|
@@ -89,8 +94,13 @@ export declare class SheetError extends Error {
|
|
|
89
94
|
export declare function sheetArtifactName(characterName: string): string;
|
|
90
95
|
export declare function characterNameFromArtifact(artifactName: string): string;
|
|
91
96
|
export declare function isSheetArtifact(artifactName: string): boolean;
|
|
97
|
+
export declare function foeArtifactName(foeName: string): string;
|
|
98
|
+
export declare function foeNameFromArtifact(artifactName: string): string;
|
|
99
|
+
export declare function isFoeArtifact(artifactName: string): boolean;
|
|
100
|
+
export declare function combatantArtifactName(state: SheetState): string;
|
|
92
101
|
export declare function parseSheet(body: string): SheetState;
|
|
93
102
|
export declare function extractNotes(body: string): string;
|
|
103
|
+
export declare function sheetFieldNames(): string[];
|
|
94
104
|
export declare function collectWarnings(raw: any, normalized: SheetState): string[];
|
|
95
105
|
export declare function clamp(value: number, min: number, max: number): number;
|
|
96
106
|
export declare function renderSheet(state: SheetState, notes: string): string;
|
|
@@ -33,12 +33,17 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.SheetError = exports.ENCOUNTER_ARTIFACT = exports.PARTY_STATUS_ARTIFACT = exports.SHEET_NAME_PREFIX = exports.SHEET_STATE_VERSION = void 0;
|
|
36
|
+
exports.SheetError = exports.ENCOUNTER_ARTIFACT = exports.PARTY_STATUS_ARTIFACT = exports.FOE_NAME_PREFIX = exports.SHEET_NAME_PREFIX = exports.SHEET_STATE_VERSION = void 0;
|
|
37
37
|
exports.sheetArtifactName = sheetArtifactName;
|
|
38
38
|
exports.characterNameFromArtifact = characterNameFromArtifact;
|
|
39
39
|
exports.isSheetArtifact = isSheetArtifact;
|
|
40
|
+
exports.foeArtifactName = foeArtifactName;
|
|
41
|
+
exports.foeNameFromArtifact = foeNameFromArtifact;
|
|
42
|
+
exports.isFoeArtifact = isFoeArtifact;
|
|
43
|
+
exports.combatantArtifactName = combatantArtifactName;
|
|
40
44
|
exports.parseSheet = parseSheet;
|
|
41
45
|
exports.extractNotes = extractNotes;
|
|
46
|
+
exports.sheetFieldNames = sheetFieldNames;
|
|
42
47
|
exports.collectWarnings = collectWarnings;
|
|
43
48
|
exports.clamp = clamp;
|
|
44
49
|
exports.renderSheet = renderSheet;
|
|
@@ -48,9 +53,11 @@ const srd_1 = require("../data/srd");
|
|
|
48
53
|
const rules = __importStar(require("./rules"));
|
|
49
54
|
const races_1 = require("./races");
|
|
50
55
|
const backgrounds_1 = require("./backgrounds");
|
|
56
|
+
const kits_1 = require("./kits");
|
|
51
57
|
const encumbrance_1 = require("./encumbrance");
|
|
52
58
|
exports.SHEET_STATE_VERSION = 1;
|
|
53
59
|
exports.SHEET_NAME_PREFIX = 'Sheet: ';
|
|
60
|
+
exports.FOE_NAME_PREFIX = 'Foe: ';
|
|
54
61
|
exports.PARTY_STATUS_ARTIFACT = 'Party Status';
|
|
55
62
|
exports.ENCOUNTER_ARTIFACT = 'Encounter';
|
|
56
63
|
const STATE_FENCE_TAG = 'briyah-state';
|
|
@@ -77,6 +84,20 @@ function characterNameFromArtifact(artifactName) {
|
|
|
77
84
|
function isSheetArtifact(artifactName) {
|
|
78
85
|
return artifactName.startsWith(exports.SHEET_NAME_PREFIX);
|
|
79
86
|
}
|
|
87
|
+
function foeArtifactName(foeName) {
|
|
88
|
+
return `${exports.FOE_NAME_PREFIX}${foeName}`;
|
|
89
|
+
}
|
|
90
|
+
function foeNameFromArtifact(artifactName) {
|
|
91
|
+
return artifactName.startsWith(exports.FOE_NAME_PREFIX)
|
|
92
|
+
? artifactName.slice(exports.FOE_NAME_PREFIX.length)
|
|
93
|
+
: artifactName;
|
|
94
|
+
}
|
|
95
|
+
function isFoeArtifact(artifactName) {
|
|
96
|
+
return artifactName.startsWith(exports.FOE_NAME_PREFIX);
|
|
97
|
+
}
|
|
98
|
+
function combatantArtifactName(state) {
|
|
99
|
+
return state.foe ? foeArtifactName(state.name) : sheetArtifactName(state.name);
|
|
100
|
+
}
|
|
80
101
|
function parseSheet(body) {
|
|
81
102
|
const block = extractStateBlock(body);
|
|
82
103
|
if (block === null) {
|
|
@@ -147,6 +168,8 @@ function normalizeState(raw) {
|
|
|
147
168
|
saveProf: toStringArray(raw.saveProf),
|
|
148
169
|
skillProf: toStringArray(raw.skillProf).map((s) => s.toLowerCase()),
|
|
149
170
|
skillExp: toStringArray(raw.skillExp).map((s) => s.toLowerCase()),
|
|
171
|
+
toolProf: toStringArray(raw.toolProf),
|
|
172
|
+
toolExp: toStringArray(raw.toolExp),
|
|
150
173
|
hp: {
|
|
151
174
|
max: Math.max(Number(raw.hp?.max) || 1, 1),
|
|
152
175
|
cur: Number.isFinite(Number(raw.hp?.cur)) ? Number(raw.hp.cur) : Number(raw.hp?.max) || 1,
|
|
@@ -175,10 +198,26 @@ function normalizeState(raw) {
|
|
|
175
198
|
inv: normalizeInventory(raw.inv),
|
|
176
199
|
coin: normalizeCoin(raw.coin),
|
|
177
200
|
xp: Math.max(Number(raw.xp) || 0, 0),
|
|
201
|
+
foe: raw.foe === true ? true : undefined,
|
|
202
|
+
saveBonus: normalizeSaveBonus(raw.saveBonus),
|
|
178
203
|
};
|
|
179
204
|
state.hp.cur = clamp(state.hp.cur, 0, state.hp.max);
|
|
180
205
|
return state;
|
|
181
206
|
}
|
|
207
|
+
function normalizeSaveBonus(raw) {
|
|
208
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw))
|
|
209
|
+
return undefined;
|
|
210
|
+
const out = {};
|
|
211
|
+
for (const ability of srd_1.ABILITIES) {
|
|
212
|
+
const value = Number(raw[ability]);
|
|
213
|
+
if (Number.isFinite(value))
|
|
214
|
+
out[ability] = value;
|
|
215
|
+
}
|
|
216
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
217
|
+
}
|
|
218
|
+
function sheetFieldNames() {
|
|
219
|
+
return Object.keys(normalizeState({})).sort();
|
|
220
|
+
}
|
|
182
221
|
function collectWarnings(raw, normalized) {
|
|
183
222
|
const warnings = [];
|
|
184
223
|
const rawCur = Number(raw?.hp?.cur);
|
|
@@ -313,7 +352,42 @@ function trimNotes(notes) {
|
|
|
313
352
|
function signed(value) {
|
|
314
353
|
return value >= 0 ? `+${value}` : `${value}`;
|
|
315
354
|
}
|
|
355
|
+
function renderFoeSummary(state) {
|
|
356
|
+
const lines = [`# ${state.name}`];
|
|
357
|
+
const dead = state.deathSaves.f >= 3 || state.hp.cur <= 0;
|
|
358
|
+
lines.push(`**HP ${state.hp.cur}/${state.hp.max}**${state.hp.temp > 0 ? ` +${state.hp.temp} temp` : ''}` +
|
|
359
|
+
` | **AC ${state.ac}** | **Speed ${state.speed} ft**${dead ? ' | **DEAD**' : ''}`);
|
|
360
|
+
lines.push(srd_1.ABILITIES.map((ability) => `${ability.toUpperCase()} ${state.abil[ability]} (${signed(rules.abilityModifier(state, ability))})`).join(' · '));
|
|
361
|
+
const saves = srd_1.ABILITIES.filter((ability) => state.saveBonus?.[ability] !== undefined);
|
|
362
|
+
if (saves.length > 0) {
|
|
363
|
+
lines.push('**Saves:** ' +
|
|
364
|
+
saves.map((a) => `${a.toUpperCase()} ${signed(state.saveBonus[a])}`).join(' · '));
|
|
365
|
+
}
|
|
366
|
+
if (state.attacks.length > 0) {
|
|
367
|
+
lines.push('**Attacks:** ' +
|
|
368
|
+
state.attacks
|
|
369
|
+
.map((attack) => {
|
|
370
|
+
const type = attack.type ? ` ${attack.type}` : '';
|
|
371
|
+
const range = attack.range ? `, ${attack.range}` : '';
|
|
372
|
+
return `${attack.n} ${signed(attack.atk)} (${attack.dmg}${type}${range})`;
|
|
373
|
+
})
|
|
374
|
+
.join(' · '));
|
|
375
|
+
}
|
|
376
|
+
if (state.resist.length > 0)
|
|
377
|
+
lines.push(`**Resistant to:** ${state.resist.join(', ')}`);
|
|
378
|
+
if (state.immune.length > 0)
|
|
379
|
+
lines.push(`**Immune to:** ${state.immune.join(', ')}`);
|
|
380
|
+
if (state.vuln.length > 0)
|
|
381
|
+
lines.push(`**Vulnerable to:** ${state.vuln.join(', ')}`);
|
|
382
|
+
if (state.cond.length > 0) {
|
|
383
|
+
lines.push('**Conditions:** ' +
|
|
384
|
+
state.cond.map((c) => (c.dur ? `${c.n} (${c.dur})` : c.n)).join(', '));
|
|
385
|
+
}
|
|
386
|
+
return lines.join('\n');
|
|
387
|
+
}
|
|
316
388
|
function renderSummary(state) {
|
|
389
|
+
if (state.foe)
|
|
390
|
+
return renderFoeSummary(state);
|
|
317
391
|
const level = rules.totalLevel(state);
|
|
318
392
|
const prof = rules.proficiencyBonus(state);
|
|
319
393
|
const classLine = state.class
|
|
@@ -354,6 +428,13 @@ function renderSummary(state) {
|
|
|
354
428
|
.map((skill) => `${titleCase(skill)} ${signed(rules.skillModifier(state, skill))}`)
|
|
355
429
|
.join(' · '));
|
|
356
430
|
}
|
|
431
|
+
const tools = [...new Set([...(state.toolProf || []), ...(state.toolExp || [])])];
|
|
432
|
+
if (tools.length > 0) {
|
|
433
|
+
lines.push('**Tools (proficient):** ' +
|
|
434
|
+
tools
|
|
435
|
+
.map((tool) => `${tool}${(0, kits_1.hasToolExpertise)(state, tool) ? '*' : ''}`)
|
|
436
|
+
.join(' · '));
|
|
437
|
+
}
|
|
357
438
|
if (state.attacks.length > 0) {
|
|
358
439
|
lines.push('**Attacks:** ' +
|
|
359
440
|
state.attacks
|
|
@@ -7,6 +7,7 @@ const dice_tools_1 = require("./tools/dice.tools");
|
|
|
7
7
|
const state_tools_1 = require("./tools/state.tools");
|
|
8
8
|
const sheet_tools_1 = require("./tools/sheet.tools");
|
|
9
9
|
const world_tools_1 = require("./tools/world.tools");
|
|
10
|
+
const encounter_tool_1 = require("./tools/encounter.tool");
|
|
10
11
|
const monster_tool_1 = require("./tools/monster.tool");
|
|
11
12
|
const item_tool_1 = require("./tools/item.tool");
|
|
12
13
|
const spell_tool_1 = require("./tools/spell.tool");
|
|
@@ -14,6 +15,7 @@ function dnd5eTools() {
|
|
|
14
15
|
return [
|
|
15
16
|
dice_tools_1.rollDiceTool,
|
|
16
17
|
dice_tools_1.rollInitiativeTool,
|
|
18
|
+
encounter_tool_1.encounterTool,
|
|
17
19
|
check_tool_1.checkTool,
|
|
18
20
|
state_tools_1.applyHpTool,
|
|
19
21
|
state_tools_1.restTool,
|
|
@@ -39,12 +39,14 @@ const dice_1 = require("../engine/dice");
|
|
|
39
39
|
const rules = __importStar(require("../engine/rules"));
|
|
40
40
|
const sheet_1 = require("../engine/sheet");
|
|
41
41
|
const character_1 = require("../engine/character");
|
|
42
|
+
const kits_1 = require("../engine/kits");
|
|
42
43
|
const shared_1 = require("./shared");
|
|
43
44
|
const BATCH_EXAMPLE = '[{"character":"Thalia","kind":"save","subject":"dex","dc":15},{"character":"Dorn","kind":"save","subject":"dex","dc":15}]';
|
|
44
45
|
const MAX_BATCH = 12;
|
|
46
|
+
const DEFAULT_TOOL_ABILITY = 'dex';
|
|
45
47
|
exports.checkTool = {
|
|
46
48
|
name: 'check',
|
|
47
|
-
description: 'Make one or more d20 rolls for a character using the modifiers on their sheet. "kind" is skill, ability, save, attack, initiative, or death (a death saving throw). "subject" names what is rolled: a skill (stealth), an ability (dex), or an attack listed on the sheet (Longbow). Give "dc" if you know the target number; omit it to get the raw total and judge for yourself. "mode" is normal, advantage or disadvantage — the character\'s own conditions and exhaustion are applied on top of what you ask for. "bonus" is any situational modifier. For an attack it also rolls damage, doubling the dice on a critical hit. Death saving throws are recorded on the sheet, and three successes or failures are reported. To make several rolls at once — a group saving throw, two attacks in a round — set "batch" to a JSON array of objects using the same keys and leave the other parameters out: ' +
|
|
49
|
+
description: 'Make one or more d20 rolls for a character using the modifiers on their sheet. "kind" is skill, ability, save, attack, initiative, tool, or death (a death saving throw). "subject" names what is rolled: a skill (stealth), an ability (dex), a tool (thieves\' tools), or an attack listed on the sheet (Longbow). For a tool check the proficiency bonus is added only if the character actually has that tool proficiency, and doubled for expertise; "ability" says which ability the check uses and defaults to dex, so pass it for anything that is not a Dexterity check — "ability":"int" to identify a poison with a poisoner\'s kit. Give "dc" if you know the target number; omit it to get the raw total and judge for yourself. "mode" is normal, advantage or disadvantage — the character\'s own conditions and exhaustion are applied on top of what you ask for. "bonus" is any situational modifier. For an attack it also rolls damage, doubling the dice on a critical hit. Death saving throws are recorded on the sheet, and three successes or failures are reported. To make several rolls at once — a group saving throw, two attacks in a round — set "batch" to a JSON array of objects using the same keys and leave the other parameters out: ' +
|
|
48
50
|
BATCH_EXAMPLE +
|
|
49
51
|
'. One batched call costs one turn instead of several.',
|
|
50
52
|
parameters: [
|
|
@@ -52,13 +54,19 @@ exports.checkTool = {
|
|
|
52
54
|
{
|
|
53
55
|
name: 'kind',
|
|
54
56
|
type: 'string',
|
|
55
|
-
description: 'skill, ability, save, attack, initiative, or death',
|
|
57
|
+
description: 'skill, ability, save, attack, initiative, tool, or death',
|
|
56
58
|
required: false,
|
|
57
59
|
},
|
|
58
60
|
{
|
|
59
61
|
name: 'subject',
|
|
60
62
|
type: 'string',
|
|
61
|
-
description: 'The skill, ability, or attack name being rolled',
|
|
63
|
+
description: 'The skill, ability, tool, or attack name being rolled',
|
|
64
|
+
required: false,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'ability',
|
|
68
|
+
type: 'string',
|
|
69
|
+
description: 'For a tool check, which ability it uses; defaults to dex',
|
|
62
70
|
required: false,
|
|
63
71
|
},
|
|
64
72
|
{ name: 'dc', type: 'number', description: 'The target number, if you know it', required: false },
|
|
@@ -118,6 +126,7 @@ function collectRequests(args) {
|
|
|
118
126
|
dc: entry.dc !== undefined && entry.dc !== null && entry.dc !== '' ? (0, coerce_1.int)(entry.dc, 'dc') : undefined,
|
|
119
127
|
mode: entry.mode !== undefined ? (0, coerce_1.str)(entry.mode, 'mode') : undefined,
|
|
120
128
|
bonus: entry.bonus !== undefined && entry.bonus !== '' ? (0, coerce_1.int)(entry.bonus, 'bonus', 0) : 0,
|
|
129
|
+
ability: entry.ability !== undefined ? (0, coerce_1.str)(entry.ability, 'ability') : undefined,
|
|
121
130
|
};
|
|
122
131
|
});
|
|
123
132
|
}
|
|
@@ -134,10 +143,13 @@ function normalizeKind(raw) {
|
|
|
134
143
|
initiative: 'initiative',
|
|
135
144
|
death: 'death',
|
|
136
145
|
'death save': 'death',
|
|
146
|
+
tool: 'tool',
|
|
147
|
+
tools: 'tool',
|
|
148
|
+
'tool check': 'tool',
|
|
137
149
|
};
|
|
138
150
|
const kind = known[key];
|
|
139
151
|
if (!kind) {
|
|
140
|
-
throw new Error(`"${raw}" is not a kind of roll. Use skill, ability, save, attack, initiative, or death.`);
|
|
152
|
+
throw new Error(`"${raw}" is not a kind of roll. Use skill, ability, save, attack, initiative, tool, or death.`);
|
|
141
153
|
}
|
|
142
154
|
return kind;
|
|
143
155
|
}
|
|
@@ -160,7 +172,9 @@ function resolveCheck(room, request) {
|
|
|
160
172
|
const kind = request.kind === 'attack' ? 'attack' : request.kind === 'save' ? 'save' : 'check';
|
|
161
173
|
const subject = kind === 'save'
|
|
162
174
|
? rules.resolveAbility(request.subject || '')
|
|
163
|
-
:
|
|
175
|
+
: request.kind === 'tool'
|
|
176
|
+
? toolAbility(request)
|
|
177
|
+
: (request.subject || '').trim().toLowerCase();
|
|
164
178
|
const effects = rules.conditionEffects(state, kind, subject);
|
|
165
179
|
if (effects.autoFail) {
|
|
166
180
|
const outcome = {
|
|
@@ -220,8 +234,12 @@ function resolveCheck(room, request) {
|
|
|
220
234
|
outcome.passed = roll.total >= request.dc;
|
|
221
235
|
}
|
|
222
236
|
outcome.detail = describeOutcome(outcome, roll.kept[0]);
|
|
237
|
+
if (resolved.note)
|
|
238
|
+
outcome.note = resolved.note;
|
|
223
239
|
if (sheet.warnings.length > 0) {
|
|
224
|
-
outcome.note = `Sheet warnings: ${sheet.warnings.join(' ')}
|
|
240
|
+
outcome.note = [outcome.note, `Sheet warnings: ${sheet.warnings.join(' ')}`]
|
|
241
|
+
.filter(Boolean)
|
|
242
|
+
.join(' ');
|
|
225
243
|
}
|
|
226
244
|
if (rules.isIncapacitated(state) && request.kind === 'attack') {
|
|
227
245
|
outcome.note = [outcome.note, `${state.name} is incapacitated and should not be attacking.`]
|
|
@@ -230,6 +248,16 @@ function resolveCheck(room, request) {
|
|
|
230
248
|
}
|
|
231
249
|
return outcome;
|
|
232
250
|
}
|
|
251
|
+
function toolAbility(request) {
|
|
252
|
+
const named = (request.ability || '').trim();
|
|
253
|
+
if (!named)
|
|
254
|
+
return DEFAULT_TOOL_ABILITY;
|
|
255
|
+
const ability = rules.resolveAbility(named);
|
|
256
|
+
if (!ability) {
|
|
257
|
+
throw new Error(`"${named}" is not an ability. A tool check uses str, dex, con, int, wis or cha.`);
|
|
258
|
+
}
|
|
259
|
+
return ability;
|
|
260
|
+
}
|
|
233
261
|
function resolveModifier(state, request) {
|
|
234
262
|
const subject = (request.subject || '').trim();
|
|
235
263
|
if (request.kind === 'initiative') {
|
|
@@ -250,6 +278,23 @@ function resolveModifier(state, request) {
|
|
|
250
278
|
attack: { dmg: attack.dmg, type: attack.type },
|
|
251
279
|
};
|
|
252
280
|
}
|
|
281
|
+
if (request.kind === 'tool') {
|
|
282
|
+
if (!subject) {
|
|
283
|
+
throw new Error('A tool check needs a "subject" naming the tool, e.g. "thieves\' tools".');
|
|
284
|
+
}
|
|
285
|
+
const ability = toolAbility(request);
|
|
286
|
+
const tool = (0, kits_1.canonicalToolName)(subject);
|
|
287
|
+
const resolved = rules.toolCheckModifier(state, tool, ability);
|
|
288
|
+
return {
|
|
289
|
+
modifier: resolved.modifier,
|
|
290
|
+
label: `${tool} (${ability.toUpperCase()})`,
|
|
291
|
+
note: resolved.proficient
|
|
292
|
+
? resolved.expertise
|
|
293
|
+
? `${state.name} has expertise with ${tool}, so the proficiency bonus is doubled.`
|
|
294
|
+
: undefined
|
|
295
|
+
: `${state.name} is not proficient with ${tool}, so no proficiency bonus was added. The roll is legal without it.`,
|
|
296
|
+
};
|
|
297
|
+
}
|
|
253
298
|
if (request.kind === 'skill') {
|
|
254
299
|
const skill = subject.toLowerCase();
|
|
255
300
|
if (!rules.skillNames().includes(skill)) {
|
|
@@ -4,6 +4,7 @@ exports.rollInitiativeTool = exports.rollDiceTool = void 0;
|
|
|
4
4
|
const coerce_1 = require("../engine/coerce");
|
|
5
5
|
const dice_1 = require("../engine/dice");
|
|
6
6
|
const sheet_1 = require("../engine/sheet");
|
|
7
|
+
const encounter_1 = require("../engine/encounter");
|
|
7
8
|
const shared_1 = require("./shared");
|
|
8
9
|
const coerce_2 = require("../engine/coerce");
|
|
9
10
|
exports.rollDiceTool = {
|
|
@@ -91,20 +92,29 @@ exports.rollInitiativeTool = {
|
|
|
91
92
|
roll: entry.roll.kept[0],
|
|
92
93
|
modifier: entry.modifier,
|
|
93
94
|
}));
|
|
95
|
+
const cleared = (0, shared_1.clearFoes)(room, order.map((entry) => entry.name));
|
|
94
96
|
const encounterName = args.encounter_name ? (0, coerce_1.str)(args.encounter_name, 'encounter_name') : 'Encounter';
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
const tracked = (0, shared_1.listFoeNames)(room);
|
|
98
|
+
const isFoe = new Set(tracked.map((name) => (0, coerce_2.nameKey)(name)));
|
|
99
|
+
const encounter = (0, encounter_1.newEncounter)(encounterName, order.map((entry) => ({
|
|
100
|
+
name: entry.name,
|
|
101
|
+
init: entry.initiative,
|
|
102
|
+
foe: isFoe.has((0, coerce_2.nameKey)(entry.name)) ? true : undefined,
|
|
103
|
+
})));
|
|
104
|
+
room.update(sheet_1.ENCOUNTER_ARTIFACT, () => (0, encounter_1.renderEncounter)(encounter), {
|
|
105
|
+
viewers: room.agentNicknames,
|
|
106
|
+
transient: true,
|
|
107
|
+
});
|
|
103
108
|
return {
|
|
104
109
|
encounter: encounterName,
|
|
105
110
|
order,
|
|
106
111
|
summary: order.map((e) => `${e.name} ${e.initiative}`).join(', '),
|
|
107
|
-
|
|
112
|
+
trackedMonsters: tracked.length > 0 ? tracked : undefined,
|
|
113
|
+
clearedFromLastFight: cleared.length > 0 ? cleared : undefined,
|
|
114
|
+
note: `Round 1, ${order[0]?.name} is up. The order is stored in the "${sheet_1.ENCOUNTER_ARTIFACT}" artifact — call encounter with action "next" at the end of each turn rather than tracking it yourself.` +
|
|
115
|
+
(tracked.length > 0
|
|
116
|
+
? ` Hit points are tracked for ${tracked.join(', ')} — use apply_hp on them by name rather than counting in your head.`
|
|
117
|
+
: ' No monsters are being tracked: place them with stat_block\'s "place" parameter so their hit points are kept for you.'),
|
|
108
118
|
};
|
|
109
119
|
},
|
|
110
120
|
};
|