Skip to content

Commit

Permalink
refactor(v12): changed some functions with foundry.utils and system.j…
Browse files Browse the repository at this point in the history
…son, removed handlebars errors

Now mergeObject is foundry.utils.mergeObject, Math.clamped is Math.clamp, {{editor content=... is
{{editor ...
  • Loading branch information
SouOWendel committed May 22, 2024
1 parent 44675c2 commit 2bea2ce
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions module/documents/actor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,14 @@ export class OrdemActor extends Actor {
spaces.value += spaces.bonus.value;
spaces.max += spaces.bonus.max;

spaces.pct = Math.clamped((spaces.value * 100) / spaces.max, 0, 100);
spaces.pct = Math.clamp((spaces.value * 100) / spaces.max, 0, 100);

// Apply the debuffs
if (spaces.value > spaces.max) {
spaces.over = spaces.value - spaces.max;
system.desloc.value += -3;
system.defense.value += -5;
spaces.pctMax = Math.clamped((spaces.over * 100) / spaces.max, 0, 100);
spaces.pctMax = Math.clamp((spaces.over * 100) / spaces.max, 0, 100);
}
if (spaces.value > spaces.max * 2) ui.notifications.warn(game.i18n.localize('WARN.overWeight'));
}
Expand Down
10 changes: 6 additions & 4 deletions module/sheets/actor-sheet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,11 @@ export class OrdemActorSheet extends ActorSheet {

// Render the item sheet for viewing/editing prior to the editable check.
html.find('.item-edit').click((ev) => {
const li = $(ev.currentTarget).parents('.item');
const item = this.actor.items.get(li.data('itemId'));
item.sheet.render(true);
ev.preventDefault();
ev.stopPropagation();
const liItemId = ev.currentTarget.closest('[data-item-id]')?.dataset.itemId;
const item = this.actor.items.get(liItemId);
item?.sheet.render(true);
});

// -------------------------------------------------------------
Expand Down Expand Up @@ -251,7 +253,7 @@ export class OrdemActorSheet extends ActorSheet {
// Get the type of item to create.
const type = header.dataset.type;
// Grab any data associated with this control.
const data = duplicate(header.dataset);
const data = foundry.utils.duplicate(header.dataset);
// Initialize a default name.
const name = game.i18n.localize('ordemparanormal.newItem') + ' ' + game.i18n.localize('TYPES.Item.' + type);
// Prepare the item object.
Expand Down
4 changes: 2 additions & 2 deletions module/sheets/item-sheet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import {
export class OrdemItemSheet extends ItemSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ['ordemparanormal', 'sheet', 'item'],
width: 540,
height: 440,
template: 'systems/ordemparanormal/templates/itemn/item-sheet.html',
template: 'systems/ordemparanormal/templates/item/item-sheet.html',
tabs: [
{
navSelector: '.sheet-tabs',
Expand Down
6 changes: 3 additions & 3 deletions system.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"compatibility": {
"minimum": "11",
"verified": "11.315",
"maximum": "11"
"maximum": "12"
},
"authors": [
{
Expand Down Expand Up @@ -280,8 +280,8 @@
]
}
},
"gridDistance": 1.5,
"gridUnits": "m",
"grid.distance": 1.5,
"grid.units": "m",
"primaryTokenAttribute": "PV",
"secondaryTokenAttribute": "SAN",
"url": "https://github.com/SouOWendel/ordemparanormal-fvtt",
Expand Down
2 changes: 1 addition & 1 deletion templates/actor/actor-agent-sheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ <h1 class="charname">
<div class="resource-content flexrow flex-center flex-between">
{{#if system.class }}
<select name="system.trilha" data-dtype="String">
{{ selectOptions (concatObjAndStr optionTrilhas system.class) selected=system.trilha nameAttr="name"
{{ selectOptions (concatObjAndStr optionTrilhas system.class) selected=system.trilha valueAttr="name"
labelAttr="label" blank="—" localize=true }}
</select>
{{else}}
Expand Down
2 changes: 1 addition & 1 deletion templates/item/item-ability-sheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h1 class="charname"><input name="name" type="text" value="{{item.name}}" placeh
<section class="sheet-body">
{{!-- Description Tab --}}
<div class="tab description" data-group="primary" data-tab="description">
{{editor content=system.description target="system.description" rollData=rollData button=true owner=owner
{{editor system.description target="system.description" rollData=rollData button=true owner=owner
editable=editable}}
</div>

Expand Down
2 changes: 1 addition & 1 deletion templates/item/item-armament-sheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h1 class="charname"><input name="name" type="text" value="{{item.name}}" placeh
{{!-- Description Tab --}}
<div class="tab description" data-group="primary" data-tab="description">
{{!-- To render inline rolls in a TinyMCE editor, you need to pass the parent actor's (if any) roll data to the rollData prop. --}}
{{editor content=system.description target="system.description" rollData=rollData button=true owner=owner editable=editable}}
{{editor system.description target="system.description" rollData=rollData button=true owner=owner editable=editable}}
</div>

{{!-- Specifications Tab --}}
Expand Down
2 changes: 1 addition & 1 deletion templates/item/item-generalEquipment-sheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h1 class="charname"><input name="name" type="text" value="{{item.name}}" placeh
{{!-- Description Tab --}}
<div class="tab" data-group="primary" data-tab="description">
{{!-- To render inline rolls in a TinyMCE editor, you need to pass the parent actor's (if any) roll data to the rollData prop. --}}
{{editor content=system.description target="system.description" rollData=rollData button=true owner=owner editable=editable}}
{{editor system.description target="system.description" rollData=rollData button=true owner=owner editable=editable}}
</div>

{{!-- Attributes Tab --}}
Expand Down
2 changes: 1 addition & 1 deletion templates/item/item-protection-sheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h1 class="charname"><input name="name" type="text" value="{{item.name}}" placeh
{{!-- Description Tab --}}
<div class="tab" data-group="primary" data-tab="description">
{{!-- To render inline rolls in a TinyMCE editor, you need to pass the parent actor's (if any) roll data to the rollData prop. --}}
{{editor content=system.description target="system.description" rollData=rollData button=true owner=owner editable=editable}}
{{editor system.description target="system.description" rollData=rollData button=true owner=owner editable=editable}}
</div>

{{!-- Attributes Tab --}}
Expand Down

0 comments on commit 2bea2ce

Please sign in to comment.