Skip to content

p4535992/foundryvtt-character-actions-dnd5e

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

98 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Character Actions 5e Variant

Latest Release Download Count Forge Installs Foundry Hub Endorsements Foundry Hub Comments

Foundry Core Compatible Version Manifest+ Version

ko-fi patreon

THIS MODULE IS A VARIANT VERSION OF THE Character Actions 5e

This module provides a placeable reusable "component" which details all of the actions a given Character Actor can take, intending to replicate the list in the Actions Tab of the D&DBeyond character sheet. The module has two ways in which it can be used: it will either inject the actions tab itself, or another module can leverage the API it provides and use that to inject the proper HTML wherever it desires.

What is variant ?

The original author expressed doubts about accepting PR on this because the changes on the code are many and would require many checks, but upgrading the system to 2.1.X forced my hand and o decided to create a variant module of the original one for private use anyone can use it if they find it useful. Below are the differences

  • Update typescript and all that goes with it (for example replace getGame() with standard game)
  • restructured the code to comply with the standard "languages", "scripts", "assests", "lib" folders from https://github.com/League-of-Foundry-Developers/FoundryVTT-Module-Template
  • all functions related to the API have been transferred to the file "api.ts" and reachable on game.modules.get('character-actions-list-5e').api
  • For retrocompatibility issue i still use the original module id so be aware
  • There is a better css compatibility with the orrible Tidy5e Sheet...

I think I could have done the job better, but let me know what you think.

preview

Known Issues

  • Using an item which changes charges or spell slots on any sheet that does not natively implement CharacterActions causes the tab to change.

List Features

By default the list will attempt to narrow down your active abilities, items, and spells into the ones most likely to be useful in Combat. The full logic for the filter is in isItemInActionList inside src/modules/helpers.ts. Here are the basics:

For Weapons:

  • Is it equipped?

For Equipment:

  • Does it have an activation cost (excluding anything that takes longer than a minute or none) and is it equipped?

For Consumables:

  • If the "Include Consumables" setting is set, does it have an activation cost (excluding anything that takes longer than a minute or none)?

For Spells:

  • If the spell needs to be prepared but isn't, exclude it.
  • Does it do damage (or healing)?
  • Does it have an activation cost of 1 reaction or 1 bonus action?
  • If the "Include Minute-long Spells" setting is set, does it have a duration of up to 1 minute (1 round - 1 minute)?
  • If the "Include Spells With Effects" setting is set, does the spell have any active effects?

For Features:

  • Does it have an activation cost (excluding anything that takes longer than a minute or none)?

Additionally, you can override the default list by selectively including or excluding items by toggling the little Fist in item controls.

Installation

Module JSON:

https://github.com/p4535992/foundryvtt-character-actions-dnd5e/releases/latest/download/module.json

Options

Name Description
Limit Actions to Cantrips Instead of showing all spells that deal damage in the Actions list, limit it to only cantrips. This is the default D&DBeyond behavior.
Include Minute-long Spells as Actions Include spells with a duration of one minute or less (e.g. 1 round) and an activation time of 1 Action or 1 Bonus Action (e.g. Bless, Bane, Command) in the Actions tab/panel by default.
Include Spells with Active Effects as Actions Include spells with active effects attached (e.g. Barkskin) in the Actions tab/panel by default.
Include Consumables as Actions Include consumables which have an activation cost (Action, Bonus Action, etc) in the Actions list by default.
Inject Character Actions List Should this module inject an Actions List into the default character sheet? Note that if you are using a sheet module which integrates the actions list on its own, this will not affect that sheet.
Inject NPC Actions List Should this module inject an Actions List into the default npc sheet? Note that if you are using a sheet module which integrates the actions list on its own, this will not affect that sheet.
Inject Vehicle Actions List Should this module inject an Actions List into the default vehicle sheet? Note that if you are using a sheet module which integrates the actions list on its own, this will not affect that sheet.

API

After the hook CharacterActions5eReady is fired, the following api methods are expected to be available in the game.modules entry for this module: game.modules.get('character-actions-list-5e').api:

async renderActionsList(actorData: Actor5eCharacter, appId: number): HTMLElement

Returns the output of renderTemplate (an HTMLElement) after getting the provided actor's action data. This can then be injected wherever in your own DOM.

Example

class MyCoolCharacterSheet extends ActorSheet5e {

  // other stuff your sheet module does...

