Module:GameData/doc: Difference between revisions

Splitting output data over multiple pages, as it is now too large for a single page (exceeds $wgMaxArticleSize)
(Support data modifications, alter equipmentSlots data structure, remove milestoneCount (logic for mastery token drop rates have changed), and include bankSortOrder for sorting various tables)
(Splitting output data over multiple pages, as it is now too large for a single page (exceeds $wgMaxArticleSize))
Line 23: Line 23:
}
}
});
});
// The output data is now long enough that it exceeds the maximum allowed MediaWiki article
// length of 2,048KB. The below determines how the data should be separated over multiple
// pages (Module:GameData then combines the data into a single structure upon
// initialization).
this.printPages = [
{ includeCategories: '*', destination: 'Module:GameData/data' },
{ includeCategories: ['items'], destination: 'Module:GameData/data2' }
];


this.packData = {};
this.packData = {};
Line 71: Line 79:
}
}
let dataObjText;
let dataObjText;
if (this.prettyPrint) {
this.printPages.forEach((page) => {
dataObjText = JSON.stringify(this.gameData, undefined, '\t');
let inclCat = [];
}
if (Array.isArray(page.includeCategories)) {
else {
inclCat = page.includeCategories;
dataObjText = JSON.stringify(this.gameData);
}
}
else if (page.includeCategories === '*') {
dataObjText = dataObjText.replace(/\'/g, "\\\'");
// Special value, include all categories other than those included within
dataObjText = dataObjText.replace(/\\\"/g, "\\\\\"");
// other pages
inclCat = Object.keys(this.gameData).filter((cat) => !this.printPages.some((p) => Array.isArray(p.includeCategories) && p.includeCategories.includes(cat)));
}
let gameDataFiltered = {};
inclCat.forEach((cat) => gameDataFiltered[cat] = wd.gameData[cat]);


let dataText = '-- Version: ' + this.getGameVersion();
// Convert game data into a JSON string for export
dataText += "\r\n\r\nlocal gameData = mw.text.jsonDecode('";
dataObjText = undefined;
dataText += dataObjText;
if (this.prettyPrint) {
dataText += "')\r\n\r\nreturn gameData";
dataObjText = JSON.stringify(gameDataFiltered, undefined, '\t');
console.log(dataText);
}
else {
dataObjText = JSON.stringify(gameDataFiltered);
}
dataObjText = dataObjText.replace(/\'/g, "\\\'");
dataObjText = dataObjText.replace(/\\\"/g, "\\\\\"");
let dataText = '-- Version: ' + this.getGameVersion();
dataText += "\r\n\r\nlocal gameData = mw.text.jsonDecode('";
dataText += dataObjText;
dataText += "')\r\n\r\nreturn gameData";
console.log(`For page "${ page.destination }" (${ dataText.length.toLocaleString() } bytes):`);
console.log(dataText);
});
}
}
async getDataPackage(url) {
async getDataPackage(url) {