Skip to content

Instantly share code, notes, and snippets.

@mcpie87
Last active April 7, 2021 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcpie87/1e098779fe0d008a8e00c6bd36fa1839 to your computer and use it in GitHub Desktop.
Save mcpie87/1e098779fe0d008a8e00c6bd36fa1839 to your computer and use it in GitHub Desktop.
GI - convert extracted wishes to wish tally format
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);
})
});
@mcpie87
Copy link
Author

mcpie87 commented Apr 7, 2021

Usage:

node convert-to-tally.js [STANDARD/NOVICE/WEAPON/CHARACTER]

This will create a txt file for selected banner, ready to paste into wish tally

In order to get extracted wish history, refer to this gist:
https://gist.github.com/mcpie87/b20e8e4ad83ec0b666ebc53ecb3980be

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment