First PC sheet, WIP

This commit is contained in:
2025-12-20 17:20:01 +01:00
parent 189b03ca91
commit e75824cd20
19 changed files with 961 additions and 600 deletions
+20 -1
View File
@@ -94,6 +94,17 @@ export default class PrismRPGActor extends Actor {
name: game.i18n.localize(`PRISMRPG.Label.${rollKey}`)
}
break
case "sub-attribute":
if (!this.system.subAttributes || !this.system.subAttributes[rollKey]) {
ui.notifications.error(`Sub-attribute ${rollKey} not found`)
return
}
rollTarget = {
...foundry.utils.duplicate(this.system.subAttributes[rollKey]),
rollKey: rollKey,
name: game.i18n.localize(SYSTEM.SUB_ATTRIBUTES[rollKey].label)
}
break
case "granted":
rollTarget = {
name: rollKey,
@@ -112,6 +123,10 @@ export default class PrismRPGActor extends Actor {
rollTarget = foundry.utils.duplicate(this.system.saves[rollKey])
rollTarget.rollKey = rollKey
rollTarget.rollDice = rollDice
// Pass the characteristic value for D&D 5e modifier calculation
rollTarget.characteristicValue = this.system.characteristics[rollKey].value
// The save bonus is the proficiency modifier (value stored in saves)
rollTarget.saveBonus = this.system.saves[rollKey].value
break
case "spell":
rollTarget = this.items.find((i) => i.type === "spell" && i.id === rollKey)
@@ -128,12 +143,16 @@ export default class PrismRPGActor extends Actor {
ui.notifications.warn(game.i18n.localize("PRISMRPG.Notifications.rollFromWeapon"))
return
}
// Get the primary attribute for D&D 5e style rolls
const attrKey = rollTarget.system.primaryAttribute || "dex"
rollTarget.characteristicValue = this.system.characteristics[attrKey].value
rollTarget.proficiencyBonus = rollTarget.system.modifier
break
case "spell-attack":
case "spell-power":
case "miracle-attack":
case "miracle-power":
rollTarget = this.items.find((i) => (i.type === "miracle" || i.type == "spell") && i.id === rollKey)
rollTarget = this.items.find((i) => (i.type === "miracle" || i.type === "spell") && i.id === rollKey)
rollTarget.rollKey = rollKey
break
case "shield-roll": {
+35 -3
View File
@@ -7,6 +7,15 @@ import { SYSTEM } from "../config/system.mjs"
export default class PrismRPGRoll extends Roll {
static CHAT_TEMPLATE = "systems/fvtt-prism-rpg/templates/chat-message.hbs"
/**
* Calculate D&D 5e style ability modifier from ability score
* @param {number} abilityScore The ability score value (3-18+)
* @returns {number} The ability modifier
*/
static getAbilityModifier(abilityScore) {
return Math.floor((abilityScore - 10) / 2)
}
// Getters for roll data
get type() {
return this.options.type
@@ -89,17 +98,40 @@ export default class PrismRPGRoll extends Roll {
switch (options.rollType) {
case "characteristic":
options.rollName = options.rollTarget.name
// Value already set in actor.mjs
// Calculate D&D 5e modifier from characteristic value
options.rollTarget.value = this.getAbilityModifier(options.rollTarget.value)
break
case "sub-attribute":
options.rollName = options.rollTarget.name
// Sub-attribute value is already a modifier (calculated in prepareDerivedData)
break
case "challenge":
case "save":
options.rollName = game.i18n.localize(`PRISMRPG.Label.${options.rollTarget.rollKey}`)
break
case "save":
options.rollName = `${game.i18n.localize(`PRISMRPG.Label.${options.rollTarget.rollKey}`)} Save`
// Calculate D&D 5e saving throw: ability modifier + proficiency bonus
// Get the characteristic value from rollTarget
const charValue = options.rollTarget.characteristicValue
const abilityMod = this.getAbilityModifier(charValue)
const saveBonus = options.rollTarget.saveBonus || 0
// Store separate values for display
options.rollTarget.abilityModifier = abilityMod
options.rollTarget.saveProficiency = saveBonus
// Add the save bonus (proficiency) stored in saves
options.rollTarget.value = abilityMod + saveBonus
break
case "skill":
options.rollName = options.rollTarget.name
options.rollTarget.value = Math.floor(options.rollTarget.system.skillTotal / 10)
// D&D 5e style: ability modifier + proficiency bonus
const skillCharValue = options.rollTarget.characteristicValue
const skillAbilityMod = this.getAbilityModifier(skillCharValue)
const proficiency = options.rollTarget.proficiencyBonus || 0
options.rollTarget.value = skillAbilityMod + proficiency
break
case "weapon-attack":