Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with Foundry v12 & dnd5e v4 #22

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "character-actions-list-5e",
"title": "Character Actions List dnd5e",
"description": "Provides an Actions List Component",
"version": "7.1.1",
"version": "7.1.2",
"authors": [
{
"name": "Cameron East",
Expand Down Expand Up @@ -39,7 +39,7 @@
},
"compatibility": {
"minimum": 11,
"verified": 11.315
"verified": 12.331
},
"bugs": "https://github.com/eastcw/foundryvtt-dnd5eCharacterActions/issues",
"changelog": "https://github.com/eastcw/foundryvtt-dnd5eCharacterActions/releases",
Expand Down
8 changes: 5 additions & 3 deletions src/module/scripts/api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getActivationType, getGame, log, isActiveItem } from './helpers';
import { MODULE_ID, MyFlags, MySettings, damageTypeIconMap, ItemTypeSortValues } from './constants';
import { MODULE_ID, MyFlags, MySettings, damageTypeIconMap, ItemTypeSortValues, TEMPLATES } from './constants';

export function getActorActionsData(actor) {
const filteredItems = actor.items
Expand Down Expand Up @@ -130,14 +130,16 @@ export function isItemInActionList(item) {
*/
export function renderActionsList(actorData, options) {
const actionData = getActorActionsData(actorData);

log(false, 'renderActionsList', {
actorData,
options,
data: actionData,
});

if (options !== undefined) {
if (options.sheetVersion == 'actor-actions-list-v2') {
return renderTemplate(`modules/${MODULE_ID}/templates/actor-actions-list-v2.hbs`, {
return renderTemplate(TEMPLATES.actionListv2, {
actionData,
abilities: getGame().dnd5e.config.abilities.label,
activationTypes: {
Expand All @@ -154,7 +156,7 @@ export function renderActionsList(actorData, options) {
});
}
} else {
return renderTemplate(`modules/${MODULE_ID}/templates/actor-actions-list.hbs`, {
return renderTemplate(TEMPLATES.actionList, {
actionData,
abilities: getGame().dnd5e.config.abilities.label,
activationTypes: {
Expand Down
179 changes: 90 additions & 89 deletions src/templates/actor-actions-list-v2.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,107 +17,108 @@

<ol class="item-list unlist">
{{#each items as |item|}}
<li class="item context-enabled" data-item-id="{{item.id}}" data-entry-id="{{item.id}}" data-item-name="{{item.name}}" data-item-sort="0" data-ungrouped="all" data-grouped="{{item.type}}" draggable="true">

<div class="item-name item-action item-tooltip rollable" role="button" data-action="use" aria-label="{{item.name}}" data-tooltip="
<section class=&quot;loading&quot; data-uuid=&quot;Actor.{{actor.id}}.Item.{{item.id}}&quot;><i class=&quot;fas fa-spinner fa-spin-pulse&quot;></i></section>
" data-tooltip-class="dnd5e2 dnd5e-tooltip item-tooltip" data-tooltip-direction="LEFT">
<img class="item-image gold-icon" src="{{item.img}}" alt="{{item.name}}">
<div class="name name-stacked">
<span class="title">{{item.name}}</span>
<span class="subtitle">
{{#if (ne item.type 'spell')}}
{{item.labels.type}}
{{/if}}
{{#if (and (eq item.type 'spell') (ne item.system.level 0))}}
{{item.labels.level}} {{item.labels.school}}
{{else}}
{{item.labels.school}} {{item.labels.level}}
{{/if}}
</span>
</div>
</div>
<li class="item context-enabled" data-item-id="{{item.id}}" data-entry-id="{{item.id}}" data-item-name="{{item.name}}" data-item-sort="0" data-ungrouped="all" data-grouped="{{item.type}}">
<div class="item-row" draggable="true">
<div class="item-name item-action item-tooltip rollable" role="button" data-action="use" aria-label="{{item.name}}" data-tooltip="
<section class=&quot;loading&quot; data-uuid=&quot;Actor.{{actor.id}}.Item.{{item.id}}&quot;><i class=&quot;fas fa-spinner fa-spin-pulse&quot;></i></section>
" data-tooltip-class="dnd5e2 dnd5e-tooltip item-tooltip" data-tooltip-direction="LEFT">
<img class="item-image gold-icon" src="{{item.img}}" alt="{{item.name}}">
<div class="name name-stacked">
<span class="title">{{item.name}}</span>
<span class="subtitle">
{{#if (ne item.type 'spell')}}
{{item.labels.type}}
{{/if}}
{{#if (and (eq item.type 'spell') (ne item.system.level 0))}}
{{item.labels.level}} {{item.labels.school}}
{{else}}
{{item.labels.school}} {{item.labels.level}}
{{/if}}
</span>
</div>
</div>

<div class="item-detail item-uses" title="{{localize 'DND5E.Uses'}}">
{{#if (or item.system.recharge.value item.hasLimitedUses (eq item.system.activation.type "legendary"))}}
<div class="item-detail item-uses" title="{{localize 'DND5E.Uses'}}">
{{#if (or item.system.recharge.value item.hasLimitedUses (eq item.system.activation.type "legendary"))}}

{{#if (and item.system.recharge.charged item.system.recharge.value)}}
{{localize "DND5E.Charged"}}
{{else if item.system.recharge.value}}
<a class="item-recharge rollable">{{item.labels.recharge}}</a>
{{else if item.hasLimitedUses}}
{{#if (and (eq item.system.uses.value item.system.uses.max) item.system.uses.autoDestroy)}}
<span title='{{item.system.quantity}}'>{{item.system.quantity}}</span>
<small>{{localize "DND5E.Quantity"}}</small>
{{else}}
<span>
{{item.system.uses.value}} / {{item.system.uses.max}}
</span>
{{#if (and item.system.recharge.charged item.system.recharge.value)}}
{{localize "DND5E.Charged"}}
{{else if item.system.recharge.value}}
<a class="item-recharge rollable">{{item.labels.recharge}}</a>
{{else if item.hasLimitedUses}}
{{#if (and (eq item.system.uses.value item.system.uses.max) item.system.uses.autoDestroy)}}
<span title='{{item.system.quantity}}'>{{item.system.quantity}}</span>
<small>{{localize "DND5E.Quantity"}}</small>
{{else}}
<span>
{{item.system.uses.value}} / {{item.system.uses.max}}
</span>
{{/if}}
{{/if}}
{{#if (eq item.system.activation.type 'legendary')}}
{{item.system.activation.cost}}
{{/if}}
{{/if}}
{{#if (eq item.system.activation.type 'legendary')}}
{{item.system.activation.cost}}
</div>

<div class="item-header item-usage">
{{#if (eq system.activation.type "action")}}
{{system.activation.cost}} A
{{else if (eq system.activation.type "bonus")}}
{{system.activation.cost}} BA
{{else if (eq system.activation.type "reaction")}}
{{system.activation.cost}} R
{{else if (eq system.activation.type "special")}}
S
{{else}}
{{system.activation.cost}} {{system.activation.type}}
{{/if}}
{{/if}}
</div>
</div>

<div class="item-header item-usage">
{{#if (eq system.activation.type "action")}}
{{system.activation.cost}} A
{{else if (eq system.activation.type "bonus")}}
{{system.activation.cost}} BA
{{else if (eq system.activation.type "reaction")}}
{{system.activation.cost}} R
{{else if (eq system.activation.type "special")}}
S
{{else}}
{{system.activation.cost}} {{system.activation.type}}
{{/if}}
</div>
<div class="item-detail item-range name-stacked">
{{#if (eq system.target.type 'self')}}
<span title="{{labels.target}}">{{labels.target}}</span>
{{else}}
<span title="{{labels.range}}">
<span class="value">{{item.system.range.value}}</span>
<span class="units">{{item.system.range.units}}</span>
</span>
{{#if labels.target}}
<small title="{{labels.target}}">
{{labels.target}}
</small>
{{/if}}
{{/if}}
</div>

<div class="item-detail item-range name-stacked">
{{#if (eq system.target.type 'self')}}
<span title="{{labels.target}}">{{labels.target}}</span>
{{else}}
<span title="{{labels.range}}">
<span class="value">{{item.system.range.value}}</span>
<span class="units">{{item.system.range.units}}</span>
</span>
{{#if labels.target}}
<small title="{{labels.target}}">
{{labels.target}}
</small>
<div class="item-detail item-roll">
{{#if item.hasAttack}}
<span title="{{labels.toHit}}">{{labels.toHit}}</span>
{{/if}}
{{/if}}
</div>
{{#if item.hasSave}}
<div class="stacked">
<span class="ability">{{item.system.save.ability}}</span>
<span class="value">{{item.system.save.dc}}</span>
</div>
{{/if}}
</div>

<div class="item-detail item-roll">
{{#if item.hasAttack}}
<span title="{{labels.toHit}}">{{labels.toHit}}</span>
{{/if}}
{{#if item.hasSave}}
<div class="stacked">
<span class="ability">{{item.system.save.ability}}</span>
<span class="value">{{item.system.save.dc}}</span>
<div class="item-detail item-uses">
{{#each labels.derivedDamage}}
<p title="{{#if label}}{{label}}{{else}}{{formula}} {{lookup @root/damageTypes
damageType}}{{/if}}">
{{formula}} <span>{{{lookup @root/damageTypeIconMap
damageType}}}</span>
</p>
{{/each}}
</div>

{{#if @root/isOwner}}
<div class="item-detail item-controls">
{{!-- Control is Injected in handleFavoriteControls.ts --}}
</div>
{{/if}}
</div>

<div class="item-detail item-uses">
{{#each labels.derivedDamage}}
<p title="{{#if label}}{{label}}{{else}}{{formula}} {{lookup @root/damageTypes
damageType}}{{/if}}">
{{formula}} <span>{{{lookup @root/damageTypeIconMap
damageType}}}</span>
</p>
{{/each}}
</div>

{{#if @root/isOwner}}
<div class="item-detail item-controls">
{{!-- Control is Injected in handleFavoriteControls.ts --}}
</div>
{{/if}}
</li>
{{/each}}
</ol>
Expand Down