Skip to content

Commit

Permalink
closes #924
Browse files Browse the repository at this point in the history
  • Loading branch information
Muttley committed Nov 3, 2024
1 parent 3106c3d commit a1d8f98
Show file tree
Hide file tree
Showing 14 changed files with 326 additions and 235 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- Settings for compendium art mapping are now found in *Settings > Core > Compendium Art*

* [#917] Restructure Item sheet templates to make them a bit more manageable
* [#924] Perform an audit of existing templates to ensure we don't have any raw strings that should be i18n-ified
* [#927] Migration runner accessing globalThis.duplicate which must now be accessed via foundry.utils.duplicate
* [#928] Migrate "Deities" to new "Patrons and Deities" compendium
* [#929] Merged Russian language updates from Crowdin
Expand Down
8 changes: 8 additions & 0 deletions i18n/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,14 @@ SHADOWDARK.sheet.player.class.label: Class
SHADOWDARK.sheet.player.class.tooltip: Your character's job
SHADOWDARK.sheet.player.deity.label: Deity
SHADOWDARK.sheet.player.deity.tooltip: Your character’s cosmic link to the opposing forces of Law and Chaos, or balanced Neutrality.
SHADOWDARK.sheet.player.inventory.gear.label: Gear
SHADOWDARK.sheet.player.inventory.items.label: Items
SHADOWDARK.sheet.player.inventory.quantity_short.label: Qty
SHADOWDARK.sheet.player.inventory.slots.label: Slots
SHADOWDARK.sheet.player.inventory.stashed_item.label: Stashed Item
SHADOWDARK.sheet.player.inventory.treasure.label: Treasure
SHADOWDARK.sheet.player.inventory.type.label: Type
SHADOWDARK.sheet.player.inventory.value.label: Value
SHADOWDARK.sheet.player.languages: Languages
SHADOWDARK.sheet.player.luck: Luck
SHADOWDARK.sheet.player.melee_attacks: Melee Attacks
Expand Down
6 changes: 4 additions & 2 deletions system/src/documents/CompendiumsSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ export default class CompendiumsSD {
}

static async ammunition(filterSources=true) {
const documents =
await CompendiumsSD._documents("Item", "Basic", filterSources);
const documents = shadowdark.utils.combineCollection(
await CompendiumsSD._documents("Item", "Basic", filterSources),
await CompendiumsSD._documents("Item", "Weapon", filterSources)
);

return this._collectionFromArray(
documents.filter(document => document.system.isAmmunition)
Expand Down
7 changes: 6 additions & 1 deletion system/src/sheets/PlayerSheetSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -841,8 +841,13 @@ export default class PlayerSheetSD extends ActorSheetSD {
const freeCarrySeen = {};

for (const i of this._sortAllItems(context)) {
i.uuid = `Actor.${this.actor._id}.Item.${i._id}`;

if (i.system.isPhysical && i.type !== "Gem") {
i.showQuantity = i.system.slots.per_slot > 1 ? true : false;
i.showQuantity =
i.system.isAmmunition || i.system.slots.per_slot > 1
? true
: false;

// We calculate how many slots are used by this item, taking
// into account the quantity and any free items.
Expand Down
5 changes: 5 additions & 0 deletions system/src/templates.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ export default function() {
"systems/shadowdark/templates/actors/player/details/title.hbs",
"systems/shadowdark/templates/actors/player/details/xp.hbs",
"systems/shadowdark/templates/actors/player/inventory.hbs",
"systems/shadowdark/templates/actors/player/inventory/carried-gear.hbs",
"systems/shadowdark/templates/actors/player/inventory/coins.hbs",
"systems/shadowdark/templates/actors/player/inventory/equipped-gear.hbs",
"systems/shadowdark/templates/actors/player/inventory/gems.hbs",
"systems/shadowdark/templates/actors/player/inventory/item.hbs",
"systems/shadowdark/templates/actors/player/inventory/slots.hbs",
"systems/shadowdark/templates/actors/player/inventory/stashed-gear.hbs",
"systems/shadowdark/templates/actors/player/inventory/treasure.hbs",
"systems/shadowdark/templates/actors/player/notes.hbs",
"systems/shadowdark/templates/actors/player/spells.hbs",
"systems/shadowdark/templates/actors/player/talents.hbs",
Expand Down
13 changes: 13 additions & 0 deletions system/src/utils/UtilitySD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,19 @@ export default class UtilitySD {
return itemList;
}

static combineCollection(map1, map2) {
map2.forEach(value => {
if (map1.has(value._id)) {
shadowdark.warn(`Map already contains an item with key ${key}`);
}
else {
map1.set(value._id, value);
}
});

return map1;
}

// If this is a new release, show the release notes to the GM the first time
// they login
static async showNewReleaseNotes() {
Expand Down
3 changes: 2 additions & 1 deletion system/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
"sp": 0
},
"equipped": false,
"isAmmunition": false,
"isPhysical": true,
"magicItem": false,
"quantity": 1,
Expand Down Expand Up @@ -257,7 +258,6 @@
"lightSource",
"physical"
],
"isAmmunition": false,
"scroll": false,
"treasure": false
},
Expand Down Expand Up @@ -535,6 +535,7 @@
"oneHanded": "",
"twoHanded": ""
},

"properties": [],
"range": "close",
"type": "melee",
Expand Down
235 changes: 4 additions & 231 deletions system/templates/actors/player/inventory.hbs
Original file line number Diff line number Diff line change
@@ -1,238 +1,11 @@
<section class="tab tab-inventory" data-group="primary" data-tab="tab-inventory">
<div class="inventory-grid">
<div>

<!--Equipped Gear-->
<div class="SD-banner">{{localize "SHADOWDARK.inventory.equipped_gear"}}</div>
<ol class="SD-list item-list">
<li class="header">
<div class="item-name">Gear</div>
<div class="quantity">Qty</div>
<div class="slots">Slots</div>
<div class="actions"></div>
</li>

{{#each inventory.equipped as |item|}}
<li class="item" data-item-id="{{item._id}}" data-uuid="Actor.{{../actor._id}}.Item.{{item._id}}">
<div class="item-image" style="background-image: url({{item.img}})">
<i class="fas fa-comment fa-lg"></i>
</div>
<a class="item-name" data-action="show-details">
{{item.name}}
</a>
<div class="quantity"></div>
<div class="slots">{{item.slotsUsed}}</div>
<div class="actions">
<a
data-action="toggle-equipped"
data-item-id="{{item._id}}"
data-tooltip="{{localize 'SHADOWDARK.inventory.tooltip.toggle_equipped'}}"
>
<i style="color:var(--primary);" class="fas fa-user-shield"></i>
</a>
</div>
</li>
{{/each}}
</ol>

<br>

<!--Carried Gear-->
<div class="SD-banner">{{localize "SHADOWDARK.inventory.carried_gear"}}</div>
<ol class="SD-list item-list">
<li class="header">
<div class="item-name">
<a
class="fa-solid fa-square-plus"
style="margin:0px 8px 0px 4px"
data-action="create-item"
></a>
Items
</div>
<div class="quantity">Qty</div>
<div class="slots">Slots</div>
<div class="actions"></div>
</li>

{{#each inventory.carried as |item|}}
<li class="item" data-item-id="{{item._id}}" data-uuid="Actor.{{../actor._id}}.Item.{{item._id}}">
<div class="item-image" style="background-image: url({{item.img}})">
<i class="fas fa-comment fa-lg"></i>
</div>
<a
class="item-name"
data-action="show-details"
>
{{item.name}}
{{#if item.lightSourceUsed}}
<em>{{localize "SHADOWDARK.inventory.item.light_used"}}</em>
{{/if}}
</a>
{{#if item.lightSourceUsed}}
<div
data-tooltip="{{lightSourceTimeRemaining}}"
>
{{item.lightSourceProgress}}
</div>
{{/if}}
<div class="quantity">
{{#if item.showQuantity}}
{{#if ../owner}}
<a
data-action="item-decrement"
data-item-id="{{item._id}}"
data-tooltip="{{localize 'SHADOWDARK.inventory.tooltip.item_decrement'}}"
>
<i class="fa-regular fa-minus fa-xs"></i>
</a>
{{/if}}
{{item.system.quantity}}/{{item.system.slots.per_slot}}
{{#if ../owner}}
<a
data-action="item-increment"
data-item-id="{{item._id}}"
data-tooltip="{{localize 'SHADOWDARK.inventory.tooltip.item_increment'}}"
>
<i class="fa-regular fa-plus fa-xs"></i>
</a>
{{/if}}
{{else}}
&nbsp;
{{/if}}


</div>
<div class="slots">
{{item.slotsUsed}}
</div>
<div class="actions">
{{#if item.system.canBeEquipped}}
<a
data-action="toggle-equipped"
data-item-id="{{item._id}}"
data-tooltip="{{localize 'SHADOWDARK.inventory.tooltip.toggle_equipped'}}"
>
<i class="fas fa-user-shield"></i>
</a>
{{/if}}
{{#if item.system.light.isSource}}
<a
style="{{#if item.system.light.active}}color: darkorange;{{/if}}"
data-action="toggle-light"
data-item-id="{{item._id}}"
data-tooltip="{{localize 'SHADOWDARK.inventory.tooltip.toggle_light_source'}}"
>
<i class="fa-solid fa-fire-flame-curved"></i>
</a>
{{/if}}
{{#ifEq item.type "Potion"}}
<a
class="item-control use-potion"
data-action="use-potion"
data-item-id="{{item._id}}"
data-tooltip="{{localize 'SHADOWDARK.sheet.player.tooltip.use_potion'}}"
>
<i class="fas fa-prescription-bottle"></i>
</a>
{{/ifEq}}
<a
data-action="toggle-stashed"
data-item-id="{{item._id}}"
data-tooltip="{{localize 'SHADOWDARK.inventory.tooltip.toggle_stashed'}}"
>
<i class="fa-solid fa-box"></i>
</a>
</div>
</li>
{{/each}}
</ol>

<!-- Treasure list -->
<ol class="SD-list item-list" style="margin-top:8px">
<li class="header">
<div class="item-name">
<a
class="fa-solid fa-square-plus"
style="margin:0px 8px 0px 4px"
data-action="create-treasure"
></a>
Treasure
</div>
<div class="quantity">Value</div>
<div class="slots">Slots</div>
<div class="actions"></div>
</li>

{{#each inventory.treasure as |item|}}
<li class="item" data-item-id="{{item._id}}" data-uuid="Actor.{{../actor._id}}.Item.{{item._id}}">
<div class="item-image" style="background-image: url({{item.img}})">
<i class="fas fa-comment fa-lg"></i>
</div>
<a class="item-name" data-action="show-details">
{{item.name}}
</a>
<div class="quantity">{{displayCost item}}</div>
<div class="slots">{{item.slotsUsed}}</div>
<div class="actions">
<a
data-action="sell-treasure"
data-item-id="{{item._id}}"
data-tooltip="{{localize 'SHADOWDARK.inventory.tooltip.sell_treasure'}}"
>
<i class="fa-solid fa-coins"></i>
</a>
<a
data-action="toggle-stashed"
data-item-id="{{item._id}}"
data-tooltip="{{localize 'SHADOWDARK.inventory.tooltip.toggle_stashed'}}"
>
<i class="fa-solid fa-box"></i>
</a>
</div>
</li>
{{/each}}
</ol>

<br>

<!--Stashed Gear-->
<div class="SD-banner">{{localize "SHADOWDARK.inventory.stashed_gear"}}</div>
<ol class="SD-list item-list">
<li class="header">
<div class="item-name">Stashed Item</div>
<div class="flex-80-px">Type</div>
<div class="slots">Slots</div>
<div class="actions" style="flex: 0 0 30px">
</div>
</li>

{{#each inventory.stashed as |item|}}
<li class="item" data-item-id="{{item._id}}" data-uuid="Actor.{{../actor._id}}.Item.{{item._id}}">
<div class="item-image" style="background-image: url({{item.img}})">
<i class="fas fa-comment fa-lg"></i>
</div>
<a class="item-name" data-action="show-details">
{{item.name}}
{{#if item.lightSourceUsed}}
<em>{{localize 'SHADOWDARK.inventory.item.light_used'}}</em>
{{/if}}
</a>
<div class="flex-80-px">{{item.type}}</div>
<div class="slots">{{item.slotsUsed}}</div>
<div class="actions" style="flex: 0 0 30px">
<a
data-action="toggle-stashed"
data-item-id="{{item._id}}"
data-tooltip="{{localize 'SHADOWDARK.inventory.tooltip.toggle_stashed'}}"
>
<i style="color:var(--primary)" class="fa-solid fa-box"></i>
</a>
</div>
</li>
{{/each}}
</ol>
<br>
{{> actors/player/inventory/equipped-gear }}
{{> actors/player/inventory/carried-gear }}
{{> actors/player/inventory/stashed-gear }}
</div>

<!--Sidebar-->
<div>
<div class="grid-1-columns">
Expand Down
35 changes: 35 additions & 0 deletions system/templates/actors/player/inventory/carried-gear.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--Carried Gear-->
<div class="SD-banner">
{{localize "SHADOWDARK.inventory.carried_gear"}}
</div>

<ol class="SD-list item-list">
<li class="header">
<div class="item-name">
<a
class="fa-solid fa-square-plus"
data-action="create-item"
style="margin:0px 8px 0px 4px"
></a>
{{localize "SHADOWDARK.sheet.player.inventory.items.label"}}
</div>
<div class="quantity">
{{localize "SHADOWDARK.sheet.player.inventory.quantity_short.label"}}
</div>
<div class="slots">
{{localize "SHADOWDARK.sheet.player.inventory.slots.label"}}
</div>
<div class="actions"></div>
</li>

{{#each inventory.carried as |item|}}
{{> actors/player/inventory/item
item=item
owner=../owner
}}
{{/each}}
</ol>

{{> actors/player/inventory/treasure }}

<br>
Loading

0 comments on commit a1d8f98

Please sign in to comment.