Created
September 14, 2020 10:26
-
-
Save Kaptard/ba8bf53d3da3889c7ccb0417e4f0cdb8 to your computer and use it in GitHub Desktop.
warframe-items drop mismatch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = require('request-promise') | |
async function fetchBuild(uri) { | |
return request({ uri, json: true }) | |
} | |
function getDiff(oldItem, newItem) { | |
if (oldItem.drops && !newItem.drops) { | |
return { item: oldItem.uniqueName, old: oldItem.drops.length, new: 0 } | |
} | |
else if (oldItem.drops && newItem.drops && oldItem.drops.length !== newItem.drops.length) { | |
return { item: oldItem.uniqueName, old: oldItem.drops.length, new: newItem.drops.length } | |
} | |
return null | |
} | |
function addDiff(diff, result) { | |
if (!diff) return | |
if (result.find(i => i.item === diff.item)) return | |
result.push(diff) | |
} | |
async function compare(oldBranch, newBranch) { | |
const getUrl = branch => `https://raw.githubusercontent.com/WFCD/warframe-items/${branch}/data/json/All.json` | |
const oldBuild = await fetchBuild(getUrl(oldBranch)) | |
const newBuild = await fetchBuild(getUrl(newBranch)) | |
const result = [] | |
for (const oldItem of oldBuild) { | |
const newItem = newBuild.find(i => i.uniqueName === oldItem.uniqueName) | |
addDiff(getDiff(oldItem, newItem), result) | |
if (!oldItem.components) continue | |
for (const oldComponent of oldItem.components) { | |
const newComponent = newItem.components.find(c => c.uniqueName === oldComponent.uniqueName) | |
addDiff(getDiff(oldComponent, newComponent), result) | |
} | |
} | |
console.log(result) | |
} | |
compare('development', 'faster-drops') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment