Auto-patch careers + tables

This commit is contained in:
sladecraven 2022-10-21 18:24:39 +02:00
parent 8bc52b8712
commit a8e906cdd6
7 changed files with 5075 additions and 3025 deletions

View File

@ -187,6 +187,31 @@ Hooks.once('init', () => {
return skills_list; return skills_list;
}, },
"resultConverter": (results, translated) => {
console.log("rolltable data", results, translated)
if (translated) {
for (let data of results) {
if ( translated[`${data.range[0]}-${data.range[1]}`] ) {
data.text = translated[`${data.range[0]}-${data.range[1]}`]
}
}
return results
}
if ( results[0].documentCollection && results[0].documentCollection == "wfrp4e-core.career-descriptions" ) {
for (let data of results) {
let career = data.text.match(/{(.*)}/)
if (career && career[1]) {
let careerFR = Babele.instance.converters.career_careergroup(career[1])
data.text = data.text.replace(career[1], careerFR)
}
}
}
if ( results[0].documentCollection ) {
return Babele.instance.converters.tableResults(results)
}
return results
},
"npc_details": (details) => { "npc_details": (details) => {
//console.log("DETAILS: ", details); //console.log("DETAILS: ", details);
let newDetails = duplicate(details); let newDetails = duplicate(details);
@ -414,9 +439,11 @@ Hooks.once('init', () => {
if (!newName) newName = value if (!newName) newName = value
return newName return newName
} else { } else {
ui.notifications.error("Impossible de trouver la carrière " + value + ". Elle n'est probablement pas traduite.", { permanent: true }) ui.notifications.error("Impossible de trouver la carrière " + value + ". Elle n'est probablement pas traduite.", { permanent: true })
} }
return value
}, },
"mutations_modifier": (value) => { // This is really UGLYYYY i know, but i started like this and discovered afterward that many strings were not easy to automate... Sorry :) "mutations_modifier": (value) => { // This is really UGLYYYY i know, but i started like this and discovered afterward that many strings were not easy to automate... Sorry :)
//console.log("Parsing mutation :", value); //console.log("Parsing mutation :", value);
value = value.toLowerCase(); value = value.toLowerCase();

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,11 @@
{ {
"label": "Tables (Core)", "label": "Tables (Core)",
"mapping": {
"results": {
"path": "results",
"converter": "resultConverter"
}
},
"entries": [ "entries": [
{ {
"id": "Career - Dwarf", "id": "Career - Dwarf",

View File

@ -8,7 +8,7 @@
} }
], ],
"url": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr", "url": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr",
"version": "6.2.12", "version": "6.2.13",
"esmodules": [ "esmodules": [
"babele-register.js", "babele-register.js",
"addon-register.js", "addon-register.js",
@ -136,11 +136,12 @@
} }
], ],
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr/raw/v10/module.json", "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr/raw/v10/module.json",
"download": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr/archive/foundryvtt-wh4-lang-fr-6.2.12.zip", "download": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr/archive/foundryvtt-wh4-lang-fr-6.2.13.zip",
"id": "wh4-fr-translation", "id": "wh4-fr-translation",
"compatibility": { "compatibility": {
"minimum": "10", "minimum": "10",
"verified": "10.285" "verified": "10",
"maximum": 10
}, },
"relationships": { "relationships": {
"systems": [ "systems": [

2493
tools/careerv10.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2,22 +2,42 @@ package.path = package.path .. ";luajson/?.lua"
local JSON = require"json" local JSON = require"json"
--local enjsonf = "/home/morr/foundry/foundrydata-dev/Data/modules/wfrp4e-dotr/lang/en.json" --local enjsonf = "/home/morr/foundry/foundrydata-dev/Data/modules/wfrp4e-dotr/lang/en.json"
local careerv9 = "../compendium/wfrp4e-core.career-descriptions.json" local careerv10 = "careerv10.json"
local careerv10 = "../compendium/v10_entries.json" local goodC = "../compendium/wfrp4e-core.careers.json"
local fp = io.open(careerv9, "r") local fp = io.open(careerv10, "r")
local c9 = JSON.decode( fp:read("*a") ) local c10 = JSON.decode( fp:read("*a") )
fp:close() fp:close()
local c10 = {} local fp = io.open(goodC, "r")
for k, v in pairs( c9.entries) do local good10 = JSON.decode( fp:read("*a") )
c10[v.id] = { fp:close()
name = v.name,
text = v.description
} for k1, v1 in pairs( good10.entries) do
for k2, v2 in pairs(c10.entries) do
if v1.id == v2.id then
local careerGroup = string.match(v2.description, "{([%w%s]*)}")
local careerFR
for k3, v3 in pairs( good10.entries) do
if v3.id == careerGroup then
careerFR = v3.name
end
end
if ( careerGroup == 'Slayer' ) then
careerFR = "Tueur"
end
if careerGroup and careerFR then
local careerGroupFR = string.gsub(v2.description, careerGroup, careerFR)
v1.description = careerGroupFR
else
print("Error", v2.description)
end
--print("Career group", careerGroupFR, careerGroup)
end
end
end end
local json10 = JSON.encode(c10) local fp = io.open(goodC, "w+")
fp = io.open(careerv10, "w+") fp:write( JSON.encode(good10))
fp:write( json10) fp:close()
fp:close()