Fix actor sheet modifications/updates
This commit is contained in:
+20
-11
@@ -44,11 +44,7 @@ export default class AwEActor extends Actor {
|
||||
const attribute = this.system.attributes[attrId]
|
||||
if (!attribute) return null
|
||||
|
||||
const knowledgeBonuses = this.itemTypes.field?.map(f => ({
|
||||
label: f.name,
|
||||
bonus: f.system.knowledgeBonus ?? ""
|
||||
})).filter(f => f.bonus !== "") ?? []
|
||||
|
||||
const knowledgeBonuses = this.#buildItemBonuses()
|
||||
const { conditionBonus, conditionLabels } = this.#buildConditionOptions()
|
||||
|
||||
const roll = await AwERoll.prompt({
|
||||
@@ -101,12 +97,7 @@ export default class AwEActor extends Actor {
|
||||
const attribute = this.system.attributes[attributeId]
|
||||
if (!attribute) return null
|
||||
|
||||
// Collect knowledge bonuses from embedded Field items
|
||||
const knowledgeBonuses = this.itemTypes.field?.map(f => ({
|
||||
label: f.name,
|
||||
bonus: f.system.knowledgeBonus ?? ""
|
||||
})).filter(f => f.bonus !== "") ?? []
|
||||
|
||||
const knowledgeBonuses = this.#buildItemBonuses()
|
||||
const { conditionBonus, conditionLabels } = this.#buildConditionOptions()
|
||||
|
||||
const roll = await AwERoll.prompt({
|
||||
@@ -127,6 +118,19 @@ export default class AwEActor extends Actor {
|
||||
return roll
|
||||
}
|
||||
|
||||
/** Collect roll bonuses from all item types that declare a rollBonus or knowledgeBonus. */
|
||||
#buildItemBonuses() {
|
||||
const entries = [
|
||||
// Field items use the original knowledgeBonus field
|
||||
...(this.itemTypes.field ?? []).map(i => ({ label: i.name, bonus: i.system.knowledgeBonus ?? "" })),
|
||||
// Ability, equipment, specialization use rollBonus
|
||||
...(this.itemTypes.ability ?? []).map(i => ({ label: i.name, bonus: i.system.rollBonus ?? "" })),
|
||||
...(this.itemTypes.equipment ?? []).map(i => ({ label: i.name, bonus: i.system.rollBonus ?? "" })),
|
||||
...(this.itemTypes.specialization ?? []).map(i => ({ label: i.name, bonus: i.system.rollBonus ?? "" })),
|
||||
]
|
||||
return entries.filter(e => e.bonus !== "")
|
||||
}
|
||||
|
||||
#buildConditionOptions() {
|
||||
let conditionBonus = 0
|
||||
const conditionLabels = []
|
||||
@@ -142,6 +146,11 @@ export default class AwEActor extends Actor {
|
||||
conditionBonus -= 2
|
||||
conditionLabels.push({ label: game.i18n.localize("AWEMMY.Condition.Jumbled"), bonus: -2 })
|
||||
}
|
||||
if (this.statuses.has("inhibited")) {
|
||||
const penalty = this.system.inhibitedPenalty ?? 2
|
||||
conditionBonus -= penalty
|
||||
conditionLabels.push({ label: game.i18n.localize("AWEMMY.Condition.Inhibited"), bonus: -penalty })
|
||||
}
|
||||
return { conditionBonus, conditionLabels }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user