mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-22 07:23:37 +02:00
[V14] Refactor ArmorChange schema and fix some bugs (#1742)
* Refactor ArmorChange schema and fix some bugs * Add current back to schema * Fixed so changing armor values and taking damage works again * Fixed so that scrolltexts for armor changes work again * Removed old marks on armor.system * Restored damageReductionDialog armorScore.value * Use toggle for css class addition/removal * Fix armor change type choices * Added ArmorChange DamageThresholds --------- Co-authored-by: WBHarry <williambjrklund@gmail.com>
This commit is contained in:
parent
6193153596
commit
50dcbf4396
68 changed files with 356 additions and 428 deletions
|
|
@ -42,15 +42,15 @@ export default class DhCharacter extends DhCreature {
|
|||
}),
|
||||
evasion: new fields.NumberField({ initial: 0, integer: true, label: 'DAGGERHEART.GENERAL.evasion' }),
|
||||
damageThresholds: new fields.SchemaField({
|
||||
severe: new fields.NumberField({
|
||||
integer: true,
|
||||
initial: 0,
|
||||
label: 'DAGGERHEART.GENERAL.DamageThresholds.severeThreshold'
|
||||
}),
|
||||
major: new fields.NumberField({
|
||||
integer: true,
|
||||
initial: 0,
|
||||
label: 'DAGGERHEART.GENERAL.DamageThresholds.majorThreshold'
|
||||
}),
|
||||
severe: new fields.NumberField({
|
||||
integer: true,
|
||||
initial: 0,
|
||||
label: 'DAGGERHEART.GENERAL.DamageThresholds.severeThreshold'
|
||||
})
|
||||
}),
|
||||
experiences: new fields.TypedObjectField(
|
||||
|
|
@ -479,14 +479,14 @@ export default class DhCharacter extends DhCreature {
|
|||
for (const armorEffect of orderedEffects) {
|
||||
let usedArmorChange = 0;
|
||||
if (clear) {
|
||||
usedArmorChange -= armorEffect.system.armorChange.value;
|
||||
usedArmorChange -= armorEffect.system.armorChange.value.current;
|
||||
} else {
|
||||
if (increasing) {
|
||||
const remainingArmor = armorEffect.system.armorData.max - armorEffect.system.armorData.value;
|
||||
const remainingArmor = armorEffect.system.armorData.max - armorEffect.system.armorData.current;
|
||||
usedArmorChange = Math.min(remainingChange, remainingArmor);
|
||||
remainingChange -= usedArmorChange;
|
||||
} else {
|
||||
const changeChange = Math.min(armorEffect.system.armorData.value, remainingChange);
|
||||
const changeChange = Math.min(armorEffect.system.armorData.current, remainingChange);
|
||||
usedArmorChange -= changeChange;
|
||||
remainingChange -= changeChange;
|
||||
}
|
||||
|
|
@ -503,7 +503,10 @@ export default class DhCharacter extends DhCreature {
|
|||
...change,
|
||||
value:
|
||||
change.type === 'armor'
|
||||
? armorEffect.system.armorChange.value + usedArmorChange
|
||||
? {
|
||||
...change.value,
|
||||
current: armorEffect.system.armorChange.value.current + usedArmorChange
|
||||
}
|
||||
: change.value
|
||||
}))
|
||||
});
|
||||
|
|
@ -519,11 +522,12 @@ export default class DhCharacter extends DhCreature {
|
|||
|
||||
async updateArmorEffectValue({ uuid, value }) {
|
||||
const effect = await foundry.utils.fromUuid(uuid);
|
||||
const effectValue = effect.system.armorChange.value;
|
||||
await effect.update({
|
||||
'system.changes': [
|
||||
{
|
||||
...effect.system.armorChange,
|
||||
value: effect.system.armorChange.value + value
|
||||
value: { ...effectValue, current: effectValue.current + value }
|
||||
}
|
||||
]
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue