This commit is contained in:
Dapoolp 2025-07-29 22:23:19 +02:00
parent d136593968
commit 41046cdfca
13 changed files with 43 additions and 30 deletions

View file

@ -716,7 +716,7 @@
"name": "Hope",
"abbreviation": "HO"
},
"armorStack": {
"armorSlot": {
"name": "Armor Slot",
"abbreviation": "AS"
},

View file

@ -225,7 +225,7 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
await super.close({});
}
static async armorStackQuery({ actorId, damage, type }) {
static async armorSlotQuery({ actorId, damage, type }) {
return new Promise(async (resolve, reject) => {
const actor = await fromUuid(actorId);
if (!actor || !actor?.isOwner) reject();

View file

@ -112,7 +112,7 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
context.disableOption = this.disableOption.bind(this);
context.isNPC = this.action.actor?.isNPC;
context.baseSaveDifficulty = this.action.actor?.baseSaveDifficulty;
context.baseAttackBonus = this.action.actor?.system.attack?.damage.parts[0].value.bonus;
context.baseAttackBonus = this.action.actor?.system.attack?.roll.bonus;
context.hasRoll = this.action.hasRoll;
const settingsTiers = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LevelTiers).tiers;

View file

@ -85,10 +85,10 @@ export const healingTypes = {
label: 'DAGGERHEART.CONFIG.HealingType.hope.name',
abbreviation: 'DAGGERHEART.CONFIG.HealingType.hope.abbreviation'
},
armorStack: {
id: 'armorStack',
label: 'DAGGERHEART.CONFIG.HealingType.armorStack.name',
abbreviation: 'DAGGERHEART.CONFIG.HealingType.armorStack.abbreviation'
armorSlot: {
id: 'armorSlot',
label: 'DAGGERHEART.CONFIG.HealingType.armorSlot.name',
abbreviation: 'DAGGERHEART.CONFIG.HealingType.armorSlot.abbreviation'
},
fear: {
id: 'fear',
@ -199,7 +199,7 @@ export const defaultRestOptions = {
actionType: 'action',
chatDisplay: false,
healing: {
applyTo: healingTypes.armorStack.id,
applyTo: healingTypes.armorSlot.id,
value: {
custom: {
enabled: true,
@ -287,7 +287,7 @@ export const defaultRestOptions = {
actionType: 'action',
chatDisplay: false,
healing: {
applyTo: healingTypes.armorStack.id,
applyTo: healingTypes.armorSlot.id,
value: {
custom: {
enabled: true,
@ -425,8 +425,8 @@ export const refreshTypes = {
};
export const abilityCosts = {
hp: {
id: 'hp',
hitPoints: {
id: 'hitPoints',
label: 'DAGGERHEART.CONFIG.HealingType.hitPoints.name',
group: 'Global'
},

View file

@ -604,7 +604,7 @@ export const weaponFeatures = {
img: 'icons/skills/melee/hand-grip-sword-strike-orange.webp',
cost: [
{
type: 'armorStack',
type: 'armorSlot',
value: 1
}
],

View file

@ -203,6 +203,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
async consume(config) {
const usefulResources = foundry.utils.deepClone(this.actor.system.resources);
for (var cost of config.costs) {
if (cost.keyIsID) {
usefulResources[cost.key] = {
@ -223,13 +224,10 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
keyIsID: resource.keyIsID
};
});
console.log(resources)
await this.actor.modifyResource(resources);
if (config.uses?.enabled) {
const newActions = foundry.utils.getProperty(this.item.system, this.systemPath).map(x => x.toObject());
newActions[this.index].uses.value++;
await this.item.update({ [`system.${this.systemPath}`]: newActions });
}
if (config.uses?.enabled)
this.update({ 'uses.value': this.uses.value + 1 });
}
/* */

View file

@ -563,6 +563,12 @@ export default class DhCharacter extends BaseDataActor {
this.resources.hope.value = Math.min(baseHope, this.resources.hope.max);
this.attack.roll.trait = this.rules.attack.roll.trait ?? this.attack.roll.trait;
this.resources.armor = {
value: this.armor.system.marks.value,
max: this.armorScore,
isReversed: true
};
this.attack.damage.parts[0].value.custom.formula = `@prof${this.basicAttackDamageDice}${this.rules.attack.damage.bonus ? ` + ${this.rules.attack.damage.bonus}` : ''}`;
}

View file

@ -26,11 +26,19 @@ export default class CostField extends fields.ArrayField {
}
static calcCosts(costs) {
console.log(costs, CostField.getResources.call(this, costs))
const resources = CostField.getResources.call(this, costs);
return costs.map(c => {
c.scale = c.scale ?? 1;
c.step = c.step ?? 1;
c.total = c.value * c.scale * c.step;
c.total = c.value + ((c.scale - 1) * c.step);
c.enabled = c.hasOwnProperty('enabled') ? c.enabled : true;
c.max = c.key === 'fear'
? game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Resources.Fear)
: resources[c.key].isReversed
? resources[c.key].max
: resources[c.key].value
if(c.scalable) c.maxStep = Math.floor(c.max / c.step);
return c;
});
}

View file

@ -72,7 +72,7 @@ export class DHActionRollData extends foundry.abstract.DataModel {
if(!this.parent?.actor) return modifiers;
switch (this.parent.actor.type) {
case 'character':
const trait = this.useDefault || !this.trait ? this.parent.item.system.attack.roll.trait : this.trait;
const trait = this.useDefault || !this.trait ? (this.parent.item.system.attack.roll.trait ?? 'agility') : this.trait;
if(this.type === CONFIG.DH.GENERAL.rollTypes.attack.id || this.type === CONFIG.DH.GENERAL.rollTypes.trait.id)
modifiers.push(
{

View file

@ -481,7 +481,7 @@ export default class DhpActor extends Actor {
this.system.armor &&
this.#canReduceDamage(hpDamage.value, hpDamage.damageTypes)
) {
const armorStackResult = await this.owner.query('armorStack', {
const armorSlotResult = await this.owner.query('armorSlot', {
actorId: this.uuid,
damage: hpDamage.value,
type: [...hpDamage.damageTypes]
@ -490,11 +490,11 @@ export default class DhpActor extends Actor {
timeout: 30000
}
);
if (armorStackResult) {
const { modifiedDamage, armorSpent, stressSpent } = armorStackResult;
if (armorSlotResult) {
const { modifiedDamage, armorSpent, stressSpent } = armorSlotResult;
updates.find(u => u.key === 'hitPoints').value = modifiedDamage;
updates.push(
...(armorSpent ? [{ value: armorSpent, key: 'armorStack' }] : []),
...(armorSpent ? [{ value: armorSpent, key: 'armor' }] : []),
...(stressSpent ? [{ value: stressSpent, key: 'stress' }] : [])
);
}
@ -569,6 +569,7 @@ export default class DhpActor extends Actor {
armor: { target: this.system.armor, resources: {} },
items: {}
};
resources.forEach(r => {
if (r.keyIsID) {
updates.items[r.key] = {
@ -584,7 +585,7 @@ export default class DhpActor extends Actor {
game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Resources.Fear) + r.value
);
break;
case 'armorStack':
case 'armor':
updates.armor.resources['system.marks.value'] = Math.max(
Math.min(this.system.armor.system.marks.value + r.value, this.system.armorScore),
0

View file

@ -77,7 +77,7 @@ export const registerSocketHooks = () => {
};
export const registerUserQueries = () => {
CONFIG.queries.armorStack = DamageReductionDialog.armorStackQuery;
CONFIG.queries.armorSlot = DamageReductionDialog.armorSlotQuery;
CONFIG.queries.reactionRoll = game.system.api.models.actions.actionsTypes.base.rollSaveQuery;
}

View file

@ -6,7 +6,7 @@
{{#each source as |cost index|}}
<div class="nest-inputs">
{{formField ../fields.scalable label="Scalable" value=cost.scalable name=(concat "cost." index ".scalable") classes="checkbox"}}
{{formField ../fields.key choices=(@root.disableOption index @root.costOptions ../source) label="Resource" value=cost.key name=(concat "cost." index ".key") localize=true}}
{{formField ../fields.key choices=(@root.disableOption index @root.costOptions ../source) label="Resource" value=cost.key name=(concat "cost." index ".key") localize=true blank=false}}
{{formField ../fields.value label="Amount" value=cost.value name=(concat "cost." index ".value")}}
{{formField ../fields.step label="Step" value=cost.step name=(concat "cost." index ".step") disabled=(not cost.scalable)}}
<a class="btn" data-tooltip="{{localize "CONTROLS.CommonDelete"}}" data-action="removeElement" data-index="{{index}}"><i class="fas fa-trash"></i></a>

View file

@ -20,10 +20,10 @@
<label>{{label}}</label>
</div>
</div>
{{#if scalable}}
<input type="range" value="{{scale}}" min="1" max="10" step="{{step}}" name="costs.{{index}}.scale">
{{#if (and scalable (gt maxStep 1))}}
<input type="range" value="{{scale}}" min="1" max="{{maxStep}}" step="1" name="costs.{{index}}.scale">
{{/if}}
<label class="modifier-label">{{total}}/10</label>
<label class="modifier-label">{{total}}/{{max}}</label>
</li>
{{/each}}
</ul>