Skip to content

Commit

Permalink
Updated API, fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Haxxer committed Jan 17, 2022
1 parent 951973f commit 734f626
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Item Piles Changelog

## Version 1.2.4 Hotfix
- Fixed error in `ItemPiles.API.addItems` throwing errors
- Fixed D&D 3.5e system not correctly implemented

## Version 1.2.3
- Added API method:
- `ItemPiles.API.openItemPileInventory` - forces a given set of users to open an item pile's inventory UI
Expand Down
8 changes: 4 additions & 4 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ ItemPiles.API.revertTokensFromItemPiles(selectedTokens);
<dt><a href="#createItemPile">createItemPile(position, { items, pileActorName })</a> ⇒ <code>Promise</code></dt>
<dd><p>Creates the default item pile token at a location.</p>
</dd>
<dt><a href="#turnTokensIntoItemPiles">turnTokensIntoItemPiles(targets, pileSettings, tokenSettings)</a> ⇒ <code>Promise.&lt;Array&gt;</code></dt>
<dt><a href="#turnTokensIntoItemPiles">turnTokensIntoItemPiles(targets, { pileSettings, tokenSettings })</a> ⇒ <code>Promise.&lt;Array&gt;</code></dt>
<dd><p>Turns tokens and its actors into item piles</p>
</dd>
<dt><a href="#revertTokensFromItemPiles">revertTokensFromItemPiles(targets, tokenSettings)</a> ⇒ <code>Promise.&lt;Array&gt;</code></dt>
<dt><a href="#revertTokensFromItemPiles">revertTokensFromItemPiles(targets, { tokenSettings })</a> ⇒ <code>Promise.&lt;Array&gt;</code></dt>
<dd><p>Reverts tokens from an item pile into a normal token and actor</p>
</dd>
<dt><a href="#openItemPile">openItemPile(target, interactingToken)</a> ⇒ <code>Promise</code></dt>
Expand Down Expand Up @@ -265,7 +265,7 @@ Creates the default item pile token at a location.

---

## turnTokensIntoItemPiles(targets, pileSettings, tokenSettings) ⇒ <code>Promise.&lt;Array&gt;</code>
## turnTokensIntoItemPiles(targets, { pileSettings, tokenSettings }) ⇒ <code>Promise.&lt;Array&gt;</code>
Turns tokens and its actors into item piles
**Returns**: <code>Promise.&lt;Array&gt;</code> - The uuids of the targets after they were turned into item piles

Expand All @@ -279,7 +279,7 @@ Turns tokens and its actors into item piles

---

## revertTokensFromItemPiles(targets, tokenSettings) ⇒ <code>Promise.&lt;Array&gt;</code>
## revertTokensFromItemPiles(targets, { tokenSettings }) ⇒ <code>Promise.&lt;Array&gt;</code>
Reverts tokens from an item pile into a normal token and actor
**Returns**: <code>Promise.&lt;Array&gt;</code> - The uuids of the targets after they were reverted from being item piles

Expand Down
8 changes: 5 additions & 3 deletions scripts/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ export default class API {
"scale": lib.getItemPileTokenScale(target, pileSettings),
});

const [_, sceneId, __, tokenId] = targetUuid.split('.');
const sceneId = targetUuid.split('.')[1];
const tokenId = targetUuid.split('.')[3];

if (!tokenUpdateGroups[sceneId]) {
tokenUpdateGroups[sceneId] = []
Expand Down Expand Up @@ -293,7 +294,8 @@ export default class API {
const pileSettings = foundry.utils.mergeObject(defaults, lib.getItemPileData(target));
pileSettings.enabled = false;

const [_, sceneId, __, tokenId] = targetUuid.split('.');
const sceneId = targetUuid.split('.')[1];
const tokenId = targetUuid.split('.')[3];

if (!tokenUpdateGroups[sceneId]) {
tokenUpdateGroups[sceneId] = [];
Expand Down Expand Up @@ -865,7 +867,7 @@ export default class API {
}
return {
item: item,
quantity: itemData?.quantity ?? getProperty(foundActorItem.data, API.ITEM_QUANTITY_ATTRIBUTE)
quantity: itemData?.quantity ?? getProperty(item.data, API.ITEM_QUANTITY_ATTRIBUTE)
}
});

Expand Down
2 changes: 1 addition & 1 deletion scripts/systems.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import dnd5e from "./systems/dnd5e.js";
// ↓ IMPORT SYSTEMS HERE ↓
import pf1 from "./systems/pf1.js";
import ds4 from "./systems/ds4.js";
import d35e from "./systems/ds4.js";
import d35e from "./systems/d35e.js";
import swade from "./systems/swade.js";
import tormenta20 from "./systems/tormenta20.js";
// ↑ IMPORT SYSTEMS HERE ↑
Expand Down

0 comments on commit 734f626

Please sign in to comment.