diff --git a/lang/en.json b/lang/en.json index 7fe6f341..24eeeab9 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2487,6 +2487,7 @@ "step": "Step", "stress": "Stress", "subclasses": "Subclasses", + "subType": "Subtype", "success": "Success", "summon": { "single": "Summon", diff --git a/module/applications/dialogs/levelupOptionsDialog.mjs b/module/applications/dialogs/levelupOptionsDialog.mjs index afc247b3..dfe098e1 100644 --- a/module/applications/dialogs/levelupOptionsDialog.mjs +++ b/module/applications/dialogs/levelupOptionsDialog.mjs @@ -53,8 +53,23 @@ export default class LevelupOptionsDialog extends HandlebarsApplicationMixin(App async _prepareContext(_options) { const context = await super._prepareContext(_options); - context.item = this.item; context.fields = this.item.system.schema.fields.levelupOptionTiers.element.element.fields; + context.item = this.item; + context.levelupOptionTiers = Object.keys(this.item.system.levelupOptionTiers).reduce((acc, key) => { + const tier = this.item.system.levelupOptionTiers[key]; + acc[key] = Object.keys(tier).reduce((acc, key) => { + const option = tier[key]; + acc[key] = { + ...option, + typeData: option.type ? LevelOptionType[option.type] : null + }; + + return acc; + }, {}); + + return acc; + }, {}) + context.optionTypes = LevelOptionType; context.selectedOption = this.selectedOption; @@ -63,6 +78,7 @@ export default class LevelupOptionsDialog extends HandlebarsApplicationMixin(App static async updateData(_event, _element, formData) { const data = foundry.utils.expandObject(formData.object); + await this.item.update(data) this.render(); } diff --git a/module/applications/levelup/levelup.mjs b/module/applications/levelup/levelup.mjs index c4616d9a..4a9afcac 100644 --- a/module/applications/levelup/levelup.mjs +++ b/module/applications/levelup/levelup.mjs @@ -527,7 +527,8 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2) minCost: Number(button.dataset.cost), amount: button.dataset.amount ? Number(button.dataset.amount) : null, value: button.dataset.value, - type: button.dataset.type + type: button.dataset.type, + subType: button.dataset.subType }; if (button.dataset.type === 'domainCard') { diff --git a/module/data/actor/character.mjs b/module/data/actor/character.mjs index f4d9ab7b..787c19b3 100644 --- a/module/data/actor/character.mjs +++ b/module/data/actor/character.mjs @@ -766,8 +766,8 @@ export default class DhCharacter extends DhCreature { } }); break; - case 'comboStrikes': - this.rules.roll.comboDieIndex += 1; + case 'dice': + this.rules.roll[selection.subType] += 1; break; } } diff --git a/module/data/levelData.mjs b/module/data/levelData.mjs index 4f55d9ee..ac5546c0 100644 --- a/module/data/levelData.mjs +++ b/module/data/levelData.mjs @@ -41,6 +41,7 @@ export default class DhLevelData extends foundry.abstract.DataModel { level: new fields.NumberField({ required: true, integer: true }), optionKey: new fields.StringField({ required: true }), type: new fields.StringField({ required: true, choices: LevelOptionType }), + subType: new fields.StringField({ nullable: true }), checkboxNr: new fields.NumberField({ required: true, integer: true }), value: new fields.NumberField({ integer: true }), minCost: new fields.NumberField({ integer: true }), diff --git a/module/data/levelTier.mjs b/module/data/levelTier.mjs index 6a9c13f6..d300756e 100644 --- a/module/data/levelTier.mjs +++ b/module/data/levelTier.mjs @@ -69,6 +69,10 @@ export class DhLevelOption extends foundry.abstract.DataModel { choices: LevelOptionType, label: 'DAGGERHEART.GENERAL.type' }), + subType: new fields.StringField({ + nullable: true, + label: 'DAGGERHEART.GENERAL.subType', + }), value: new fields.NumberField({ integer: true, label: 'DAGGERHEART.GENERAL.value' @@ -136,13 +140,6 @@ export const CompanionLevelOptionType = { } }; -export const ClassLevelOptionTypes = { - comboStrikes: { - id: 'comboStrikes', - label: 'Increase your Combo Die size', - }, -}; - export const LevelOptionType = { trait: { id: 'trait', @@ -192,7 +189,16 @@ export const LevelOptionType = { id: 'multiclass', label: 'Multiclass' }, - ...ClassLevelOptionTypes, + dice: { + id: 'dice', + label: 'Increase Dice Size', + subTypes: { + hopeIndex: { key: 'hopeIndex', label: 'DAGGERHEART.GENERAL.hope' }, + fearIndex: { key: 'fearIndex', label: 'DAGGERHEART.GENERAL.fear' }, + advantageIndex: { key: 'advantageIndex', label: 'DAGGERHEART.GENERAL.Advantage.full' }, + comboDieIndex:{ key: 'comboDieIndex', label: 'Combo Die' } // Translation pending actual useage + }, + }, ...CompanionLevelOptionType }; diff --git a/module/data/levelup.mjs b/module/data/levelup.mjs index 4dc1c058..37d579c8 100644 --- a/module/data/levelup.mjs +++ b/module/data/levelup.mjs @@ -90,6 +90,7 @@ export class DhLevelup extends foundry.abstract.DataModel { checkboxSelections: new fields.NumberField({ required: true, integer: true }), minCost: new fields.NumberField({ required: true, integer: true }), type: new fields.StringField({ required: true, choices: LevelOptionType }), + subType: new fields.StringField({ nullable: true }), value: new fields.NumberField({ integer: true }), amount: new fields.NumberField({ integer: true }) }) @@ -242,7 +243,7 @@ export class DhLevelup extends foundry.abstract.DataModel { const checkboxes = [...Array(option.checkboxSelections).keys()].flatMap(index => { const checkboxNr = index + 1; const checkboxData = selections[tierKey]?.[optionKey]?.[checkboxNr]; - const checkbox = { ...option, checkboxNr, tier: tierKey }; + const checkbox = { ...option, checkboxNr, tier: tierKey, option: optionKey }; if (checkboxData) { checkbox.level = checkboxData.level; @@ -343,7 +344,8 @@ export class DhLevelupLevel extends foundry.abstract.DataModel { value: new fields.StringField(), data: new fields.ArrayField(new fields.StringField()), secondaryData: new fields.TypedObjectField(new fields.StringField()), - type: new fields.StringField({ required: true }) + type: new fields.StringField({ required: true }), + subType: new fields.StringField({ nullable: true }), }) ) ) diff --git a/templates/dialogs/levelupOptionsDialog/parts/tier.hbs b/templates/dialogs/levelupOptionsDialog/parts/tier.hbs index 906e3407..f8f4cbab 100644 --- a/templates/dialogs/levelupOptionsDialog/parts/tier.hbs +++ b/templates/dialogs/levelupOptionsDialog/parts/tier.hbs @@ -5,18 +5,21 @@ - {{#with (lookup item.system.levelupOptionTiers tab.tier)}} + {{#with (lookup levelupOptionTiers tab.tier)}} {{#unless (empty this)}} {{#each this as |option key|}}
- {{formGroup @root.fields.label value=option.label name=(concat "system.levelOptionTiers." ../../tab.tier "." key ".label") localize=true }} - {{formGroup @root.fields.type value=option.type name=(concat "system.levelOptionTiers." ../../tab.tier "." key ".type") localize=true }} -
- {{formGroup @root.fields.checkboxSelections value=option.checkboxSelections name=(concat "system.levelOptionTiers." ../../tab.tier "." key ".checkboxSelections") localize=true }} - {{formGroup @root.fields.minCost value=option.minCost name=(concat "system.levelOptionTiers." ../../tab.tier "." key ".minCost") localize=true }} + {{formGroup @root.fields.label value=option.label name=(concat "system.levelupOptionTiers." ../../tab.tier "." key ".label") localize=true }} + {{formGroup @root.fields.type value=option.type name=(concat "system.levelupOptionTiers." ../../tab.tier "." key ".type") localize=true }} +
+ {{formGroup @root.fields.checkboxSelections value=option.checkboxSelections name=(concat "system.levelupOptionTiers." ../../tab.tier "." key ".checkboxSelections") localize=true }} + {{formGroup @root.fields.minCost value=option.minCost name=(concat "system.levelupOptionTiers." ../../tab.tier "." key ".minCost") localize=true }} + {{#if option.typeData}} + {{formGroup @root.fields.subType value=option.subType name=(concat "system.levelupOptionTiers." ../../tab.tier "." key ".subType") choices=option.typeData.subTypes localize=true }} + {{/if}}
diff --git a/templates/levelup/tabs/advancements.hbs b/templates/levelup/tabs/advancements.hbs index 5e65be34..f1b197b5 100644 --- a/templates/levelup/tabs/advancements.hbs +++ b/templates/levelup/tabs/advancements.hbs @@ -19,12 +19,13 @@ type="checkbox" class="selection-checkbox{{#if (gt this.cost 1)}} multi{{/if}}" {{checked this.selected}} {{#if this.disabled}}disabled{{/if}} data-tier="{{this.tier}}" data-level="{{this.level}}" - data-option="{{this.type}}" + data-option="{{this.option}}" data-checkbox-nr="{{this.checkboxNr}}" data-cost="{{this.minCost}}" data-amount="{{this.amount}}" data-value="{{this.value}}" data-type="{{this.type}}" + data-sub-type="{{this.subType}}" /> {{/each}}