Various updates

This commit is contained in:
2025-01-09 22:26:37 +01:00
parent d0284d2b84
commit 949755b680
36 changed files with 288 additions and 14 deletions

View File

@ -15,6 +15,8 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
actions: {
createEquipment: LethalFantasyCharacterSheet.#onCreateEquipment,
rangedAttackDefense: LethalFantasyCharacterSheet.#onRangedAttackDefense,
armorHitPointsPlus: LethalFantasyCharacterSheet.#onArmorHitPointsPlus,
armorHitPointsMinus: LethalFantasyCharacterSheet.#onArmorHitPointsMinus,
},
}
@ -138,10 +140,6 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
}
}
async #onDropPathItem(item) {
await this.document.addPath(item)
}
static async #onRangedAttackDefense(event, target) {
const hasTarget = false
let roll = await LethalFantasyRoll.promptRangedDefense({
@ -154,10 +152,40 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
await roll.toMessage({}, { rollMode: roll.options.rollMode })
}
static #onArmorHitPointsPlus(event, target) {
let armorHP = this.actor.system.combat.armorHitPoints
armorHP += 1
this.actor.update({ "system.combat.armorHitPoints": armorHP })
}
static #onArmorHitPointsMinus(event, target) {
let armorHP = this.actor.system.combat.armorHitPoints
armorHP -= 1
this.actor.update({ "system.combat.armorHitPoints": Math.max(armorHP, 0) })
}
static #onCreateEquipment(event, target) {
}
_onRender(context, options) {
// Inputs with class `item-quantity`
const woundDescription = this.element.querySelectorAll('.wound-data')
for (const input of woundDescription) {
input.addEventListener("change", (e) => {
e.preventDefault();
e.stopImmediatePropagation();
const newValue = e.currentTarget.value
const index = e.currentTarget.dataset.index
const fieldName = e.currentTarget.dataset.name
let tab = foundry.utils.duplicate(this.actor.system.hp.wounds)
tab[index][fieldName] = newValue
console.log(tab, index, fieldName, newValue)
this.actor.update( { "system.hp.wounds": tab } );
})
}
super._onRender();
}
getBestWeaponClassSkill(skills, rollType, multiplier = 1.0) {
let maxValue = 0
let goodSkill = skills[0]
@ -278,7 +306,7 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
// In all cases
rollTarget.magicUser = this.actor.system.biodata.magicUser
rollTarget.actorModifiers = foundry.utils.duplicate(this.actor.system.modifiers)
console.log(rollTarget)
await this.document.system.roll(rollType, rollTarget)
}
// #endregion