Skip to content

Commit

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

const PREFIX = "PF2E.Actions.LearnASpell";

class LearnASpellActionVariant extends SingleCheckActionVariant {
override async use(

Check failure on line 12 in src/module/system/action-macros/general/learn-a-spell.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `⏎········options:·Partial<SingleCheckActionUseOptions>,⏎····` with `options:·Partial<SingleCheckActionUseOptions>`
options: Partial<SingleCheckActionUseOptions>,
): Promise<CheckResultCallback[]> {
if (!options?.statistic) {
return Promise.reject(game.i18n.localize(`${PREFIX}.Warning.NoSkill`));
}
const rollOption = `action:learn-a-spell:${options.statistic}`;
options.rollOptions ??= [];
if (!options.rollOptions.includes(rollOption)) {
options.rollOptions.push(rollOption);
}
return super.use(options);
}
}

class LearnASpellAction extends SingleCheckAction {
constructor() {
super({
description: `${PREFIX}.Description`,
name: `${PREFIX}.Title`,
notes: [
{ outcome: ["criticalSuccess"], text: `${PREFIX}.Notes.criticalSuccess` },
{ outcome: ["success"], text: `${PREFIX}.Notes.success` },
{ outcome: ["failure"], text: `${PREFIX}.Notes.failure` },
{ outcome: ["criticalFailure"], text: `${PREFIX}.Notes.criticalFailure` },
],
rollOptions: ["action:learn-a-spell"],
section: "skill",
slug: "learn-a-spell",
statistic: ["arcana", "nature", "occultism", "religion"],
traits: ["concentrate", "exploration"],
});
}

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

const learnASpell = new LearnASpellAction();

export { learnASpell };
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 @@ -43,6 +43,7 @@ import * as avoidNotice from "./exploration/avoid-notice.ts";
import * as senseDirection from "./exploration/sense-direction.ts";
import * as track from "./exploration/track.ts";
import * as decipherWriting from "./general/decipher-writing.ts";
import { learnASpell } from "./general/learn-a-spell.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 @@ -192,6 +193,7 @@ export const SystemActions: Action[] = [
impersonate.action,
interact,
leap,
learnASpell,
lie.action,
longJump.action,
makeAnImpression.action,
Expand Down
7 changes: 5 additions & 2 deletions static/lang/action-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -498,14 +498,17 @@
"Title": "Leap"
},
"LearnASpell": {
"Description": "<p>You can gain access to a new spell of your tradition from someone who knows that spell or from magical writing like a spellbook or scroll. If you can cast spells of multiple traditions, you can Learn a Spell of any of those traditions, but you must use the corresponding skill to do so. For example, if you were a cleric with the bard multiclass archetype, you couldn't use Religion to add an occult spell to your bardic spell repertoire.</p><p>To learn the spell, you must do the following:</p><ul><li> Spend 1 hour per spell rank, during which you must remain in conversation with a person who knows the spell or have the magical writing in your possession. </li><li> Have materials with the Price indicated in the Learning a Spell table. </li><li> Attempt a skill check for the skill corresponding to your tradition (DC determined by the GM, often close to the DC on the Learning a Spell Table). Uncommon or rare spells have higher DCs; full guidelines for the GM appear on page 52 of GM Core.</p><p><strong>Critical Success</strong> You expend half the materials and learn the spell.</p><p><strong>Success</strong> You expend the materials and learn the spell.</p><p><strong>Failure</strong> You fail to learn the spell but can try again after you gain a level. The materials aren't expended.</p><p><strong>Critical Failure</strong> As failure, except you expend half the materials.</p>",
"Description": "<p><strong>Requirements</strong> You have a spellcasting class feature, and the spell you want to learn is on your magical tradition's spell list.</p><hr><p>You can gain access to a new spell of your tradition from someone who knows that spell or from magical writing like a spellbook or scroll. If you can cast spells of multiple traditions, you can Learn a Spell of any of those traditions, but you must use the corresponding skill to do so. For example, if you were a cleric with the bard multiclass archetype, you couldn't use Religion to add an occult spell to your bardic spell repertoire.</p><p>To learn the spell, you must do the following:</p><ul><li>Spend 1 hour per spell rank, during which you must remain in conversation with a person who knows the spell or have the magical writing in your possession.</li><li>Have materials with the Price indicated in the Learning a Spell table.</li><li>Attempt a skill check for the skill corresponding to your tradition (DC determined by the GM, often close to the DC on the Learning a Spell Table). Uncommon or rare spells have higher DCs; full guidelines for the GM appear on page 52 of GM Core.</li></ul><p><strong>Critical Success</strong> You expend half the materials and learn the spell.</p><p><strong>Success</strong> You expend the materials and learn the spell.</p><p><strong>Failure</strong> You fail to learn the spell but can try again after you gain a level. The materials aren't expended.</p><p><strong>Critical Failure</strong> As failure, except you expend half the materials.</p>",
"Notes": {
"criticalFailure": "<strong>Critical Failure</strong> You fail to learn the spell but can try again after you gain a level. You expend half the materials.",
"criticalSuccess": "<strong>Critical Success</strong> You expend half the materials and learn the spell.",
"failure": "<strong>Failure</strong> You fail to learn the spell but can try again after you gain a level. The materials aren't expended.",
"success": "<strong>Success</strong> You expend the materials and learn the spell."
},
"Title": "Learn A Spell"
"Title": "Learn a Spell",
"Warning": {
"NoSkill": "The Learn a Spell action can be used with different skills, and no skill was specified. Each magical tradition has a corresponding skill: Arcana for the arcane tradition, Nature for the primal tradition, Occultism for the occult tradition, and Religion for the divine tradition."
}
},
"Lie": {
"Description": "<p>You try to fool someone with an untruth. Doing so takes at least 1 round, or longer if the lie is elaborate. You roll a single Deception check and compare it against the Perception DC of every creature you are trying to fool. The GM might give them a circumstance bonus based on the situation and the nature of the lie you are trying to tell. Elaborate or highly unbelievable lies are much harder to get a creature to believe than simpler and more believable lies, and some lies are so big that it's impossible to get anyone to believe them.</p><p>At the GM's discretion, if a creature initially believes your lie, it might attempt a Perception check later to @UUID[Compendium.pf2e.actionspf2e.Item.1xRFPTFtWtGJ9ELw]{Sense Motive} against your Deception DC to realize it's a lie. This usually happens if the creature discovers enough evidence to counter your statements.</p><p><strong>Success</strong> The target believes your lie.<br><strong>Failure</strong> The target doesn't believe your lie and gains a +4 circumstance bonus against your attempts to Lie for the duration of your conversation. The target is also more likely to be suspicious of you in the future.</p>",
Expand Down

0 comments on commit 16fafe8

Please sign in to comment.