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:
parent
de9d3bbb48
commit
c733644f3a
@ -1850,26 +1850,6 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
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 = {}) {
|
||||
RdDEmpoignade.checkEmpoignadeEnCours(this)
|
||||
|
@ -294,6 +294,25 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
||||
createCallbackAppelAuMoral() { return this.createEmptyCallback(); }
|
||||
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
|
||||
* @param {*} caracName code ou label de la caractéristique. On peut utiliser 'intel' pour Intellect.
|
||||
|
@ -36,12 +36,14 @@ export class RdDCreature extends RdDBaseActorSang {
|
||||
|
||||
mapCarac(caracCode) {
|
||||
switch (caracCode) {
|
||||
case 'vue': case 'ouie':
|
||||
case 'odoratgout':
|
||||
case 'empathie':
|
||||
case 'vue': case 'ouie': case 'odoratgout': case 'empathie': case 'perception':
|
||||
return 'perception'
|
||||
}
|
||||
case 'agilite':
|
||||
return 'force'
|
||||
case 'force': case 'constitution': case 'taille': case 'reve': case 'volonte':
|
||||
return caracCode
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -121,6 +121,7 @@ export class RdDEntite extends RdDBaseActorReve {
|
||||
mapCarac(caracCode) {
|
||||
switch (caracCode) {
|
||||
case 'taille':
|
||||
case 'reve':
|
||||
return caracCode
|
||||
}
|
||||
return 'reve'
|
||||
|
@ -41,7 +41,7 @@ export class TextRollCaracCompetence {
|
||||
if (diff.match(REGEX_DICE_DIFF)) {
|
||||
const roll = new Roll(diff)
|
||||
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 diff
|
||||
@ -49,18 +49,15 @@ export class TextRollCaracCompetence {
|
||||
|
||||
async doRoll(actor, caracCode, competence, diff) {
|
||||
caracCode = actor.mapCarac(caracCode)
|
||||
if (caracCode) {
|
||||
if (competence) {
|
||||
if (actor.type == ACTOR_TYPES.personnage) {
|
||||
await actor.rollCaracCompetence(caracCode, competence, diff)
|
||||
}
|
||||
else {
|
||||
await actor.doRollCaracCompetence(caracCode, competence, diff)
|
||||
}
|
||||
}
|
||||
else {
|
||||
await actor.rollCarac(caracCode, { diff })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getSelectedActors(actor) {
|
||||
const selected = canvas.tokens.controlled.map(it => it.actor).filter(it => it)
|
||||
|
@ -8,6 +8,7 @@ import { RdDCarac } from "./rdd-carac.js";
|
||||
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
||||
import { ReglesOptionnelles } from "./settings/regles-optionnelles.js";
|
||||
import { Grammar } from "./grammar.js";
|
||||
import { ACTOR_TYPES } from "./item.js";
|
||||
|
||||
/**
|
||||
* Extend the base Dialog entity to select roll parameters
|
||||
@ -62,7 +63,7 @@ export class RdDRoll extends Dialog {
|
||||
forceDiceResult: -1
|
||||
}
|
||||
// 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
|
||||
}
|
||||
|
||||
@ -131,11 +132,12 @@ export class RdDRoll extends Dialog {
|
||||
console.log('RdDRoll.activateListeners', this.rollData);
|
||||
|
||||
// Update html, according to rollData
|
||||
if (this.rollData.competence) {
|
||||
const defaut_carac = this.rollData.competence.system.defaut_carac
|
||||
if (!this.rollData.selectedCarac && this.rollData.competence) {
|
||||
// Set the default carac from the competence item
|
||||
this.rollData.selectedCarac = this.rollData.carac[defaut_carac];
|
||||
this.html.find("[name='carac']").val(defaut_carac);
|
||||
this.rollData.selectedCarac = this.rollData.carac[this.actor.mapCarac(this.rollData.competence.system.defaut_carac)]
|
||||
}
|
||||
if (this.rollData.selectedCarac) {
|
||||
this.html.find("[name='carac']").val(RdDCarac.caracDetails(this.rollData.selectedCarac.label).code)
|
||||
}
|
||||
if (this.rollData.selectedSort) {
|
||||
this.setSelectedSort(this.rollData.selectedSort);
|
||||
|
Loading…
x
Reference in New Issue
Block a user