Last active
April 7, 2021 22:44
-
-
Save mcpie87/1e098779fe0d008a8e00c6bd36fa1839 to your computer and use it in GitHub Desktop.
GI - convert extracted wishes to wish tally format
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 fs = require('fs'); | |
const GACHA_TYPES = [ | |
"STANDARD", | |
"NOVICE", | |
"WEAPON", | |
"CHARACTER", | |
] | |
const GACHA_TYPE = process.argv[2]; | |
if (!GACHA_TYPES.includes(GACHA_TYPE)) { | |
console.log("Invalid gacha type. Available types are:\n" + (GACHA_TYPES).map(e => "\t- " + e).join("\n")) | |
process.exit(0); | |
} | |
fs.readFile(`${GACHA_TYPE}.json`, (err, data) => { | |
if (err) { | |
return console.log(err); | |
} | |
const wishList = JSON.parse(data).map((wish) => ({ | |
item_type: wish.item_type, | |
name: wish.name, | |
time: wish.time | |
})).reverse(); | |
const h = {} | |
for (const wish of wishList) { | |
if (!h[wish.time]) { | |
h[wish.time] = [wish]; | |
} else { | |
h[wish.time].push(wish); | |
} | |
} | |
const res = []; | |
for (const date in h) { | |
if (h[date].length < 10 && h[date].length > 1) { | |
throw `Inaccurate length of ${h[date].length}, ${JSON.stringify(h[date])}`; | |
} | |
const type = h[date].length == 10 ? "MULTI" : "SINGLE" | |
let i = 1; | |
for (wish of h[date]) { | |
res.push(`${wish.item_type}${wish.name}${wish.time}\t${i++}`) | |
} | |
} | |
fs.writeFile(`${new Date().toISOString()}-${GACHA_TYPE}-wishtally.txt`, res.join("\n"), (err) => { | |
// console.log(err); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
This will create a
txt
file for selected banner, ready to paste into wish tallyIn order to get extracted wish history, refer to this gist:
https://gist.github.com/mcpie87/b20e8e4ad83ec0b666ebc53ecb3980be