-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateCollectionStats.js
More file actions
36 lines (32 loc) · 1.22 KB
/
createCollectionStats.js
File metadata and controls
36 lines (32 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const fs = require("fs");
const configs = require("./config");
const keyforge = {};
const set = {};
configs.expansion
.filter(expansion => expansion.code < 1000)
.filter(expansion => expansion.name !== "")
.forEach(expansion => {
console.log("Loading cards from " + expansion.longname + "...");
const decks = JSON.parse(
fs.readFileSync(`./collection/${expansion.name}.json`).toString()
);
const cards = decks._linked.cards;
console.log("Setup to processing " + cards.length + " cards...");
set[expansion.name] = {};
cards
.filter(card => card.house !== "")
.filter(card => !card.is_maverick && card.expansion === expansion.code)
.forEach(card => {
const cardName = `${card.card_title}${
card.rarity === "Evil Twin" ? " (GM)" : ""
}`;
if (!keyforge[cardName]) keyforge[cardName] = [];
if (!set[expansion.name][cardName]) {
set[expansion.name][cardName] = [];
}
keyforge[cardName].push(card);
set[expansion.name][cardName].push(card);
});
console.log(Object.keys(set[expansion.name]).length + " different cards!");
});
console.log(`You have ${Object.keys(keyforge).length} total different cards!`);