Irk/83 homebrew currency (#193)

* add homebrew options to rename currency names

* add title. remove localization from settings file since it didn't work.

* use enabled toggle to use localized initial label values.

* cleanup
This commit is contained in:
IrkTheImp 2025-06-28 14:00:42 -05:00 committed by GitHub
parent 778e569037
commit b25e1cec78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 121 additions and 23 deletions

View file

@ -24,14 +24,16 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
editItem: this.editItem,
removeItem: this.removeItem,
resetMoves: this.resetMoves,
save: this.save
save: this.save,
reset: this.reset
},
form: { handler: this.updateData, submitOnChange: true }
};
static PARTS = {
main: {
template: 'systems/daggerheart/templates/settings/homebrew-settings.hbs'
template: 'systems/daggerheart/templates/settings/homebrew-settings.hbs',
scrollable: ['']
}
};
@ -154,4 +156,27 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
await game.settings.set(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Homebrew, this.settings.toObject());
this.close();
}
static async reset() {
const resetSettings = new DhHomebrew();
let localizedSettings = this.localizeObject(resetSettings);
this.settings.updateSource(localizedSettings);
this.render();
}
localizeObject(obj) {
for (let key in obj) {
if (obj.hasOwnProperty(key)) {
const value = obj[key];
if (typeof value === 'object' && value !== null) {
obj[key] = this.localizeObject(value);
} else {
if (typeof value === 'string' && value.startsWith('DAGGERHEART.')) {
obj[key] = game.i18n.localize(value);
}
}
}
}
return obj;
}
}

View file

@ -409,9 +409,21 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
quantity: game.i18n.localize('DAGGERHEART.Sheets.PC.InventoryTab.QuantityTitle')
},
items: this.document.items.filter(x => x.type === 'armor')
},
currency: {
title: game.i18n.localize('DAGGERHEART.Sheets.PC.Gold.Title'),
coins: game.i18n.localize('DAGGERHEART.Sheets.PC.Gold.Coins'),
handfulls: game.i18n.localize('DAGGERHEART.Sheets.PC.Gold.Handfulls'),
bags: game.i18n.localize('DAGGERHEART.Sheets.PC.Gold.Bags'),
chests: game.i18n.localize('DAGGERHEART.Sheets.PC.Gold.Chests')
}
};
const homebrewCurrency = game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Homebrew).currency;
if (homebrewCurrency.enabled) {
context.inventory.currency = homebrewCurrency;
}
if (context.inventory.length === 0) {
context.inventory = Array(1).fill(Array(5).fill([]));
}

View file

@ -163,13 +163,15 @@ export const defaultRestOptions = {
id: 'repairArmor',
name: game.i18n.localize('DAGGERHEART.Downtime.ShortRest.RepairArmor.Name'),
img: 'icons/skills/trades/smithing-anvil-silver-red.webp',
description: game.i18n.localize('DAGGERHEART.Downtime.ShortRest.RepairArmor.Description')
description: game.i18n.localize('DAGGERHEART.Downtime.ShortRest.RepairArmor.Description'),
actions: []
},
prepare: {
id: 'prepare',
name: game.i18n.localize('DAGGERHEART.Downtime.ShortRest.Prepare.Name'),
img: 'icons/skills/trades/academics-merchant-scribe.webp',
description: game.i18n.localize('DAGGERHEART.Downtime.ShortRest.Prepare.Description')
description: game.i18n.localize('DAGGERHEART.Downtime.ShortRest.Prepare.Description'),
actions: []
}
}),
longRest: () => ({
@ -177,31 +179,36 @@ export const defaultRestOptions = {
id: 'tendToWounds',
name: game.i18n.localize('DAGGERHEART.Downtime.LongRest.TendToWounds.Name'),
img: 'icons/magic/life/cross-worn-green.webp',
description: game.i18n.localize('DAGGERHEART.Downtime.LongRest.TendToWounds.Description')
description: game.i18n.localize('DAGGERHEART.Downtime.LongRest.TendToWounds.Description'),
actions: []
},
clearStress: {
id: 'clearStress',
name: game.i18n.localize('DAGGERHEART.Downtime.LongRest.ClearStress.Name'),
img: 'icons/magic/perception/eye-ringed-green.webp',
description: game.i18n.localize('DAGGERHEART.Downtime.LongRest.ClearStress.Description')
description: game.i18n.localize('DAGGERHEART.Downtime.LongRest.ClearStress.Description'),
actions: []
},
repairArmor: {
id: 'repairArmor',
name: game.i18n.localize('DAGGERHEART.Downtime.LongRest.RepairArmor.Name'),
img: 'icons/skills/trades/smithing-anvil-silver-red.webp',
description: game.i18n.localize('DAGGERHEART.Downtime.LongRest.RepairArmor.Description')
description: game.i18n.localize('DAGGERHEART.Downtime.LongRest.RepairArmor.Description'),
actions: []
},
prepare: {
id: 'prepare',
name: game.i18n.localize('DAGGERHEART.Downtime.LongRest.Prepare.Name'),
img: 'icons/skills/trades/academics-merchant-scribe.webp',
description: game.i18n.localize('DAGGERHEART.Downtime.LongRest.Prepare.Description')
description: game.i18n.localize('DAGGERHEART.Downtime.LongRest.Prepare.Description'),
actions: []
},
workOnAProject: {
id: 'workOnAProject',
name: game.i18n.localize('DAGGERHEART.Downtime.LongRest.WorkOnAProject.Name'),
img: 'icons/skills/social/thumbsup-approval-like.webp',
description: game.i18n.localize('DAGGERHEART.Downtime.LongRest.WorkOnAProject.Description')
description: game.i18n.localize('DAGGERHEART.Downtime.LongRest.WorkOnAProject.Description'),
actions: []
}
}),
custom: {

View file

@ -16,6 +16,38 @@ export default class DhHomebrew extends foundry.abstract.DataModel {
traitArray: new fields.ArrayField(new fields.NumberField({ required: true, integer: true }), {
initial: () => [2, 1, 1, 0, 0, -1]
}),
currency: new fields.SchemaField({
enabled: new fields.BooleanField({
required: true,
initial: false,
label: 'DAGGERHEART.Settings.Homebrew.Currency.enabled'
}),
title: new fields.StringField({
required: true,
initial: 'Gold',
label: 'DAGGERHEART.Settings.Homebrew.Currency.currencyName'
}),
coins: new fields.StringField({
required: true,
initial: 'Coins',
label: 'DAGGERHEART.Settings.Homebrew.Currency.coinName'
}),
handfulls: new fields.StringField({
required: true,
initial: 'Handfulls',
label: 'DAGGERHEART.Settings.Homebrew.Currency.handfullName'
}),
bags: new fields.StringField({
required: true,
initial: 'Bags',
label: 'DAGGERHEART.Settings.Homebrew.Currency.bagName'
}),
chests: new fields.StringField({
required: true,
initial: 'Chests',
label: 'DAGGERHEART.Settings.Homebrew.Currency.chestName'
})
}),
restMoves: new fields.SchemaField({
longRest: new fields.SchemaField({
nrChoices: new fields.NumberField({ required: true, integer: true, min: 1, initial: 2 }),