This commit is contained in:
WBHarry 2026-04-20 19:02:13 +00:00 committed by GitHub
commit 01a1a0ce77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 132 additions and 83 deletions

View file

@ -237,10 +237,6 @@
"unequip": "Unequip", "unequip": "Unequip",
"useItem": "Use Item" "useItem": "Use Item"
}, },
"defaultHopeDice": "Default Hope Dice",
"defaultFearDice": "Default Fear Dice",
"defaultAdvantageDice": "Default Advantage Dice",
"defaultDisadvantageDice": "Default Disadvantage Dice",
"disadvantageSources": { "disadvantageSources": {
"label": "Disadvantage Sources", "label": "Disadvantage Sources",
"hint": "Add single words or short text as reminders and hints of what a character has disadvantage on." "hint": "Add single words or short text as reminders and hints of what a character has disadvantage on."
@ -306,6 +302,16 @@
}, },
"noPartner": "No Partner selected" "noPartner": "No Partner selected"
}, },
"Creature": {
"rules": {
"roll": {
"hope": { "label": "Default Hope Dice Index", "hint": "Index for the default hope dice. 0=d4, 1=d6, 2=d8, 3=d10, 4=d12, 5=d20" },
"fear": { "label": "Default Fear Dice Index", "hint": "Index for the default fear dice. 0=d4, 1=d6, 2=d8, 3=d10, 4=d12, 5=d20" },
"advantage": { "label": "Default Advantage Dice Index", "hint": "Index for the default advantage dice. 0=d4, 1=d6, 2=d8, 3=d10, 4=d12, 5=d20" },
"disadvantage": { "label": "Default Disadvantage Dice Index", "hint": "Index for the default disadvantage dice. 0=d4, 1=d6, 2=d8, 3=d10, 4=d12, 5=d20" }
}
}
},
"Environment": { "Environment": {
"FIELDS": { "FIELDS": {
"description": { "description": {
@ -1268,7 +1274,7 @@
}, },
"LevelupData": { "LevelupData": {
"checkboxSelections": "Checkboxes", "checkboxSelections": "Checkboxes",
"minCost": "Cost Per Checkbox" "minCost": "Minimum Boxes Picked"
}, },
"Range": { "Range": {
"self": { "self": {
@ -2481,6 +2487,7 @@
"step": "Step", "step": "Step",
"stress": "Stress", "stress": "Stress",
"subclasses": "Subclasses", "subclasses": "Subclasses",
"subType": "Subtype",
"success": "Success", "success": "Success",
"summon": { "summon": {
"single": "Summon", "single": "Summon",

View file

@ -176,11 +176,11 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
this.config.roll.advantage = this.config.roll.advantage === advantage ? 0 : advantage; this.config.roll.advantage = this.config.roll.advantage === advantage ? 0 : advantage;
if (this.config.roll.advantage === 1 && this.config.data.rules.roll.defaultAdvantageDice) { if (this.config.roll.advantage === 1 && this.config.data.rules.roll.advantageFaces) {
const faces = Number.parseInt(this.config.data.rules.roll.defaultAdvantageDice); const faces = Number.parseInt(this.config.data.rules.roll.advantageFaces);
this.roll.advantageFaces = Number.isNaN(faces) ? this.roll.advantageFaces : faces; this.roll.advantageFaces = Number.isNaN(faces) ? this.roll.advantageFaces : faces;
} else if (this.config.roll.advantage === -1 && this.config.data.rules.roll.defaultDisadvantageDice) { } else if (this.config.roll.advantage === -1 && this.config.data.rules.roll.disadvantageFaces) {
const faces = Number.parseInt(this.config.data.rules.roll.defaultDisadvantageDice); const faces = Number.parseInt(this.config.data.rules.roll.disadvantageFaces);
this.roll.advantageFaces = Number.isNaN(faces) ? this.roll.advantageFaces : faces; this.roll.advantageFaces = Number.isNaN(faces) ? this.roll.advantageFaces : faces;
} }

View file

@ -53,8 +53,23 @@ export default class LevelupOptionsDialog extends HandlebarsApplicationMixin(App
async _prepareContext(_options) { async _prepareContext(_options) {
const context = await super._prepareContext(_options); const context = await super._prepareContext(_options);
context.item = this.item;
context.fields = this.item.system.schema.fields.levelupOptionTiers.element.element.fields; 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.optionTypes = LevelOptionType;
context.selectedOption = this.selectedOption; context.selectedOption = this.selectedOption;
@ -63,6 +78,7 @@ export default class LevelupOptionsDialog extends HandlebarsApplicationMixin(App
static async updateData(_event, _element, formData) { static async updateData(_event, _element, formData) {
const data = foundry.utils.expandObject(formData.object); const data = foundry.utils.expandObject(formData.object);
await this.item.update(data)
this.render(); this.render();
} }

View file

@ -527,7 +527,8 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2)
minCost: Number(button.dataset.cost), minCost: Number(button.dataset.cost),
amount: button.dataset.amount ? Number(button.dataset.amount) : null, amount: button.dataset.amount ? Number(button.dataset.amount) : null,
value: button.dataset.value, value: button.dataset.value,
type: button.dataset.type type: button.dataset.type,
subType: button.dataset.subType
}; };
if (button.dataset.type === 'domainCard') { if (button.dataset.type === 'domainCard') {

View file

@ -261,24 +261,6 @@ export default class DhCharacter extends DhCreature {
}) })
} }
}), }),
dualityRoll: new fields.SchemaField({
defaultHopeDice: new fields.NumberField({
nullable: false,
required: true,
integer: true,
choices: CONFIG.DH.GENERAL.dieFaces,
initial: 12,
label: 'DAGGERHEART.ACTORS.Character.defaultHopeDice'
}),
defaultFearDice: new fields.NumberField({
nullable: false,
required: true,
integer: true,
choices: CONFIG.DH.GENERAL.dieFaces,
initial: 12,
label: 'DAGGERHEART.ACTORS.Character.defaultFearDice'
})
}),
burden: new fields.SchemaField({ burden: new fields.SchemaField({
ignore: new fields.BooleanField({ label: 'DAGGERHEART.ACTORS.Character.burden.ignore.label' }) ignore: new fields.BooleanField({ label: 'DAGGERHEART.ACTORS.Character.burden.ignore.label' })
}), }),
@ -287,29 +269,49 @@ export default class DhCharacter extends DhCreature {
label: 'DAGGERHEART.ACTORS.Character.roll.guaranteedCritical.label', label: 'DAGGERHEART.ACTORS.Character.roll.guaranteedCritical.label',
hint: 'DAGGERHEART.ACTORS.Character.roll.guaranteedCritical.hint' hint: 'DAGGERHEART.ACTORS.Character.roll.guaranteedCritical.hint'
}), }),
defaultAdvantageDice: new fields.NumberField({ hopeIndex: new fields.NumberField({
nullable: true,
required: true, required: true,
integer: true, integer: true,
choices: CONFIG.DH.GENERAL.dieFaces, min: 0,
initial: null, max: 5,
label: 'DAGGERHEART.ACTORS.Character.defaultAdvantageDice' initial: 4,
label: 'DAGGERHEART.ACTORS.Creature.rules.roll.hope.label',
hint: 'DAGGERHEART.ACTORS.Creature.rules.roll.hope.hint'
}), }),
defaultDisadvantageDice: new fields.NumberField({ fearIndex: new fields.NumberField({
nullable: true,
required: true, required: true,
integer: true, integer: true,
choices: CONFIG.DH.GENERAL.dieFaces, min: 0,
initial: null, max: 5,
label: 'DAGGERHEART.ACTORS.Character.defaultDisadvantageDice' initial: 4,
label: 'DAGGERHEART.ACTORS.Creature.rules.roll.fear.label',
hint: 'DAGGERHEART.ACTORS.Creature.rules.roll.fear.hint'
}), }),
advantageIndex: new fields.NumberField({
required: true,
integer: true,
min: 0,
max: 5,
initial: 1,
label: 'DAGGERHEART.ACTORS.Creature.rules.roll.advantage.label',
hint: 'DAGGERHEART.ACTORS.Creature.rules.roll.advantage.hint'
}),
disadvantageIndex: new fields.NumberField({
required: true,
integer: true,
min: 0,
max: 5,
initial: 1,
label: 'DAGGERHEART.ACTORS.Creature.rules.roll.disadvantage.label',
hint: 'DAGGERHEART.ACTORS.Creature.rules.roll.disadvantage.hint'
}),
comboDieIndex: new fields.NumberField({
integer: true,
min: 0,
max: 5,
initial: 0,
})
}), }),
comboDieIndex: new fields.NumberField({
integer: true,
min: 0,
max: 5,
initial: 0,
})
}) })
}; };
} }
@ -764,8 +766,8 @@ export default class DhCharacter extends DhCreature {
} }
}); });
break; break;
case 'comboStrikes': case 'dice':
this.rules.comboDieIndex += 1; this.rules.roll[selection.subType] += 1;
break; break;
} }
} }
@ -824,6 +826,14 @@ export default class DhCharacter extends DhCreature {
isReversed: true isReversed: true
}; };
/* Add convience <dice>Faces properties for all dice */
const { hopeIndex, fearIndex, advantageIndex, disadvantageIndex, comboDieIndex } = this.rules.roll;
const dice = { hopeIndex, fearIndex, advantageIndex, disadvantageIndex, comboDieIndex };
for (const dieKey of Object.keys(dice)) {
const diceBaseKey = dieKey.replace('Index', '');
this.rules.roll[`${diceBaseKey}Faces`] = CONFIG.DH.GENERAL.dieFaces[dice[dieKey]];
}
this.attack.damage.parts.hitPoints.value.custom.formula = `@prof${this.basicAttackDamageDice}${this.rules.attack.damage.bonus ? ` + ${this.rules.attack.damage.bonus}` : ''}`; this.attack.damage.parts.hitPoints.value.custom.formula = `@prof${this.basicAttackDamageDice}${this.rules.attack.damage.bonus ? ` + ${this.rules.attack.damage.bonus}` : ''}`;
} }

