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,7 +4,7 @@ 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.";
@ -34,31 +34,30 @@ const _patch_eis = () => {
/* Manages /auberge command */
const _manage_inn_roll = async (content, msg) => {
// Split input into arguments
let command = content.split(" ").map(function(item) {
let command = content.split(" ").map(function (item) {
return item.trim();
})
console.log("COMMANDES", command);
if (command[0] == "/auberge" && command[1] )
{
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++) {
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()) ) {
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"} );
my_rollTable.draw({ rollMode: "gmroll" });
return false;
}
}
}
if ( content.includes("/auberge") ) {
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."
@ -68,39 +67,42 @@ const _manage_inn_roll = async (content, msg) => {
}
/************************************************************************************/
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,
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,
}
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,13 +112,13 @@ 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 ) {
for (let entryData of translEntries) {
let mydata = duplicate(entryData.data);
mydata.content = mydata.content.replace(/wfrp4e-content/g, compmod );
entryData.update( mydata );
mydata.content = mydata.content.replace(/wfrp4e-content/g, compmod);
entryData.update(mydata);
}
compData.locked = true;
}
@ -137,14 +139,14 @@ 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;
@ -156,48 +158,51 @@ const patch_core_tables = (tableList) => {
/************************************************************************************/
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" +
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>",
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") } );
whisper: ChatMessage.getWhisperRecipients("GM")
});
}
}
@ -207,23 +212,19 @@ const convertColumnToMulti = (table) => {
let newTable = duplicate(table)
delete newTable.columns;
newTable.rows = table.rows.map(i => {return {range : {}}})
newTable.rows = table.rows.map(i => { return { range: {} } })
newTable.multi = table.columns
for(let column of columns)
{
for (let row of newTable.rows)
{
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}
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]
}
}
@ -231,12 +232,32 @@ const convertColumnToMulti = (table) => {
}
/************************************************************************************/
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,
@ -264,7 +285,7 @@ const __add_actors_translation = ( ) => {
//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",
@ -287,11 +308,11 @@ const __add_actors_translation = ( ) => {
/* 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 */
@ -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 => {
@ -364,4 +387,4 @@ Hooks.once('ready', () => {
__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;
}