Auto-patch careers + tables
This commit is contained in:
parent
8bc52b8712
commit
a8e906cdd6
@ -187,6 +187,31 @@ Hooks.once('init', () => {
|
||||
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) => {
|
||||
//console.log("DETAILS: ", details);
|
||||
let newDetails = duplicate(details);
|
||||
@ -414,9 +439,11 @@ Hooks.once('init', () => {
|
||||
if (!newName) newName = value
|
||||
return newName
|
||||
} 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 :)
|
||||
//console.log("Parsing mutation :", value);
|
||||
value = value.toLowerCase();
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -1,5 +1,11 @@
|
||||
{
|
||||
"label": "Tables (Core)",
|
||||
"mapping": {
|
||||
"results": {
|
||||
"path": "results",
|
||||
"converter": "resultConverter"
|
||||
}
|
||||
},
|
||||
"entries": [
|
||||
{
|
||||
"id": "Career - Dwarf",
|
||||
|
@ -8,7 +8,7 @@
|
||||
}
|
||||
],
|
||||
"url": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr",
|
||||
"version": "6.2.12",
|
||||
"version": "6.2.13",
|
||||
"esmodules": [
|
||||
"babele-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",
|
||||
"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",
|
||||
"compatibility": {
|
||||
"minimum": "10",
|
||||
"verified": "10.285"
|
||||
"verified": "10",
|
||||
"maximum": 10
|
||||
},
|
||||
"relationships": {
|
||||
"systems": [
|
||||
|
2493
tools/careerv10.json
Normal file
2493
tools/careerv10.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -2,22 +2,42 @@ package.path = package.path .. ";luajson/?.lua"
|
||||
local JSON = require"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 = "../compendium/v10_entries.json"
|
||||
local careerv10 = "careerv10.json"
|
||||
local goodC = "../compendium/wfrp4e-core.careers.json"
|
||||
|
||||
local fp = io.open(careerv9, "r")
|
||||
local c9 = JSON.decode( fp:read("*a") )
|
||||
local fp = io.open(careerv10, "r")
|
||||
local c10 = JSON.decode( fp:read("*a") )
|
||||
fp:close()
|
||||
|
||||
local c10 = {}
|
||||
for k, v in pairs( c9.entries) do
|
||||
c10[v.id] = {
|
||||
name = v.name,
|
||||
text = v.description
|
||||
}
|
||||
local fp = io.open(goodC, "r")
|
||||
local good10 = JSON.decode( fp:read("*a") )
|
||||
fp:close()
|
||||
|
||||
|
||||
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
|
||||
|
||||
local json10 = JSON.encode(c10)
|
||||
fp = io.open(careerv10, "w+")
|
||||
fp:write( json10)
|
||||
fp:close()
|
||||
local fp = io.open(goodC, "w+")
|
||||
fp:write( JSON.encode(good10))
|
||||
fp:close()
|
Loading…
Reference in New Issue
Block a user