diff --git a/lang/en.json b/lang/en.json index 9d4093cc..cdd79c6a 100644 --- a/lang/en.json +++ b/lang/en.json @@ -20,7 +20,7 @@ "ITEM.TypeSpecialization": "Specialization", "ITEM.TypeSpecies": "Species", "ITEM.TypeWeapon": "Weapon", - + "SWFFG.Name": "Name", "SWFFG.Species": "Species", "SWFFG.Career": "Career", @@ -308,6 +308,11 @@ "SWFFG.DefaultMedicalItemName": "Stimpacks", "SWFFG.MedicalItemName": "Healing Item Name", "SWFFG.MedicalItemNameHint": "Name of the item characters use to heal.", + "SWFFG.MedicalItemNameUseTitle": "Choose Action", + "SWFFG.MedicalItemNameUseRest": "Rest", + "SWFFG.MedicalItemNameUseReset": "Reset Only", + "SWFFG.MedicalItemNameUsePrompt": "Prompt", + "SWFFG.MedicalItemSetting": "Healing Item Action", "SWFFG.EnablePrivateTriggers": "Enable Private Group Manager Table Rolls", "SWFFG.EnablePrivateTriggersHint": "Enable making Obligation/Duty/Morality Table Rolls from group manager private so that players do not see the result", "SWFFG.EnableDebug": "Enable console debugging", diff --git a/modules/actors/actor-sheet-ffg.js b/modules/actors/actor-sheet-ffg.js index 6fe68419..bcf699d9 100644 --- a/modules/actors/actor-sheet-ffg.js +++ b/modules/actors/actor-sheet-ffg.js @@ -393,9 +393,54 @@ export class ActorSheetFFG extends ActorSheet { }); html.find(".resetMedical").click(async (ev) => { - let updateData = {}; - setProperty(updateData, `data.stats.medical.uses`, 0); - this.object.update(updateData); + if (game.settings.get("starwarsffg", "HealingItemAction") === '0') { + // prompt + // show a prompt asking what the user wants to do + new Dialog( + { + title: game.i18n.localize("SWFFG.MedicalItemNameUseTitle"), + buttons: { + done: { + icon: '', + label: game.i18n.localize("SWFFG.MedicalItemNameUseRest"), + callback: (that) => { + // rest + let updateData = {}; + setProperty(updateData, `data.stats.medical.uses`, 0); + setProperty(updateData, `data.stats.strain.value`, 0); + setProperty(updateData, `data.stats.wounds.value`, Math.max(0, this.object.data.data.stats.wounds.value - 1)); + this.object.update(updateData); + }, + }, + cancel: { + icon: '', + label: game.i18n.localize("SWFFG.MedicalItemNameUseReset"), + callback: (that) => { + // reset + let updateData = {}; + setProperty(updateData, `data.stats.medical.uses`, 0); + this.object.update(updateData); + }, + }, + }, + }, + { + classes: ["dialog", "starwarsffg"], + } + ).render(true); + } else if (game.settings.get("starwarsffg", "HealingItemAction") === '1') { + // rest + let updateData = {}; + setProperty(updateData, `data.stats.medical.uses`, 0); + setProperty(updateData, `data.stats.strain.value`, 0); + setProperty(updateData, `data.stats.wounds.value`, Math.max(0, this.object.data.data.stats.wounds.value - 1)); + this.object.update(updateData); + } else if (game.settings.get("starwarsffg", "HealingItemAction") === '2') { + // reset + let updateData = {}; + setProperty(updateData, `data.stats.medical.uses`, 0); + this.object.update(updateData); + } }); // Toggle item equipped diff --git a/modules/settings/settings-helpers.js b/modules/settings/settings-helpers.js index 376be70c..7391cacb 100644 --- a/modules/settings/settings-helpers.js +++ b/modules/settings/settings-helpers.js @@ -339,6 +339,20 @@ export default class SettingsHelpers { type: String, onChange: this.debouncedReload, }); + + let stimpackChoices = [ + game.i18n.localize("SWFFG.MedicalItemNameUsePrompt"), + game.i18n.localize("SWFFG.MedicalItemNameUseRest"), + game.i18n.localize("SWFFG.MedicalItemNameUseReset"), + ]; + game.settings.register("starwarsffg", "HealingItemAction", { + name: game.i18n.localize("SWFFG.MedicalItemSetting"), + scope: "world", + default: '0', + config: true, + type: String, + choices: stimpackChoices, + }); } static debouncedReload = debounce(() => window.location.reload(), 100); diff --git a/modules/swffg-main.js b/modules/swffg-main.js index ee6a4aff..9684a99f 100644 --- a/modules/swffg-main.js +++ b/modules/swffg-main.js @@ -603,12 +603,12 @@ Hooks.once("ready", async () => { ui.notifications.info(`Migrating Starwars FFG System for version ${game.system.data.version}. Please be patient and do not close your game or shut down your server.`, { permanent: true }); try { - + // Update old pack to latest data model for (let pack of game.packs) { await pack.migrate(); } - + // Copy old flags to new system scope FlagMigrationHelpers.migrateFlags() diff --git a/templates/parts/actor/ffg-healingitem.html b/templates/parts/actor/ffg-healingitem.html index 9ed5c527..5c986e8c 100644 --- a/templates/parts/actor/ffg-healingitem.html +++ b/templates/parts/actor/ffg-healingitem.html @@ -16,7 +16,7 @@ {{else}} 0/5 {{/if}} - +