Fix: aucune méditation connue

Cas de haut-rêvant ne connaissant pas de méditations
This commit is contained in:
2025-12-13 01:09:00 +01:00
parent 8077656ea1
commit a4e614860a
5 changed files with 21 additions and 12 deletions
+10 -8
View File
@@ -4,7 +4,7 @@ import { CARACS } from "../rdd-carac.js"
import { RdDTimestamp } from "../time/rdd-timestamp.js"
import { TMRUtility } from "../tmr-utility.js"
import { ROLL_TYPE_MEDITATION } from "./roll-constants.mjs"
import { PART_CARAC, RollPartCarac } from "./roll-part-carac.mjs"
import { PART_CARAC } from "./roll-part-carac.mjs"
import { PART_COMP } from "./roll-part-comp.mjs"
import { RollPartSelect } from "./roll-part-select.mjs"
import { ROLLDIALOG_SECTION, RollPart } from "./roll-part.mjs"
@@ -70,7 +70,7 @@ export class RollPartMeditation extends RollPartSelect {
}
getMalusEchecs(rollData) {
return this.getCurrent(rollData).meditation.system.malus
return this.getCurrent(rollData).meditation?.system.malus ?? 0
}
getAjustements(rollData) {
@@ -90,16 +90,18 @@ export class RollPartMeditation extends RollPartSelect {
$selectConditionMeditation(rollData) {
const current = this.getCurrent(rollData)
current.heureMonde = RdDTimestamp.getWorldTime().heure
current.heureMeditation = RdDTimestamp.findHeure(current.meditation.system.heure)?.heure
current.isHeure = current.heureMeditation == current.heureMonde
current.isTMR = Grammar.equalsInsensitive(current.meditation.system.tmr, TMRUtility.getTMRType(rollData.active.actor.system.reve.tmrpos.coord))
if (current.meditation){
current.heureMonde = RdDTimestamp.getWorldTime().heure
current.heureMeditation = RdDTimestamp.findHeure(current.meditation.system.heure)?.heure
current.isHeure = current.heureMeditation == current.heureMonde
current.isTMR = Grammar.equalsInsensitive(current.meditation.system.tmr, TMRUtility.getTMRType(rollData.active.actor.system.reve.tmrpos.coord))
}
}
async _onRender(rollDialog, context, options) {
const selectMeditation = rollDialog.element.querySelector(`roll-section[name="${this.code}"] select[name="select-meditation"]`)
selectMeditation.addEventListener("change", e => {
selectMeditation?.addEventListener("change", e => {
const selectOptions = e.currentTarget.options
const index = selectOptions.selectedIndex
this.$selectMeditation(rollDialog.rollData, selectOptions[index]?.value)
@@ -111,7 +113,7 @@ export class RollPartMeditation extends RollPartSelect {
setupListenerCondition(rollDialog, inputName) {
const checkbox = rollDialog.element.querySelector(`roll-section[name="${this.code}"] input[name="${inputName}"]`)
checkbox.addEventListener("change", e => {
checkbox?.addEventListener("change", e => {
const current = this.getCurrent(rollDialog.rollData)
current[inputName] = e.currentTarget.checked
rollDialog.render()
+2 -2
View File
@@ -11,7 +11,7 @@ export class RollTypeMeditation extends RollType {
visible(rollData) { return rollData.active.actor.isHautRevant() }
title(rollData) {
const current = rollData.current[PART_MEDITATION]
const theme = current?.meditation.system.theme
const theme = current?.meditation?.system.theme
return theme ? 'médite sur ' + theme : 'médite'
}
@@ -23,7 +23,7 @@ export class RollTypeMeditation extends RollType {
static async $onRollMeditation(rollData) {
const actor = rollData.active.actor
const meditation = rollData.current.meditation.meditation
const meditation = rollData.current.meditation?.meditation
const rolled = rollData.rolled
if (meditation && rolled) {
if (rolled.isSuccess) {