forked from public/foundryvtt-reve-de-dragon
Preparation callbacks pour nouveaux Rolls
This commit is contained in:
106
module/actor.js
106
module/actor.js
@ -42,6 +42,7 @@ 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']
|
||||
|
||||
@ -1390,7 +1391,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
ethylismeData.doses = ethylisme.nb_doses;
|
||||
|
||||
await this.update({ 'system.compteurs.ethylisme': ethylisme });
|
||||
await RdDResolutionTable.displayRollData(ethylismeData, this, 'chat-resultat-ethylisme.html');
|
||||
await RdDRollResult.displayRollData(ethylismeData, this, 'chat-resultat-ethylisme.html');
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -1479,7 +1480,6 @@ 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,7 +1487,6 @@ 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)
|
||||
};
|
||||
}
|
||||
@ -1558,7 +1557,10 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async appliquerAjoutExperience(rollData, hideChatMessage = 'show') {
|
||||
if (!Misc.hasConnectedGM()) {
|
||||
if (!rollData.rolled.isPart ||
|
||||
rollData.finalLevel >= 0 ||
|
||||
game.settings.get("core", "rollMode") == 'selfroll' ||
|
||||
!Misc.hasConnectedGM()) {
|
||||
return
|
||||
}
|
||||
hideChatMessage = hideChatMessage == 'hide' || (Misc.isRollModeHiddenToPlayer() && !game.user.isGM)
|
||||
@ -1582,7 +1584,9 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _appliquerAppelMoral(rollData) {
|
||||
if (!rollData.use.moral) return;
|
||||
if (!rollData.use.moral || game.settings.get("core", "rollMode") == 'selfroll'){
|
||||
return
|
||||
}
|
||||
if (rollData.rolled.isEchec ||
|
||||
(rollData.ajustements.diviseurSignificative && (rollData.rolled.roll * rollData.ajustements.diviseurSignificative > rollData.score))) {
|
||||
rollData.perteMoralEchec = rollData.moral <= -3 ? 'dissolution' : 'perte';
|
||||
@ -1657,10 +1661,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
diffLibre: RdDItemSort.getDifficulte(sorts[0], -7), // Per default at startup
|
||||
coutreve: Array(30).fill().map((item, index) => 1 + index),
|
||||
},
|
||||
callbackAction: async r => {
|
||||
await this._rollUnSortResult(r);
|
||||
if (!r.isSortReserve) this.tmrApp?.close();
|
||||
}
|
||||
callbacks: [{ action: r => this._rollUnSortResult(r) }]
|
||||
});
|
||||
this.tmrApp?.setTMRPendingAction(dialog);
|
||||
}
|
||||
@ -1764,12 +1765,44 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
reveActuel = Math.max(reveActuel - rollData.depenseReve, 0);
|
||||
await this.update({ "system.reve.reve.value": reveActuel });
|
||||
|
||||
// Final chat message
|
||||
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-sort.html');
|
||||
await RdDRollResult.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;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -1823,6 +1856,27 @@ 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)
|
||||
@ -1831,7 +1885,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: {
|
||||
@ -1844,7 +1898,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
[tacheData.system.carac]: foundry.utils.duplicate(this.system.carac[tacheData.system.carac])
|
||||
}
|
||||
},
|
||||
callbackAction: async r => await this._tacheResult(r, options)
|
||||
callbacks: [{ action: r => this._tacheResult(r, options) }]
|
||||
});
|
||||
}
|
||||
|
||||
@ -1867,7 +1921,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
await this.updateEmbeddedDocuments('Item', [rollData.tache]);
|
||||
await this.santeIncDec("fatigue", rollData.tache.system.fatigue);
|
||||
|
||||
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-tache.html');
|
||||
await RdDRollResult.displayRollData(rollData, this, 'chat-resultat-tache.html');
|
||||
if (options?.onRollAutomate) {
|
||||
options.onRollAutomate(rollData);
|
||||
}
|
||||
@ -1894,12 +1948,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,
|
||||
callbackAction: callbackAction
|
||||
});
|
||||
callbacks: [{ action: callbackAction }],
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -1908,7 +1962,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 RdDResolutionTable.displayRollData(artData, this.name, `chat-resultat-${artData.art}.html`);
|
||||
await RdDRollResult.displayRollData(artData, this.name, `chat-resultat-${artData.art}.html`);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -1985,7 +2039,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 RdDResolutionTable.displayRollData(cuisine, this.name, `chat-resultat-${cuisine.art}.html`);
|
||||
await RdDRollResult.displayRollData(cuisine, this.name, `chat-resultat-${cuisine.art}.html`);
|
||||
}
|
||||
|
||||
async preparerNourriture(item) {
|
||||
@ -2080,7 +2134,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
await this.createEmbeddedDocuments("Item", [RdDItemSigneDraconique.prepareSigneDraconiqueMeditation(meditationRoll.meditation, meditationRoll.rolled)]);
|
||||
}
|
||||
|
||||
await RdDResolutionTable.displayRollData(meditationRoll, this.name, 'chat-resultat-meditation.html');
|
||||
await RdDRollResult.displayRollData(meditationRoll, this.name, 'chat-resultat-meditation.html');
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -2167,7 +2221,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 RdDResolutionTable.displayRollData(rollData, this.name, 'chat-resultat-lecture-signedraconique.html');
|
||||
await RdDRollResult.displayRollData(rollData, this.name, 'chat-resultat-lecture-signedraconique.html');
|
||||
this.tmrApp.close();
|
||||
}
|
||||
|
||||
@ -2178,13 +2232,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: '' },
|
||||
callbackAction: async r => await this._appelChanceResult(r, onSuccess, onEchec)
|
||||
callbacks: [{ action: r => this.$appelChanceResult(r, onSuccess, onEchec) }]
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _appelChanceResult(rollData, onSuccess, onEchec) {
|
||||
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-appelchance.html')
|
||||
async $appelChanceResult(rollData, onSuccess, onEchec) {
|
||||
await RdDRollResult.displayRollData(rollData, this, 'chat-resultat-appelchance.html')
|
||||
if (rollData.rolled.isSuccess) {
|
||||
await this.setFlag(SYSTEM_RDD, 'utilisationChance', true);
|
||||
await this.chanceActuelleIncDec(-1);
|
||||
@ -2658,7 +2712,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _alchimieResult(rollData) {
|
||||
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-alchimie.html');
|
||||
await RdDRollResult.displayRollData(rollData, this, 'chat-resultat-alchimie.html');
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
Reference in New Issue
Block a user