Skip to content

Commit

Permalink
update items
Browse files Browse the repository at this point in the history
  • Loading branch information
albertcui committed Jul 19, 2019
1 parent c579f0b commit be1ef5f
Show file tree
Hide file tree
Showing 27 changed files with 2,608 additions and 2,602 deletions.
198 changes: 99 additions & 99 deletions build/underlords_localization_bg.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_cs.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_da.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_de.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_en.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_es-419.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_es.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_fi.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_hu.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_it.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_ja.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_ko.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_nl.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_no.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_pl.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_pt-BR.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_pt.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_ro.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_ru.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_sv.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_th.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_tr.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_uk.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_vn.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_zh-CN.json

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions build/underlords_localization_zh-TW.json

Large diffs are not rendered by default.

62 changes: 34 additions & 28 deletions tasks/updateconstants.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const axios = require('axios');
const fs = require('fs');
const simplevdf = require('simple-vdf');
const STRING_REPLACE_REGEX = /({s:[^}]*})/g;
const STRING_REPLACE_REGEX = /({(s|d):[^}]*})/g;
const STRING_REPLACE_KEY_REGEX = /({s:)|({d:)|(})/g;
const ABILITY_IMAGE_MAPPING = {
"bloodseeker_blood_rage": "bloodseeker_bloodrage",
"clockwerk_battery_assault": "rattletrap_battery_assault",
Expand Down Expand Up @@ -127,6 +128,24 @@ const sources = [
}
];

function replacePlaceholders(str, values) {
const matches = str.match(STRING_REPLACE_REGEX);
if (matches) {
matches.forEach((s) => {
let replace = '';
const key = s.replace(STRING_REPLACE_KEY_REGEX, '');
if (key in values) {
const val = values[key];
replace = Array.isArray(val) ? `[${val.join('/')}]` : val;
}

str = str.replace(s, replace);
})
}

return str;
}

function transformAbilities (resObj) {
const strings = normalize(resObj[0].tokens)
const abilities = resObj[1];
Expand All @@ -135,19 +154,7 @@ function transformAbilities (resObj) {
stringKey = `dac_ability_${key}_description`;
let desc = strings[stringKey];
if (desc) {
const matches = desc.match(STRING_REPLACE_REGEX);
if (matches) {
matches.forEach((s) => {
let replace = '';
const key = s.replace('{s:', '').replace('}', '');
if (key in ability) {
const val = ability[key];
replace = Array.isArray(val) ? `[${val.join('/')}]` : val;
}

desc = desc.replace(s, replace);
})
}
desc = replacePlaceholders(desc, ability);
strings[stringKey] = desc.replace(/<br>/g, '\n');
}
});
Expand All @@ -158,30 +165,28 @@ function transformAbilities (resObj) {
function transformLocalization (resObj) {
const strings = resObj[0];
const synergies = resObj[1];
const items = resObj[2];

Object.entries(synergies).forEach(([key, synergy]) => {
synergy.levels.forEach((l, i) => {
stringKey = `dac_synergy_desc_${key.toLocaleLowerCase()}_${i+1}`;
let desc = strings[stringKey];
if (desc) {
const matches = desc.match(STRING_REPLACE_REGEX);
if (matches) {
matches.forEach((s) => {
let replace = '';
const key = s.replace('{s:', '').replace('}', '');
if (key in synergy) {
const val = synergy[key];
replace = Array.isArray(val) ? val[i] : val;
}

desc = desc.replace(s, replace);
})
}
desc = replacePlaceholders(desc, synergy);
strings[stringKey] = desc.replace(/<br>/g, '\n');
}
})
});

Object.entries(items).forEach(([key, item]) => {
stringKey = `dac_item_${key}_desc`;
let desc = strings[stringKey];
if (desc) {
desc = replacePlaceholders(desc, item);
strings[stringKey] = desc.replace(/<br>/g, '\n');
}
})

return strings;
}

Expand Down Expand Up @@ -233,7 +238,8 @@ async function start()
key: `underlords_localization_${val}`,
url: [
`https://raw.githubusercontent.com/SteamDatabase/GameTracking-Underlords/master/game/dac/panorama/localization/dac_${key}.txt`,
'https://raw.githubusercontent.com/SteamDatabase/GameTracking-Underlords/master/game/dac/pak01_dir/scripts/synergies.json'
'https://raw.githubusercontent.com/SteamDatabase/GameTracking-Underlords/master/game/dac/pak01_dir/scripts/synergies.json',
'https://raw.githubusercontent.com/SteamDatabase/GameTracking-Underlords/master/game/dac/pak01_dir/scripts/items.json'
],
transform: transformLocalization
});
Expand Down

0 comments on commit be1ef5f

Please sign in to comment.