GenerateDatabaseEntries() function

This commit is contained in:
ReznoRMichael 2022-01-18 15:04:34 +01:00
commit 7f391c08d1
3 changed files with 380 additions and 16 deletions

View file

@ -97,6 +97,39 @@ function TranslateMapName(mapCode, dictionary = MAP) {
return translation;
}
/**
* Generates database entries text. Provides an easy filling solution.
* @param {array} HKWorldItems
* @param {string} searchText
* @param {string} entryName
* @param {string} entryDB
* @param {string} wiki
*/
function GenerateDatabaseEntries(HKWorldItems, searchText = "", entryName = "", entryDB = "", wiki = "") {
let fillText = "";
let count = 0;
for (let i = 0, ln = HKWorldItems.length; i < ln; i++) {
if (HKWorldItems[i].id.includes(searchText)) {
count++;
fillText += `
${entryDB}${count}: {
name: "${entryName} #${count}",
spoiler: "${TranslateMapName(HKWorldItems[i].sceneName)}",
id: "${HKWorldItems[i].id}",
sceneName: "${HKWorldItems[i].sceneName}",
wiki: "${wiki}"
},`;
}
}
return fillText;
}
/* ------------------------- Exports ------------------------------- */
export {