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
+1
View File
@@ -13,6 +13,7 @@
- affichage des ajustements dans la fenêtre d'attaque avec arme à distance
- gestion des défenses contre les armes à distance
- défense contre possession
- correction du mode "méditation" quand le haut-rêvant ne connait pas de méditation
- Corrections liées à Foundry v12/v13
- Fix ajout de notes dans le journal par un joueur (/chrono, ou clic sur le libelé de l'heure dans l'horloge)
+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) {
+2 -2
View File
@@ -173,10 +173,10 @@ export class RdDTimestamp {
}
filtered = DEFINITION_HEURES.filter(it => Grammar.toLowerCaseNoAccentNoSpace(it.label).includes(heure));
if (filtered.length > 0) {
filtered.sort(Misc.ascending(h => h.label.length));
filtered.sort(Misc.ascending(h => h.label.length))
return filtered[0]
}
return undefined;
return undefined
}
/**
+6
View File
@@ -2,6 +2,7 @@
<img src="{{current.meditation.img}}" data-tooltip="{{current.meditation.name}}" />
</roll-part-img>
<roll-part-detail>
{{#if refs.meditations}}
<subline>
Rêve actuel: {{rollData.active.actor.system.reve.reve.value}}
</subline>
@@ -71,4 +72,9 @@
<span name="veture">{{current.meditation.system.veture}}</span>
</label>
</subline>
{{else}}
<subline>
<p>Le haut-rêvant ne connait aucune méditation</p>
</subline>
{{/if}}
</roll-part-detail>