mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-21 18:09:54 +02:00
Added update of resource when a 1 is rolled
This commit is contained in:
parent
85e6e8580f
commit
f004227232
5 changed files with 33 additions and 9 deletions
|
|
@ -2225,7 +2225,9 @@
|
|||
},
|
||||
"Resource": {
|
||||
"single": "Resource",
|
||||
"plural": "Resources"
|
||||
"plural": "Resources",
|
||||
"unloaded": "The weapon is not loaded",
|
||||
"loaded": "The weapon is loaded"
|
||||
},
|
||||
"Roll": {
|
||||
"attack": "Attack Roll",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import DhDeathMove from '../../dialogs/deathMove.mjs';
|
|||
import { CharacterLevelup, LevelupViewMode } from '../../levelup/_module.mjs';
|
||||
import DhCharacterCreation from '../../characterCreation/characterCreation.mjs';
|
||||
import FilterMenu from '../../ux/filter-menu.mjs';
|
||||
import { getArmorSources, getDocFromElement, getDocFromElementSync, sortBy } from '../../../helpers/utils.mjs';
|
||||
import { getArmorSources, getDocFromElement, getDocFromElementSync, itemAbleRollParse, sortBy } from '../../../helpers/utils.mjs';
|
||||
|
||||
/**@typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction */
|
||||
|
||||
|
|
@ -29,6 +29,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
toggleResourceDice: CharacterSheet.#toggleResourceDice,
|
||||
handleResourceDice: CharacterSheet.#handleResourceDice,
|
||||
advanceResourceDie: CharacterSheet.#advanceResourceDie,
|
||||
toggleItemReload: CharacterSheet.#onToggleItemReload,
|
||||
cancelBeastform: CharacterSheet.#cancelBeastform,
|
||||
toggleResourceManagement: CharacterSheet.#toggleResourceManagement,
|
||||
useDowntime: this.useDowntime,
|
||||
|
|
@ -954,11 +955,21 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
});
|
||||
}
|
||||
|
||||
/** */
|
||||
static #advanceResourceDie(_, target) {
|
||||
this.updateResourceDie(target, true);
|
||||
}
|
||||
|
||||
static async #onToggleItemReload(_, target) {
|
||||
const item = await getDocFromElement(target);
|
||||
if (!item || !item.system.resource?.type === 'simple' || !item.system.resource.max)
|
||||
return;
|
||||
|
||||
const isReloaded = item.system.resource.value > 0;
|
||||
await item.update({
|
||||
'system.resource.value': isReloaded ? 0 : itemAbleRollParse(item.system.resource.max, this.document, item)
|
||||
})
|
||||
}
|
||||
|
||||
lowerResourceDie(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
|
|
|||
|
|
@ -70,12 +70,12 @@ export default class DHAttackAction extends DHDamageAction {
|
|||
game.dice3d.showForRoll(roll, game.user, true);
|
||||
}
|
||||
|
||||
const needsToReload = roll.total === 1;
|
||||
const needsToReload = true;
|
||||
// const needsToReload = roll.total === 1;
|
||||
if (needsToReload) {
|
||||
// TODO: Update item resource value when the functionality has been added to the system
|
||||
// this.item.update({ 'system.resource.value': 0 });
|
||||
this.item.update({ 'system.resource.value': 0 });
|
||||
}
|
||||
return true;
|
||||
|
||||
return needsToReload;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -144,6 +144,10 @@
|
|||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
|
||||
.unloaded {
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,14 @@
|
|||
|
||||
{{#if (eq item.system.resource.type 'simple')}}
|
||||
<div class="item-resource">
|
||||
<i class="{{#if item.system.resource.icon}}{{item.system.resource.icon}}{{else}}fa-solid fa-hashtag{{/if}}"></i>
|
||||
<input type="number" id="{{item.uuid}}-resource" class="inventory-item-resource" value="{{item.system.resource.value}}" min="0" max="{{rollParsed item.system.resource.max item.actor item true}}" />
|
||||
{{#if item.system.hasReload}}
|
||||
<a data-action="toggleItemReload" title="{{localize (ifThen (eq item.system.resource.value 0) 'DAGGERHEART.GENERAL.Resource.unloaded' 'DAGGERHEART.GENERAL.Resource.loaded')}}">
|
||||
<i class="fa-solid fa-gun {{#if (eq item.system.resource.value 0)}}unloaded{{/if}}"></i>
|
||||
</a>
|
||||
{{else}}
|
||||
<i class="{{#if item.system.resource.icon}}{{item.system.resource.icon}}{{else}}fa-solid fa-hashtag{{/if}}"></i>
|
||||
<input type="number" id="{{item.uuid}}-resource" class="inventory-item-resource" value="{{item.system.resource.value}}" min="0" max="{{rollParsed item.system.resource.max item.actor item true}}" />
|
||||
{{/if}}
|
||||
</div>
|
||||
{{else if (eq item.system.resource.type 'diceValue')}}
|
||||
<div class="item-resources">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue