Jets de compétence avec carac imposée

Fonctionne maintenant correctement

Pour les créatures/entitées: on fait au mieux, mais ça ne correspond
pas forcément bien, car les carac/compétences ne correspondent
pas toujours
This commit is contained in:
Vincent Vandemeulebrouck 2025-01-13 21:44:02 +01:00
parent de9d3bbb48
commit c733644f3a
6 changed files with 37 additions and 36 deletions

View File

@ -1850,26 +1850,6 @@ export class RdDActor extends RdDBaseActorSang {
return undefined; return undefined;
} }
async rollCaracCompetence(caracName, compName, diff, options = { title: "" }) {
RdDEmpoignade.checkEmpoignadeEnCours(this)
const competence = this.getCompetence(compName);
await this.openRollDialog({
name: 'jet-competence',
label: 'Jet ' + Grammar.apostrophe('de', competence.name),
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-competence.html',
rollData: {
alias: this.getAlias(),
carac: this.system.carac,
selectedCarac: this.getCaracByName(caracName),
selectedCaracName: caracName,
diffLibre: diff,
competence: competence,
show: { title: options?.title ?? '' }
},
callbackAction: r => this.$onRollCompetence(r, options)
});
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollTache(id, options = {}) { async rollTache(id, options = {}) {
RdDEmpoignade.checkEmpoignadeEnCours(this) RdDEmpoignade.checkEmpoignadeEnCours(this)

View File

@ -294,6 +294,25 @@ export class RdDBaseActorReve extends RdDBaseActor {
createCallbackAppelAuMoral() { return this.createEmptyCallback(); } createCallbackAppelAuMoral() { return this.createEmptyCallback(); }
async _onCloseRollDialog(html) { } async _onCloseRollDialog(html) { }
async rollCaracCompetence(caracName, compName, diff, options = { title: "" }) {
RdDEmpoignade.checkEmpoignadeEnCours(this)
const competence = this.getCompetence(compName);
await this.openRollDialog({
name: 'jet-competence',
label: competence? 'Jet ' + Grammar.apostrophe('de', competence.name) : `Jet sans compétence (${compName})`,
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-competence.html',
rollData: {
alias: this.getAlias(),
carac: this.system.carac,
selectedCarac: this.getCaracByName(caracName),
selectedCaracName: caracName,
diffLibre: diff,
competence: competence,
show: { title: options?.title ?? '' }
},
callbackAction: r => this.$onRollCompetence(r, options)
});
}
/** /**
* Méthode pour faire un jet prédéterminer sans ouvrir la fenêtre de dialogue * Méthode pour faire un jet prédéterminer sans ouvrir la fenêtre de dialogue
* @param {*} caracName code ou label de la caractéristique. On peut utiliser 'intel' pour Intellect. * @param {*} caracName code ou label de la caractéristique. On peut utiliser 'intel' pour Intellect.

View File

@ -36,12 +36,14 @@ export class RdDCreature extends RdDBaseActorSang {
mapCarac(caracCode) { mapCarac(caracCode) {
switch (caracCode) { switch (caracCode) {
case 'vue': case 'ouie': case 'vue': case 'ouie': case 'odoratgout': case 'empathie': case 'perception':
case 'odoratgout':
case 'empathie':
return 'perception' return 'perception'
case 'agilite':
return 'force'
case 'force': case 'constitution': case 'taille': case 'reve': case 'volonte':
return caracCode
} }
return caracCode return undefined
} }
} }

View File

@ -121,6 +121,7 @@ export class RdDEntite extends RdDBaseActorReve {
mapCarac(caracCode) { mapCarac(caracCode) {
switch (caracCode) { switch (caracCode) {
case 'taille': case 'taille':
case 'reve':
return caracCode return caracCode
} }
return 'reve' return 'reve'

View File

@ -41,7 +41,7 @@ export class TextRollCaracCompetence {
if (diff.match(REGEX_DICE_DIFF)) { if (diff.match(REGEX_DICE_DIFF)) {
const roll = new Roll(diff) const roll = new Roll(diff)
await roll.evaluate() await roll.evaluate()
await roll.toMessage({flavor: `La difficulté de ${diff} a donné ${roll.total}`}) await roll.toMessage({ flavor: `La difficulté de ${diff} a donné ${roll.total}` })
return roll.total return roll.total
} }
return diff return diff
@ -49,17 +49,14 @@ export class TextRollCaracCompetence {
async doRoll(actor, caracCode, competence, diff) { async doRoll(actor, caracCode, competence, diff) {
caracCode = actor.mapCarac(caracCode) caracCode = actor.mapCarac(caracCode)
if (competence) { if (caracCode) {
if (actor.type == ACTOR_TYPES.personnage) { if (competence) {
await actor.rollCaracCompetence(caracCode, competence, diff) await actor.rollCaracCompetence(caracCode, competence, diff)
} }
else { else {
await actor.doRollCaracCompetence(caracCode, competence, diff) await actor.rollCarac(caracCode, { diff })
} }
} }
else {
await actor.rollCarac(caracCode, { diff })
}
} }
getSelectedActors(actor) { getSelectedActors(actor) {

View File

@ -8,6 +8,7 @@ import { RdDCarac } from "./rdd-carac.js";
import { RdDResolutionTable } from "./rdd-resolution-table.js"; import { RdDResolutionTable } from "./rdd-resolution-table.js";
import { ReglesOptionnelles } from "./settings/regles-optionnelles.js"; import { ReglesOptionnelles } from "./settings/regles-optionnelles.js";
import { Grammar } from "./grammar.js"; import { Grammar } from "./grammar.js";
import { ACTOR_TYPES } from "./item.js";
/** /**
* Extend the base Dialog entity to select roll parameters * Extend the base Dialog entity to select roll parameters
@ -62,7 +63,7 @@ export class RdDRoll extends Dialog {
forceDiceResult: -1 forceDiceResult: -1
} }
// Mini patch :Ajout du rêve actuel // Mini patch :Ajout du rêve actuel
if (actor.system.type == "personnage") { if (actor.type == ACTOR_TYPES.personnage) {
defaultRollData.carac["reve-actuel"] = actor.system.reve.reve defaultRollData.carac["reve-actuel"] = actor.system.reve.reve
} }
@ -131,11 +132,12 @@ export class RdDRoll extends Dialog {
console.log('RdDRoll.activateListeners', this.rollData); console.log('RdDRoll.activateListeners', this.rollData);
// Update html, according to rollData // Update html, according to rollData
if (this.rollData.competence) { if (!this.rollData.selectedCarac && this.rollData.competence) {
const defaut_carac = this.rollData.competence.system.defaut_carac
// Set the default carac from the competence item // Set the default carac from the competence item
this.rollData.selectedCarac = this.rollData.carac[defaut_carac]; this.rollData.selectedCarac = this.rollData.carac[this.actor.mapCarac(this.rollData.competence.system.defaut_carac)]
this.html.find("[name='carac']").val(defaut_carac); }
if (this.rollData.selectedCarac) {
this.html.find("[name='carac']").val(RdDCarac.caracDetails(this.rollData.selectedCarac.label).code)
} }
if (this.rollData.selectedSort) { if (this.rollData.selectedSort) {
this.setSelectedSort(this.rollData.selectedSort); this.setSelectedSort(this.rollData.selectedSort);