Version 12.0.24 #724
@ -360,13 +360,14 @@ export class RdDCommands {
|
|||||||
|
|
||||||
async getTMRAleatoire(msg, params) {
|
async getTMRAleatoire(msg, params) {
|
||||||
if (params.length < 2) {
|
if (params.length < 2) {
|
||||||
let type = params[0];
|
let type = params[0]
|
||||||
const tmr = await TMRUtility.getTMRAleatoire(type ? (it => it.type == type) : (it => true));
|
const solvedTerrain = TMRUtility.findTMRLike(type)?.type
|
||||||
return RdDCommands._chatAnswer(msg, `Case aléatoire: ${tmr.coord} - ${tmr.label}`);
|
if (solvedTerrain){
|
||||||
}
|
const tmr = await TMRUtility.getTMRAleatoire(type ? (it => it.type == solvedTerrain) : (it => true))
|
||||||
else {
|
return RdDCommands._chatAnswer(msg, `Case aléatoire: ${tmr.coord} - ${tmr.label}`)
|
||||||
return false;
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async findTMR(msg, params) {
|
async findTMR(msg, params) {
|
||||||
@ -384,11 +385,11 @@ export class RdDCommands {
|
|||||||
async tableRencontres(msg, params) {
|
async tableRencontres(msg, params) {
|
||||||
if (params && params.length > 0) {
|
if (params && params.length > 0) {
|
||||||
const search = Misc.join(params, ' ');
|
const search = Misc.join(params, ' ');
|
||||||
const solvedTerrain = TMRUtility.findTMRLike(search);
|
const solvedTerrain = TMRUtility.findTMRLike(search)
|
||||||
if (solvedTerrain == undefined) {
|
if (solvedTerrain == undefined) {
|
||||||
return RdDCommands._chatAnswer(msg, 'Aucune TMR correspondant à ' + search);
|
return RdDCommands._chatAnswer(msg, 'Aucune TMR correspondant à ' + search);
|
||||||
}
|
}
|
||||||
return await game.system.rdd.rencontresTMR.chatTable(solvedTerrain);
|
return await game.system.rdd.rencontresTMR.chatTable(solvedTMRType.name)
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -284,23 +284,20 @@ export class CompendiumTableHelpers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static async tableRowToChatMessage(row, type = 'Item') {
|
static async tableRowToChatMessage(row, type, options = {showSource: true}) {
|
||||||
if (!row) {
|
if (!row) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const percentages = (row.total == 100) ? '%' : ''
|
|
||||||
const flavorContent = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-compendium-table-roll.hbs', {
|
const flavorContent = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-compendium-table-roll.hbs', {
|
||||||
roll: row.roll,
|
roll: row.roll,
|
||||||
document: row.document,
|
document: row.document,
|
||||||
percentages,
|
|
||||||
typeName: Misc.typeName(type, row.document?.type ?? 'objet'),
|
typeName: Misc.typeName(type, row.document?.type ?? 'objet'),
|
||||||
isGM: game.user.isGM,
|
isGM: game.user.isGM,
|
||||||
|
options
|
||||||
});
|
});
|
||||||
const messageData = {
|
const messageData = {
|
||||||
// flavor: flavorContent,
|
|
||||||
user: game.user.id,
|
user: game.user.id,
|
||||||
type: CONST.CHAT_MESSAGE_TYPES.ROLL,
|
rolls: [row.roll],
|
||||||
roll: row.roll,
|
|
||||||
sound: CONFIG.sounds.dice,
|
sound: CONFIG.sounds.dice,
|
||||||
content: flavorContent
|
content: flavorContent
|
||||||
};
|
};
|
||||||
|
@ -26,22 +26,19 @@ export class TMRRencontres {
|
|||||||
* @param {*} forcedRoll
|
* @param {*} forcedRoll
|
||||||
*/
|
*/
|
||||||
async rollRencontre(terrain, forcedRoll) {
|
async rollRencontre(terrain, forcedRoll) {
|
||||||
terrain = TMRUtility.findTMRLike(terrain);
|
const tmrType = TMRUtility.findTMRLike(terrain)?.type
|
||||||
if (terrain == undefined) {
|
if (tmrType == undefined) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forcedRoll && (forcedRoll <= 0 || forcedRoll > 100)) {
|
if (forcedRoll && (forcedRoll <= 0 || forcedRoll > 100)) {
|
||||||
forcedRoll = undefined;
|
forcedRoll = undefined;
|
||||||
}
|
}
|
||||||
const codeTerrain = Grammar.toLowerCaseNoAccent(terrain)
|
const filtreMauvaise = tmrType == 'mauvaise' ? it => it.system.mauvaiseRencontre : it => !it.system.mauvaiseRencontre;
|
||||||
const filtreMauvaise = codeTerrain == 'mauvaise' ? it => it.system.mauvaiseRencontre : it => !it.system.mauvaiseRencontre;
|
const frequence = it => it.system.frequence[tmrType];
|
||||||
const frequence = it => it.system.frequence[codeTerrain];
|
|
||||||
const row = await this.table.getRandom(frequence, filtreMauvaise, forcedRoll);
|
const row = await this.table.getRandom(frequence, filtreMauvaise, forcedRoll);
|
||||||
if (row) {
|
if (row) {
|
||||||
console.log("DORM", row);
|
await CompendiumTableHelpers.tableRowToChatMessage(row, 'Item', {showSource: false});
|
||||||
//row.document.system.computedForce = new Roll(row.document.system.formula).roll({async: false}).total;
|
|
||||||
await CompendiumTableHelpers.tableRowToChatMessage(row);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return row?.document;
|
return row?.document;
|
||||||
|
@ -284,18 +284,18 @@ export class TMRUtility {
|
|||||||
static findTMRLike(type, options = { inclusMauvaise: true }) {
|
static findTMRLike(type, options = { inclusMauvaise: true }) {
|
||||||
const choix = [...Object.values(TMRType)]
|
const choix = [...Object.values(TMRType)]
|
||||||
if (options.inclusMauvaise) {
|
if (options.inclusMauvaise) {
|
||||||
choix.push({ name: 'Mauvaise' });
|
choix.push({ name: 'Mauvaise', type: 'mauvaise'});
|
||||||
}
|
}
|
||||||
const selection = Misc.findAllLike(type, choix).map(it => it.name);
|
const selection = Misc.findAllLike(type, choix)
|
||||||
if (selection.length == 0) {
|
if (selection.length == 0) {
|
||||||
ui.notifications.warn(`Un type de TMR doit être indiqué, '${type}' n'est pas trouvé dans ${choix}`);
|
ui.notifications.warn(`Un type de TMR doit être indiqué, '${type}' n'est pas trouvé dans ${choix}`);
|
||||||
return undefined;
|
return undefined
|
||||||
}
|
}
|
||||||
if (selection.length > 1) {
|
if (selection.length > 1) {
|
||||||
ui.notifications.warn(`Plusieurs types de TMR pourraient correspondre à '${type}': ${selection}`);
|
ui.notifications.warn(`Plusieurs types de TMR pourraient correspondre à '${type}': ${selection.map(it => it.name)}`);
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
return selection[0];
|
return selection[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
static typeTmrName(type) {
|
static typeTmrName(type) {
|
||||||
@ -320,7 +320,7 @@ export class TMRUtility {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static deplacement(coordOrig, moveName) {
|
static deplacement(coordOrig, moveName) {
|
||||||
const tmrMove = TMR_MOVE[moveName];
|
const tmrMove = TMR_MOVE[moveName];
|
||||||
if (! tmrMove) {
|
if (!tmrMove) {
|
||||||
ui.notifications.error(`Le déplacement dans les TMR '${moveName}' est inconnu`)
|
ui.notifications.error(`Le déplacement dans les TMR '${moveName}' est inconnu`)
|
||||||
return coordOrig
|
return coordOrig
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
<h4>Tirage aléatoire: {{document.name}}</h4>
|
<h4>Tirage aléatoire: {{document.name}}</h4>
|
||||||
<div>Tirage de {{typeName}} aléatoire depuis {{document.pack}}</div>
|
<div>
|
||||||
<div>Jet {{roll.formula}} : {{roll.total}}{{percentages}}</div>
|
Tirage de {{typeName}} aléatoire
|
||||||
|
{{#if options.showSource}} depuis {{document.pack}}{{/if}}
|
||||||
|
</div>
|
||||||
|
<div>Jet {{roll.formula}} : {{roll.total}}</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div>
|
<div>
|
||||||
<img class="chat-icon" src="{{document.img}}" data-tooltip="{{document.name}}" />
|
<img class="chat-icon" src="{{document.img}}" data-tooltip="{{document.name}}" />
|
||||||
|
Loading…
Reference in New Issue
Block a user