View file

@ -63,21 +63,23 @@ export default class DhCompanion extends DhCreature {
}) })
}), }),
roll: new fields.SchemaField({ roll: new fields.SchemaField({
defaultAdvantageDice: new fields.NumberField({ advantage: new fields.NumberField({
nullable: true,
required: true, required: true,
integer: true, integer: true,
choices: CONFIG.DH.GENERAL.dieFaces, min: 0,
initial: null, max: 5,
label: 'DAGGERHEART.ACTORS.Character.defaultAdvantageDice' initial: 1,
label: 'DAGGERHEART.ACTORS.Creature.rules.roll.advantage.label',
hint: 'DAGGERHEART.ACTORS.Creature.rules.roll.advantage.hint'
}), }),
defaultDisadvantageDice: new fields.NumberField({ disadvantage: new fields.NumberField({
nullable: true,
required: true, required: true,
integer: true, integer: true,
choices: CONFIG.DH.GENERAL.dieFaces, min: 0,
initial: null, max: 5,
label: 'DAGGERHEART.ACTORS.Character.defaultDisadvantageDice' initial: 1,
label: 'DAGGERHEART.ACTORS.Creature.rules.roll.disadvantage.label',
hint: 'DAGGERHEART.ACTORS.Creature.rules.roll.disadvantage.hint'
}), }),
}) })
}), }),

