Skip to content

Commit

Permalink
Merge pull request #541 from mrstarbuck007/shadowdark
Browse files Browse the repository at this point in the history
Shadowdark system
  • Loading branch information
Haxxer authored Mar 23, 2024
2 parents 159bd97 + 225458e commit 645dcd6
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ dist/*
.vite-cache/*
module.js
module.js.map
style.css
style.css
*.iml
4 changes: 4 additions & 0 deletions src/systems.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import wfrp4e from "./systems/wfrp4e.js";
import splittermond from "./systems/splittermond.js";
import forbiddenLands from "./systems/forbidden-lands.js";
import icrpg from "./systems/icrpg.js";
import shadowdark from "./systems/shadowdark.js";
import swse from "./systems/swse.js";
import sw5e from "./systems/sw5e.js";
import sw5e203 from "./systems/sw5e-2.0.3.2.3.8.js";
Expand Down Expand Up @@ -155,6 +156,9 @@ export const SYSTEMS = {
"demonlord": {
"latest": demonlord
},
"shadowdark": {
"latest": shadowdark
},
// ↑ ADD SYSTEMS HERE ↑
},

Expand Down
82 changes: 82 additions & 0 deletions src/systems/shadowdark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
export default {

"VERSION": "1.0.2",

// 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.
"ACTOR_CLASS_TYPE": "Player",

// The item quantity attribute is the path to the attribute on items that denote how many of that item that exists
"ITEM_QUANTITY_ATTRIBUTE": "system.quantity",

// Item filters actively remove items from the item pile inventory UI that users cannot loot, such as spells, feats, and classes
"ITEM_FILTERS": [
{
"path": "type",
"filters": "Ancestry,Background,Boon,Class Ability,Class,Deity,Effect,Language,NPC Attack,NPC Special Attack,NPC Spell,NPC Feature,Property,Spell,Talent"
},
],

// Item similarities determines how item piles detect similarities and differences in the system
"ITEM_SIMILARITIES": ["name", "type"],

// 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)
// In the case of attributes, the path is relative to the "actor.system"
// In the case of items, it is recommended you export the item with `.toObject()` and strip out any module data
"CURRENCIES": [
{
"type": "attribute",
"name": "Gold Pieces",
"img": "icons/commodities/currency/coin-embossed-crown-gold.webp",
"abbreviation": "{#}GP",
"data": {
"path": "system.coins.gp",
},
"primary": true,
"exchangeRate": 1
},
{
"type": "attribute",
"name": "Silver Pieces",
"img": "icons/commodities/currency/coin-engraved-moon-silver.webp",
"abbreviation": "{#}SP",
"data": {
"path": "system.coins.sp",
},
"primary": false,
"exchangeRate": 0.1
},
{
"type": "attribute",
"name": "Copper Pieces",
"img": "icons/commodities/currency/coin-engraved-waves-copper.webp",
"abbreviation": "{#}CP",
"data": {
"path": "system.coins.cp",
},
"primary": false,
"exchangeRate": 0.01
}
],

// This function is an optional system handler that specifically transforms an item's price into a more unified numeric format
"ITEM_COST_TRANSFORMER": (item, currencies) => {
const cost = getProperty(item, "system.cost") ?? {};
let totalCost = 0;
for (const costDenomination in cost) {
const subCost = Number(getProperty(cost, costDenomination)) ?? 0;
if (subCost === 0) {
continue;
}

const currencyDenomination = currencies
.filter(currency => currency.type === "attribute")
.find(currency => {
return currency.data.path.toLowerCase().endsWith(costDenomination);
});

totalCost += subCost * currencyDenomination?.exchangeRate ?? 0;
}

return totalCost;
}
}

0 comments on commit 645dcd6

Please sign in to comment.