Skip to content

Commit 6448ea0

Browse files
authored
Updates to Item Piles system integration (#292)
* Updates to system integration * Added unstackable item types
1 parent 6cf617d commit 6448ea0

File tree

1 file changed

+52
-49
lines changed

1 file changed

+52
-49
lines changed

src/module/fvttModuleAPIs.js

+52-49
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,59 @@ export const registerFVTTModuleAPIs = () => {
22
// see docs for more info https://github.com/fantasycalendar/FoundryVTT-ItemPiles/blob/master/docs/api.md
33
Hooks.once("item-piles-ready", async function () {
44

5-
if(game.itempiles.API.ACTOR_CLASS_TYPE !== "character"){
6-
await game.itempiles.API.setActorClassType("character");
7-
}
8-
9-
if (game.itempiles.API.ITEM_QUANTITY_ATTRIBUTE !== "system.quantity.value") {
10-
await game.itempiles.API.setItemQuantityAttribute("system.quantity.value");
11-
}
12-
13-
if (game.itempiles.API.ITEM_PRICE_ATTRIBUTE !== "system.cost") {
14-
await game.itempiles.API.setItemPriceAttribute("system.cost");
15-
}
16-
17-
const filters = [{
18-
path: "type",
19-
filters: "spell,ability",
20-
}];
21-
if (JSON.stringify(game.itempiles.API.ITEM_FILTERS) !== JSON.stringify(filters)) {
22-
await game.itempiles.API.setItemFilters(filters);
23-
}
24-
25-
const similarities = ["type", "type"];
26-
if (JSON.stringify(game.itempiles.API.ITEM_SIMILARITIES) !== JSON.stringify(similarities)) {
27-
await game.itempiles.API.setItemSimilarities(similarities);
28-
}
29-
30-
const currencies = [{
31-
type: "item",
32-
name: "OSE.items.gp.long",
33-
img: "systems/ose/assets/gold.png",
34-
abbreviation: "{#}GP",
35-
data: {
36-
item: {
37-
"name": game.i18n.localize("OSE.items.gp.long"),
38-
"type": "item",
39-
"img": "systems/ose/assets/gold.png",
40-
"system": {
41-
"quantity": { "value": 1, "max": null },
42-
"weight": 0.1,
43-
"cost": 1,
44-
"treasure": true,
5+
game.itempiles.API.addSystemIntegration({
6+
7+
"VERSION": "1.0.0",
8+
9+
// The actor class type is the type of actor that will be used for the default item pile actor that is created on first item drop.
10+
"ACTOR_CLASS_TYPE": "character",
11+
12+
// The item quantity attribute is the path to the attribute on items that denote how many of that item that exists
13+
"ITEM_QUANTITY_ATTRIBUTE": "system.quantity.value",
14+
15+
// The item price attribute is the path to the attribute on each item that determine how much it costs
16+
"ITEM_PRICE_ATTRIBUTE": "system.cost",
17+
18+
// Item types and the filters actively remove items from the item pile inventory UI that users cannot loot, such as spells, feats, and classes
19+
"ITEM_FILTERS": [
20+
{
21+
"path": "type",
22+
"filters": "spell,ability"
23+
}
24+
],
25+
26+
"UNSTACKABLE_ITEM_TYPES": ["weapon", "armor", "container"],
27+
28+
// Item similarities determines how item piles detect similarities and differences in the system
29+
"ITEM_SIMILARITIES": ["name", "type", "system.treasure"],
30+
31+
// Currencies in item piles is a versatile system that can accept actor attributes (a number field on the actor's sheet) or items (actual items in their inventory)
32+
// In the case of attributes, the path is relative to the "actor.system"
33+
// In the case of items, it is recommended you export the item with `.toObject()` and strip out any module data
34+
"CURRENCIES": [
35+
{
36+
type: "item",
37+
name: "OSE.items.gp.long",
38+
img: "systems/ose/assets/gold.png",
39+
abbreviation: "{#}GP",
40+
data: {
41+
item: {
42+
"name": "Cold Coins",
43+
"type": "item",
44+
"img": "systems/ose/assets/gold.png",
45+
"system": {
46+
"quantity": { "value": 1, "max": null },
47+
"weight": 0.1,
48+
"cost": 1,
49+
"treasure": true,
50+
}
4551
}
46-
}
47-
},
48-
primary: true,
49-
exchangeRate: 1
50-
}];
51-
// Still allows people to customize their own currencies
52-
if (!game.itempiles.API.CURRENCIES.length) {
53-
await game.itempiles.API.setCurrencies(currencies);
54-
}
52+
},
53+
primary: true,
54+
exchangeRate: 1
55+
}
56+
]
57+
});
5558

5659
});
5760
};

0 commit comments

Comments
 (0)