### Get Available Item Type Choices for PF2eAutoPopulate (JavaScript) Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt Retrieves grouped item type choices for use in configuration dialogs within the PF2eAutoPopulate framework. This helps users select specific item types for hotbar population. ```javascript import { Pf2eAutoPopulate } from './features/Pf2eAutoPopulate.js'; const autoPopulate = new Pf2eAutoPopulate(); // Get grouped item type choices for configuration dialog const choices = await autoPopulate.getItemTypeChoices(); // Returns grouped choices: // [ // { // group: "Combat", // choices: [ // { value: 'actions', label: 'Actions' }, // { value: 'spell', label: 'Spells' }, // { value: 'spell:focus', label: 'Focus Spells' } // ] // }, // { // group: "Consumables", // choices: [ // { value: 'consumable', label: 'Consumables' }, // { value: 'ammo', label: 'Ammunition' } // ] // }, // { // group: "Equipment", // choices: [ // { value: 'equipment', label: 'Equipment' }, // { value: 'armor', label: 'Armor' }, // { value: 'backpack', label: 'Backpacks' } // ] // } // ] ``` -------------------------------- ### Get PF2e Button Definitions - JavaScript Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt Retrieves an array of button definitions for PF2e-specific actions like 'End Turn' and 'Rest'. Each button object includes a key, icon, tooltip, visibility condition, and an onClick handler. ```javascript import { Pf2eActionButtonsContainer } from './components/containers/Pf2eActionButtonsContainer.js'; const container = new Pf2eActionButtonsContainer({ actor, token }); const buttons = container.getPf2eButtons(); // Returns: // [ // { // key: 'end-turn', // icon: 'fas fa-stopwatch', // tooltip: 'End Turn', // visible: () => game.combat?.started && game.combat?.combatant?.actor?.id === actor.id, // onClick: async () => await game.combat.nextTurn() // }, // { // key: 'rest', // icon: 'fas fa-bed', // label: 'Rest', // tooltip: 'Recover - Daily Preparations', // visible: () => !game.combat?.started, // onClick: async (event) => { // await game.pf2e.actions.restForTheNight({ actors: [actor], event }); // } // } // ] ``` -------------------------------- ### Get PF2e Filter Definitions (JavaScript) Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt Provides action economy, item type, and spell rank filters specific to PF2e. This function returns an array of filter definitions, including action economy pips, item type filters (weapon, action, feat), focus pool filters, cantrip filters, and spell rank groups. ```javascript import { Pf2eFilterContainer } from './components/containers/Pf2eFilterContainer.js'; const filterContainer = new Pf2eFilterContainer({ actor: myActor }); const filters = filterContainer.getPf2eFilters(); // Returns filter definitions: // [ // // Action economy pips (track remaining actions) // { id: 'action-1', short: '1', value: 3, max: 1, data: { actionCost: 1 }, alwaysShow: true }, // { id: 'action-2', short: '2', value: 3, max: 2, data: { actionCost: 2 }, alwaysShow: true }, // { id: 'action-3', short: '3', value: 3, max: 3, data: { actionCost: 3 }, alwaysShow: true }, // // // Item type filters // { id: 'weapon', symbol: 'fa-sword', data: { itemType: 'weapon' } }, // { id: 'action', symbol: 'fa-hand-fist', data: { itemType: 'action' } }, // { id: 'feat', symbol: 'fa-star', data: { itemType: 'feat' } }, // // // Focus pool filter (if actor has focus spells) // { id: 'focus-spell', short: 'F', value: 2, max: 3, data: { isFocusSpell: true } }, // // // Cantrip filter // { id: 'spell', centerLabel: 'C', data: { level: 0 } }, // // // Spell rank group (ranks I-X with Roman numerals) // { id: 'spell-ranks-group', type: 'group', symbol: 'fa-hat-wizard', // children: [ // { id: 'spell-1', centerLabel: 'I', data: { level: 1 } }, // { id: 'spell-2', centerLabel: 'II', data: { level: 2 } }, // // ... up to X // ] // } // ] ``` -------------------------------- ### Get Cell Context Menu Items (JavaScript) Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt Retrieves context menu items for a cell, with special handling for shield items and weapons with two-hand/versatile traits. This function is part of the cell interaction logic. ```javascript // Get context menu items for a cell (right-click menu) const menuItems = await adapter.getCellMenuItems(cell); // Shield items get special menu options: // - "Raise Shield" / "Lower Shield" // - "Take Cover" / "Remove Cover" // Weapons with two-hand/versatile traits get: // - "Switch to 1-Handed" / "Switch to 2-Handed" ``` -------------------------------- ### Get Health Data - JavaScript Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt Retrieves current health, maximum health, damage percentage, and temporary HP for an actor. This function is part of the Pf2ePortraitContainer and requires actor and token objects as input. ```javascript import { createPf2ePortraitContainer } from './components/containers/Pf2ePortraitContainer.js'; const Pf2ePortraitContainer = await createPf2ePortraitContainer(); const portraitContainer = new Pf2ePortraitContainer({ actor, token }); const health = portraitContainer.getHealth(); // Returns: // { // current: 45, // max: 60, // percent: 75, // damage: 25, // Damage percent for overlay // temp: 5 // Temporary HP // } ``` -------------------------------- ### Get Matching Items for Auto-Population (JavaScript) Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt Retrieves items from an actor that match specified types, such as 'actions' and 'spell'. The 'actions' type includes various combat and consumable items. It returns an array of cell data objects, each representing an item with its properties. ```javascript // Get items from actor matching selected types const items = await autoPopulate.getMatchingItems(actor, ['actions', 'spell']); // 'actions' type includes: // - Weapon strikes from actor.system.actions // - Action-type items with action costs // - Feats with action costs // - Consumables with actions (potions, elixirs) // Returns array of cell data objects: // [ // { uuid: "Actor.xyz.Item.longsword", type: "Item", name: "Longsword", img: "..." }, // { uuid: "Actor.xyz.Item.fireball", type: "Item", name: "Fireball", img: "...", // uses: { value: 2, max: 3 }, depleted: false } // ] ``` -------------------------------- ### Get Enhanced Target Display Data (JavaScript) Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt Retrieves detailed target information for display purposes, including name, image, range status, cover, flanking, distance, disposition, and status effects. Useful for UI elements related to targeting. ```javascript import { getTargetInfo } from './utils/Pf2eTargetingRules.js'; // Get detailed target info for display const info = getTargetInfo({ sourceToken: attackerToken, targetToken: defenderToken, item: weapon, activity: strike }); // Returns: // { // name: "Goblin Warrior", // img: "tokens/goblin.png", // inRange: true, // inLongRange: true, // coverStatus: 'none', // isFlanked: true, // distance: 10, // In scene units (feet) // disposition: 'hostile', // statusEffects: ['flat-footed', 'frightened'] // } ``` -------------------------------- ### Access Module Settings - JavaScript Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt Demonstrates how to access various module settings for 'bg3-hud-pf2e'. This includes client-scoped display settings, world-scoped auto-populate settings (GM only), and the auto-populate grid configuration. ```javascript // Display settings (client-scoped) game.settings.get('bg3-hud-pf2e', 'showItemNames'); // Show item names on cells game.settings.get('bg3-hud-pf2e', 'showItemUses'); // Show uses counter game.settings.get('bg3-hud-pf2e', 'showHealthOverlay'); // Show damage overlay on portrait // Auto-populate settings (world-scoped, GM only) game.settings.get('bg3-hud-pf2e', 'autoPopulateEnabled'); // Auto-fill on token create game.settings.get('bg3-hud-pf2e', 'autoPopulatePassivesEnabled'); // Auto-fill passives game.settings.get('bg3-hud-pf2e', 'filterPreparedSpellsPlayers'); // Only show prepared (players) game.settings.get('bg3-hud-pf2e', 'filterPreparedSpellsNPCs'); // Only show prepared (NPCs) // Auto-populate grid configuration game.settings.get('bg3-hud-pf2e', 'autoPopulateConfiguration'); // Default: { // grid0: ['weapon', 'melee', 'action'], // grid1: ['feat', 'spell'], // grid2: ['consumable', 'ammo'] // } ``` -------------------------------- ### Register PF2e Components with BG3 HUD Core API Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt This JavaScript code snippet demonstrates how the BG3 Inspired HUD - PF2e module registers its system-specific components with the BG3 HUD Core API. It listens for the 'bg3HudReady' hook, verifies the game system is 'pf2e', and then registers various container classes, an adapter, a menu builder, and a tooltip renderer. It also signals completion via the 'bg3HudRegistrationComplete' hook. ```javascript // The module listens for the bg3HudReady hook and registers all PF2e components Hooks.on('bg3HudReady', async (BG3HUD_API) => { // Verify we're in PF2e system if (game.system.id !== 'pf2e') return; // Create and register container classes const Pf2ePortraitContainer = await createPf2ePortraitContainer(); const Pf2ePassivesContainer = await createPf2ePassivesContainer(); const Pf2eWeaponSetContainer = await createPf2eWeaponSetContainer(); // Register all components with core BG3HUD_API.registerPortraitContainer(Pf2ePortraitContainer); BG3HUD_API.registerPassivesContainer(Pf2ePassivesContainer); BG3HUD_API.registerWeaponSetContainer(Pf2eWeaponSetContainer); BG3HUD_API.registerActionButtonsContainer(Pf2eActionButtonsContainer); BG3HUD_API.registerFilterContainer(Pf2eFilterContainer); BG3HUD_API.registerInfoContainer(Pf2eInfoContainer); // Register the adapter and menu builder const adapter = new Pf2eAdapter(); BG3HUD_API.registerAdapter(adapter); BG3HUD_API.registerMenuBuilder('pf2e', Pf2eMenuBuilder, { adapter: adapter }); // Register tooltip renderer BG3HUD_API.registerTooltipRenderer('pf2e', renderPf2eTooltip); // Signal completion Hooks.call('bg3HudRegistrationComplete'); }); ``` -------------------------------- ### Render Info Panel (JavaScript) Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt Renders the information panel for an actor, displaying ability scores, skills grouped by ability, and saving throws with proficiency tiers. Skills and saving throws are clickable for rolling, and abilities are clickable to expand their associated skills. ```javascript import { Pf2eInfoContainer } from './components/containers/Pf2eInfoContainer.js'; const infoContainer = new Pf2eInfoContainer({ actor: myActor }); const content = await infoContainer.renderContent(); // Renders three columns: // 1. Skills (filtered to selected ability, clickable to roll) // 2. Abilities (STR, DEX, CON, INT, WIS, CHA - clickable to expand skills) // 3. Saving Throws (Fortitude, Reflex, Will - clickable to roll) // Skills show proficiency tier indicator (U/T/E/M/L) // All modifiers show +/- prefix via CSS ``` -------------------------------- ### Render Item Tooltip - JavaScript Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt Renders a rich tooltip for PF2e items, including item name, image, subtitle, action cost, traits, and an enriched description. It can also include spell-specific details like level, school, and traditions. The function returns an object containing the HTML content, CSS classes, and display direction. ```javascript import { renderPf2eTooltip } from './utils/tooltipRenderer.js'; // Render tooltip for a PF2e item const tooltip = await renderPf2eTooltip(item, options); // Returns: // { // content: "", // classes: ['pf2e', 'chat-card', 'pf2e-tooltip', 'item-tooltip'], // direction: 'UP' // } // Tooltip includes: // - Item name and image // - Subtitle (item type) // - Action cost label // - Traits // - Enriched description (with inline rolls, links) // - Spell-specific: level, school, traditions ``` -------------------------------- ### Extract Targeting Requirements (JavaScript) Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt Extracts targeting configuration from an item, including minimum and maximum targets, range, target type, and template information. Supports both standard targeting and area spells with templates. ```javascript import { getTargetRequirements } from './utils/Pf2eTargetingRules.js'; // Get targeting requirements from an item const requirements = getTargetRequirements({ item: spell, activity: null }); // Returns: // { // minTargets: 1, // maxTargets: 2, // range: 12, // In grid squares // longRange: null, // targetType: 'creature', // hasTemplate: false, // template: null // } // For area spells with templates: // { // hasTemplate: true, // template: { type: 'burst', size: 20 } // } ``` -------------------------------- ### PF2eAdapter: Handle Item/Strike/Macro Usage on Cell Click Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt This JavaScript code illustrates the `onCellClick` method within the `Pf2eAdapter` class. It handles user interactions with hotbar cells, routing the action based on the clicked item's type (Item, Strike, or Macro). It also includes logic for modifier key support (Shift, Ctrl, Alt) to modify strike rolls based on Attack of Opportunity (MAP) rules. ```javascript // The adapter handles different item types when a hotbar cell is clicked const adapter = new Pf2eAdapter(); // Handle cell click with proper type routing await adapter.onCellClick(cell, event); // Internally routes based on data.type: // - 'Item': Uses _useItem() for spells, weapons, consumables, etc. // - 'Strike': Uses _useStrike() for weapon strikes // - 'Macro': Uses _executeMacro() for macros // Modifier key support for strikes: // - Shift+Click: Roll primary attack (MAP 0) // - Ctrl+Click: Roll MAP -5 variant // - Alt+Click: Roll MAP -10 variant ``` -------------------------------- ### Initiative Rolling (JavaScript) Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt Initiative can be rolled by right-clicking on the info button. This action internally calls the actor's rollInitiative method, with an option to create combatants if necessary. ```javascript // Right-click on info button rolls initiative await infoContainer.onButtonRightClick(event); // Internally calls: await actor.rollInitiative({ createCombatants: true }); ``` -------------------------------- ### Equip/Unequip on Set Change - JavaScript Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt Handles the automatic equipping and un-equipping of items when a weapon set is switched. It updates the `item.system.equipped` properties for items in both the previous and new sets to reflect their worn or held status. ```javascript // When switching weapon sets, automatically equip/unequip items await container.onSetSwitch(newSetIndex, newSetContainer); // Updates item.system.equipped for all items in both sets: // - Previous set items: carryType: 'worn', handsHeld: 0, inSlot: false // - New set items: carryType: 'held', handsHeld: 1|2, inSlot: true ``` -------------------------------- ### PF2eAdapter: Convert PF2e Items to Cell Data Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt This JavaScript code demonstrates the `transformItemToCellData` method of the `Pf2eAdapter` class. It converts Pathfinder 2nd Edition items into a standardized format suitable for the HUD's hotbar cells. The output includes essential item details like UUID, name, image, type, and usage information for consumables and spells. It specifically handles prepared spells by consolidating their usage data. ```javascript // Transform a PF2e item into hotbar cell data format const cellData = await adapter.transformItemToCellData(item); // Returns object with: // { // uuid: "Actor.xyz.Item.abc", // name: "Longsword", // img: "icons/weapons/swords/sword.png", // type: "Item", // uses: { value: 2, max: 3 }, // For prepared spells // depleted: false, // True if all uses expended // quantity: 5 // For consumables // } // Prepared spells return consolidated data with uses counter: const spellCellData = await adapter.transformItemToCellData(healSpell); // { // type: "Item", // uuid: "Actor.xyz.Item.heal", // entryId: "spellcasting-entry-id", // spellId: "heal-spell-id", // name: "Heal", // img: "icons/magic/heal.png", // uses: { value: 2, max: 3 }, // 2 of 3 preparations remaining // depleted: false // } ``` -------------------------------- ### Sort Items by PF2e Priority (JavaScript) Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt Extends the AutoSortFramework with PF2e-specific sorting rules. It first enriches items with sort data and then sorts them in place according to a defined priority order, including spells by rank and actions/feats by cost. Items of the same type are sorted alphabetically. ```javascript import { Pf2eAutoSort } from './features/Pf2eAutoSort.js'; const autoSort = new Pf2eAutoSort(); // Enrich items with sort data first await autoSort.enrichItemsForSort(items); // Sort items in place using PF2e priority rules await autoSort.sortItems(items); // Sort priority order: // 1. weapon // 2. melee // 3. action // 4. feat // 5. spell (sorted by rank: cantrips first, then 1-10) // 6. consumable // 7. ammo // 8. equipment // 9. armor // 10. shield // 11. backpack // Within same type: // - Spells: sorted by spell rank (cantrips = 0), then alphabetically // - Actions/Feats: sorted by action cost (1, 2, 3), then alphabetically // - Others: sorted alphabetically ``` -------------------------------- ### HP Input Controls - Description Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt Describes the special syntax supported by the HP input field for setting health values. This includes exact values, relative adjustments, and percentage-based settings, along with buttons for death and full heal. ```plaintext // HP input supports special syntax: // "=50" - Set HP to exactly 50 // "+10" - Add 10 HP // "-15" - Remove 15 HP // "50%" - Set HP to 50% of max // Death button: Sets HP and temp HP to 0 // Full heal button: Sets HP to max ``` -------------------------------- ### PF2eAdapter: Default Portrait Badge Configuration Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt This JavaScript code snippet shows how to retrieve the default configuration for portrait badge slots using the `getPortraitDataDefaults` method of the `Pf2eAdapter` class. This configuration defines the data paths, icons, and colors for various status indicators displayed on character portraits within the HUD. ```javascript // Returns default portrait data slot configuration for PF2e const defaults = adapter.getPortraitDataDefaults(); // Returns array of slot configurations: // [ // { path: 'system.attributes.ac.value', icon: 'fas fa-shield-alt', color: '#4a90d9' }, // { path: '{{system.resources.heroPoints.value}}/{{system.resources.heroPoints.max}}', icon: 'fas fa-star', color: '#f1c40f' }, // { path: '', icon: '', color: '#ffffff' }, // { path: '', icon: '', color: '#ffffff' }, // { path: 'system.attributes.speed.total', icon: 'fas fa-running', color: '#2ecc71' }, // { path: '', icon: '', color: '#ffffff' } // ] ``` -------------------------------- ### Calculate Item Range Information (JavaScript) Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt Calculates the effective range for an item, returning details like range in grid squares, feet, and whether it's a touch or self-targeting range. Handles standard and touch ranges. ```javascript import { calculateRange } from './utils/Pf2eTargetingRules.js'; // Calculate effective range for an item const rangeInfo = calculateRange({ item: spell, activity: null, actor: caster }); // Returns: // { // range: 12, // Range in grid squares (60ft / 5ft per square) // rangeInFeet: 60, // Original feet value // longRange: null, // PF2e doesn't use long range // units: 'ft', // isTouch: false, // isSelf: false, // isUnlimited: false // } // Touch range calculation const touchRange = calculateRange({ item: touchSpell }); // Returns: { range: 1, isTouch: true, rangeInFeet: 5 } ``` -------------------------------- ### Two-Handed Weapon Handling - JavaScript Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt Manages weapon sets, with specific logic for two-handed weapons. This includes occupying both weapon slots, displaying a faded duplicate, and locking the second slot to prevent accidental drops. It provides functions to check if a cell is locked and if a drop should be prevented. ```javascript import { createPf2eWeaponSetContainer } from './components/containers/Pf2eWeaponSetContainer.js'; const Pf2eWeaponSetContainer = await createPf2eWeaponSetContainer(); const container = new Pf2eWeaponSetContainer({ actor, token }); // Two-handed weapons automatically: // - Occupy both slots in a weapon set // - Show faded duplicate in second slot // - Lock second slot to prevent drops // Check if cell is locked (occupied by two-handed duplicate) const isLocked = container.isCellLocked(cell); // Prevent drops on locked cells const shouldPrevent = container.shouldPreventDrop(targetCell); // Returns true and shows warning notification if locked ``` -------------------------------- ### Decorate Cell Element with PF2e Data Attributes (JavaScript) Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt Adds PF2e-specific dataset attributes to a cell element for filtering purposes. Attributes include item type, action cost, traits, level, and spell IDs. ```javascript // Decorate a cell element with PF2e-specific dataset attributes for filtering await adapter.decorateCellElement(cellElement, cellData); // Adds dataset attributes: // - data-item-type="spell" // - data-action-cost="2" // - data-traits="fire,evocation" // - data-level="3" // - data-spell-id="abc123" // - data-spell-entry-id="xyz789" // - data-is-focus-spell="true" // - data-expended="true" (for depleted spells) ``` -------------------------------- ### Skill and Saving Throw Rolling (JavaScript) Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt Enables rolling for skills and saving throws using the PF2e API (v7.7.2+). Skills are identified by canonical IDs like 'athletics' or 'acrobatics', and saving throws by their type (e.g., 'fortitude'). The rolling action is typically triggered by a click event. ```javascript // Skills are clickable and roll using PF2e v7.7.2+ API // Uses canonical skill IDs: "athletics", "acrobatics", "arcana", etc. const skill = actor.skills.athletics; await skill.roll({ event: clickEvent }); // Saving throws work similarly: const save = actor.saves.fortitude; await save.roll({ event: clickEvent }); ``` -------------------------------- ### Update Health Display - JavaScript Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt Efficiently updates the health display elements without re-rendering the entire component. This includes the damage overlay, HP text, temporary HP display, and HP input field if not focused. ```javascript // Efficiently update health display when HP changes await portraitContainer.updateHealth(); // Updates: // - Damage overlay height (--damage-percent CSS variable) // - HP text label // - Temp HP display // - HP input field (if not focused) ``` -------------------------------- ### Check if Cell Matches Filter (JavaScript) Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt Determines if a given cell element matches the criteria of a specific filter. The matching logic considers focus spells, spell levels, item types, and action costs based on the cell's dataset attributes and the filter's data. ```javascript // Check if a cell element matches a filter's criteria const matches = filterContainer.matchesFilter(filter, cellElement); // Matching logic: // - Focus spells: cell.dataset.isFocusSpell === 'true' // - Spell level: cell.dataset.itemType === 'spell' && cell.dataset.level === filterLevel // - Item type: cell.dataset.itemType === filterItemType // - Action cost: cell.dataset.actionCost === filterActionCost ``` -------------------------------- ### Check if Item Requires Targeting (JavaScript) Source: https://context7.com/bragginrites/bg3-hud-pf2e/llms.txt Determines if a given item requires the target selector based on its traits and targeting behavior. It handles strikes, self-targeting items, and area spells. ```javascript import { needsTargeting } from './utils/Pf2eTargetingRules.js'; // Check if an item needs the target selector const requiresTarget = needsTargeting({ item: fireball, activity: null }); // Returns: true (has attack trait or targets creatures) // Strikes always need targeting const strikeNeedsTarget = needsTargeting({ item: weapon, activity: strike }); // Returns: true // Self-targeting items don't need selector const selfTarget = needsTargeting({ item: selfBuff }); // Returns: false // Area templates (emanation, burst, cone, line) don't need selector const areaSpell = needsTargeting({ item: fireball }); // Returns: false (uses template placement instead) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.