Skip to content

Commit

Permalink
Merge pull request #844 from kgar/issue-842-limited-uses-additional-s…
Browse files Browse the repository at this point in the history
…pells

[#842] Spellbook fixes
  • Loading branch information
kgar authored Nov 24, 2024
2 parents 58b8034 + f5bbc6c commit f58a482
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/components/spellbook/SpellbookList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import ClassicControls from 'src/sheets/shared/ClassicControls.svelte';
import ConcentrationOverlayIcon from './ConcentrationOverlayIcon.svelte';
import DeleteOrOpenActivity from '../item-list/controls/DeleteOrOpenActivity.svelte';
import ActivityUses from '../item-list/ActivityUses.svelte';
let context = getContext<Readable<CharacterSheetContext | NpcSheetContext>>(
CONSTANTS.SVELTE_CONTEXT.CONTEXT,
Expand Down Expand Up @@ -206,6 +207,10 @@
<ItemTableCell baseWidth="3.125rem">
<ItemUses item={spell} />
</ItemTableCell>
{:else if (spell.system.linkedActivity?.uses?.max ?? 0) > 0}
<ItemTableCell baseWidth="3.125rem">
<ActivityUses activity={spell.system.linkedActivity} />
</ItemTableCell>
{/if}
{#if allowFavorites && $settingStore.showIconsNextToTheItemName && 'favoriteId' in ctx && !!ctx.favoriteId}
<InlineFavoriteIcon />
Expand Down
9 changes: 8 additions & 1 deletion src/features/sections/SheetSections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,14 @@ export class SheetSections {

const spellbookMap = spellbook.reduce<Record<string, SpellbookSection>>(
(prev, curr) => {
const key = curr.prop ?? '';
let key = curr.prop ?? '';

// Handle "Additional Spells" section
if (curr.order === 'item') {
key = 'dnd5e-cast-activity-additional-spells';
curr.canCreate = false;
}

curr.key = key;

// Tidy passes the dataset directly to the item creation code, rather than planting it on the HTML.
Expand Down
2 changes: 1 addition & 1 deletion src/mixins/SvelteApplicationMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ export function SvelteApplicationMixin<
this.#focusedInputSelector = focusedElement?.name
? `${focusedElement.tagName}[name="${focusedElement.name}"]`
: focusedElement?.id
? `#${focusedElement.id}`
? `[id="${focusedElement.id}"]`
: undefined;
}

Expand Down
2 changes: 1 addition & 1 deletion src/sheets/item/parts/FieldUses.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
ev.currentTarget.value,
)}
disabled={!$context.editable}
value={recovery.data.formula}
value={recovery.data.formula ?? ''}
/>
{/if}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export type SimpleEditableColumn = {
};

export type SpellbookSection = {
order?: number;
order?: number | string;
usesSlots: boolean;
canCreate: boolean;
canPrepare: boolean;
Expand Down

0 comments on commit f58a482

Please sign in to comment.