Utiliser les fenêtres de jets pour les jets

This commit is contained in:
Vincent Vandemeulebrouck 2025-01-11 19:29:29 +01:00
parent 551438f514
commit 1b75decb18
4 changed files with 23 additions and 7 deletions

View File

@ -222,7 +222,7 @@ export class RdDActorSheet extends RdDBaseActorSangSheet {
} }
// Points de reve actuel // Points de reve actuel
this.html.find('.roll-reve-actuel').click(async event => this.actor.rollCarac('reve-actuel', true)) this.html.find('.roll-reve-actuel').click(async event => this.actor.rollCarac('reve-actuel', {resistance:true}))
this.html.find('.empoignade-label a').click(async event => RdDEmpoignade.onAttaqueEmpoignadeFromItem(RdDSheetUtility.getItem(event, this.actor))) this.html.find('.empoignade-label a').click(async event => RdDEmpoignade.onAttaqueEmpoignadeFromItem(RdDSheetUtility.getItem(event, this.actor)))
this.html.find('.roll-arme').click(async event => this.actor.rollArme(foundry.utils.duplicate(this._getEventArmeCombat(event)), 'competence')) this.html.find('.roll-arme').click(async event => this.actor.rollArme(foundry.utils.duplicate(this._getEventArmeCombat(event)), 'competence'))

View File

@ -28,7 +28,7 @@ export class RdDBaseActorReveSheet extends RdDBaseActorSheet {
this.html.find('.button-encaissement').click(async event => this.actor.encaisser()) this.html.find('.button-encaissement').click(async event => this.actor.encaisser())
this.html.find('.roll-carac').click(async event => { this.html.find('.roll-carac').click(async event => {
this.actor.rollCarac(Grammar.toLowerCaseNoAccent(event.currentTarget.attributes['data-carac-name'].value))}); this.actor.rollCarac(Grammar.toLowerCaseNoAccent(event.currentTarget.attributes['data-carac-name'].value))})
this.html.find('.roll-competence').click(async event => this.actor.rollCompetence(RdDSheetUtility.getItemId(event))); this.html.find('.roll-competence').click(async event => this.actor.rollCompetence(RdDSheetUtility.getItemId(event)));
this.html.find('.endurance-plus').click(async event => this.actor.santeIncDec("endurance", 1)); this.html.find('.endurance-plus').click(async event => this.actor.santeIncDec("endurance", 1));
this.html.find('.endurance-moins').click(async event => this.actor.santeIncDec("endurance", -1)); this.html.find('.endurance-moins').click(async event => this.actor.santeIncDec("endurance", -1));

View File

@ -344,14 +344,15 @@ export class RdDBaseActorReve extends RdDBaseActor {
competences: this.itemTypes['competence'] competences: this.itemTypes['competence']
}, },
callbackAction: r => this.$onRollCaracResult(r) callbackAction: r => this.$onRollCaracResult(r)
}); })
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollCarac(caracName, jetResistance = undefined) { async rollCarac(caracName, options = {}) {
if (Grammar.equalsInsensitive(caracName, 'taille')) { if (Grammar.equalsInsensitive(caracName, 'taille')) {
return return
} }
foundry.utils.mergeObject(options, { resistance: false, diff: 0 }, { overwrite: false })
RdDEmpoignade.checkEmpoignadeEnCours(this) RdDEmpoignade.checkEmpoignadeEnCours(this)
let selectedCarac = this.getCaracByName(caracName) let selectedCarac = this.getCaracByName(caracName)
console.log("selectedCarac", selectedCarac) console.log("selectedCarac", selectedCarac)
@ -362,7 +363,8 @@ export class RdDBaseActorReve extends RdDBaseActor {
rollData: { rollData: {
selectedCarac: selectedCarac, selectedCarac: selectedCarac,
competences: this.itemTypes['competence'], competences: this.itemTypes['competence'],
jetResistance: jetResistance ? caracName : undefined diffLibre: options.diff ?? 0,
jetResistance: options.resistance ? caracName : undefined
}, },
callbackAction: r => this.$onRollCaracResult(r) callbackAction: r => this.$onRollCaracResult(r)
}); });

View File

@ -32,9 +32,23 @@ class TextRollCaracCompetence {
const path = RdDCarac.caracDetails(caracCode)?.path const path = RdDCarac.caracDetails(caracCode)?.path
const actors = TextRollCaracCompetence.getSelectedActors(actor) const actors = TextRollCaracCompetence.getSelectedActors(actor)
actors.filter(it => foundry.utils.getProperty(it, path) != undefined) actors.filter(it => foundry.utils.getProperty(it, path) != undefined)
.forEach(it => it.doRollCaracCompetence(caracCode, competence, diff)) .forEach(it => TextRollCaracCompetence.doRoll(it, caracCode, competence, diff))
} }
} }
static async doRoll(actor, caracCode, competence, diff) {
if (competence) {
if (actor.type == ACTOR_TYPES.personnage) {
actor.rollCaracCompetence(caracCode, competence, diff)
}
else {
actor.doRollCaracCompetence(caracCode, competence, diff)
}
}
else {
actor.rollCarac(caracCode, { diff })
}
}
static getSelectedActors(actor) { static getSelectedActors(actor) {
const selected = canvas.tokens.controlled.map(it => it.actor).filter(it => it) const selected = canvas.tokens.controlled.map(it => it.actor).filter(it => it)
if (selected.length > 0) { if (selected.length > 0) {