First PC sheet, WIP
This commit is contained in:
@@ -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":
|
||||
|
||||
Reference in New Issue
Block a user