View file

@ -41,6 +41,7 @@ export default class DhLevelData extends foundry.abstract.DataModel {
level: new fields.NumberField({ required: true, integer: true }), level: new fields.NumberField({ required: true, integer: true }),
optionKey: new fields.StringField({ required: true }), optionKey: new fields.StringField({ required: true }),
type: new fields.StringField({ required: true, choices: LevelOptionType }), type: new fields.StringField({ required: true, choices: LevelOptionType }),
subType: new fields.StringField({ nullable: true }),
checkboxNr: new fields.NumberField({ required: true, integer: true }), checkboxNr: new fields.NumberField({ required: true, integer: true }),
value: new fields.NumberField({ integer: true }), value: new fields.NumberField({ integer: true }),
minCost: new fields.NumberField({ integer: true }), minCost: new fields.NumberField({ integer: true }),

View file

@ -69,6 +69,10 @@ export class DhLevelOption extends foundry.abstract.DataModel {
choices: LevelOptionType, choices: LevelOptionType,
label: 'DAGGERHEART.GENERAL.type' label: 'DAGGERHEART.GENERAL.type'
}), }),
subType: new fields.StringField({
nullable: true,
label: 'DAGGERHEART.GENERAL.subType',
}),
value: new fields.NumberField({ value: new fields.NumberField({
integer: true, integer: true,
label: 'DAGGERHEART.GENERAL.value' 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 = { export const LevelOptionType = {
trait: { trait: {
id: 'trait', id: 'trait',
@ -192,7 +189,16 @@ export const LevelOptionType = {
id: 'multiclass', id: 'multiclass',
label: '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 ...CompanionLevelOptionType
}; };

View file

@ -90,6 +90,7 @@ export class DhLevelup extends foundry.abstract.DataModel {
checkboxSelections: new fields.NumberField({ required: true, integer: true }), checkboxSelections: new fields.NumberField({ required: true, integer: true }),
minCost: new fields.NumberField({ required: true, integer: true }), minCost: new fields.NumberField({ required: true, integer: true }),
type: new fields.StringField({ required: true, choices: LevelOptionType }), type: new fields.StringField({ required: true, choices: LevelOptionType }),
subType: new fields.StringField({ nullable: true }),
value: new fields.NumberField({ integer: true }), value: new fields.NumberField({ integer: true }),
amount: 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 checkboxes = [...Array(option.checkboxSelections).keys()].flatMap(index => {
const checkboxNr = index + 1; const checkboxNr = index + 1;
const checkboxData = selections[tierKey]?.[optionKey]?.[checkboxNr]; const checkboxData = selections[tierKey]?.[optionKey]?.[checkboxNr];
const checkbox = { ...option, checkboxNr, tier: tierKey }; const checkbox = { ...option, checkboxNr, tier: tierKey, option: optionKey };
if (checkboxData) { if (checkboxData) {
checkbox.level = checkboxData.level; checkbox.level = checkboxData.level;
@ -343,7 +344,8 @@ export class DhLevelupLevel extends foundry.abstract.DataModel {
value: new fields.StringField(), value: new fields.StringField(),
data: new fields.ArrayField(new fields.StringField()), data: new fields.ArrayField(new fields.StringField()),
secondaryData: new fields.TypedObjectField(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 }),
}) })
) )
) )

View file

@ -11,7 +11,7 @@ export default class DualityRoll extends D20Roll {
this.rallyChoices = this.setRallyChoices(); this.rallyChoices = this.setRallyChoices();
this.guaranteedCritical = options.guaranteedCritical; this.guaranteedCritical = options.guaranteedCritical;
const advantageFaces = data.rules?.roll?.defaultAdvantageDice ? Number.parseInt(data.rules.roll.defaultAdvantageDice) : 6 const advantageFaces = data.rules?.roll?.advantageFaces ? Number.parseInt(data.rules.roll.advantageFaces) : 6
this.advantageFaces = Number.isNaN(advantageFaces) ? 6 : advantageFaces; this.advantageFaces = Number.isNaN(advantageFaces) ? 6 : advantageFaces;
} }
@ -137,11 +137,11 @@ export default class DualityRoll extends D20Roll {
} }
this.terms[0] = new game.system.api.dice.diceTypes.HopeDie({ this.terms[0] = new game.system.api.dice.diceTypes.HopeDie({
faces: this.data.rules.dualityRoll?.defaultHopeDice ?? 12 faces: this.data.rules.roll?.hopeFaces ?? 12
}); });
this.terms[1] = new foundry.dice.terms.OperatorTerm({ operator: '+' }); this.terms[1] = new foundry.dice.terms.OperatorTerm({ operator: '+' });
this.terms[2] = new game.system.api.dice.diceTypes.FearDie({ this.terms[2] = new game.system.api.dice.diceTypes.FearDie({
faces: this.data.rules.dualityRoll?.defaultFearDice ?? 12 faces: this.data.rules.roll?.fearFaces ?? 12
}); });
} }

