Skip to content

Commit

Permalink
Wrycu/stim update (#1068)
Browse files Browse the repository at this point in the history
Adds the ability to perform rests when resetting healing item. This is configurable via the game settings:

![image](https://user-images.githubusercontent.com/4709746/173661881-5f6d71f5-6b34-4b7d-b0f5-34f395106e35.png)

The "prompt" setting will prompt every user every time and is the default.
The "rest" setting will perform a rest (-1 wound, recover all strain, reset healing item count)
The "reset" setting will only reset the healing item count
  • Loading branch information
wrycu authored Jun 16, 2022
1 parent 1acd7a3 commit 315782d
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 7 deletions.
7 changes: 6 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"ITEM.TypeSpecialization": "Specialization",
"ITEM.TypeSpecies": "Species",
"ITEM.TypeWeapon": "Weapon",

"SWFFG.Name": "Name",
"SWFFG.Species": "Species",
"SWFFG.Career": "Career",
Expand Down Expand Up @@ -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",
Expand Down
51 changes: 48 additions & 3 deletions modules/actors/actor-sheet-ffg.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '<i class="fas fa-hourglass"></i>',
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: '<i class="fas fa-recycle"></i>',
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
Expand Down
14 changes: 14 additions & 0 deletions modules/settings/settings-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions modules/swffg-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion templates/parts/actor/ffg-healingitem.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{{else}}
0/5
{{/if}}

<i class="fas fa-plus-circle medical"></i>
</div>
</div>
Expand Down

0 comments on commit 315782d

Please sign in to comment.