forked from foundryvtt/pf2e
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Learn a Spell action object (foundryvtt#12984)
- Loading branch information
Showing
3 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
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(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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters