Full SAN management
This commit is contained in:
@ -180,6 +180,55 @@ export default class CthulhuEternalUtils {
|
||||
});
|
||||
}
|
||||
|
||||
static async applySANType(rollMessage, event) {
|
||||
let rollData = rollMessage.getFlag("fvtt-cthulhu-eternal", "rollData")
|
||||
if (!rollData) {
|
||||
ui.notifications.error(game.i18n.localize("CTHULHUETERNAL.Notifications.noRollDataFound"))
|
||||
return
|
||||
}
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
if (!actor) {
|
||||
ui.notifications.error(game.i18n.localize("CTHULHUETERNAL.Notifications.noActorFound"))
|
||||
return
|
||||
}
|
||||
let sanType = event.currentTarget.dataset.sanType;
|
||||
if (!sanType) {
|
||||
ui.notifications.error(game.i18n.localize("CTHULHUETERNAL.Notifications.noSanTypeFound"))
|
||||
return
|
||||
}
|
||||
// If the sanType is "none", we don't apply any SAN processing
|
||||
if (sanType === "none") {
|
||||
ui.notifications.info(game.i18n.localize("CTHULHUETERNAL.Notifications.noSanLossApplied"))
|
||||
return
|
||||
}
|
||||
rollData.sanType = sanType
|
||||
await actor.system.applySANConsequences(rollData)
|
||||
// Delete the roll message
|
||||
await rollMessage.delete()
|
||||
}
|
||||
|
||||
static async applySANLoss(rollMessage, event) {
|
||||
let rollData = rollMessage.getFlag("fvtt-cthulhu-eternal", "rollData")
|
||||
if (!rollData) {
|
||||
ui.notifications.error(game.i18n.localize("CTHULHUETERNAL.Notifications.noRollDataFound"))
|
||||
return
|
||||
}
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
if (!actor) {
|
||||
ui.notifications.error(game.i18n.localize("CTHULHUETERNAL.Notifications.noActorFound"))
|
||||
return
|
||||
}
|
||||
// Get the san loss from the event : data-san-value
|
||||
let sanLoss = event.currentTarget.dataset.sanValue
|
||||
let r = new Roll(sanLoss.toString())
|
||||
await r.evaluate()
|
||||
rollData.sanLoss = -r.total
|
||||
|
||||
await actor.system.modifySAN(rollData)
|
||||
// Delete the roll message
|
||||
await rollMessage.delete()
|
||||
}
|
||||
|
||||
static async healingRoll(rollMessage) {
|
||||
let rollData = rollMessage.rolls[0]?.options?.rollData
|
||||
let healingFormula = rollData.rollItem.system.healingFormula
|
||||
|
Reference in New Issue
Block a user