Skip to content

Commit

Permalink
feat: Add Make an Impression with Performance to BAM
Browse files Browse the repository at this point in the history
This requires a feat.  It's not the same as the alt skill check, as it's
necessary to select which skill to use.  So it should be another action,
but only show if the feat is present.
  • Loading branch information
xyzzy42 committed Oct 30, 2024
1 parent b153f53 commit 851d1ea
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions src/module/feature/macros/basicActionMacros.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,31 @@ function createButtonData(
}

type MacroAction = {
// These are supplied for each supported action
actionType: "basic" | "skill_untrained" | "skill_trained" | "other";
// Skill name or blank for non-skill actions
skill: StatisticSlug | "";
// The altSkillAndFeat stuff should really be more flexible. Maybe look at what SkillActions did for prereqs?
altSkillAndFeat?: { skill: StatisticSlug; feat: string }[];
// Localized name to appear in menu
name: string;
// Path to icon
icon: string;
// Object to use when action is selected
action: Function | Action | ActionVariant | undefined;
// Optional parameters for an Action.use() call for Action or ActionVariant type actions
options?: Partial<ActionUseOptions>;
// Module needed for action to be present (external macros)
module?: string;
// Feat needed to for action to be present
feat?: string;

// These are all filled in based on the action and actor data
best?: number;
whoIsBest?: string;
showMAP?: boolean;
showExploration?: boolean;
showDowntime?: boolean;
// Optional parameters for an Action.use() call
options?: Partial<ActionUseOptions>;
actionType?: "basic" | "skill_untrained" | "skill_trained" | "other";
};

/**
Expand All @@ -116,15 +126,16 @@ type MacroAction = {
*/
function prepareActions(selectedActor: ActorPF2e, bamActions: MacroAction[]): MacroAction[] {
const showUnusable = game.settings.get(MODULENAME, "bamShowUnusable");
const hasFeat = (slug: string) => selectedActor.itemTypes.feat.some((feat) => feat.slug === slug);

const actionsToUse = bamActions
.filter((x) => {
const hasSkill = selectedActor.skills?.[x.skill]?.rank ?? 0 > 0;
const hasAltSkillAndFeat = x.altSkillAndFeat?.some(
(y) =>
selectedActor.skills?.[y.skill].rank &&
selectedActor.itemTypes.feat.some((feat) => feat.slug === y.feat),
(y) => selectedActor.skills?.[y.skill].rank && hasFeat(y.feat),
);
if (x.module && !game.modules.get(x.module)?.active) return false;
if (x.feat && !hasFeat(x.feat)) return false;

return (
showUnusable ||
Expand All @@ -135,7 +146,6 @@ function prepareActions(selectedActor: ActorPF2e, bamActions: MacroAction[]): Ma
hasAltSkillAndFeat
);
})
.filter((m) => (m.module ? game.modules.get(m.module)?.active : true))
.sort((a, b) => a.name.localeCompare(b.name, game.i18n.lang));

actionsToUse.forEach((x) => {
Expand Down Expand Up @@ -452,6 +462,18 @@ export async function basicActionMacros() {
action: game.pf2e.actions.get("make-an-impression"),
icon: "icons/environment/people/commoner.webp",
},
{
actionType: "skill_trained",
name:
game.i18n.localize(`${MODULENAME}.macros.basicActionMacros.actions.MakeAnImpression`) +
" - " +
game.i18n.localize("PF2E.Skill.Performance"),
skill: "performance",
action: game.pf2e.actions.get("make-an-impression"),
options: { statistic: "performance" },
icon: "icons/environment/people/commoner.webp",
feat: "impressive-performance",
},
{
actionType: "skill_trained",
name: game.i18n.localize(`${MODULENAME}.macros.basicActionMacros.actions.ManeuverInFlight`),
Expand Down

0 comments on commit 851d1ea

Please sign in to comment.