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

View File

@ -42,6 +42,12 @@ export const MONEY = {
}
}
export const FAVOR_CHOICES = {
"none": {label: "None", value: "none"},
"favor": {label: "Favor", value: "favor"},
"disfavor": {label: "Disfavor", value: "disfavor"}
}
export const MOVEMENT_CHOICES = {
"none": {label: "None (D8E)", value: "D8"},
"walk": {label: "Walk (D10E)", value: "D10"},
@ -192,5 +198,6 @@ export const SYSTEM = {
MOVE_DIRECTION_CHOICES,
SIZE_CHOICES,
RANGE_CHOICES,
FAVOR_CHOICES,
ATTACKER_AIM_CHOICES
}

View File

@ -92,6 +92,10 @@ export default class LethalFantasyRoll extends Roll {
return this.options.D30result
}
get badResult() {
return this.options.badResult
}
/**
* Prompt the user with a dialog to configure and execute a roll.
*
@ -117,6 +121,7 @@ export default class LethalFantasyRoll extends Roll {
let hasModifier = true
let hasChangeDice = false
let hasD30 = false
let hasFavor = false
if (options.rollType === "challenge" || options.rollType === "save") {
options.rollName = options.rollTarget.rollKey
@ -137,6 +142,7 @@ export default class LethalFantasyRoll extends Roll {
baseFormula = "D100"
maxValue = 100
hasModifier = true
hasFavor = true
hasChangeDice = false
options.rollTarget.value = options.rollTarget.system.skillTotal
@ -148,6 +154,7 @@ export default class LethalFantasyRoll extends Roll {
maxValue = 20
hasModifier = true
hasChangeDice = false
hasFavor = true
if (options.rollType === "weapon-attack") {
options.rollTarget.value = options.rollTarget.combat.attackModifier + options.rollTarget.weaponSkillModifier
options.rollTarget.charModifier = options.rollTarget.combat.attackModifier
@ -209,6 +216,7 @@ export default class LethalFantasyRoll extends Roll {
const choiceModifier = SYSTEM.CHOICE_MODIFIERS
const choiceDice = SYSTEM.CHOICE_DICE
const choiceFavor = SYSTEM.FAVOR_CHOICES
let modifier = "+0"
let targetName
@ -219,17 +227,20 @@ export default class LethalFantasyRoll extends Roll {
rollName: options.rollName,
rollModes,
hasModifier,
hasFavor,
hasChangeDice,
baseValue: options.rollTarget.value,
changeDice: `${dice}`,
fieldRollMode,
choiceModifier,
choiceDice,
choiceFavor,
baseFormula,
dice,
hasTarget: options.hasTarget,
modifier,
saveSpell: false,
favor : "none",
targetName
}
console.log("dialogContext", dialogContext)
@ -322,12 +333,46 @@ export default class LethalFantasyRoll extends Roll {
*/
if (Hooks.call("fvtt-lethal-fantasy.preRoll", options, rollData) === false) return
const rollBase = new this(baseFormula, options.data, rollData)
let rollBase = new this(baseFormula, options.data, rollData)
const rollModifier = new Roll(modifierFormula, options.data, rollData)
rollModifier.evaluate()
await rollBase.evaluate()
let rollFavor
let badResult
if (rollContext.favor === "favor") {
rollFavor = new this(baseFormula, options.data, rollData)
await rollFavor.evaluate()
if (game?.dice3d) {
await game.dice3d.showForRoll(rollFavor, game.user, true)
}
if (rollFavor.result > rollBase.result) {
badResult = rollBase.result
rollBase = rollFavor
} else {
badResult = rollFavor.result
}
}
if (rollContext.favor === "disfavor") {
rollFavor = new this(baseFormula, options.data, rollData)
await rollFavor.evaluate()
if (game?.dice3d) {
await game.dice3d.showForRoll(rollFavor, game.user, true)
}
if (rollFavor.result < rollBase.result) {
badResult = rollBase.result
rollBase = rollFavor
} else {
badResult = rollFavor.result
}
}
if (hasD30) {
let rollD30 = await new Roll("1D30").evaluate()
if (game?.dice3d) {
await game.dice3d.showForRoll(rollFavor, game.user, true)
}
options.D30result = rollD30.total
}
@ -367,6 +412,7 @@ export default class LethalFantasyRoll extends Roll {
rollBase.options.rollTarget = options.rollTarget
rollBase.options.titleFormula = titleFormula
rollBase.options.D30result = options.D30result
rollBase.options.badResult = badResult
/**
* A hook event that fires after the roll has been made.
@ -589,6 +635,7 @@ export default class LethalFantasyRoll extends Roll {
targetName: this.targetName,
targetArmor: this.targetArmor,
D30result: this.D30result,
badResult: this.badResult,
isPrivate: isPrivate
}
cardData.cssClass = cardData.css.join(" ")

View File

@ -68,7 +68,9 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
max: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
painDamage: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
wounds: new fields.ArrayField(new fields.SchemaField(woundFieldSchema ) ),
wounds: new fields.ArrayField(new fields.SchemaField(woundFieldSchema ) , { initial: [{description:"", value:0, duration:0},{description:"", value:0, duration:0},
{description:"", value:0, duration:0},{description:"", value:0, duration:0},{description:"", value:0, duration:0},{description:"", value:0, duration:0},
{description:"", value:0, duration:0},{description:"", value:0, duration:0}], min:8} ),
})
schema.perception = new fields.SchemaField({

View File

@ -31,9 +31,7 @@ export default class LethalFantasySkill extends foundry.abstract.TypeDataModel {
validate(options) {
let isError = super.validate(options)
console.log(this)
let bonus = this._source.weaponBonus.attack + this._source.weaponBonus.defense + this._source.weaponBonus.damage
console.log(bonus, this._source.skillTotal)
if (bonus > Math.floor(this._source.skillTotal / 10)) {
ui.notifications.error(game.i18n.localize("LETHALFANTASY.Skill.error.weaponBonus"))
isError = true