17,376
edits
(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; | ||
this.printPages.forEach((page) => { | |||
let inclCat = []; | |||
if (Array.isArray(page.includeCategories)) { | |||
inclCat = page.includeCategories; | |||
} | |||
else if (page.includeCategories === '*') { | |||
// Special value, include all categories other than those included within | |||
// 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]); | |||
// Convert game data into a JSON string for export | |||
dataObjText = undefined; | |||
if (this.prettyPrint) { | |||
dataObjText = JSON.stringify(gameDataFiltered, undefined, '\t'); | |||
} | |||
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) { |