Files
foundryvtt-reve-de-dragon/module/roll/roll-type-tache.mjs
Vincent Vandemeulebrouck fa6769fcd7 Fenêtres Roll V2
Maintenant disponibles pour:
- méditation
- tâches
- soins
2025-10-05 03:09:52 +02:00

43 lines
1.6 KiB
JavaScript

import { ITEM_TYPES } from "../constants.js"
import { ReglesOptionnelles } from "../settings/regles-optionnelles.js"
import { DIFF, ROLL_TYPE_TACHE } from "./roll-constants.mjs"
import { PART_TACHE } from "./roll-part-tache.mjs"
import { RollType } from "./roll-type.mjs"
export class RollTypeTache extends RollType {
get code() { return ROLL_TYPE_TACHE }
get name() { return `Travailler à une tâche` }
visible(rollData) { return rollData.active.actor.isPersonnage() }
title(rollData) {
const current = rollData.current[PART_TACHE]
const tache = current?.tache
return `travaille à sa tâche: ${tache.name ?? ''}`
}
onSelect(rollData) {
this.setDiffType(rollData, DIFF.AUCUN)
}
callbacks(rollOptions) { return [ async r => await RollTypeTache.$onRollTache(r, rollOptions)] }
static async $onRollTache(rollData, rollOptions) {
const actor = rollData.active.actor
const tache = rollData.current[PART_TACHE].tache
if (ReglesOptionnelles.isUsing("appliquer-fatigue")) {
await actor.santeIncDec("fatigue", tache.system.fatigue)
}
rollData.current[PART_TACHE].tache = await tache.update({
'system.points_de_tache_courant': tache.system.points_de_tache_courant + rollData.rolled.ptTache,
'system.nb_jet_succes': tache.system.nb_jet_succes + (rollData.rolled.isSuccess ? 1 : 0),
'system.nb_jet_echec': tache.system.nb_jet_echec + (rollData.rolled.isSuccess ? 0 : 1),
'system.difficulte': tache.system.difficulte - (rollData.rolled.isETotal ? 1 : 0),
}, {render:true})
if (rollOptions?.onRollAutomate) {
await rollOptions.onRollAutomate(rollData)
}
}
}