Corrections compétences créatures

This commit is contained in:
Vincent Vandemeulebrouck 2025-01-26 23:04:12 +01:00
parent 7ed9a4a12b
commit 70e3e63001
5 changed files with 37 additions and 30 deletions

View File

@ -411,7 +411,7 @@ export class RdDBaseActorReve extends RdDBaseActor {
return;
}
// Transformer la competence de créature
RdDItemCompetenceCreature.setRollDataCreature(this, rollData, competence)
RdDItemCompetenceCreature.setRollDataCreature(rollData)
}
const dialogLabel = 'Jet ' + Grammar.apostrophe('de', competence.name);
await this.openRollDialog({

View File

@ -1,5 +1,6 @@
import { ITEM_TYPES } from "./constants.js";
import { Grammar } from "./grammar.js";
import { RdDCombatManager } from "./rdd-combat.js";
export const CATEGORIES_COMPETENCES_CREATURES = {
@ -17,9 +18,11 @@ export class RdDItemCompetenceCreature extends Item {
/* -------------------------------------------- */
static setRollDataCreature(rollData) {
rollData.carac = { "carac_creature": { label: rollData.competence.name, value: rollData.competence.system.carac_value } }
rollData.competence.system.defaut_carac = "carac_creature"
rollData.selectedCarac = rollData.carac.carac_creature
const code = Grammar.toLowerCaseNoAccentNoSpace(rollData.competence.name);
const selectedCarac = { code: code, label: rollData.competence.name, value: rollData.competence.system.carac_value };
rollData.carac = { [code]: selectedCarac }
rollData.competence.system.defaut_carac = code
rollData.selectedCarac = selectedCarac
rollData.arme = RdDItemCompetenceCreature.armeCreature(rollData.competence);
}

View File

@ -75,12 +75,12 @@ const LIST_CARAC_ROLL = Object.values(LIST_CARAC_PERSONNAGE).filter(it => it.isC
export class RdDCarac {
static caracDetails(name) {
static caracDetails(name, options = { onMessage: undefined }) {
let entry = Misc.findFirstLike(name, LIST_CARAC_ROLL, { mapper: it => it.code, description: 'caractéristique', onMessage: m => { } })
if (entry) {
return entry
}
return Misc.findFirstLike(name, LIST_CARAC_ROLL, { mapper: it => it.label, description: 'caractéristique' })
return Misc.findFirstLike(name, LIST_CARAC_ROLL, { mapper: it => it.label, description: 'caractéristique', onMessage: options.onMessage })
}
static carac(code) {

View File

@ -3,6 +3,7 @@ import { RdDItemCompetenceCreature } from "./item-competencecreature.js";
import { Targets } from "./targets.js";
import { ITEM_TYPES } from "./constants.js";
import { RdDRollResult } from "./rdd-roll-result.js";
import { Grammar } from "./grammar.js";
/* -------------------------------------------- */
/* On part du principe qu'une entité démarre tjs
@ -97,7 +98,10 @@ export class RdDPossession {
static selectCompetenceDraconicOuPossession(rollData, rollingActor) {
rollData.competence = rollingActor.getDraconicOuPossession();
if (rollingActor.isCreatureEntite()) {
RdDItemCompetenceCreature.setRollDataCreature(rollData)
const carac = rollingActor.system.carac
rollData.carac = carac
rollData.competence.system.defaut_carac = 'reve'
rollData.selectedCarac = carac.reve
}
else {
rollData.selectedCarac = rollingActor.system.carac.reve

View File

@ -138,9 +138,9 @@ export class RdDRoll extends Dialog {
}
if (this.rollData.selectedCarac) {
this.html.find("[name='carac']").val(
this.actor?.type == ACTOR_TYPES.personnage
? RdDCarac.caracDetails(this.rollData.selectedCarac.label).code
: this.rollData.selectedCarac.label
RdDCarac.caracDetails(this.rollData.selectedCarac.label, { onMessage: m => { } })?.code
?? this.rollData.selectedCarac.code
?? Grammar.toLowerCaseNoAccentNoSpace(this.rollData.selectedCarac.label)
)
}
if (this.rollData.selectedSort) {