Fix career + minor glitches

This commit is contained in:
sladecraven 2022-03-30 13:38:01 +02:00
parent f65110f2a8
commit f6f8f71001
4 changed files with 499 additions and 474 deletions

View File

@ -4,12 +4,12 @@ import { WH4FRPatchConfig } from "./modules/config-patch.js";
/************************************************************************************/
const _patch_eis = () => {
if ( WFRP4E && WFRP4E.symptoms && WFRP4E.symptoms["delirium"] == undefined ) {
if (WFRP4E && WFRP4E.symptoms && WFRP4E.symptoms["delirium"] == undefined) {
WFRP4E.symptoms["delirium"] = "Délire";
WFRP4E.symptomDescriptions["delirium"] = "Votre sensibilité va et vient, avec des moments de clarté remplaçés subitement Your sensibility comes and goes, with moments of clarity replaced suddenly par des accès de délire, des hallucinations et de la terreur. Faites un <b>Test de Force Mentale Intermédiaire (+0)</b> chaque heure, et consultez la table <b><a class='table-click' data-table='delirium'>Délires</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>
// '<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"] = "Certaines autorités traitent le délire comme un fièvre, avec les mêmes prescriptions. Les médicaments coutent quelques sous à quelques pistoles, en seulement 10% sont efficaces.<br><br>Avec des soins corrects, un test de <b>Guérison Intermédiaire (0)</b> arrêtes les hallucinations pour <b><a class = 'chat-roll'>1d10</a></b> heures.<br><br>Il est aussi courant de soigner les patients délirants avec des drogues tranquillisantes, comme la Fleur de Lune ou même de la Racine de Mandragore, pour garder les patients calmes pendant la crise, les envoyant dans un sommeil agité jusqu'à ce qu'il erécupèrent ou meurent.";
WFRP4E.symptoms["swelling"] = "Gonflement";
@ -25,7 +25,7 @@ const _patch_eis = () => {
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";
}
}
@ -33,74 +33,76 @@ const _patch_eis = () => {
/************************************************************************************/
/* Manages /auberge command */
const _manage_inn_roll = async (content, msg) => {
// Split input into arguments
let command = content.split(" ").map(function(item) {
return item.trim();
})
console.log("COMMANDES", command);
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);
rollList = rollList.contents;
for (var i=0; i< rollList.length; i++) {
var rollTab = rollList[i];
console.log("Got compendium...", rollList, rollTab.name);
if ( rollTab.name.toLowerCase().includes(command[1].toLowerCase()) ) {
let my_rollTable;
await compendium.getDocument(rollTab._id).then(mytab => my_rollTable = mytab);
my_rollTable.draw( { rollMode : "gmroll"} );
return false;
}
// Split input into arguments
let command = content.split(" ").map(function (item) {
return item.trim();
})
console.log("COMMANDES", command);
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);
rollList = rollList.contents;
for (var i = 0; i < rollList.length; i++) {
var rollTab = rollList[i];
console.log("Got compendium...", rollList, rollTab.name);
if (rollTab.name.toLowerCase().includes(command[1].toLowerCase())) {
let my_rollTable;
await compendium.getDocument(rollTab._id).then(mytab => my_rollTable = mytab);
my_rollTable.draw({ rollMode: "gmroll" });
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;
}
}
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;
}
}
/************************************************************************************/
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,
"vehiclemishap": 1,"quadruped": 1, "ridingmishap": 1, "weather": 1,
"delirium": 1
}
let __dotr_tables = { "rowingboat":1, "sailingboat":1, "wind-direction": 1, "waterborne": 1, "traderumour": 1
}
let __wfrp4e_tables = { "career": 1, "critbody":1, "critleg": 1, "doom": 1, "doom2": 1, "eyes": 1, "majormis": 1, "mutatemental": 1, "oops": 1, "species":1, "travel": 1,
"hitloc": 1, "critarm": 1, "crithead": 1, "delirium": 1, "event": 1, "hair": 1, "minormis": 1, "mutatephys": 1, "talents": 1, "wrath": 1,
"astral": 1, "corruption": 1, "snake": 1, "spider": 1, "job": 1
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,
"vehiclemishap": 1, "quadruped": 1, "ridingmishap": 1, "weather": 1,
"delirium": 1
}
let __dotr_tables = {
"rowingboat": 1, "sailingboat": 1, "wind-direction": 1, "waterborne": 1, "traderumour": 1
}
let __wfrp4e_tables = {
"career": 1, "critbody": 1, "critleg": 1, "doom": 1, "doom2": 1, "eyes": 1, "majormis": 1, "mutatemental": 1, "oops": 1, "species": 1, "travel": 1,
"hitloc": 1, "critarm": 1, "crithead": 1, "delirium": 1, "event": 1, "hair": 1, "minormis": 1, "mutatephys": 1, "talents": 1, "wrath": 1,
"astral": 1, "corruption": 1, "snake": 1, "spider": 1, "job": 1
}
let __to_table_translate = [ { name:"traits", transl:"Traits"}, {name:"talents", transl:"Talents"}, {name:"skills", transl:"Compétences"} ,
{ name:"careers", transl:"Carrières"}, {name:"spells", transl:"Sorts"}, {name:"prayers", transl:"Bénédictions et Miracles" } ,
{ name:"injuries", transl:"Blessures"}, {name:"criticals", transl:"Critiques"}, {name:"trappings", transl:"Equipement" },
{ name:"bestiary", transl:"Bestiaire"}, { name:"diseases", transl:"Maladies"}
]
}
let __to_table_translate = [{ name: "traits", transl: "Traits" }, { name: "talents", transl: "Talents" }, { name: "skills", transl: "Compétences" },
{ name: "careers", transl: "Carrières" }, { name: "spells", transl: "Sorts" }, { name: "prayers", transl: "Bénédictions et Miracles" },
{ name: "injuries", transl: "Blessures" }, { name: "criticals", transl: "Critiques" }, { name: "trappings", transl: "Equipement" },
{ name: "bestiary", transl: "Bestiaire" }, { name: "diseases", transl: "Maladies" }
]
/************************************************************************************/
const __create_translation_tables = async (compmod) => {
for (let iterData of __to_table_translate) {
let entityName = compmod+'.' + iterData.name;
let compData = game.packs.get( entityName);
let entityName = compmod + '.' + iterData.name;
let compData = game.packs.get(entityName);
let compFull = await compData.getContent();
let htmlTab = "<table border='1'><tbody>";
for (let entryData of compFull ) {
htmlTab += "<tr><td>"+ entryData.data.originalName + "</td><td>@Compendium["+ entityName + '.' + entryData.id + "]{"+ entryData.name +"}</td></tr>\n";
};
for (let entryData of compFull) {
htmlTab += "<tr><td>" + entryData.data.originalName + "</td><td>@Compendium[" + entityName + '.' + entryData.id + "]{" + entryData.name + "}</td></tr>\n";
};
htmlTab += "</table>";
let myjournal = await JournalEntry.create( {name: 'Traduction des ' + iterData.transl, content: htmlTab } );
game.journal.insert( myjournal );
let myjournal = await JournalEntry.create({ name: 'Traduction des ' + iterData.transl, content: htmlTab });
game.journal.insert(myjournal);
}
}
@ -110,20 +112,20 @@ const __create_translation_tables = async (compmod) => {
* */
const __auto_patch_translation_journal_compendium = async (compmod) => {
if (game.user.isGM) {
let compData = game.packs.get( "WH4-fr-translation.tables-des-traductions" );
let compData = game.packs.get("WH4-fr-translation.tables-des-traductions");
compData.locked = false;
let translEntries = await compData.getContent();
for (let entryData of translEntries ) {
let mydata = duplicate(entryData.data);
mydata.content = mydata.content.replace(/wfrp4e-content/g, compmod );
entryData.update( mydata );
for (let entryData of translEntries) {
let mydata = duplicate(entryData.data);
mydata.content = mydata.content.replace(/wfrp4e-content/g, compmod);
entryData.update(mydata);
}
compData.locked = true;
}
}
/************************************************************************************/
const loadCompendiumData = async (compendium) => {
const loadCompendiumData = async (compendium) => {
const pack = game.packs.get(compendium);
return await pack?.getDocuments() ?? [];
}
@ -137,134 +139,153 @@ const loadCompendium = async (compendium, filter = item => true) => {
/************************************************************************************/
const patch_core_tables = (tableList) => {
if ( game.version) { // v9 and above
if (game.version) { // v9 and above
return;
}
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 ( tableList[filename] == 1 ) { // Matching table name -> patch !
fetch(file).then(r=>r.json()).then(records => {
let filename = file.substring(file.lastIndexOf("/") + 1, file.indexOf(".json"))
if (tableList[filename] == 1) { // Matching table name -> patch !
fetch(file).then(r => r.json()).then(records => {
//console.log("Patch !!!", filename, records);
//WFRP_Tables[filename] = records;
game.wfrp4e.tables[filename] = records;
});
}
});
}
}
});
}
/************************************************************************************/
const patch_trade_gazeteer = () => {
if ( game.wfrp4e.config.trade?.gazetteer) {
fetch( "modules/WH4-fr-translation/tables/gazetteer.json").then( r => r.json()).then(records => {
if (game.wfrp4e.config.trade?.gazetteer) {
fetch("modules/WH4-fr-translation/tables/gazetteer.json").then(r => r.json()).then(records => {
game.wfrp4e.config.trade.gazetteer = records;
}) ;
});
}
}
/************************************************************************************/
const __check_fix_wrong_modules = ( chatFlag, patchFinished ) => {
const __check_fix_wrong_modules = (chatFlag, patchFinished) => {
WH4FRPatchConfig.perform_patch();
game.modules.forEach((module, name) => {
if ( name == "wfrp4e-core" && module.active) {
patch_core_tables( __wfrp4e_tables );
if (name == "wfrp4e-core" && module.active) {
patch_core_tables(__wfrp4e_tables);
}
if ( name == "wfrp4e-eis" && module.active) {
patch_core_tables( __eis_tables );
if (name == "wfrp4e-eis" && module.active) {
patch_core_tables(__eis_tables);
}
if ( name == "wfrp4e-dotr" && module.active) {
patch_core_tables( __dotr_tables );
if (name == "wfrp4e-dotr" && module.active) {
patch_core_tables(__dotr_tables);
patch_trade_gazeteer()
}
if ( name == 'ogre-kingdom-wfrp4e' && module.active) {
if (name == 'ogre-kingdom-wfrp4e' && module.active) {
WH4FRPatchConfig.perform_ogrekingdom_patch();
if (game.user.isGM && chatFlag)
ChatMessage.create( { content: "<div><strong>Le module Ogre-Kingdom a été detecté et automatiquement patché.</strong></div>", whisper: ChatMessage.getWhisperRecipients("GM") } );
ChatMessage.create({ content: "<div><strong>Le module Ogre-Kingdom a été detecté et automatiquement patché.</strong></div>", whisper: ChatMessage.getWhisperRecipients("GM") });
}
if ( name == "wfrp4e-ew" && module.active && game.user.isGM && chatFlag) {
ChatMessage.create( { content: "<div><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></div>",
if (name == "wfrp4e-ew" && module.active && game.user.isGM && chatFlag) {
ChatMessage.create({
content: "<div><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></div>",
whisper: ChatMessage.getWhisperRecipients("GM")
} );
});
}
});
if (game.user.isGM && patchFinished) {
ChatMessage.create( { content: "<div>Les modules WFRP4E ont été <strong>patchés avec succés</strong>. Vous pouvez y aller et que <strong>Shallya vous garde !</strong></div>",
user: game.user.id,
whisper: ChatMessage.getWhisperRecipients("GM") } );
ChatMessage.create({
content: "<div>Les modules WFRP4E ont été <strong>patchés avec succés</strong>. Vous pouvez y aller et que <strong>Shallya vous garde !</strong></div>",
user: game.user.id,
whisper: ChatMessage.getWhisperRecipients("GM")
});
}
}
/************************************************************************************/
const convertColumnToMulti = (table) => {
let columns = table.columns;
let newTable = duplicate(table)
let columns = table.columns;
let newTable = duplicate(table)
delete newTable.columns;
newTable.rows = table.rows.map(i => {return {range : {}}})
newTable.multi = table.columns
delete newTable.columns;
newTable.rows = table.rows.map(i => { return { range: {} } })
newTable.multi = table.columns
for(let column of columns)
{
for (let row of newTable.rows)
{
row[column] = {}
row.range[column] = []
}
for (let column of columns) {
for (let row of newTable.rows) {
row[column] = {}
row.range[column] = []
}
}
for(let index in newTable.rows)
{
for (let column in table.rows[index].range)
{
newTable.rows[index][column] = {name : table.rows[index].name}
newTable.rows[index].range[column] = table.rows[index].range[column]
}
for (let index in newTable.rows) {
for (let column in table.rows[index].range) {
newTable.rows[index][column] = { name: table.rows[index].name }
newTable.rows[index].range[column] = table.rows[index].range[column]
}
return newTable;
}
return newTable;
}
/************************************************************************************/
const __add_actors_translation = ( ) => {
const __patchStyleSheet = () => {
for( let styleSheet of document.styleSheets) {
if (styleSheet.href && styleSheet.href.includes("wfrp4e.css") ) {
let found = 0
for (let i=0; i<styleSheet.cssRules.length; i++) {
let rule = styleSheet.cssRules[i]
if (rule.selectorText == '.sidebar-popout') {
console.log("DELETE RULE", rule)
found = i
/*rule.cssText = ".sidebar-popout { }"
rule.style.width = ""
console.log("Found rul2", rule)*/
}
}
styleSheet.deleteRule(found)
}
}
}
/************************************************************************************/
const __add_actors_translation = () => {
const lang = game.settings.get('core', 'language');
if ( lang == "fr" ) {
if (lang == "fr") {
let pack_array = [];
for ( let metadata of game.data.packs ) {
if(!game.babele.isTranslated(metadata) && metadata.documentName === 'Actor') {
for (let metadata of game.data.packs) {
if (!game.babele.isTranslated(metadata) && metadata.documentName === 'Actor') {
//console.log("PACK : ", metadata);
let translations = {
"label": metadata.name,
"mapping": {
"name": "name",
"description": "details.biography.value",
"items": {
"path": "items",
"converter": "bestiary_traits"
},
"characteristics": {
"path": "data.characteristics",
"converter": "npc_characteristics"
},
"details": {
"path": "data.details",
"converter": "npc_details"
}
},
"entries": [
]
};
"label": metadata.name,
"mapping": {
"name": "name",
"description": "details.biography.value",
"items": {
"path": "items",
"converter": "bestiary_traits"
},
"characteristics": {
"path": "data.characteristics",
"converter": "npc_characteristics"
},
"details": {
"path": "data.details",
"converter": "npc_details"
}
},
"entries": [
]
};
game.babele.packs.set(collection, new TranslatedCompendium(metadata, translation));
//newpack = new TranslatedCompendium(pack, translations);
//console.log("Actor compendium has been replaced !!!!", pack.metadata.name);
}
//console.log("Parsing pack", metadata);
if (!game.babele.isTranslated(metadata) && metadata.name == "forien-armoury" ) {
if (!game.babele.isTranslated(metadata) && metadata.name == "forien-armoury") {
/** TODO !!!/
metadata.mapping.mapping["qualities"] = {
"path": "data.qualities.value",
@ -279,24 +300,24 @@ const __add_actors_translation = ( ) => {
}
//pack_array.push( [name, newpack ] );
}
}
}
}
/************************************************************************************/
/* Hook for specific command */
Hooks.on("chatMessage", (html, content, msg) => {
if ( content.toLowerCase().includes('auberge') ) {
_manage_inn_roll( content, msg );
if (content.toLowerCase().includes('auberge')) {
_manage_inn_roll(content, msg);
return false;
}
} );
}
});
/************************************************************************************/
/* Additionnal hooks ready */
Hooks.once('ready', () => {
if (game.user.isGM) {
let chatData = {
user: game.user.id,
@ -306,7 +327,7 @@ Hooks.once('ready', () => {
}
ChatMessage.create(chatData);
}
/** New modifiers */
game.wfrp4e.config.difficultyModifiers = {
"veasy": 60,
@ -335,8 +356,10 @@ Hooks.once('ready', () => {
}
//setTimeout( __check_fix_wrong_modules, 2000, true, false);
setTimeout( __check_fix_wrong_modules, 20000, true, true);
setTimeout( __add_actors_translation, 21000, false, true);
setTimeout(__check_fix_wrong_modules, 20000, true, true);
setTimeout(__add_actors_translation, 21000, false, true);
//__patchStyleSheet()
/* ATTEMPT !!
loadCompendium("wfrp4e-core.spells").then( comp => {
@ -363,5 +386,5 @@ Hooks.once('ready', () => {
Auto-create translation journal tables
__create_translation_tables(compmod);
*/
} );
});

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,7 @@
"authors": [ {"name":"LeRatierBretonnien" }],
"url": "https://gitlab.com/LeRatierBretonnien/foundryvtt-wh4-lang-fr-fr",
"flags": {},
"version": "5.2.1",
"version": "5.2.2",
"minimumCoreVersion": "0.8.0",
"compatibleCoreVersion": "9",
"scripts": [],

View File

@ -1,3 +1,5 @@
/** To deal with wrong menu background */
:root{
--color-bg-option: #352516;
}
}