Skip to content

Commit

Permalink
Add recall knowledge action object
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaj-a committed Jan 19, 2024
1 parent 9900bfc commit 6246dd2
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/module/system/action-macros/general/recall-knowledge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import {
SingleCheckAction,
SingleCheckActionUseOptions,
SingleCheckActionVariant,
SingleCheckActionVariantData,
} from "@actor/actions/index.ts";
import { CheckResultCallback } from "@system/action-macros/types.ts";

const PREFIX = "PF2E.Actions.RecallKnowledge";

class RecallKnowledgeActionVariant extends SingleCheckActionVariant {
override async use(
options: Partial<SingleCheckActionUseOptions> & { statistic: string },
): Promise<CheckResultCallback[]> {
if (!options?.statistic) {
throw new Error(game.i18n.localize(`${PREFIX}.Warning.NoSkill`));
}
const rollOption = `action:recall-knowledge:${options.statistic}`;
options.rollOptions ??= [];
if (!options.rollOptions.includes(rollOption)) {
options.rollOptions.push(rollOption);
}
return super.use(options);
}
}

class RecallKnowledgeAction extends SingleCheckAction {
constructor() {
super({
cost: 1,
description: `${PREFIX}.Description`,
name: `${PREFIX}.Title`,
notes: [
{ outcome: ["criticalSuccess"], text: `${PREFIX}.Notes.criticalSuccess` },
{ outcome: ["success"], text: `${PREFIX}.Notes.success` },
{ outcome: ["criticalFailure"], text: `${PREFIX}.Notes.criticalFailure` },
],
rollOptions: ["action:recall-knowledge"],
sampleTasks: {
untrained: `${PREFIX}.SampleTasks.Untrained`,
trained: `${PREFIX}.SampleTasks.Trained`,
expert: `${PREFIX}.SampleTasks.Expert`,
master: `${PREFIX}.SampleTasks.Master`,
legendary: `${PREFIX}.SampleTasks.Legendary`,
},
section: "skill",
slug: "recall-knowledge",
statistic: ["arcana", "crafting", "medicine", "nature", "occultism", "religion", "society"],
traits: ["concentrate", "secret"],
});
}

protected override toActionVariant(data?: SingleCheckActionVariantData): RecallKnowledgeActionVariant {
return new RecallKnowledgeActionVariant(this, data);
}
}

const recallKnowledge = new RecallKnowledgeAction();

export { recallKnowledge };
2 changes: 2 additions & 0 deletions src/module/system/action-macros/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import * as track from "./exploration/track.ts";
import * as decipherWriting from "./general/decipher-writing.ts";
import { identifyMagic } from "./general/identify-magic.ts";
import { learnASpell } from "./general/learn-a-spell.ts";
import { recallKnowledge } from "./general/recall-knowledge.ts";
import * as subsist from "./general/subsist.ts";
import * as coerce from "./intimidation/coerce.ts";
import * as demoralize from "./intimidation/demoralize.ts";
Expand Down Expand Up @@ -207,6 +208,7 @@ export const SystemActions: Action[] = [
pickALock.action,
pointOut,
ready,
recallKnowledge,
release,
reposition.action,
request.action,
Expand Down
20 changes: 20 additions & 0 deletions static/lang/action-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,26 @@
"Description": "<p>You prepare to use an action that will occur outside your turn. Choose a single action or free action you can use, and designate a trigger. Your turn then ends. If the trigger you designated occurs before the start of your next turn, you can use the chosen action as a reaction (provided you still meet the requirements to use it). You can't Ready a free action that already has a trigger.</p><p>If you have a multiple attack penalty and your readied action is an attack action, your readied attack takes the multiple attack penalty you had at the time you used Ready. This is one of the few times the multiple attack penalty applies when it's not your turn.</p>",
"Title": "Ready"
},
"RecallKnowledge": {
"Description": "<p>You attempt a skill check to try to remember a bit of knowledge regarding a topic related to that skill. Suggest which skill you'd like to use and ask the GM one question. The GM determines the DC. You might need to collaborate with the GM to narrow down the question or skills, and you can decide not to Recall Knowledge before committing to the action if you don't like your options.</p><p><strong>Critical Success</strong> You recall the knowledge accurately. The GM answers your question truthfully and either tells you additional information or context, or answers one follow-up question.</p><p><strong>Success</strong> You recall the knowledge accurately. The GM answers your question truthfully.</p><p><strong>Critical Failure</strong> You recall incorrect information. The GM answers your question falsely (or decides to give you no information, as on a failure).</p>",
"Notes": {
"criticalFailure": "<strong>Critical Failure</strong> You recall incorrect information. The GM answers your question falsely (or decides to give you no information, as on a failure).",
"criticalSuccess": "<strong>Critical Success</strong> You recall the knowledge accurately. The GM answers your question truthfully and either tells you additional information or context, or answers one follow-up question.",
"success": "<strong>Success</strong> You recall the knowledge accurately. The GM answers your question truthfully."
},
"SampleTasks": {
"Caption": "The following examples use Society or Religion.",
"Untrained": "name of a ruler, head of state, key noble, or major deity",
"Trained": "line of succession for a major noble family, core doctrines of a major deity",
"Expert": "genealogy of a minor noble, teachings of an ancient priest",
"Master": "hierarchy of a genie noble court, major extraplanar temples of a deity",
"Legendary": "existence of a long-lost noble heir, secret doctrines of a religion"
},
"Title": "Recall Knowledge",
"Warning": {
"NoSkill": "The Recall Knowledge action can be used with different skills, and no skill was specified."
}
},
"Release": {
"Description": "<p>You release something you're holding in your hand or hands. This might mean dropping an item, removing one hand from your weapon while continuing to hold it in another hand, releasing a rope suspending a chandelier, or performing a similar action. Unlike most manipulate actions, Release does not trigger reactions that can be triggered by actions with the manipulate trait (such as Reactive Strike).</p><p>If you want to prepare to Release something outside of your turn, use the Ready activity.</p>",
"Drop": {
Expand Down

0 comments on commit 6246dd2

Please sign in to comment.