diff --git a/lang/en.json b/lang/en.json index 0eeba4d5..39e49b67 100755 --- a/lang/en.json +++ b/lang/en.json @@ -1014,6 +1014,30 @@ "singular": "Adversary", "plural": "Adversaries" }, + "Bonuses": { + "rest": { + "shortRest": { + "shortRestMoves": { + "label": "Short Rest: Bonus Short Rest Moves", + "hint": "The number of extra Short Rest Moves the character can take during a Short Rest." + }, + "longRestMoves": { + "label": "Short Rest: Bonus Long Rest Moves", + "hint": "The number of extra Long Rest Moves the character can take during a Short Rest." + } + }, + "longRest": { + "shortRestMoves": { + "label": "Long Rest: Bonus Short Rest Moves", + "hint": "The number of extra Short Rest Moves the character can take during a Long Rest." + }, + "longRestMoves": { + "label": "Long Rest: Bonus Long Rest Moves", + "hint": "The number of extra Long Rest Moves the character can take during a Long Rest." + } + } + } + }, "Character": { "singular": "Character", "plural": "Characters" @@ -1163,28 +1187,6 @@ "hint": "The cost in stress you can pay to reduce minor damage to none." } } - }, - "rest": { - "shortRest": { - "shortRestMoves": { - "label": "Short Rest: Short Rest Moves", - "hint": "The number of Short Rest Moves the character can take during a Short Rest." - }, - "longRestMoves": { - "label": "Short Rest: Long Rest Moves", - "hint": "The number of Long Rest Moves the character can take during a Short Rest." - } - }, - "longRest": { - "shortRestMoves": { - "label": "Long Rest: Short Rest Moves", - "hint": "The number of Short Rest Moves the character can take during a Long Rest." - }, - "longRestMoves": { - "label": "Long Rest: Long Rest Moves", - "hint": "The number of Long Rest Moves the character can take during a Long Rest." - } - } } }, "Tabs": { diff --git a/module/applications/dialogs/downtime.mjs b/module/applications/dialogs/downtime.mjs index 0b263799..680bc9c3 100644 --- a/module/applications/dialogs/downtime.mjs +++ b/module/applications/dialogs/downtime.mjs @@ -7,13 +7,19 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV this.actor = actor; this.shortrest = shortrest; - this.moveData = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).restMoves; + this.moveData = foundry.utils.deepClone( + game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).restMoves + ); this.nrChoices = { shortRest: { - max: actor.system.rules.rest[`${shortrest ? 'short' : 'long'}Rest`].shortMoves + max: + (shortrest ? this.moveData.shortRest.nrChoices : 0) + + actor.system.bonuses.rest[`${shortrest ? 'short' : 'long'}Rest`].shortMoves }, longRest: { - max: actor.system.rules.rest[`${shortrest ? 'short' : 'long'}Rest`].longMoves + max: + (!shortrest ? this.moveData.longRest.nrChoices : 0) + + actor.system.bonuses.rest[`${shortrest ? 'short' : 'long'}Rest`].longMoves } }; this.nrChoices.total = { max: this.nrChoices.shortRest.max + this.nrChoices.longRest.max }; @@ -45,7 +51,7 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV super._attachPartListeners(partId, htmlElement, options); htmlElement - .querySelectorAll('.activity-select-section') + .querySelectorAll('.activity-container') .forEach(element => element.addEventListener('contextmenu', this.deselectMove.bind(this))); } @@ -106,7 +112,7 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV } deselectMove(event) { - const button = event.target.closest('.activity-select-section'); + const button = event.target.closest('.activity-container'); const move = button.dataset.move; this.moveData[button.dataset.category].moves[move].selected = this.moveData[button.dataset.category].moves[move] .selected @@ -118,7 +124,9 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV static async takeDowntime() { const moves = Object.values(this.moveData).flatMap(category => { - return Object.values(category.moves).filter(x => x.selected); + return Object.values(category.moves) + .filter(x => x.selected) + .flatMap(move => [...Array(move.selected).keys()].map(_ => move)); }); const cls = getDocumentClass('ChatMessage'); diff --git a/module/data/actor/character.mjs b/module/data/actor/character.mjs index b56d26db..c15d2221 100644 --- a/module/data/actor/character.mjs +++ b/module/data/actor/character.mjs @@ -126,6 +126,44 @@ export default class DhCharacter extends BaseDataActor { }), rally: new fields.ArrayField(new fields.StringField(), { label: 'DAGGERHEART.CLASS.Feature.rallyDice' + }), + rest: new fields.SchemaField({ + shortRest: new fields.SchemaField({ + shortMoves: new fields.NumberField({ + required: true, + integer: true, + min: 0, + initial: 0, + label: 'DAGGERHEART.GENERAL.Bonuses.rest.shortRest.shortRestMoves.label', + hint: 'DAGGERHEART.GENERAL.Bonuses.rest.shortRest.shortRestMoves.hint' + }), + longMoves: new fields.NumberField({ + required: true, + integer: true, + min: 0, + initial: 0, + label: 'DAGGERHEART.GENERAL.Bonuses.rest.shortRest.longRestMoves.label', + hint: 'DAGGERHEART.GENERAL.Bonuses.rest.shortRest.longRestMoves.hint' + }) + }), + longRest: new fields.SchemaField({ + shortMoves: new fields.NumberField({ + required: true, + integer: true, + min: 0, + initial: 0, + label: 'DAGGERHEART.GENERAL.Bonuses.rest.longRest.shortRestMoves.label', + hint: 'DAGGERHEART.GENERAL.Bonuses.rest.longRest.shortRestMoves.hint' + }), + longMoves: new fields.NumberField({ + required: true, + integer: true, + min: 0, + initial: 0, + label: 'DAGGERHEART.GENERAL.Bonuses.rest.longRest.longRestMoves.label', + hint: 'DAGGERHEART.GENERAL.Bonuses.rest.longRest.longRestMoves.hint' + }) + }) }) }), companion: new ForeignDocumentUUIDField({ type: 'Actor', nullable: true, initial: null }), @@ -173,44 +211,6 @@ export default class DhCharacter extends BaseDataActor { */ flipMinDiceValue: new fields.BooleanField({ intial: false }) }), - rest: new fields.SchemaField({ - shortRest: new fields.SchemaField({ - shortMoves: new fields.NumberField({ - required: true, - integer: true, - min: 1, - initial: 2, - label: 'DAGGERHEART.GENERAL.Rules.rest.shortRest.shortRestMoves.label', - hint: 'DAGGERHEART.GENERAL.Rules.rest.shortRest.shortRestMoves.hint' - }), - longMoves: new fields.NumberField({ - required: true, - integer: true, - min: 0, - initial: 0, - label: 'DAGGERHEART.GENERAL.Rules.rest.shortRest.longRestMoves.label', - hint: 'DAGGERHEART.GENERAL.Rules.rest.shortRest.longRestMoves.hint' - }) - }), - longRest: new fields.SchemaField({ - shortMoves: new fields.NumberField({ - required: true, - integer: true, - min: 0, - initial: 0, - label: 'DAGGERHEART.GENERAL.Rules.rest.longRest.shortRestMoves.label', - hint: 'DAGGERHEART.GENERAL.Rules.rest.longRest.shortRestMoves.hint' - }), - longMoves: new fields.NumberField({ - required: true, - integer: true, - min: 1, - initial: 2, - label: 'DAGGERHEART.GENERAL.Rules.rest.longRest.longRestMoves.label', - hint: 'DAGGERHEART.GENERAL.Rules.rest.longRest.longRestMoves.hint' - }) - }) - }), runeWard: new fields.BooleanField({ initial: false }) }) }; diff --git a/templates/dialogs/downtime/activities.hbs b/templates/dialogs/downtime/activities.hbs index 4b56572c..d13b6339 100644 --- a/templates/dialogs/downtime/activities.hbs +++ b/templates/dialogs/downtime/activities.hbs @@ -3,16 +3,16 @@