Compare commits

..

No commits in common. "70e3e630011ad34fe9a50135433bb0d13a71645f" and "acfab362a0810e8cd115f53011631d9fc75681dd" have entirely different histories.

11 changed files with 136 additions and 209 deletions

View File

@ -42,7 +42,6 @@ import { RdDItemTete } from "./item/tete.js";
import { DialogSelect } from "./dialog-select.js";
import { PAS_DE_DRACONIC, POSSESSION_SANS_DRACONIC } from "./item/base-items.js";
import { RdDItemRace } from "./item/race.js";
import { RdDRollResult } from "./rdd-roll-result.js";
export const MAINS_DIRECTRICES = ['Droitier', 'Gaucher', 'Ambidextre']
@ -1391,7 +1390,7 @@ export class RdDActor extends RdDBaseActorSang {
ethylismeData.doses = ethylisme.nb_doses;
await this.update({ 'system.compteurs.ethylisme': ethylisme });
await RdDRollResult.displayRollData(ethylismeData, this, 'chat-resultat-ethylisme.html');
await RdDResolutionTable.displayRollData(ethylismeData, this, 'chat-resultat-ethylisme.html');
}
/* -------------------------------------------- */
@ -1480,6 +1479,7 @@ export class RdDActor extends RdDBaseActorSang {
/* -------------------------------------------- */
createCallbackExperience() {
return {
condition: r => r.rolled.isPart && r.finalLevel < 0 && game.settings.get("core", "rollMode") != 'selfroll',
action: r => this.appliquerAjoutExperience(r)
};
}
@ -1487,6 +1487,7 @@ export class RdDActor extends RdDBaseActorSang {
/* -------------------------------------------- */
createCallbackAppelAuMoral() { /* Si l'appel au moral est utilisé, on l'affiche dans le chat et on diminue éventuellement le moral */
return {
condition: r => r.use.appelAuMoral && game.settings.get("core", "rollMode") != 'selfroll',
action: r => this._appliquerAppelMoral(r)
};
}
@ -1557,10 +1558,7 @@ export class RdDActor extends RdDBaseActorSang {
/* -------------------------------------------- */
async appliquerAjoutExperience(rollData, hideChatMessage = 'show') {
if (!rollData.rolled.isPart ||
rollData.finalLevel >= 0 ||
game.settings.get("core", "rollMode") == 'selfroll' ||
!Misc.hasConnectedGM()) {
if (!Misc.hasConnectedGM()) {
return
}
hideChatMessage = hideChatMessage == 'hide' || (Misc.isRollModeHiddenToPlayer() && !game.user.isGM)
@ -1584,9 +1582,7 @@ export class RdDActor extends RdDBaseActorSang {
/* -------------------------------------------- */
async _appliquerAppelMoral(rollData) {
if (!rollData.use.moral || game.settings.get("core", "rollMode") == 'selfroll'){
return
}
if (!rollData.use.moral) return;
if (rollData.rolled.isEchec ||
(rollData.ajustements.diviseurSignificative && (rollData.rolled.roll * rollData.ajustements.diviseurSignificative > rollData.score))) {
rollData.perteMoralEchec = rollData.moral <= -3 ? 'dissolution' : 'perte';
@ -1661,7 +1657,10 @@ export class RdDActor extends RdDBaseActorSang {
diffLibre: RdDItemSort.getDifficulte(sorts[0], -7), // Per default at startup
coutreve: Array(30).fill().map((item, index) => 1 + index),
},
callbacks: [{ action: r => this._rollUnSortResult(r) }]
callbackAction: async r => {
await this._rollUnSortResult(r);
if (!r.isSortReserve) this.tmrApp?.close();
}
});
this.tmrApp?.setTMRPendingAction(dialog);
}
@ -1765,44 +1764,12 @@ export class RdDActor extends RdDBaseActorSang {
reveActuel = Math.max(reveActuel - rollData.depenseReve, 0);
await this.update({ "system.reve.reve.value": reveActuel });
await RdDRollResult.displayRollData(rollData, this, 'chat-resultat-sort.html');
// Final chat message
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-sort.html');
if (reveActuel == 0) { // 0 points de reve
ChatMessage.create({ content: this.name + " est réduit à 0 Points de Rêve, et tombe endormi !" });
}
if (!rollData.isSortReserve) {
this.tmrApp?.close();
}
}
/**
* Méthode pour faire un jet prédéterminer sans ouvrir la fenêtre de dialogue
* @param {*} caracName
* @param {*} compName
* @param {*} diff
* @param {*} options
* @returns
*/
async doRollCaracCompetence(caracName, compName, diff, options = { title: "" }) {
const carac = this.getCaracByName(caracName);
if (!carac) {
ui.notifications.warn(`${this.name} n'a pas de caractéristique correspondant à ${caracName}`)
return;
}
const competence = this.getCompetence(compName);
let rollData = {
alias: this.getAlias(),
caracValue: Number(carac.value),
selectedCarac: carac,
competence: competence,
diffLibre: diff,
show: { title: options?.title ?? '' }
};
RollDataAjustements.calcul(rollData, this);
await RdDResolutionTable.rollData(rollData);
this._gererExperience(rollData);
await RdDRollResult.displayRollData(rollData, this)
return rollData.rolled;
}
/* -------------------------------------------- */
@ -1856,27 +1823,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 ?? '' }
},
// TODO:
callbacks: [{ action: r => this.$onRollCompetence(r, options) }]
});
}
/* -------------------------------------------- */
async rollTache(id, options = {}) {
RdDEmpoignade.checkEmpoignadeEnCours(this)
@ -1885,7 +1831,7 @@ export class RdDActor extends RdDBaseActorSang {
compData.system.defaut_carac = tacheData.system.carac; // Patch !
await this.openRollDialog({
name: 'jet-competence',
name: 'jet-competence',
label: 'Jet de Tâche ' + tacheData.name,
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-competence.html',
rollData: {
@ -1898,7 +1844,7 @@ export class RdDActor extends RdDBaseActorSang {
[tacheData.system.carac]: foundry.utils.duplicate(this.system.carac[tacheData.system.carac])
}
},
callbacks: [{ action: r => this._tacheResult(r, options) }]
callbackAction: async r => await this._tacheResult(r, options)
});
}
@ -1921,7 +1867,7 @@ export class RdDActor extends RdDBaseActorSang {
await this.updateEmbeddedDocuments('Item', [rollData.tache]);
await this.santeIncDec("fatigue", rollData.tache.system.fatigue);
await RdDRollResult.displayRollData(rollData, this, 'chat-resultat-tache.html');
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-tache.html');
if (options?.onRollAutomate) {
options.onRollAutomate(rollData);
}
@ -1948,12 +1894,12 @@ export class RdDActor extends RdDBaseActorSang {
}
await this.openRollDialog({
name: `jet-${artData.art}`,
name: `jet-${artData.art}`,
label: `${artData.verbe} ${oeuvre.name}`,
template: `systems/foundryvtt-reve-de-dragon/templates/dialog-roll-${oeuvre.type}.html`,
template: `systems/foundryvtt-reve-de-dragon/templates/dialog-roll-${oeuvre.type}.html`,
rollData: artData,
callbacks: [{ action: callbackAction }],
})
callbackAction: callbackAction
});
}
/* -------------------------------------------- */
@ -1962,7 +1908,7 @@ export class RdDActor extends RdDBaseActorSang {
const baseQualite = (artData.rolled.isSuccess ? niveau : artData.competence.system.niveau);
artData.qualiteFinale = Math.min(baseQualite, niveau) + artData.rolled.ptQualite;
await RdDRollResult.displayRollData(artData, this.name, `chat-resultat-${artData.art}.html`);
await RdDResolutionTable.displayRollData(artData, this.name, `chat-resultat-${artData.art}.html`);
}
/* -------------------------------------------- */
@ -2039,7 +1985,7 @@ export class RdDActor extends RdDBaseActorSang {
ui.notifications.info(`${platCuisine.system.quantite} rations de ${platCuisine.name} ont été ajoutés à votre équipement`);
}
cuisine.platCuisine = platCuisine;
await RdDRollResult.displayRollData(cuisine, this.name, `chat-resultat-${cuisine.art}.html`);
await RdDResolutionTable.displayRollData(cuisine, this.name, `chat-resultat-${cuisine.art}.html`);
}
async preparerNourriture(item) {
@ -2134,7 +2080,7 @@ export class RdDActor extends RdDBaseActorSang {
await this.createEmbeddedDocuments("Item", [RdDItemSigneDraconique.prepareSigneDraconiqueMeditation(meditationRoll.meditation, meditationRoll.rolled)]);
}
await RdDRollResult.displayRollData(meditationRoll, this.name, 'chat-resultat-meditation.html');
await RdDResolutionTable.displayRollData(meditationRoll, this.name, 'chat-resultat-meditation.html');
}
/* -------------------------------------------- */
@ -2221,7 +2167,7 @@ export class RdDActor extends RdDBaseActorSang {
await ExperienceLog.add(this, XP_TOPIC.XPSORT, fromXp, toXp, `${rollData.competence.name} : signe draconique`);
}
await this.deleteEmbeddedDocuments("Item", [rollData.signe._id]);
await RdDRollResult.displayRollData(rollData, this.name, 'chat-resultat-lecture-signedraconique.html');
await RdDResolutionTable.displayRollData(rollData, this.name, 'chat-resultat-lecture-signedraconique.html');
this.tmrApp.close();
}
@ -2232,13 +2178,13 @@ export class RdDActor extends RdDBaseActorSang {
label: 'Appel à la chance',
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html',
rollData: { selectedCarac: this.getCaracByName('chance-actuelle'), surprise: '' },
callbacks: [{ action: r => this.$appelChanceResult(r, onSuccess, onEchec) }]
callbackAction: async r => await this._appelChanceResult(r, onSuccess, onEchec)
});
}
/* -------------------------------------------- */
async $appelChanceResult(rollData, onSuccess, onEchec) {
await RdDRollResult.displayRollData(rollData, this, 'chat-resultat-appelchance.html')
async _appelChanceResult(rollData, onSuccess, onEchec) {
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-appelchance.html')
if (rollData.rolled.isSuccess) {
await this.setFlag(SYSTEM_RDD, 'utilisationChance', true);
await this.chanceActuelleIncDec(-1);
@ -2712,7 +2658,7 @@ export class RdDActor extends RdDBaseActorSang {
/* -------------------------------------------- */
async _alchimieResult(rollData) {
await RdDRollResult.displayRollData(rollData, this, 'chat-resultat-alchimie.html');
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-alchimie.html');
}
/* -------------------------------------------- */

View File

@ -15,7 +15,6 @@ import { StatusEffects } from "../settings/status-effects.js";
import { Targets } from "../targets.js";
import { RdDConfirm } from "../rdd-confirm.js";
import { RdDCarac } from "../rdd-carac.js";
import { RdDRollResult } from "../rdd-roll-result.js";
import { ChatUtility } from "../chat-utility.js";
import { DialogValidationEncaissement } from "../dialog-validation-encaissement.js";
@ -269,11 +268,19 @@ export class RdDBaseActorReve extends RdDBaseActor {
}
/* -------------------------------------------- */
async openRollDialog({ name, label, template, rollData, callbacks }) {
async openRollDialog({ name, label, template, rollData, callbackAction }) {
const dialog = await RdDRoll.create(this, rollData,
{ html: template, close: async html => await this._onCloseRollDialog(html) },
{ name: name, label: label, callbacks: [this.createCallbackExperience(), this.createCallbackAppelAuMoral()].concat(callbacks) })
dialog.render(true)
{
name: name,
label: label,
callbacks: [
this.createCallbackExperience(),
this.createCallbackAppelAuMoral(),
{ action: callbackAction }
]
});
dialog.render(true);
return dialog
}
@ -292,7 +299,7 @@ export class RdDBaseActorReve extends RdDBaseActor {
const competence = this.getCompetence(compName);
await this.openRollDialog({
name: 'jet-competence',
label: competence ? 'Jet ' + Grammar.apostrophe('de', competence.name) : `Jet sans compétence (${compName})`,
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(),
@ -303,7 +310,7 @@ export class RdDBaseActorReve extends RdDBaseActor {
competence: competence,
show: { title: options?.title ?? '' }
},
callbacks: [async r => this.$onRollCompetence(r, options)]
callbackAction: async r => await this.$onRollCompetence(r, options)
});
}
/**
@ -346,14 +353,16 @@ export class RdDBaseActorReve extends RdDBaseActor {
const selectedCaracName = ['apparence', 'perception', 'force', 'reve'].find(it => carac[it] != undefined)
await this.openRollDialog({
name: `jet-${this.id}`,
label: `Jet de ${this.getAlias()}`,
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll.html',
rollData: {
alias: this.getAlias(),
carac: carac,
selectedCarac: carac[selectedCaracName],
selectedCaracName: selectedCaracName,
competences: this.itemTypes['competence']
},
callbacks: [{ action: r => this.$onRollCaracResult(r) }]
callbackAction: async r => await this.$onRollCaracResult(r)
})
}
/* -------------------------------------------- */
@ -364,38 +373,32 @@ export class RdDBaseActorReve extends RdDBaseActor {
foundry.utils.mergeObject(options, { resistance: false, diff: 0 }, { overwrite: false })
RdDEmpoignade.checkEmpoignadeEnCours(this)
let selectedCarac = this.getCaracByName(caracName)
const title = 'Jet ' + Grammar.apostrophe('de', selectedCarac.label);
const jetResistance = options.resistance ? caracName : undefined;
console.log("selectedCarac", selectedCarac)
await this.openRollDialog({
name: 'jet-' + caracName,
label: title,
label: 'Jet ' + Grammar.apostrophe('de', selectedCarac.label),
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html',
rollData: {
alias: this.getAlias(),
selectedCarac: selectedCarac,
competences: this.itemTypes['competence'],
diffLibre: options.diff ?? 0,
jetResistance: jetResistance
jetResistance: options.resistance ? caracName : undefined
},
callbacks: [{ action: r => this.$onRollCaracResult(r) }]
callbackAction: async r => await this.$onRollCaracResult(r)
});
}
/* -------------------------------------------- */
async $onRollCaracResult(rollData) {
// Final chat message
await RdDRollResult.displayRollData(rollData, this, 'chat-resultat-general.html');
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-general.html');
}
/* -------------------------------------------- */
async rollCompetence(idOrName, options = { tryTarget: true, arme: undefined }) {
RdDEmpoignade.checkEmpoignadeEnCours(this)
const competence = this.getCompetence(idOrName);
let rollData = {
carac: this.system.carac,
competence: competence,
arme: options.arme
}
let rollData = { carac: this.system.carac, competence: competence, arme: options.arme }
if (competence.type == ITEM_TYPES.competencecreature) {
const token = RdDUtility.getSelectedToken(this)
const arme = RdDItemCompetenceCreature.armeCreature(competence)
@ -413,18 +416,18 @@ export class RdDBaseActorReve extends RdDBaseActor {
// Transformer la competence de créature
RdDItemCompetenceCreature.setRollDataCreature(rollData)
}
const dialogLabel = 'Jet ' + Grammar.apostrophe('de', competence.name);
await this.openRollDialog({
name: 'jet-competence',
label: dialogLabel,
label: 'Jet ' + Grammar.apostrophe('de', competence.name),
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-competence.html',
rollData: rollData,
callbacks: [{ action: r => this.$onRollCompetence(r, options) }]
callbackAction: async r => await this.$onRollCompetence(r, options)
});
}
async $onRollCompetence(rollData, options) {
await RdDRollResult.displayRollData(rollData, this, 'chat-resultat-competence.html')
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-competence.html')
if (options?.onRollAutomate) {
options.onRollAutomate(rollData);
}
@ -559,8 +562,10 @@ export class RdDBaseActorReve extends RdDBaseActor {
await entite.setEntiteReveAccordee(this);
}
await RdDRollResult.displayRollData(rollData, this, 'chat-resultat-accorder-cauchemar.html');
await this.appliquerAjoutExperience(rollData, true);
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-accorder-cauchemar.html');
if (rolled.isPart) {
await this.appliquerAjoutExperience(rollData, true);
}
return rolled.isSuccess;
}

View File

@ -1,6 +1,5 @@
import { ITEM_TYPES } from "./constants.js";
import { Grammar } from "./grammar.js";
import { RdDCombatManager } from "./rdd-combat.js";
export const CATEGORIES_COMPETENCES_CREATURES = {
@ -18,11 +17,9 @@ export class RdDItemCompetenceCreature extends Item {
/* -------------------------------------------- */
static setRollDataCreature(rollData) {
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.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
rollData.arme = RdDItemCompetenceCreature.armeCreature(rollData.competence);
}
@ -32,20 +29,20 @@ export class RdDItemCompetenceCreature extends Item {
if (categorieAttaque != undefined) {
// cloner pour ne pas modifier la compétence
return foundry.utils.mergeObject(item, {
action: item.isCompetencePossession() ? 'possession' : 'attaque',
system: {
competence: item.name,
cac: categorieAttaque == "naturelle" ? "naturelle" : "",
niveau: item.system.niveau,
initiative: RdDCombatManager.calculInitiative(item.system.niveau, item.system.carac_value),
equipe: true,
resistance: 100,
dommagesReels: item.system.dommages,
penetration: 0,
force: 0,
rapide: true,
}
}, { inplace: false, });
action: item.isCompetencePossession() ? 'possession' : 'attaque',
system: {
competence: item.name,
cac: categorieAttaque == "naturelle" ? "naturelle" : "",
niveau: item.system.niveau,
initiative: RdDCombatManager.calculInitiative(item.system.niveau, item.system.carac_value),
equipe: true,
resistance: 100,
dommagesReels: item.system.dommages,
penetration: 0,
force: 0,
rapide: true,
}
}, { inplace: false, });
}
return undefined;
}

View File

@ -57,7 +57,7 @@ export const LIST_CARAC_PERSONNAGE = {
}
export const LIST_CARAC_AUTRES = {
'perception': { code: 'perception', label: 'Perception', path: 'system.carac.perception.value' },
'perception': { code: 'perception', label: 'Perception', path: 'system.carac.perception.value' },
}
const LIST_CARAC_DERIVEE = {
@ -75,12 +75,12 @@ const LIST_CARAC_ROLL = Object.values(LIST_CARAC_PERSONNAGE).filter(it => it.isC
export class RdDCarac {
static caracDetails(name, options = { onMessage: undefined }) {
static caracDetails(name) {
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', onMessage: options.onMessage })
return Misc.findFirstLike(name, LIST_CARAC_ROLL, { mapper: it => it.label, description: 'caractéristique' })
}
static carac(code) {

View File

@ -13,7 +13,6 @@ import { ReglesOptionnelles } from "./settings/regles-optionnelles.js";
import { STATUSES } from "./settings/status-effects.js";
import { Targets } from "./targets.js";
import { RdDEmpoignade } from "./rdd-empoignade.js";
import { RdDRollResult } from "./rdd-roll-result.js";
/* -------------------------------------------- */
const premierRoundInit = [
@ -362,7 +361,7 @@ export class RdDCombatManager extends Combat {
}
/* -------------------------------------------- */
static listActionsActorCombatant(actor) {
static listActionsActorCombatant( actor) {
const possessions = actor.listActionsPossessions()
const actions = possessions.length > 0
? possessions
@ -743,23 +742,16 @@ export class RdDCombat {
this.attacker.createCallbackExperience(),
this.attacker.createCallbackAppelAuMoral(),
{ action: r => this.removeChatMessageActionsPasseArme(r.passeArme) },
{ action: r => this._increaseItemUse(r, arme) },
{ action: r => this._onAttaqueNormale(r) },
{ action: r => this._onAttaqueParticuliere(r) },
{ action: r => this._onAttaqueEchec(r) },
{ action: r => this._onAttaqueEchecTotal(r) },
{ condition: r => arme && !RdDCombat.isParticuliere(r), action: r => this.attacker.incDecItemUse(arme._id) },
{ condition: r => (RdDCombat.isReussite(r) && !RdDCombat.isParticuliere(r)), action: r => this._onAttaqueNormale(r) },
{ condition: RdDCombat.isParticuliere, action: r => this._onAttaqueParticuliere(r) },
{ condition: RdDCombat.isEchec, action: r => this._onAttaqueEchec(r) },
{ condition: RdDCombat.isEchecTotal, action: r => this._onAttaqueEchecTotal(r) },
]
});
dialog.render(true);
}
_increaseItemUse(rollData, arme) {
if (!arme || RdDCombat.isParticuliere(rollData)) {
return
}
this.attacker.incDecItemUse(arme._id)
}
/* -------------------------------------------- */
_prepareAttaque(competence, arme) {
let rollData = {
@ -776,7 +768,7 @@ export class RdDCombat {
if (this.attacker.isCreatureEntite()) {
RdDItemCompetenceCreature.setRollDataCreature(rollData);
}
}
else if (arme) {
// Usual competence
rollData.arme = RdDItemArme.armeUneOuDeuxMains(arme, RdDItemCompetence.isArmeUneMain(competence));
@ -792,9 +784,7 @@ export class RdDCombat {
/* -------------------------------------------- */
async _onAttaqueParticuliere(rollData) {
if (!RdDCombat.isParticuliere(rollData)) {
return
}
const isMeleeDiffNegative = (rollData.competence.type == 'competencecreature' || rollData.selectedCarac.label == "Mêlée") && rollData.diffLibre < 0;
// force toujours, sauf empoignade
// finesse seulement en mélée, pour l'empoignade, ou si la difficulté libre est de -1 minimum
@ -832,9 +822,6 @@ export class RdDCombat {
/* -------------------------------------------- */
async _onAttaqueNormale(attackerRoll) {
if (!RdDCombat.isReussite(attackerRoll) || RdDCombat.isParticuliere(attackerRoll)) {
return
}
console.log("RdDCombat.onAttaqueNormale >>>", attackerRoll);
attackerRoll.dmg = RdDBonus.dmg(attackerRoll, this.attacker, this.defender.isEntite());
@ -843,7 +830,7 @@ export class RdDCombat {
cible: this.defender?.getAlias() ?? 'la cible',
isRecul: (attackerRoll.particuliere == 'force' || attackerRoll.tactique == 'charge')
}
await RdDRollResult.displayRollData(attackerRoll, this.attacker, 'chat-resultat-attaque.html');
await RdDResolutionTable.displayRollData(attackerRoll, this.attacker, 'chat-resultat-attaque.html');
if (!await this.attacker.accorder(this.defender, 'avant-defense')) {
return;
@ -951,9 +938,6 @@ export class RdDCombat {
/* -------------------------------------------- */
async _onAttaqueEchecTotal(attackerRoll) {
if (!RdDCombat.isEchecTotal(attackerRoll)) {
return
}
const choixEchecTotal = await ChatMessage.create({
whisper: ChatUtility.getOwners(this.attacker),
content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-attaque-etotal.html', {
@ -981,12 +965,8 @@ export class RdDCombat {
/* -------------------------------------------- */
async _onAttaqueEchec(rollData) {
if (!RdDCombat.isEchec(rollData)) {
return
}
console.log("RdDCombat.onAttaqueEchec >>>", rollData);
await RdDRollResult.displayRollData(rollData, this.attacker, 'chat-resultat-attaque.html');
await RdDResolutionTable.displayRollData(rollData, this.attacker, 'chat-resultat-attaque.html');
}
/* -------------------------------------------- */
@ -1074,7 +1054,7 @@ export class RdDCombat {
await this.computeRecul(defenderRoll);
await this.computeDeteriorationArme(defenderRoll);
await RdDRollResult.displayRollData(defenderRoll, this.defender, 'chat-resultat-parade.html');
await RdDResolutionTable.displayRollData(defenderRoll, this.defender, 'chat-resultat-parade.html');
this.removeChatMessageActionsPasseArme(defenderRoll.passeArme);
}
@ -1082,7 +1062,7 @@ export class RdDCombat {
async _onParadeEchec(defenderRoll) {
console.log("RdDCombat._onParadeEchec >>>", defenderRoll);
await RdDRollResult.displayRollData(defenderRoll, this.defender, 'chat-resultat-parade.html');
await RdDResolutionTable.displayRollData(defenderRoll, this.defender, 'chat-resultat-parade.html');
this.removeChatMessageActionsPasseArme(defenderRoll.passeArme);
this._sendMessageDefense(defenderRoll.attackerRoll, defenderRoll, { defense: true });
@ -1149,7 +1129,7 @@ export class RdDCombat {
/* -------------------------------------------- */
async _onEsquiveNormale(defenderRoll) {
console.log("RdDCombat._onEsquiveNormal >>>", defenderRoll);
await RdDRollResult.displayRollData(defenderRoll, this.defender, 'chat-resultat-esquive.html');
await RdDResolutionTable.displayRollData(defenderRoll, this.defender, 'chat-resultat-esquive.html');
this.removeChatMessageActionsPasseArme(defenderRoll.passeArme);
}
@ -1157,7 +1137,7 @@ export class RdDCombat {
async _onEsquiveEchec(defenderRoll) {
console.log("RdDCombat._onEsquiveEchec >>>", defenderRoll);
await RdDRollResult.displayRollData(defenderRoll, this.defender, 'chat-resultat-esquive.html');
await RdDResolutionTable.displayRollData(defenderRoll, this.defender, 'chat-resultat-esquive.html');
this.removeChatMessageActionsPasseArme(defenderRoll.passeArme);
this._sendMessageDefense(defenderRoll.attackerRoll, defenderRoll, { defense: true })

View File

@ -18,7 +18,6 @@ import { FenetreRechercheTirage } from "./tirage/fenetre-recherche-tirage.js";
import { TMRUtility } from "./tmr-utility.js";
import { DialogFatigueVoyage } from "./voyage/dialog-fatigue-voyage.js";
import { ChatUtility } from "./chat-utility.js";
import { RdDRollResult } from "./rdd-roll-result.js";
const rddRollNumeric = /^(\d+)\s*([\+\-]?\d+)?\s*(s)?/;
@ -350,7 +349,7 @@ export class RdDCommands {
show: { title: "Table de résolution" }
};
await RdDResolutionTable.rollData(rollData);
return RdDCommands._chatAnswer(msg, await RdDRollResult.buildRollDataHtml(rollData));
return RdDCommands._chatAnswer(msg, await RdDResolutionTable.buildRollDataHtml(rollData));
}
/* -------------------------------------------- */

View File

@ -1,10 +1,12 @@
/* -------------------------------------------- */
import { RdDResolutionTable } from "./rdd-resolution-table.js";
import { RdDRoll } from "./rdd-roll.js";
import { RdDItemCompetenceCreature } from "./item-competencecreature.js";
import { ChatUtility } from "./chat-utility.js";
import { STATUSES } from "./settings/status-effects.js";
import { ITEM_TYPES } from "./constants.js";
import { RdDRollResult } from "./rdd-roll-result.js";
/* -------------------------------------------- */
/* -------------------------------------------- */
export class RdDEmpoignade {
@ -190,7 +192,7 @@ export class RdDEmpoignade {
}
if (empoignade.system.pointsemp >= 2) {
if (!empoignade.system.ausol) {
let msg = await RdDRollResult.displayRollData(rollData, attacker, 'chat-empoignade-entrainer.html');
let msg = await RdDResolutionTable.displayRollData(rollData, attacker, 'chat-empoignade-entrainer.html');
RdDEmpoignade.$storeRollEmpoignade(msg, rollData);
}
} else {
@ -248,7 +250,7 @@ export class RdDEmpoignade {
if (rollData.rolled.isPart) {
rollData.particuliere = "finesse";
}
let msg = await RdDRollResult.displayRollData(rollData, defender, 'chat-empoignade-resultat.html');
let msg = await RdDResolutionTable.displayRollData(rollData, defender, 'chat-empoignade-resultat.html');
RdDEmpoignade.$storeRollEmpoignade(msg, rollData);
}
@ -310,9 +312,9 @@ export class RdDEmpoignade {
RdDEmpoignade.$updateEtatEmpoignade(empoignade)
}
await RdDRollResult.displayRollData(rollData, rollData.defender, 'chat-empoignade-resultat.html')
await RdDResolutionTable.displayRollData(rollData, rollData.defender, 'chat-empoignade-resultat.html')
if (empoignade.system.pointsemp >= 2) {
let msg = await RdDRollResult.displayRollData(rollData, rollData.attacker, 'chat-empoignade-entrainer.html');
let msg = await RdDResolutionTable.displayRollData(rollData, rollData.attacker, 'chat-empoignade-entrainer.html');
RdDEmpoignade.$storeRollEmpoignade(msg, rollData);
}
}
@ -356,7 +358,7 @@ export class RdDEmpoignade {
await attacker.setEffect(STATUSES.StatusProne, true);
await defender.setEffect(STATUSES.StatusProne, true);
let msg = await RdDRollResult.displayRollData(rollData, attacker, 'chat-empoignade-entrainer-sol.html');
let msg = await RdDResolutionTable.displayRollData(rollData, attacker, 'chat-empoignade-entrainer-sol.html');
RdDEmpoignade.$storeRollEmpoignade(msg, rollData);
}
@ -372,7 +374,7 @@ export class RdDEmpoignade {
await defender.setEffect(STATUSES.StatusProne, true);
await this.$deleteEmpoignade(empoignade)
let msg = await RdDRollResult.displayRollData(rollData, attacker, 'chat-empoignade-projeter-sol.html');
let msg = await RdDResolutionTable.displayRollData(rollData, attacker, 'chat-empoignade-projeter-sol.html');
RdDEmpoignade.$storeRollEmpoignade(msg, rollData);
}
@ -399,7 +401,7 @@ export class RdDEmpoignade {
if (perteMode == "endquart") {
await defender.santeIncDec("endurance", -(3 * Math.floor(endValue / 4)));
}
let msg = await RdDRollResult.displayRollData(rollData, attacker, 'chat-empoignade-perte-endurance.html');
let msg = await RdDResolutionTable.displayRollData(rollData, attacker, 'chat-empoignade-perte-endurance.html');
RdDEmpoignade.$storeRollEmpoignade(msg, rollData);
}

View File

@ -1,9 +1,9 @@
/* -------------------------------------------- */
import { RdDResolutionTable } from "./rdd-resolution-table.js";
import { RdDRoll } from "./rdd-roll.js";
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
@ -91,17 +91,14 @@ export class RdDPossession {
}
RdDPossession.selectCompetenceDraconicOuPossession(rollData, defender)
rollData.diffLibre = RdDPossession.getInfoAttaque(rollData).diffLibre
await RdDPossession.$rollDefensePossession(defender, rollData);
}
static selectCompetenceDraconicOuPossession(rollData, rollingActor) {
rollData.competence = rollingActor.getDraconicOuPossession();
if (rollingActor.isCreatureEntite()) {
const carac = rollingActor.system.carac
rollData.carac = carac
rollData.competence.system.defaut_carac = 'reve'
rollData.selectedCarac = carac.reve
RdDItemCompetenceCreature.setRollDataCreature(rollData)
}
else {
rollData.selectedCarac = rollingActor.system.carac.reve
@ -134,7 +131,7 @@ export class RdDPossession {
}
const possession = (rollData.isECNIDefender ? rollData.attacker : rollData.defender).getPossession(rollData.possession.system.possessionid)
RdDPossession.storePossessionAttaque(possession, rollData)
await RdDRollResult.displayRollData(rollData, rollData.defender, 'chat-resultat-possession.html');
await RdDResolutionTable.displayRollData(rollData, rollData.defender, 'chat-resultat-possession.html');
}
/* -------------------------------------------- */
@ -174,7 +171,7 @@ export class RdDPossession {
rollData.possession = possession
RdDPossession.$updateEtatPossession(rollData.possession)
await RdDRollResult.displayRollData(rollData, rollData.attacker, 'chat-resultat-possession.html')
await RdDResolutionTable.displayRollData(rollData, rollData.attacker, 'chat-resultat-possession.html')
if (rollData.possession.isPosseder || rollData.possession.isConjurer) {
// conjuration
await victime.deleteEmbeddedDocuments("Item", [rollData.possession._id])

View File

@ -54,6 +54,7 @@ export class RdDResolutionTable {
return this._computeCell(level, percentage);
}
/* -------------------------------------------- */
static _computeRow(caracValue) {
let dataRow = [
@ -88,10 +89,24 @@ export class RdDResolutionTable {
return resultat;
}
/* -------------------------------------------- */
static async displayRollData(rollData, actor = undefined, template = 'chat-resultat-general.html') {
return await ChatUtility.createChatWithRollMode(
{ content: await RdDResolutionTable.buildRollDataHtml(rollData, template) },
actor
)
}
static actorChatName(actor) {
return actor ?? game.user.name;
}
/* -------------------------------------------- */
static async buildRollDataHtml(rollData, template = 'chat-resultat-general.html') {
rollData.show = rollData.show || {};
return await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/${template}`, rollData);
}
/* -------------------------------------------- */
static async rollData(rollData) {
rollData.rolled = await this.roll(rollData.caracValue, rollData.finalLevel, rollData);

View File

@ -1,17 +0,0 @@
import { ChatUtility } from "./chat-utility.js";
export class RdDRollResult {
static async displayRollData(rollData, actor = undefined, template = 'chat-resultat-general.html') {
const chatMessage = await ChatUtility.createChatWithRollMode(
{ content: await RdDRollResult.buildRollDataHtml(rollData, template) },
actor
)
return chatMessage
}
static async buildRollDataHtml(rollData, template = 'chat-resultat-general.html') {
rollData.show = rollData.show || {};
return await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/${template}`, rollData);
}
}

View File

@ -138,9 +138,9 @@ export class RdDRoll extends Dialog {
}
if (this.rollData.selectedCarac) {
this.html.find("[name='carac']").val(
RdDCarac.caracDetails(this.rollData.selectedCarac.label, { onMessage: m => { } })?.code
?? this.rollData.selectedCarac.code
?? Grammar.toLowerCaseNoAccentNoSpace(this.rollData.selectedCarac.label)
this.actor?.type == ACTOR_TYPES.personnage
? RdDCarac.caracDetails(this.rollData.selectedCarac.label).code
: this.rollData.selectedCarac.label
)
}
if (this.rollData.selectedSort) {
@ -269,12 +269,15 @@ export class RdDRoll extends Dialog {
}
async onAction(action) {
this.rollData.forceDiceResult = Number.parseInt(this.html.find("[name='force-dice-result']").val()) ?? -1
await RdDResolutionTable.rollData(this.rollData)
for (let callback of action.callbacks) {
await callback.action(this.rollData)
}
this.rollData.forceDiceResult = Number.parseInt(this.html.find("[name='force-dice-result']").val()) ?? -1;
await RdDResolutionTable.rollData(this.rollData);
console.log("RdDRoll -=>", this.rollData, this.rollData.rolled);
if (action.callbacks)
for (let callback of action.callbacks) {
if (callback.condition == undefined || callback.condition(this.rollData)) {
await callback.action(this.rollData);
}
}
}
async setSelectedSort(sort) {