  async _renderInner(...args) {
    const html = await super._renderInner(...args);
    const actionsListApi = game.modules.get('character-actions-list-5e').api;

    try {
      const actionsTab = html.find('.actions');

      const actionsTabHtml = $(await actionsListApi.renderActionsList(this.actor));
      actionsTab.html(actionsTabHtml);
    } catch (e) {
      log(true, e);
    }

    return html;
  }
}

isItemInActionList(item: Item5e): boolean

A handlebars helper is provided as well in case any sheet wants an easy way to check if an Item being rendered is expected to be part of the Actions List. character-actions-list-5e-isItemInActionList is a simple wrapper around isItemInActionList, it expects the same argument of an item instance.

Example

class MyCoolItemSheet extends ItemSheet5e {

  // other stuff your sheet module does...

  getData() {
    // const data = { someOtherStuff };
    const actionsListApi = game.modules.get('character-actions-list-5e').api;

    try {
      data.isInActionList = actionsListApi.isItemInActionList(this.item);
    } catch (e) {
      log(true, e);
    }

    return data;
  }
}

getActorActionsData(actor: Actor5e): ActorActionsList

type ActorActionsList = Record<
  'action' | 'bonus' | 'crew' | 'lair' | 'legendary' | 'reaction' | 'other',
  Set<Partial<Item5e>>
>

When passed an actor, returns the actor's 'actions list' items organized by activation type. I'm not sure why but it seems some of the information is missing from the Item5e in this list, be wary of that if you are looking to use this in another module.

Handlebars Helper: character-actions-list-5e-isItemInActionList

A handlebars helper is provided as well in case any sheet wants an easy way to check if an Item being rendered is expected to be part of the Actions List. character-actions-list-5e-isItemInActionList is a simple wrapper around isItemInActionList, it expects the same argument of an item instance.

Example

{{#each items as |item|}}
  {{!-- other stuff --}}
  {{#if (character-actions-list-5e-isItemInActionList item)}}Action{{/if}}
{{/each}}

Blocking the default Injection

If a sheet module wants to specifically block the injection of the actions tab without implementing the actions list itself, add blockActionsTab to the options being passed to the FormApplication class.

Note: that by default, the actions tab will only inject itself if no DOM element with the class .character-actions-list-5e exists in the Application being rendered.

Example

// class SomeAwesomeSheet extends SomeActorSheetClass {
  // ...
  // get defaultOptions() {
    // return mergeObject(super.defaultOptions, {
      blockActionsTab: true,
    // ...

This will cause the Actions Tab's auto injection to stop before any DOM is injected.

Compatibility

I'm honestly not sure how well this will play with modules that affect character sheets or dice rolls, I'll try to test as many as possible but if something is obviously breaking please create and issue here and I'll see what I can do.

Name Works Notes
Better Rolls 5e βœ… Compatible with version 1.3.7+.
Midi-QOL βœ… Works as expected.
Minimal Roll Enhancements βœ… Works as expected.
Mars 5e βœ… Works as expected.
FoundryVTT Magic Items 🀷 Spells assigned to magic items do not appear in the Actions List.
Inventory+ βœ… Inventory+ organization has no effect on Actions Tab

Build

Install all packages

npm install

npm build scripts

build

will build the code and copy all necessary assets into the dist folder and make a symlink to install the result into your foundry data; create a foundryconfig.json file with your Foundry Data path.

{
  "dataPath": "~/.local/share/FoundryVTT/"
}

build will build and set up a symlink between dist and your dataPath.

npm run-script build

NOTE:

You don't need to build the foundryconfig.json file you can just copy the content of the dist folder on the module folder under modules of Foundry

build:watch

build:watch will build and watch for changes, rebuilding automatically.

npm run-script build:watch

clean

clean will remove all contents in the dist folder (but keeps the link from build:install).

npm run-script clean

prettier-format

prettier-format launch the prettier plugin based on the configuration here

npm run-script prettier-format

package

package generates a zip file containing the contents of the dist folder generated previously with the build command. Useful for those who want to manually load the module or want to create their own release

npm run-script package

Issues

Any issues, bugs, or feature requests are always welcome to be reported directly to the Issue Tracker, or using the Bug Reporter Module.

Acknowledgements

Bootstrapped with Nick East's create-foundry-project.

Mad props to the League of Extraordinary FoundryVTT Developers community which helped me figure out a lot.

About

Provides a Template and data aggregator for dnd5e Character Actor Actions

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 44.1%
  • TypeScript 41.2%
  • Handlebars 7.8%
  • SCSS 6.9%