Skip to content

Commit

Permalink
Fixed a class sheet details tab error. (#774)
Browse files Browse the repository at this point in the history
Fixed max prepared spells data pull.
  • Loading branch information
kgar authored Sep 20, 2024
1 parent a0d6449 commit 4397ed7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type { Item5e } from 'src/types/item.types';
import { get, writable, type Writable } from 'svelte/store';
import { FoundryAdapter } from 'src/foundry/foundry-adapter';
import { getMaxPreparedSpellsSampleFormulas } from 'src/utils/formula';
import { TidyFlags } from 'src/foundry/TidyFlags';

export type MaxPreparedSpellsConfigContext = {
maxPreparedSpells: string;
Expand All @@ -17,6 +16,7 @@ export type MaxPreparedSpellsConfigContext = {
export class MaxPreparedSpellsConfigFormApplication extends SvelteFormApplicationBase {
context: Writable<MaxPreparedSpellsConfigContext>;
actor: Actor5e;
classToUpdate: Item5e;

constructor(actor: Actor5e, classToUpdate: Item5e, ...args: any[]) {
super(...args);
Expand Down Expand Up @@ -44,7 +44,8 @@ export class MaxPreparedSpellsConfigFormApplication extends SvelteFormApplicatio

getData(): MaxPreparedSpellsConfigContext {
return {
maxPreparedSpells: TidyFlags.maxPreparedSpells.get(this.actor) ?? '',
maxPreparedSpells:
this.classToUpdate?.system?.spellcasting?.preparation?.formula ?? '',
formulas: getMaxPreparedSpellsSampleFormulas(),
actor: this.actor,
};
Expand Down
27 changes: 0 additions & 27 deletions src/foundry/TidyFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,33 +330,6 @@ export class TidyFlags {
},
};

/**
* A formula that determines the maximum number of
* prepared spells an actor can have.
*/
static maxPreparedSpells = {
key: 'maxPreparedSpells' as const,
prop: TidyFlags.getFlagPropertyPath('maxPreparedSpells'),
/** Gets the actor's maximum number of prepared spells. */
get(actor: Actor5e): string | undefined {
// Legacy values of this flag can be of type `number`, so it is put to string, just in case.
return (
TidyFlags.tryGetFlag<string>(
actor,
TidyFlags.maxPreparedSpells.key
)?.toString() ?? undefined
);
},
/** Sets the actor's maximum number of prepared spells. */
set(actor: Actor5e, value: string): Promise<void> {
return TidyFlags.setFlag(actor, TidyFlags.maxPreparedSpells.key, value);
},
/** Clears the actor's maximum number of prepared spells. */
unset(actor: Actor5e) {
return TidyFlags.unsetFlag(actor, TidyFlags.maxPreparedSpells.key);
},
};

/**
* Denotes whether a vehicle is moving.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/sheets/item/tabs/ItemClassDetailsTab.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
labelCssClass="checkbox"
document={$context.item}
field="system.primaryAbility.value"
checked={$context.source.primaryAbility.value.has(key)}
checked={$context.system.primaryAbility.value.has(key)}
value={key}
disabled={!$context.editable}
onDataPreparing={(ev) => mapMulticlassingAbilitiesToSave($context, ev)}
Expand Down

0 comments on commit 4397ed7

Please sign in to comment.