mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-06-06 21:04:16 +02:00
[Fix] Address PR review feedback for starting gold feature
- Disabled denominations now receive 0 at character creation - Replace CharacterGoldField subclass with GoldField options callback; initial value logic now lives in character.mjs - Use formInput instead of plain text inputs for denomination labels - Rename "Quantity Name" column header to "Denomination" - Remove initialCurrency from resourceConfig and currency sync from refreshConfig (no longer needed)
This commit is contained in:
parent
d549a609e3
commit
83b25f4771
6 changed files with 39 additions and 30 deletions
|
|
@ -116,25 +116,29 @@ class ResourcesField extends fields.TypedObjectField {
|
|||
}
|
||||
|
||||
class GoldField extends fields.SchemaField {
|
||||
constructor() {
|
||||
super({
|
||||
coins: new fields.NumberField({ initial: 0, integer: true }),
|
||||
handfuls: new fields.NumberField({ initial: 1, integer: true }),
|
||||
bags: new fields.NumberField({ initial: 0, integer: true }),
|
||||
chests: new fields.NumberField({ initial: 0, integer: true })
|
||||
});
|
||||
constructor({ initial, ...options } = {}) {
|
||||
super(
|
||||
{
|
||||
coins: new fields.NumberField({ initial: 0, integer: true }),
|
||||
handfuls: new fields.NumberField({ initial: 1, integer: true }),
|
||||
bags: new fields.NumberField({ initial: 0, integer: true }),
|
||||
chests: new fields.NumberField({ initial: 0, integer: true })
|
||||
},
|
||||
options
|
||||
);
|
||||
this._initialCallback = initial;
|
||||
}
|
||||
}
|
||||
|
||||
class CharacterGoldField extends GoldField {
|
||||
getInitialValue(options) {
|
||||
const base = super.getInitialValue(options);
|
||||
const initialCurrency = CONFIG.DH.RESOURCE.character.initialCurrency;
|
||||
for (const type of ['coins', 'handfuls', 'bags', 'chests']) {
|
||||
base[type] = initialCurrency[type];
|
||||
getInitialValue(data) {
|
||||
if (this._initialCallback) {
|
||||
try {
|
||||
return this._initialCallback(data);
|
||||
} catch {
|
||||
/* settings not yet available */
|
||||
}
|
||||
}
|
||||
return base;
|
||||
return super.getInitialValue(data);
|
||||
}
|
||||
}
|
||||
|
||||
export { attributeField, ResourcesField, GoldField, CharacterGoldField, stressDamageReductionRule, bonusField };
|
||||
export { attributeField, ResourcesField, GoldField, stressDamageReductionRule, bonusField };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue