Reorder params for ease to read

(options json param at the end)
This commit is contained in:
Vincent Vandemeulebrouck 2021-01-09 19:36:19 +01:00
parent e7b9070cf1
commit b611cc9092
5 changed files with 24 additions and 25 deletions

View File

@ -1388,8 +1388,9 @@ export class RdDActor extends Actor {
value: carac.value,
xp: carac.xp
}
let content = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-carac-xp.html`, xpData);
ChatUtility.createChatMessage({ content: content }, "default", this.name);
ChatUtility.createChatMessage(this.name, "default", {
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-carac-xp.html`, xpData)
});
}
}
}
@ -1413,8 +1414,9 @@ export class RdDActor extends Actor {
archetype: competence.data.niveau_archetype,
archetypeWarning: competence.data.niveau > competence.data.niveau_archetype
}
let content = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-competence-xp.html`, xpData);
ChatUtility.createChatMessage({ content: content }, "default", this.name);
ChatUtility.createChatMessage(this.name, "default", {
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-competence-xp.html`, xpData)
});
}
}
}

View File

@ -3,21 +3,20 @@
* Class providing helper methods to get the list of users, and
*/
export class ChatUtility {
/* -------------------------------------------- */
static removeMyChatMessageContaining(part) {
const toDelete = game.messages.filter(it => it.user._id == game.user._id)
.filter(it => it.data.content.includes(part));
toDelete.forEach(it => it.delete());
}
/* -------------------------------------------- */
static chatWithRollMode(chatOptions, name) {
let rollMode = game.settings.get("core", "rollMode");
ChatUtility.createChatMessage(chatOptions, rollMode, name);
static createChatWithRollMode(name, chatOptions) {
ChatUtility.createChatMessage(name, game.settings.get("core", "rollMode"), chatOptions);
}
/* -------------------------------------------- */
static createChatMessage(chatOptions, rollMode, name) {
static createChatMessage(name, rollMode, chatOptions) {
switch (rollMode) {
case "blindroll": // GM only
if (!game.user.isGM) {

View File

@ -422,9 +422,9 @@ export class RdDCombat {
const arme = rollData.arme;
const avecArme = arme?.data.categorie_parade != 'sans-armes';
const action = (rollData.attackerRoll ? (arme ? "la parade" : "l'esquive") : "l'attaque");
ChatUtility.chatWithRollMode({
ChatUtility.createChatWithRollMode(this.defender.name, {
content: `<strong>Echec total à ${action}!</strong> ` + await RdDRollTables.getMaladresse({ arme: avecArme })
}, this.defender.name)
});
}
/* -------------------------------------------- */
@ -507,9 +507,9 @@ export class RdDCombat {
console.log("RdDCombat._onParadeParticuliere >>>", defenderRoll);
if (!defenderRoll.attackerRoll.isPart) {
// TODO: attaquant doit jouer résistance et peut être désarmé p132
ChatUtility.chatWithRollMode({
ChatUtility.createChatWithRollMode(this.defender.name, {
content: `(à gérer) L'attaquant doit jouer résistance et peut être désarmé (p132)`
}, this.defender.name)
});
}
}
@ -584,10 +584,9 @@ export class RdDCombat {
/* -------------------------------------------- */
_onEsquiveParticuliere(rollData) {
console.log("RdDCombat._onEsquiveParticuliere >>>", rollData);
let chatOptions = {
ChatUtility.createChatWithRollMode(this.defender.name, {
content: "<strong>Vous pouvez esquiver une deuxième esquive!</strong>"
}
ChatUtility.chatWithRollMode(chatOptions, this.defender.name)
});
}
/* -------------------------------------------- */
@ -757,7 +756,6 @@ export class RdDCombat {
/* -------------------------------------------- */
static async displayActorCombatStatus(actor) {
let rollMode = game.settings.get("core", "rollMode");
let rollData = {
alias: actor.name,
etatGeneral: actor.getEtatGeneral(),
@ -773,8 +771,9 @@ export class RdDCombat {
} else if (actor.countBlessuresByName("graves") > 0) {
rollData.isGrave = true;
}
let content = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-turn-summary.html`, rollData);
ChatUtility.createChatMessage({ content: content }, rollMode, actor.name);
ChatUtility.createChatWithRollMode(actor.name, {
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-turn-summary.html`, rollData)
});
}
/* -------------------------------------------- */

View File

@ -192,15 +192,14 @@ export class RdDCommands {
};
await RdDResolutionTable.rollData(rollData);
msg.content = await RdDResolutionTable.buildRollDataHtml(rollData);
ChatUtility.chatWithRollMode(msg, game.user.name);
ChatUtility.createChatWithRollMode(game.user.name, msg);
}
async rollDeDraconique(msg) {
let rollMode = game.settings.get("core", "rollMode");
let ddr = new DeDraconique().evaluate();
await RdDDice.show(ddr, rollMode);
msg.content = `Lancer d'un Dé draconique: ${ddr.total}`;
ChatUtility.createChatMessage(msg, rollMode, game.user.name);
ChatUtility.createChatWithRollMode(game.user.name, msg);
}
}

View File

@ -91,9 +91,9 @@ export class RdDResolutionTable {
/* -------------------------------------------- */
static async displayRollData(rollData, actor = undefined, template = 'chat-resultat-general.html') {
ChatUtility.chatWithRollMode(
{ content: await RdDResolutionTable.buildRollDataHtml(rollData, actor, template) },
actor?.userName ?? game.user.name)
ChatUtility.createChatWithRollMode(actor?.userName ?? game.user.name, {
content: await RdDResolutionTable.buildRollDataHtml(rollData, actor, template)
});
}
/* -------------------------------------------- */