2020-11-11 04:31:17 +01:00
|
|
|
export class RdDRollTables {
|
2020-11-12 18:42:41 +01:00
|
|
|
|
2020-11-11 04:31:17 +01:00
|
|
|
/* -------------------------------------------- */
|
2020-11-12 18:42:41 +01:00
|
|
|
static async genericGetTableResult(tableName, toChat) {
|
|
|
|
const pack = game.packs.get("foundryvtt-reve-de-dragon.tables-diverses");
|
|
|
|
const index = await pack.getIndex();
|
|
|
|
const entry = index.find(e => e.name === tableName);
|
2021-03-25 03:18:27 +01:00
|
|
|
const table = await pack.getDocument(entry._id);
|
2021-02-04 01:21:29 +01:00
|
|
|
const draw = await table.draw({ displayChat: toChat, rollMode: "gmroll"});
|
2020-12-17 02:20:03 +01:00
|
|
|
console.log("RdDRollTables", tableName, toChat, ":", draw);
|
2021-05-11 21:21:33 +02:00
|
|
|
return draw.results.length > 0 ? draw.results[0] : undefined;
|
2020-11-11 04:31:17 +01:00
|
|
|
}
|
2020-11-12 18:42:41 +01:00
|
|
|
|
2020-12-17 02:20:03 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-05-11 21:21:33 +02:00
|
|
|
static async drawItemFromRollTable(tableName, toChat = false) {
|
|
|
|
const drawResult = await RdDRollTables.genericGetTableResult(tableName, toChat);
|
|
|
|
const pack = game.packs.get(drawResult.data.collection);
|
|
|
|
return await pack.getDocument(drawResult.data.resultId);
|
2020-12-17 02:20:03 +01:00
|
|
|
}
|
2020-12-17 12:29:54 +01:00
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
static async drawTextFromRollTable(tableName, toChat) {
|
2021-05-11 21:21:33 +02:00
|
|
|
const drawResult = await RdDRollTables.genericGetTableResult(tableName, toChat);
|
|
|
|
return drawResult.data.text;
|
2020-12-17 12:29:54 +01:00
|
|
|
}
|
|
|
|
|
2021-02-11 02:48:27 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
static async getCompetence(toChat = false) {
|
|
|
|
return await RdDRollTables.drawItemFromRollTable("Détermination aléatoire de compétence", toChat);
|
|
|
|
}
|
|
|
|
|
2020-11-11 04:31:17 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-02-05 01:10:54 +01:00
|
|
|
static async getSouffle(toChat = false) {
|
2020-12-17 02:20:03 +01:00
|
|
|
return await RdDRollTables.drawItemFromRollTable("Souffles de Dragon", toChat);
|
2020-11-11 04:31:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
2021-02-05 01:10:54 +01:00
|
|
|
static async getQueue(toChat = false) {
|
2021-02-06 23:58:15 +01:00
|
|
|
let queue = await RdDRollTables.drawItemFromRollTable("Queues de dragon", toChat);
|
2020-12-17 23:06:08 +01:00
|
|
|
if (queue.name.toLowerCase().includes('lancinant') ) {
|
2021-02-28 01:40:32 +01:00
|
|
|
return await RdDRollTables.getDesirLancinant(toChat);
|
2020-12-17 23:06:08 +01:00
|
|
|
}
|
|
|
|
if (queue.name.toLowerCase().includes('fixe') ) {
|
2021-02-28 01:40:32 +01:00
|
|
|
return await RdDRollTables.getIdeeFixe(toChat);
|
2020-12-17 23:06:08 +01:00
|
|
|
}
|
|
|
|
return queue;
|
2020-11-11 04:31:17 +01:00
|
|
|
}
|
|
|
|
|
2021-02-28 01:40:32 +01:00
|
|
|
static async getDesirLancinant(toChat = false) {
|
|
|
|
return await RdDRollTables.drawItemFromRollTable("Désirs lancinants", toChat);
|
|
|
|
}
|
|
|
|
|
|
|
|
static async getIdeeFixe(toChat = false) {
|
|
|
|
return await RdDRollTables.drawItemFromRollTable("Idées fixes", toChat);
|
|
|
|
}
|
|
|
|
|
2020-11-11 04:31:17 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-02-26 01:15:08 +01:00
|
|
|
static async getTeteHR(toChat = false) {
|
2020-12-17 02:20:03 +01:00
|
|
|
return await RdDRollTables.drawItemFromRollTable("Têtes de Dragon pour haut-rêvants", toChat);
|
2020-11-11 04:31:17 +01:00
|
|
|
}
|
2020-11-12 18:42:41 +01:00
|
|
|
|
2020-11-11 04:31:17 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-02-26 01:15:08 +01:00
|
|
|
static async getTete(toChat = false) {
|
2020-12-17 02:20:03 +01:00
|
|
|
return await RdDRollTables.drawItemFromRollTable("Têtes de Dragon pour tous personnages", toChat);
|
2020-11-11 04:31:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
2021-02-05 01:10:54 +01:00
|
|
|
static async getOmbre(toChat = false) {
|
2020-12-17 02:20:03 +01:00
|
|
|
return await RdDRollTables.drawItemFromRollTable("Ombre de Thanatos", toChat);
|
2020-11-11 04:31:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
2020-11-12 18:42:41 +01:00
|
|
|
static async getTarot(toChat = true) {
|
2020-12-17 02:20:03 +01:00
|
|
|
return await RdDRollTables.drawItemFromRollTable("Tarot Draconique", toChat);
|
2020-11-11 04:31:17 +01:00
|
|
|
}
|
2020-12-17 12:29:54 +01:00
|
|
|
|
2020-12-17 23:07:04 +01:00
|
|
|
/* -------------------------------------------- */
|
2020-12-17 12:29:54 +01:00
|
|
|
static async getMaladresse(options = {toChat: false, arme: false}) {
|
|
|
|
return await RdDRollTables.drawTextFromRollTable(
|
|
|
|
options.arme ? "Maladresse armé" : "Maladresses non armé",
|
|
|
|
options.toChat);
|
|
|
|
}
|
2020-11-12 18:42:41 +01:00
|
|
|
}
|