diff --git a/fvtt-celestopol.mjs b/fvtt-celestopol.mjs index 9dc15dd..b47692e 100644 --- a/fvtt-celestopol.mjs +++ b/fvtt-celestopol.mjs @@ -67,6 +67,7 @@ Hooks.once("init", () => { SYSTEM, rollMoonStandalone: (actor = null) => CelestopolRoll.rollMoonStandalone(actor), manageFactionAspects: (actor = null) => _manageFactionAspects(actor), + resetFactionAspects: () => _resetFactionAspects(), getFactionAspectState: () => _getFactionAspectState(), getFactionAspectSummary: (actor = null) => _getFactionAspectSummary(actor), getFactionDisplayLabel: (value) => _getFactionDisplayLabel(value), @@ -1218,6 +1219,24 @@ async function _setFactionAspectState(state) { return cleanState } +async function _resetFactionAspects() { + if (!game.user.isGM) { + ui.notifications.warn(game.i18n.localize("CELESTOPOL.FactionAspect.gmOnly")) + return + } + const confirmed = await foundry.applications.api.DialogV2.confirm({ + window: { title: game.i18n.localize("CELESTOPOL.FactionAspect.resetTitle") }, + content: `

${game.i18n.localize("CELESTOPOL.FactionAspect.resetConfirm")}

`, + yes: { label: game.i18n.localize("CELESTOPOL.FactionAspect.resetConfirmYes"), icon: "fas fa-redo" }, + no: { label: game.i18n.localize("Cancel"), icon: "fas fa-times" }, + rejectClose: false, + }) + if (!confirmed) return + const state = _getFactionAspectState() + await _setFactionAspectState({ ...state, activatedAspects: [] }) + ui.notifications.info(game.i18n.localize("CELESTOPOL.FactionAspect.resetSuccess")) +} + function _refreshFactionAspectSheets() { for (const actor of game.actors.contents) { if (actor.type !== "character") continue diff --git a/lang/fr.json b/lang/fr.json index 8b74b0c..cc09186 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -189,7 +189,12 @@ "renforts": "Renforts", "renseignements": "Renseignements", "ressources": "Ressources", - "surveillance": "Surveillance" + "surveillance": "Surveillance", + "resetButton": "Réinitialiser", + "resetTitle": "Réinitialiser les Aspects de faction", + "resetConfirm": "Voulez-vous réinitialiser tous les Aspects de faction mobilisés ? Cette action efface la réserve de scénario en cours.", + "resetConfirmYes": "Réinitialiser", + "resetSuccess": "Aspects de faction réinitialisés pour le nouveau scénario." }, "Track": { "blessures": "Blessures", diff --git a/module/applications/sheets/character-sheet.mjs b/module/applications/sheets/character-sheet.mjs index a131274..48bee42 100644 --- a/module/applications/sheets/character-sheet.mjs +++ b/module/applications/sheets/character-sheet.mjs @@ -32,6 +32,7 @@ export default class CelestopolCharacterSheet extends CelestopolActorSheet { supprimerXpLog: CelestopolCharacterSheet.#onSupprimerXpLog, rollMoonDie: CelestopolCharacterSheet.#onRollMoonDie, manageFactionAspects: CelestopolCharacterSheet.#onManageFactionAspects, + resetFactionAspects: CelestopolCharacterSheet.#onResetFactionAspects, }, } @@ -245,6 +246,10 @@ export default class CelestopolCharacterSheet extends CelestopolActorSheet { await game.celestopol?.manageFactionAspects(this.document) } + static async #onResetFactionAspects() { + await game.celestopol?.resetFactionAspects() + } + /** Ouvre un dialogue pour dépenser de l'XP. */ static async #onDepenseXp() { const actor = this.document diff --git a/templates/character-factions.hbs b/templates/character-factions.hbs index 2edf0b3..6579fe1 100644 --- a/templates/character-factions.hbs +++ b/templates/character-factions.hbs @@ -7,6 +7,9 @@ {{localize "CELESTOPOL.FactionAspect.manage"}} + + {{localize "CELESTOPOL.FactionAspect.resetButton"}} + {{/if}}