Update skill sheet
This commit is contained in:
+39
-12
@@ -127,11 +127,10 @@ export default class PrismRPGRoll extends Roll {
|
||||
|
||||
case "skill":
|
||||
options.rollName = options.rollTarget.name
|
||||
// D&D 5e style: ability modifier + proficiency bonus
|
||||
const skillCharValue = options.rollTarget.characteristicValue
|
||||
const skillAbilityMod = this.getAbilityModifier(skillCharValue)
|
||||
// D&D 5e style: sub-attribute modifier + proficiency bonus
|
||||
// Default to first sub-attribute, will be recalculated if player chooses different one
|
||||
const proficiency = options.rollTarget.proficiencyBonus || 0
|
||||
options.rollTarget.value = skillAbilityMod + proficiency
|
||||
options.rollTarget.value = options.rollTarget.subAttribute1Value + proficiency
|
||||
break
|
||||
|
||||
case "weapon-attack":
|
||||
@@ -158,7 +157,7 @@ export default class PrismRPGRoll extends Roll {
|
||||
const chaMod = this.getAbilityModifier(actor.system.characteristics.cha.value)
|
||||
const bestMentalMod = Math.max(intMod, wisMod, chaMod)
|
||||
options.rollTarget.value = bestMentalMod
|
||||
|
||||
|
||||
// Store which characteristic is being used
|
||||
if (bestMentalMod === intMod) {
|
||||
options.rollTarget.mentalCharacteristic = "INT"
|
||||
@@ -284,7 +283,8 @@ export default class PrismRPGRoll extends Roll {
|
||||
attackerAimChoices,
|
||||
hasTarget: options.hasTarget,
|
||||
modifier: "+0",
|
||||
advantage: "none"
|
||||
advantage: "none",
|
||||
config: SYSTEM
|
||||
}
|
||||
|
||||
const content = await foundry.applications.handlebars.renderTemplate(
|
||||
@@ -342,6 +342,15 @@ export default class PrismRPGRoll extends Roll {
|
||||
}
|
||||
}
|
||||
|
||||
// Recalculate bonus if player chose different sub-attribute for skill
|
||||
if (rollContext.skillSubAttribute && options.rollType === "skill") {
|
||||
const chosenSubAttrValue = rollContext.skillSubAttribute === options.rollTarget.subAttribute1 ?
|
||||
options.rollTarget.subAttribute1Value :
|
||||
options.rollTarget.subAttribute2Value
|
||||
const proficiencyBonus = options.rollTarget.proficiencyBonus || 0
|
||||
bonus = chosenSubAttrValue + proficiencyBonus
|
||||
}
|
||||
|
||||
let extraModifier = rollContext.modifier === "" ? 0 : Number.parseInt(rollContext.modifier, 10)
|
||||
totalModifier = bonus + extraModifier
|
||||
|
||||
@@ -388,12 +397,27 @@ export default class PrismRPGRoll extends Roll {
|
||||
totalManaCost = options.rollTarget.system.manaCost + upcastLevel
|
||||
totalAPC = options.rollTarget.system.apc + upcastLevel
|
||||
manaUpkeep = options.rollTarget.system.manaUpkeep
|
||||
|
||||
|
||||
// Get mental characteristic info from rollTarget
|
||||
mentalCharacteristic = options.rollTarget.mentalCharacteristic
|
||||
mentalCharValue = options.rollTarget.mentalCharValue
|
||||
}
|
||||
|
||||
// Store skill sub-attribute information
|
||||
let skillSubAttribute = null
|
||||
let skillSubAttributeLabel = null
|
||||
let skillSubAttributeValue = null
|
||||
if (options.rollType === "skill" && rollContext.skillSubAttribute) {
|
||||
skillSubAttribute = rollContext.skillSubAttribute
|
||||
const subAttrConfig = SYSTEM.SUB_ATTRIBUTES?.[skillSubAttribute]
|
||||
if (subAttrConfig) {
|
||||
skillSubAttributeLabel = game.i18n.localize(subAttrConfig.label)
|
||||
}
|
||||
skillSubAttributeValue = rollContext.skillSubAttribute === options.rollTarget.subAttribute1 ?
|
||||
options.rollTarget.subAttribute1Value :
|
||||
options.rollTarget.subAttribute2Value
|
||||
}
|
||||
|
||||
const rollData = {
|
||||
type: options.rollType,
|
||||
rollType: options.rollType,
|
||||
@@ -411,6 +435,9 @@ export default class PrismRPGRoll extends Roll {
|
||||
manaUpkeep,
|
||||
mentalCharacteristic,
|
||||
mentalCharValue,
|
||||
skillSubAttribute,
|
||||
skillSubAttributeLabel,
|
||||
skillSubAttributeValue,
|
||||
...rollContext,
|
||||
}
|
||||
|
||||
@@ -420,7 +447,7 @@ export default class PrismRPGRoll extends Roll {
|
||||
if (options.rollType === "spell-cast" && totalManaCost > 0) {
|
||||
const actor = game.actors.get(options.actorId)
|
||||
const currentMana = actor.system.manaPoints.value
|
||||
|
||||
|
||||
// Check if enough mana
|
||||
if (currentMana < totalManaCost) {
|
||||
ui.notifications.error(
|
||||
@@ -428,12 +455,12 @@ export default class PrismRPGRoll extends Roll {
|
||||
)
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
// Spend mana
|
||||
await actor.update({
|
||||
"system.manaPoints.value": currentMana - totalManaCost
|
||||
await actor.update({
|
||||
"system.manaPoints.value": currentMana - totalManaCost
|
||||
})
|
||||
|
||||
|
||||
ui.notifications.info(
|
||||
`Spent ${totalManaCost} Mana (${currentMana} → ${currentMana - totalManaCost})`
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user