Sync with latest babele + auberge stuff

This commit is contained in:
2020-04-23 21:13:56 +02:00
parent 577ff31d5d
commit 063b5e277e
3 changed files with 45 additions and 24 deletions

View File

@ -146,36 +146,41 @@ class ActorWfrp4e_fr extends ActorWfrp4e {
}
Hooks.on("chatMessage", (html, content, msg) => {
// Setup new message's visibility
let rollMode = game.settings.get("core", "rollMode");
if ( ["gmroll", "blindroll"].includes(rollMode) ) msg["whisper"] = ChatMessage.getWhisperIDs("GM");
if ( rollMode === "blindroll" ) msg["blind"] = true;
msg["type"] = 0;
Hooks.on("chatMessage", async (html, content, msg) => {
// Split input into arguments
let command = content.split(" ").map(function(item) {
return item.trim();
})
// Roll on a table
if (command[0] == "/auberge")
{
var compendium = game.packs.find(p => p.collection === 'world.plats-dauberges');
compendium.getIndex().then(index => {
index.forEach(entity => {
//console.log(entity.name, entity._id);
if (entity.name.toLowerCase().includes(command[1].toLowerCase()) ) {
compendium.getEntity(entity._id).then(table => {
table.draw();
} );
}
} );
});
msg["type"] = 0;
msg["rollMode"] = "gmroll";
var compendium = game.packs.find(p => p.collection === 'WH4-fr-translation.plats-dauberges');
let rollList = [];
await compendium.getIndex().then(index => rollList = index);
//console.log("Got compendium...", rollList.length);
for (var i=0; i< rollList.length; i++) {
var rollTab = rollList[i];
if ( rollTab.name.toLowerCase().includes(command[1].toLowerCase()) ) {
let my_rollTable;
await compendium.getEntity(rollTab._id).then(mytab => my_rollTable = mytab);
var result = my_rollTable.roll();
console.log("RES: ", result[0], result[1] );
msg.content = my_rollTable.name + " : " + result[1].text;
//my_rollTable.draw();
ChatMessage.create(msg);
return false;
}
}
msg["content"] = "Syntaxe : /auberge MOT_CLE, avec MOT_CLE parmi:<br>BoissonsBase, BoissonsFortes, Desserts, PlatsCommuns, PlatsExcellents, PlatsMaritimes, PlatsMédiocres, PlatsQualité, PlatsRivières<br>Des raccourcis sont possibles avec une partie du nom : /auberge Base (correspond à BoissonBase) ou /auberge Mari (correspond à PlatsMaritimes), etc."
ChatMessage.create(msg);
return false;
}
} );
var __mywait = ms => new Promise((r, j)=>setTimeout(r, ms))
Hooks.once('init', () => {
// Replace to manage specific bonuses/char. computations
@ -302,7 +307,7 @@ Hooks.once('init', () => {
0
],
}
if(typeof Babele !== 'undefined') {
Babele.get().register({