foundryvtt-wh4-lang-fr-fr/addon-register.js

196 lines
10 KiB
JavaScript

/************************************************************************************/
const _patch_eis = () => {
WFRP4E.symptoms["delirium"] = "Délire"
WFRP4E.symptomDescriptions["delirium"] = "Your sensibility comes and goes, with moments of clarity replaced suddenly by bouts of raving, hallucinations, and terror. Make a <b>Challenging (+0) Willpower Test</b> each hour, and consult the <b><a class='table-click' data-table='delirium'>Delirium</a></b> table."
// '<br>' creates a new line
// This is how you can roll from chat cards. Wrap 'd10' in <b><a class = 'chat-roll'>___</a></b>
WFRP4E.symptomTreatment["delirium"] = "Some authorities treat delirium as part of a fever, prescribing the same measures. Remedies cost from a few pennies to a few shillings, and 10% are genuine.<br><br>With the correct medicin e, a successful <b>Challenging (+0) Heal</b> Test banishes the hallucinations for <b><a class = 'chat-roll'>1d10</a></b> hours.<br><br>It is also common to sedate delirious patients with a tranquillising drug, such as Moonflower or even Nightshade, to keep the patient comfortable until the condition has passed, sending them into a Fitful Sleep until they either recover or die."
WFRP4E.symptoms["swelling"] = "Swelling"
WFRP4E.symptomDescriptions["swelling"] = "A part of the body swells up to several times its normal size, turning an angry red or purple colour and becoming almost unusable. The affected body part is normally the location of a wound or bite causing the Swelling, or the point of contact where a disease or infection entered the body.<br><br><b>Head</b>: The eyes and tongue bulge, the cheeks become livid, the jaw is forced open. Eating is impossible, but clear liquids maybe sipped in small quantities. Any Tests requiring speech are 3 steps more Difficult.<br><b>Arm</b>:The arm and hand swell, the shoulder and elbow joints cannot move, and the hand becomes useless. For the duration, the arm counts as Amputated (WFRP, page 180).<br><b>Body</b>: The entire body swells until the sufferer can no longer wear clothes. All Tests involving movement become 3 steps more Difficult.<br><b>Leg</b>: The leg swells grotesquely, becoming as wide as the widest part of the thigh for its entire length. The foot is almost indistingushable. For the duration, the leg counts as Amputated (WFRP, page 180)."
WFRP4E.symptomTreatment["swelling"] = "Most treatments involve plunging the affected part, or sometimes the whole body, into an ice-water bath to reduce the heat that accompanies the swellings. An Extended <b>Hard (-20) Heal Test</b> requiring +3 SL reduces the swelling by <b><a class = 'chat-roll'>2d10</a></b> hours. Each Test takes an hour. The patient is left with +1 Fatigued Condition for every Test made in the process.<br><br>Some physicians instead bleed the patient with a blade or leeches. A successful <b>Extended Heal Test</b> requiring +4 SL and Trade Tools (Physician) reduces the swelling by (<a class = 'chat-roll'>1d10</a> + the patient's Toughness Bonus) hours. Each Test has a base Difficulty of <b>Impossible (-50)</b> and takes half an hour."
WFRP4E.difficultyModifiers["futile"] = -40
WFRP4E.difficultyModifiers["impossible"] = -50
WFRP4E.difficultyLabels["futile"] = "Futile (-40)"
WFRP4E.difficultyLabels["impossible"] = "Impossible (-50)"
WFRP4E.loreEffect["tzeentch"] = "Les cibles des sorts de Tzeentch sont déchirées par la magie transformatrice du Chaos. Les cibles affectées par un sort du savoir de Tzeentch doivent réussir un test d'endurance Intermédiaire (+0) ou gagner +1 Point de Corruption. S'ils réussissent leur test, ils gagnent à la place +1 Point de Chance, qui peut être utilisé normalement. Tels sont les caprices de Tzeentch"
}
/************************************************************************************/
/* Manages /auberge command */
const _manage_inn_roll = async (content, msg) => {
// Split input into arguments
let command = content.split(" ").map(function(item) {
return item.trim();
})
if (command[0] == "/auberge" && command[1] )
{
msg["type"] = 0;
msg["rollMode"] = "gmroll";
var compendium = game.packs.get('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);
let myroll = my_rollTable.roll();
//console.log("RES: ", myroll );
msg.content = my_rollTable.name + " : " + myroll.results[0].text;
//my_rollTable.draw();
ChatMessage.create(msg);
return false;
}
}
}
if ( content.includes("/auberge") ) {
msg["type"] = 0;
msg["rollMode"] = "gmroll";
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;
}
}
/************************************************************************************/
const setup_wfrp4e_tables = () => {
}
/************************************************************************************/
let __eis_tables = { "animalmishap":1, "beasthead":1, "coincedentalenc":1, "demonic-mien":1,
"expandedmutatemental":1, "expandedmutatephys":1, "fixations":1,
"harmfulenc":1, "positiveenc":1, "weather":1, "mutatephys": 1
}
/************************************************************************************/
const __check_fix_wrong_modules = () => {
game.modules.forEach((module, name) => {
if ( name == "eis" && module.active) {
FilePicker.browse("data", "modules/WH4-fr-translation/tables/").then(resp => {
for (var file of resp.files) {
let filename = file.substring(file.lastIndexOf("/")+1, file.indexOf(".json"));
if ( __eis_tables[filename] == 1 ) { // Matching table name -> patch !
fetch(file).then(r=>r.json()).then(records => {
WFRP_Tables[filename] = records;
});
}
}
});
ChatMessage.create( { title: "Module EiS patché", content: "<strong>Le module EiS a été detecté et automatiquement patché.</strong>", whisper: ChatMessage.getWhisperRecipients("GM") } );
}
if ( name == "wfrp4e-rnhd" && module.active ) {
WFRP_Tables.career.name = "Carrières aléatoires";
FilePicker.browse("data", "modules/WH4-fr-translation/tables/").then(resp => {
for (var file of resp.files) {
if ( file.match("career.json") ) {
fetch(file).then(r=>r.json()).then(records => {
let mycareer = records;
for (let k=0; k<WFRP_Tables.career.rows.length; k++) {
WFRP_Tables.career.rows[k].name = mycareer.rows[k].name; // Patch !!!
}
});
}
}
});
WFRP4E.speciesSkills["gnome"] = [
"Focalisation (Ulgu)",
"Charme",
"Résistance à l'alcool",
"Esquive",
"Divertissement (Au choix)",
"Ragots",
"Marchandage",
"Langue (Ghassally)",
"Langue (Magick)",
"Langue (Wastelander)",
"Survie en extérieur",
"Discrétion (Au choix)"
];
WFRP4E.speciesTalents["gnome"] = [
"Insignifiant, Imprégné avec Uglu",
"Chance, Imitation",
"Vision Nocturne",
"Pêcheur, Lire/Ecrire",
"Seconde Vue, Sixième Sens",
"Petit",
0
];
ChatMessage.create( { title: "Module RNHD patché", content: "<strong>Le module RHND a été detecté et automatiquement patché.</strong>", whisper: ChatMessage.getWhisperRecipients("GM") } );
}
if ( name == "wfrp4e-ew" && module.active ) {
ChatMessage.create( { title: "Module non compatible detecté !", content: "<strong>Vous avez le module EW (wfrp4e-ew ?) installé. Malheureusement, ce module n'est pas compatible avec" +
" les traductions et vient casser le fonctionnement de la traduction. Veuillez recopier les compendiums dans votre monde, désactiver le module et re-démarrer le monde</strong>",
whisper: ChatMessage.getWhisperRecipients("GM")
} );
}
});
}
/************************************************************************************/
/* Hook for specific command */
Hooks.on("chatMessage", (html, content, msg) => {
if ( content.includes("/auberge") ) {
_manage_inn_roll( content, msg );
return false;
}
} );
/************************************************************************************/
/* Additionnal hooks ready */
Hooks.once('ready', () => {
_patch_eis();
setup_wfrp4e_tables();
setTimeout( __check_fix_wrong_modules, 3000);
const lang = game.settings.get('core', 'language');
if ( lang == "fr" ) {
let pack_array = [];
game.packs.forEach((pack, name) => {
let newpack = pack;
if(!pack.translated && pack.entity === 'Actor') {
let translations = {
"label": pack.metadata.name,
"mapping": {
"name": "name",
"description": "details.biography.value",
"items": {
"path": "items",
"converter": "bestiary_traits"
},
"characteristics": {
"path": "data.characteristics",
"converter": "npc_characteristics"
}
},
"entries": [
]
};
newpack = new TranslatedCompendium(pack, translations);
console.log("Actor compendium has been replaced !!!!", newpack);
}
pack_array.push( [name, newpack ] );
} );
game.packs = new Collection( pack_array );
}
} );