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);
|
|
|
|
const table = await pack.getEntity(entry._id);
|
2020-12-17 02:20:03 +01:00
|
|
|
const draw = await table.draw({ displayChat: toChat });
|
|
|
|
console.log("RdDRollTables", tableName, toChat, ":", draw);
|
|
|
|
console.log("RdDRollTables", tableName, toChat, ":", draw.roll, draw.results);
|
|
|
|
return draw;
|
2020-11-11 04:31:17 +01:00
|
|
|
}
|
2020-11-12 18:42:41 +01:00
|
|
|
|
2020-12-17 02:20:03 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
static async drawItemFromRollTable(tableName, toChat) {
|
|
|
|
const draw = await RdDRollTables.genericGetTableResult(tableName, toChat);
|
|
|
|
const drawnItemRef = draw.results.length > 0 ? draw.results[0] : undefined;
|
|
|
|
const pack = game.packs.get(drawnItemRef.collection);
|
|
|
|
return await pack.getEntity(drawnItemRef.resultId);
|
|
|
|
}
|
2020-11-11 04:31:17 +01:00
|
|
|
/* -------------------------------------------- */
|
2020-11-14 03:16:03 +01:00
|
|
|
static async getSouffle(toChat = true) {
|
2020-12-17 02:20:03 +01:00
|
|
|
return await RdDRollTables.drawItemFromRollTable("Souffles de Dragon", toChat);
|
2020-11-11 04:31:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
2020-11-12 18:42:41 +01:00
|
|
|
static async getQueue(toChat = true) {
|
2020-12-17 02:20:03 +01:00
|
|
|
return await RdDRollTables.drawItemFromRollTable("Queues de dragon", toChat);
|
2020-11-11 04:31:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
2020-11-12 18:42:41 +01:00
|
|
|
static async getTete(toChat = true) {
|
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
|
|
|
/* -------------------------------------------- */
|
2020-11-12 18:42:41 +01:00
|
|
|
static async getTeteHR(toChat = true) {
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
2020-11-12 18:42:41 +01:00
|
|
|
static async getOmbre(toChat = true) {
|
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-11-12 18:42:41 +01:00
|
|
|
}
|