View file

@ -357,8 +357,8 @@
}, },
"changes": [ "changes": [
{ {
"key": "system.rules.dualityRoll.defaultHopeDice", "key": "system.rules.roll.hopeIndex",
"value": "d8", "value": 2,
"priority": null, "priority": null,
"type": "override" "type": "override"
} }

View file

@ -320,8 +320,8 @@
}, },
"changes": [ "changes": [
{ {
"key": "system.rules.dualityRoll.defaultFearDice", "key": "system.rules.roll.fearIndex",
"value": "d20", "value": 5,
"priority": null, "priority": null,
"type": "override" "type": "override"
} }

View file

@ -192,9 +192,9 @@
}, },
"changes": [ "changes": [
{ {
"key": "system.rules.dualityRoll.defaultHopeDice", "key": "system.rules.roll.hopeIndex",
"mode": 5, "mode": 5,
"value": "d10", "value": 3,
"priority": null "priority": null
} }
], ],

View file

@ -5,18 +5,21 @@
</select> </select>
<button data-action="addTierOption" data-tier="{{tab.tier}}" {{#unless selectedOption}}disabled{{/unless}}>{{localize "Add Levelup Option"}}</button> <button data-action="addTierOption" data-tier="{{tab.tier}}" {{#unless selectedOption}}disabled{{/unless}}>{{localize "Add Levelup Option"}}</button>
</div> </div>
{{#with (lookup item.system.levelupOptionTiers tab.tier)}} {{#with (lookup levelupOptionTiers tab.tier)}}
{{#unless (empty this)}} {{#unless (empty this)}}
{{#each this as |option key|}} {{#each this as |option key|}}
<fieldset> <fieldset>
<legend><a data-action="removeTierOption" data-tier="{{../../tab.tier}}" data-key="{{key}}"><i class="fa-solid fa-trash"></i></a></legend> <legend><a data-action="removeTierOption" data-tier="{{../../tab.tier}}" data-key="{{key}}"><i class="fa-solid fa-trash"></i></a></legend>
<div class="tier-container"> <div class="tier-container">
{{formGroup @root.fields.label value=option.label name=(concat "system.levelOptionTiers." ../../tab.tier "." key ".label") 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.levelOptionTiers." ../../tab.tier "." key ".type") localize=true }} {{formGroup @root.fields.type value=option.type name=(concat "system.levelupOptionTiers." ../../tab.tier "." key ".type") localize=true }}
<div class="two-columns even"> <div class="nest-inputs">
{{formGroup @root.fields.checkboxSelections value=option.checkboxSelections name=(concat "system.levelOptionTiers." ../../tab.tier "." key ".checkboxSelections") 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.levelOptionTiers." ../../tab.tier "." key ".minCost") 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}}
</div> </div>
</div> </div>
</fieldset> </fieldset>

View file

@ -19,12 +19,13 @@
type="checkbox" class="selection-checkbox{{#if (gt this.cost 1)}} multi{{/if}}" {{checked this.selected}} {{#if this.disabled}}disabled{{/if}} 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-tier="{{this.tier}}"
data-level="{{this.level}}" data-level="{{this.level}}"
data-option="{{this.type}}" data-option="{{this.option}}"
data-checkbox-nr="{{this.checkboxNr}}" data-checkbox-nr="{{this.checkboxNr}}"
data-cost="{{this.minCost}}" data-cost="{{this.minCost}}"
data-amount="{{this.amount}}" data-amount="{{this.amount}}"
data-value="{{this.value}}" data-value="{{this.value}}"
data-type="{{this.type}}" data-type="{{this.type}}"
data-sub-type="{{this.subType}}"
/> />
{{/each}} {{/each}}
</div> </div>