mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-15 21:21:08 +01:00
Downtime window now enumerates the actions/resources that will be refreshed upon completion. Resources can now specify their progression direction (#591)
This commit is contained in:
parent
645b8fef58
commit
599e9c7aa0
7 changed files with 140 additions and 2 deletions
|
|
@ -375,6 +375,9 @@
|
||||||
"description": "Describe how you prepare yourself for the path ahead, then gain a Hope. If you choose to Prepare with one or more members of your party, you each gain 2 Hope."
|
"description": "Describe how you prepare yourself for the path ahead, then gain a Hope. If you choose to Prepare with one or more members of your party, you each gain 2 Hope."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"refreshable": {
|
||||||
|
"title": "Refreshing Resources"
|
||||||
|
},
|
||||||
"takeDowntime": "Take Downtime"
|
"takeDowntime": "Take Downtime"
|
||||||
},
|
},
|
||||||
"HUD": {
|
"HUD": {
|
||||||
|
|
@ -903,6 +906,10 @@
|
||||||
"abbreviation": "FR"
|
"abbreviation": "FR"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"ItemResourceProgression": {
|
||||||
|
"increasing": "Increasing",
|
||||||
|
"decreasing": "Decreasing"
|
||||||
|
},
|
||||||
"ItemResourceType": {
|
"ItemResourceType": {
|
||||||
"simple": "Simple",
|
"simple": "Simple",
|
||||||
"diceValue": "Dice Value"
|
"diceValue": "Dice Value"
|
||||||
|
|
@ -1968,6 +1975,7 @@
|
||||||
"dieFaces": { "label": "Die Faces" },
|
"dieFaces": { "label": "Die Faces" },
|
||||||
"icon": { "label": "Icon" },
|
"icon": { "label": "Icon" },
|
||||||
"max": { "label": "Max" },
|
"max": { "label": "Max" },
|
||||||
|
"progression": { "label": "Progression" },
|
||||||
"recovery": { "label": "Recovery" },
|
"recovery": { "label": "Recovery" },
|
||||||
"type": { "label": "Type" },
|
"type": { "label": "Type" },
|
||||||
"value": { "label": "Value" }
|
"value": { "label": "Value" }
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV
|
||||||
actor.system.bonuses.rest[`${shortrest ? 'short' : 'long'}Rest`].longMoves
|
actor.system.bonuses.rest[`${shortrest ? 'short' : 'long'}Rest`].longMoves
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.refreshables = this.getRefreshables();
|
||||||
}
|
}
|
||||||
|
|
||||||
get title() {
|
get title() {
|
||||||
|
|
@ -81,11 +83,56 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV
|
||||||
context.shortRestMoves = this.nrChoices.shortRest.max > 0 ? this.moveData.shortRest : null;
|
context.shortRestMoves = this.nrChoices.shortRest.max > 0 ? this.moveData.shortRest : null;
|
||||||
context.longRestMoves = this.nrChoices.longRest.max > 0 ? this.moveData.longRest : null;
|
context.longRestMoves = this.nrChoices.longRest.max > 0 ? this.moveData.longRest : null;
|
||||||
|
|
||||||
|
context.refreshables = this.refreshables;
|
||||||
|
|
||||||
context.disabledDowntime = shortRestMovesSelected === 0 && longRestMovesSelected === 0;
|
context.disabledDowntime = shortRestMovesSelected === 0 && longRestMovesSelected === 0;
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getRefreshables() {
|
||||||
|
const actionItems = this.actor.items.reduce((acc, x) => {
|
||||||
|
if (x.system.actions) {
|
||||||
|
const recoverable = x.system.actions.reduce((acc, action) => {
|
||||||
|
if (action.uses.recovery && (action.uses.recovery === 'shortRest') === this.shortrest) {
|
||||||
|
acc.push({
|
||||||
|
title: x.name,
|
||||||
|
name: action.name,
|
||||||
|
uuid: action.uuid
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
if (recoverable) {
|
||||||
|
acc.push(...recoverable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
const resourceItems = this.actor.items.reduce((acc, x) => {
|
||||||
|
if (
|
||||||
|
x.system.resource &&
|
||||||
|
x.system.resource.type &&
|
||||||
|
(x.system.resource.recovery === 'shortRest') === this.shortrest
|
||||||
|
) {
|
||||||
|
acc.push({
|
||||||
|
title: game.i18n.localize(`TYPES.Item.${x.type}`),
|
||||||
|
name: x.name,
|
||||||
|
uuid: x.uuid
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
return {
|
||||||
|
actionItems,
|
||||||
|
resourceItems
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static selectMove(_, target) {
|
static selectMove(_, target) {
|
||||||
const { category, move } = target.dataset;
|
const { category, move } = target.dataset;
|
||||||
|
|
||||||
|
|
@ -172,11 +219,24 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can close the window when all moves are taken
|
// We can close the window and refresh resources when all moves are taken
|
||||||
if (
|
if (
|
||||||
this.nrChoices.shortRest.taken >= this.nrChoices.shortRest.max &&
|
this.nrChoices.shortRest.taken >= this.nrChoices.shortRest.max &&
|
||||||
this.nrChoices.longRest.taken >= this.nrChoices.longRest.max
|
this.nrChoices.longRest.taken >= this.nrChoices.longRest.max
|
||||||
) {
|
) {
|
||||||
|
for (var data of this.refreshables.actionItems) {
|
||||||
|
const action = await foundry.utils.fromUuid(data.uuid);
|
||||||
|
await action.parent.parent.update({ [`system.actions.${action.id}.uses.value`]: action.uses.max ?? 1 });
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var data of this.refreshables.resourceItems) {
|
||||||
|
const feature = await foundry.utils.fromUuid(data.uuid);
|
||||||
|
const increasing =
|
||||||
|
feature.system.resource.progression === CONFIG.DH.ITEM.itemResourceProgression.increasing.id;
|
||||||
|
const resetValue = increasing ? 0 : (feature.system.resource.max ?? 0);
|
||||||
|
await feature.update({ 'system.resource.value': resetValue });
|
||||||
|
}
|
||||||
|
|
||||||
this.close();
|
this.close();
|
||||||
} else {
|
} else {
|
||||||
this.render();
|
this.render();
|
||||||
|
|
|
||||||
|
|
@ -1473,6 +1473,17 @@ export const itemResourceTypes = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const itemResourceProgression = {
|
||||||
|
increasing: {
|
||||||
|
id: 'increasing',
|
||||||
|
label: 'DAGGERHEART.CONFIG.ItemResourceProgression.increasing'
|
||||||
|
},
|
||||||
|
decreasing: {
|
||||||
|
id: 'decreasing',
|
||||||
|
label: 'DAGGERHEART.CONFIG.ItemResourceProgression.decreasing'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const beastformTypes = {
|
export const beastformTypes = {
|
||||||
normal: {
|
normal: {
|
||||||
id: 'normal',
|
id: 'normal',
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,11 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
||||||
initial: null,
|
initial: null,
|
||||||
nullable: true
|
nullable: true
|
||||||
}),
|
}),
|
||||||
|
progression: new fields.StringField({
|
||||||
|
required: true,
|
||||||
|
choices: CONFIG.DH.ITEM.itemResourceProgression,
|
||||||
|
initial: CONFIG.DH.ITEM.itemResourceProgression.increasing.id
|
||||||
|
}),
|
||||||
diceStates: new fields.TypedObjectField(
|
diceStates: new fields.TypedObjectField(
|
||||||
new fields.SchemaField({
|
new fields.SchemaField({
|
||||||
value: new fields.NumberField({ integer: true, initial: 1, min: 1 }),
|
value: new fields.NumberField({ integer: true, initial: 1, min: 1 }),
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,36 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.refreshables-container {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 4px;
|
||||||
|
font-size: 12px;
|
||||||
|
|
||||||
|
&.wide {
|
||||||
|
grid-template-columns: 1fr 1fr 1fr 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.refreshable-container {
|
||||||
|
border: 1px solid light-dark(@dark-blue, @golden);
|
||||||
|
border-radius: 6px;
|
||||||
|
color: light-dark(@dark, @beige);
|
||||||
|
background-image: url('../assets/parchments/dh-parchment-dark.png');
|
||||||
|
padding: 0 2px;
|
||||||
|
text-align: center;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
|
||||||
|
.refreshable-title {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.refreshable-name {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
footer {
|
footer {
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,26 @@
|
||||||
{{#if shortRestMoves.moves}}{{> "systems/daggerheart/templates/dialogs/downtime/activities.hbs" moves=shortRestMoves.moves category='shortRest' nrChoices=nrChoices.shortRest}}{{/if}}
|
{{#if shortRestMoves.moves}}{{> "systems/daggerheart/templates/dialogs/downtime/activities.hbs" moves=shortRestMoves.moves category='shortRest' nrChoices=nrChoices.shortRest}}{{/if}}
|
||||||
{{#if longRestMoves.moves}}{{> "systems/daggerheart/templates/dialogs/downtime/activities.hbs" moves=longRestMoves.moves category='longRest' nrChoices=nrChoices.longRest}}{{/if}}
|
{{#if longRestMoves.moves}}{{> "systems/daggerheart/templates/dialogs/downtime/activities.hbs" moves=longRestMoves.moves category='longRest' nrChoices=nrChoices.longRest}}{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>{{localize "DAGGERHEART.APPLICATIONS.Downtime.refreshable.title"}}</legend>
|
||||||
|
|
||||||
|
<div class="refreshables-container {{#if (and shortRestMoves longRestMoves)}}wide{{/if}}">
|
||||||
|
{{#each this.refreshables.actionItems as | item |}}
|
||||||
|
<div class="refreshable-container">
|
||||||
|
<div class="refreshable-title">{{item.title}}</div>
|
||||||
|
<div class="refreshable-name">{{item.name}}</div>
|
||||||
|
</div>
|
||||||
|
{{/each}}
|
||||||
|
{{#each this.refreshables.resourceItems as | item |}}
|
||||||
|
<div class="refreshable-container">
|
||||||
|
<div class="refreshable-title">{{item.title}}</div>
|
||||||
|
<div class="refreshable-name">{{item.name}}</div>
|
||||||
|
</div>
|
||||||
|
{{/each}}
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
<button type="button" data-action="close">{{localize "Cancel"}}</button>
|
<button type="button" data-action="close">{{localize "Cancel"}}</button>
|
||||||
<button type="button" data-action="takeDowntime" {{#if disabledDowntime}}disabled{{/if}}>{{localize "DAGGERHEART.APPLICATIONS.Downtime.takeDowntime"}}</button>
|
<button type="button" data-action="takeDowntime" {{#if disabledDowntime}}disabled{{/if}}>{{localize "DAGGERHEART.APPLICATIONS.Downtime.takeDowntime"}}</button>
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,13 @@
|
||||||
</legend>
|
</legend>
|
||||||
|
|
||||||
{{#if source.system.resource}}
|
{{#if source.system.resource}}
|
||||||
<div class="two-columns even">
|
<div class="{{#if (eq source.system.resource.type 'simple')}}nest-inputs{{else}}two-columns{{/if}} even">
|
||||||
{{formGroup systemFields.resource.fields.type value=source.system.resource.type localize=true blank=false}}
|
{{formGroup systemFields.resource.fields.type value=source.system.resource.type localize=true blank=false}}
|
||||||
{{formGroup systemFields.resource.fields.recovery value=source.system.resource.recovery localize=true}}
|
{{formGroup systemFields.resource.fields.recovery value=source.system.resource.recovery localize=true}}
|
||||||
|
|
||||||
|
{{#if (eq source.system.resource.type 'simple')}}
|
||||||
|
{{formGroup systemFields.resource.fields.progression value=source.system.resource.progression localize=true}}
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="two-columns even">
|
<div class="two-columns even">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue