mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
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:
parent
778e569037
commit
b25e1cec78
8 changed files with 121 additions and 23 deletions
|
|
@ -99,6 +99,15 @@
|
||||||
"FIELDS": {
|
"FIELDS": {
|
||||||
"maxFear": { "label": "Max Fear" },
|
"maxFear": { "label": "Max Fear" },
|
||||||
"traitArray": { "label": "Initial Trait Modifiers" }
|
"traitArray": { "label": "Initial Trait Modifiers" }
|
||||||
|
},
|
||||||
|
"Currency": {
|
||||||
|
"enabled": "Enable Overrides",
|
||||||
|
"title": "Currency Overrides",
|
||||||
|
"currencyName": "Currency Name",
|
||||||
|
"coinName": "Coin Name",
|
||||||
|
"handfullName": "Handfull Name",
|
||||||
|
"bagName": "Bag Name",
|
||||||
|
"chestName": "Chest Name"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Resources": {
|
"Resources": {
|
||||||
|
|
|
||||||
|
|
@ -24,14 +24,16 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
|
||||||
editItem: this.editItem,
|
editItem: this.editItem,
|
||||||
removeItem: this.removeItem,
|
removeItem: this.removeItem,
|
||||||
resetMoves: this.resetMoves,
|
resetMoves: this.resetMoves,
|
||||||
save: this.save
|
save: this.save,
|
||||||
|
reset: this.reset
|
||||||
},
|
},
|
||||||
form: { handler: this.updateData, submitOnChange: true }
|
form: { handler: this.updateData, submitOnChange: true }
|
||||||
};
|
};
|
||||||
|
|
||||||
static PARTS = {
|
static PARTS = {
|
||||||
main: {
|
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());
|
await game.settings.set(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Homebrew, this.settings.toObject());
|
||||||
this.close();
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -409,9 +409,21 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
|
||||||
quantity: game.i18n.localize('DAGGERHEART.Sheets.PC.InventoryTab.QuantityTitle')
|
quantity: game.i18n.localize('DAGGERHEART.Sheets.PC.InventoryTab.QuantityTitle')
|
||||||
},
|
},
|
||||||
items: this.document.items.filter(x => x.type === 'armor')
|
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) {
|
if (context.inventory.length === 0) {
|
||||||
context.inventory = Array(1).fill(Array(5).fill([]));
|
context.inventory = Array(1).fill(Array(5).fill([]));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -163,13 +163,15 @@ export const defaultRestOptions = {
|
||||||
id: 'repairArmor',
|
id: 'repairArmor',
|
||||||
name: game.i18n.localize('DAGGERHEART.Downtime.ShortRest.RepairArmor.Name'),
|
name: game.i18n.localize('DAGGERHEART.Downtime.ShortRest.RepairArmor.Name'),
|
||||||
img: 'icons/skills/trades/smithing-anvil-silver-red.webp',
|
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: {
|
prepare: {
|
||||||
id: 'prepare',
|
id: 'prepare',
|
||||||
name: game.i18n.localize('DAGGERHEART.Downtime.ShortRest.Prepare.Name'),
|
name: game.i18n.localize('DAGGERHEART.Downtime.ShortRest.Prepare.Name'),
|
||||||
img: 'icons/skills/trades/academics-merchant-scribe.webp',
|
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: () => ({
|
longRest: () => ({
|
||||||
|
|
@ -177,31 +179,36 @@ export const defaultRestOptions = {
|
||||||
id: 'tendToWounds',
|
id: 'tendToWounds',
|
||||||
name: game.i18n.localize('DAGGERHEART.Downtime.LongRest.TendToWounds.Name'),
|
name: game.i18n.localize('DAGGERHEART.Downtime.LongRest.TendToWounds.Name'),
|
||||||
img: 'icons/magic/life/cross-worn-green.webp',
|
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: {
|
clearStress: {
|
||||||
id: 'clearStress',
|
id: 'clearStress',
|
||||||
name: game.i18n.localize('DAGGERHEART.Downtime.LongRest.ClearStress.Name'),
|
name: game.i18n.localize('DAGGERHEART.Downtime.LongRest.ClearStress.Name'),
|
||||||
img: 'icons/magic/perception/eye-ringed-green.webp',
|
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: {
|
repairArmor: {
|
||||||
id: 'repairArmor',
|
id: 'repairArmor',
|
||||||
name: game.i18n.localize('DAGGERHEART.Downtime.LongRest.RepairArmor.Name'),
|
name: game.i18n.localize('DAGGERHEART.Downtime.LongRest.RepairArmor.Name'),
|
||||||
img: 'icons/skills/trades/smithing-anvil-silver-red.webp',
|
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: {
|
prepare: {
|
||||||
id: 'prepare',
|
id: 'prepare',
|
||||||
name: game.i18n.localize('DAGGERHEART.Downtime.LongRest.Prepare.Name'),
|
name: game.i18n.localize('DAGGERHEART.Downtime.LongRest.Prepare.Name'),
|
||||||
img: 'icons/skills/trades/academics-merchant-scribe.webp',
|
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: {
|
workOnAProject: {
|
||||||
id: 'workOnAProject',
|
id: 'workOnAProject',
|
||||||
name: game.i18n.localize('DAGGERHEART.Downtime.LongRest.WorkOnAProject.Name'),
|
name: game.i18n.localize('DAGGERHEART.Downtime.LongRest.WorkOnAProject.Name'),
|
||||||
img: 'icons/skills/social/thumbsup-approval-like.webp',
|
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: {
|
custom: {
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,38 @@ export default class DhHomebrew extends foundry.abstract.DataModel {
|
||||||
traitArray: new fields.ArrayField(new fields.NumberField({ required: true, integer: true }), {
|
traitArray: new fields.ArrayField(new fields.NumberField({ required: true, integer: true }), {
|
||||||
initial: () => [2, 1, 1, 0, 0, -1]
|
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({
|
restMoves: new fields.SchemaField({
|
||||||
longRest: new fields.SchemaField({
|
longRest: new fields.SchemaField({
|
||||||
nrChoices: new fields.NumberField({ required: true, integer: true, min: 1, initial: 2 }),
|
nrChoices: new fields.NumberField({ required: true, integer: true, min: 1, initial: 2 }),
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<div>
|
<div class="scrollable">
|
||||||
{{formGroup settingFields.schema.fields.maxFear value=settingFields._source.maxFear localize=true}}
|
{{formGroup settingFields.schema.fields.maxFear value=settingFields._source.maxFear localize=true}}
|
||||||
|
|
||||||
<h4>{{localize "DAGGERHEART.Settings.Homebrew.FIELDS.traitArray.label"}}</h4>
|
<h4>{{localize "DAGGERHEART.Settings.Homebrew.FIELDS.traitArray.label"}}</h4>
|
||||||
|
|
@ -9,7 +9,20 @@
|
||||||
<input type="text" data-dtype="Number" name="{{concat "traitArray." index}}" value="{{this}}" />
|
<input type="text" data-dtype="Number" name="{{concat "traitArray." index}}" value="{{this}}" />
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>
|
||||||
|
{{localize "DAGGERHEART.Settings.Homebrew.Currency.title"}}
|
||||||
|
</legend>
|
||||||
|
{{formGroup settingFields.schema.fields.currency.fields.enabled value=settingFields._source.currency.enabled localize=true}}
|
||||||
|
{{formGroup settingFields.schema.fields.currency.fields.title value=settingFields._source.currency.title localize=true}}
|
||||||
|
{{formGroup settingFields.schema.fields.currency.fields.coins value=settingFields._source.currency.coins localize=true}}
|
||||||
|
{{formGroup settingFields.schema.fields.currency.fields.handfulls value=settingFields._source.currency.handfulls localize=true}}
|
||||||
|
{{formGroup settingFields.schema.fields.currency.fields.bags value=settingFields._source.currency.bags localize=true}}
|
||||||
|
{{formGroup settingFields.schema.fields.currency.fields.chests value=settingFields._source.currency.chests localize=true}}
|
||||||
|
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
<fieldset class="two-columns even">
|
<fieldset class="two-columns even">
|
||||||
<legend>{{localize "DAGGERHEART.Settings.Homebrew.DowntimeMoves"}}</legend>
|
<legend>{{localize "DAGGERHEART.Settings.Homebrew.DowntimeMoves"}}</legend>
|
||||||
|
|
|
||||||
|
|
@ -22,21 +22,21 @@
|
||||||
|
|
||||||
<div class="currency-section">
|
<div class="currency-section">
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<span>{{localize "DAGGERHEART.Sheets.PC.Gold.Coins"}}</span>
|
<span>{{localize this.inventory.currency.coins}}</span>
|
||||||
{{formInput systemFields.gold.fields.coins value=source.system.gold.coins enriched=source.system.gold.coins localize=true toggled=true}}
|
{{formInput systemFields.gold.fields.coins value=source.system.gold.coins enriched=source.system.gold.coins localize=true toggled=true}}
|
||||||
</div>
|
</div>
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<span>{{localize "DAGGERHEART.Sheets.PC.Gold.Handfulls"}}</span>
|
<span>{{localize this.inventory.currency.handfulls}}</span>
|
||||||
{{formInput systemFields.gold.fields.handfulls value=source.system.gold.handfulls enriched=source.system.gold.handfulls localize=true toggled=true}}
|
{{formInput systemFields.gold.fields.handfulls value=source.system.gold.handfulls enriched=source.system.gold.handfulls localize=true toggled=true}}
|
||||||
</div>
|
</div>
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<span>{{localize "DAGGERHEART.Sheets.PC.Gold.Bags"}}</span>
|
<span>{{localize this.inventory.currency.bags}}</span>
|
||||||
{{formInput systemFields.gold.fields.bags value=source.system.gold.bags enriched=source.system.gold.bags localize=true toggled=true}}
|
{{formInput systemFields.gold.fields.bags value=source.system.gold.bags enriched=source.system.gold.bags localize=true toggled=true}}
|
||||||
</div>
|
</div>
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<span>{{localize "DAGGERHEART.Sheets.PC.Gold.Chests"}}</span>
|
<span>{{localize this.inventory.currency.chests}}</span>
|
||||||
{{formInput systemFields.gold.fields.chests value=source.system.gold.chests enriched=source.system.gold.chests localize=true toggled=true}}
|
{{formInput systemFields.gold.fields.chests value=source.system.gold.chests enriched=source.system.gold.chests localize=true toggled=true}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
<fieldset class="left-main-container" style="padding-top: 0; margin-top: 8px;">
|
<fieldset class="left-main-container" style="padding-top: 0; margin-top: 8px;">
|
||||||
<legend class="legend" style="line-height: 2px;">{{localize "DAGGERHEART.Sheets.PC.Gold.Title"}}</legend>
|
<legend class="legend" style="line-height: 2px;">{{localize this.inventory.currency.title}}</legend>
|
||||||
|
|
||||||
<div class="gold-section">
|
<div class="gold-section">
|
||||||
<fieldset class="gold-fieldset">
|
<fieldset class="gold-fieldset">
|
||||||
<legend>
|
<legend>
|
||||||
{{localize "DAGGERHEART.Sheets.PC.Gold.Coins"}}
|
{{localize this.inventory.currency.coins}}
|
||||||
</legend>
|
</legend>
|
||||||
<div class="gold-column">
|
<div class="gold-column">
|
||||||
<div class="gold-row">
|
<div class="gold-row">
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset class="gold-fieldset">
|
<fieldset class="gold-fieldset">
|
||||||
<legend>
|
<legend>
|
||||||
{{localize "DAGGERHEART.Sheets.PC.Gold.Handfulls"}}
|
{{localize this.inventory.currency.handfulls}}
|
||||||
</legend>
|
</legend>
|
||||||
<div class="gold-column">
|
<div class="gold-column">
|
||||||
<div class="gold-row">
|
<div class="gold-row">
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset class="gold-fieldset">
|
<fieldset class="gold-fieldset">
|
||||||
<legend>
|
<legend>
|
||||||
{{localize "DAGGERHEART.Sheets.PC.Gold.Bags"}}
|
{{localize this.inventory.currency.bags}}
|
||||||
</legend>
|
</legend>
|
||||||
<div class="gold-column">
|
<div class="gold-column">
|
||||||
<div class="gold-row">
|
<div class="gold-row">
|
||||||
|
|
@ -76,7 +76,7 @@
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset class="gold-fieldset" style="min-width: 56px;">
|
<fieldset class="gold-fieldset" style="min-width: 56px;">
|
||||||
<legend>
|
<legend>
|
||||||
{{localize "DAGGERHEART.Sheets.PC.Gold.Chests"}}
|
{{localize this.inventory.currency.chests}}
|
||||||
</legend>
|
</legend>
|
||||||
|
|
||||||
<div class="gold-column">
|
<div class="gold-column">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue