Skip to content
This repository was archived by the owner on Oct 24, 2021. It is now read-only.

Commit 8a62563

Browse files
authored
feat: add new secrets in Uldum expansion (#49)
1 parent adf2f4f commit 8a62563

File tree

3 files changed

+111
-0
lines changed

3 files changed

+111
-0
lines changed

scripts/generate-secrets.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// 1. Ask Blizzard API credential (https://develop.battle.net/access/clients)
2+
// 2. Fetch all secret cards
3+
// 3. Fetch cards from hearthstonejson
4+
// 4. Make JSON with pairs of ID and description
5+
6+
const path = require("path");
7+
const got = require("got");
8+
const inquirer = require("inquirer");
9+
const writeJson = require("write-json-file");
10+
11+
const getAccessToken = async () => {
12+
const { clientId, clientSecret } = await inquirer.prompt([
13+
{ name: "clientId" },
14+
{ name: "clientSecret" }
15+
]);
16+
const res = await got.post("https://us.battle.net/oauth/token", {
17+
form: true,
18+
auth: `${clientId}:${clientSecret}`,
19+
body: { grant_type: "client_credentials" }
20+
});
21+
return JSON.parse(res.body).access_token;
22+
};
23+
24+
const getAllQuests = async accessToken => {
25+
const res = await got.get("https://us.api.blizzard.com/hearthstone/cards", {
26+
json: true,
27+
query: {
28+
locale: "en_US",
29+
textFilter: "<b>Secret:</b>",
30+
access_token: accessToken
31+
}
32+
});
33+
return res.body.cards;
34+
};
35+
36+
const getAllCards = async () => {
37+
const res = await got.get(
38+
"https://api.hearthstonejson.com/v1/latest/enUS/cards.json",
39+
{ json: true }
40+
);
41+
return res.body;
42+
};
43+
44+
const main = async () => {
45+
const accessToken = await getAccessToken();
46+
const quests = await getAllQuests(accessToken);
47+
const cards = await getAllCards();
48+
49+
const questTexts = {};
50+
quests
51+
.map(quest => {
52+
return cards.find(c => c.dbfId === quest.id);
53+
})
54+
.sort((a, b) => a.id.localeCompare(b.id))
55+
.forEach(card => {
56+
questTexts[card.id] = card.cardClass;
57+
});
58+
await writeJson(
59+
path.resolve(__dirname, "../src/data/secret-class-map.json"),
60+
questTexts
61+
);
62+
};
63+
64+
main().catch(err => {
65+
console.error(err);
66+
});

src/data/secret-class-map.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"AT_002": "MAGE",
3+
"AT_060": "HUNTER",
4+
"AT_073": "PALADIN",
5+
"BOT_908": "PALADIN",
6+
"CFM_026": "HUNTER",
7+
"CFM_620": "MAGE",
8+
"CFM_800": "PALADIN",
9+
"DAL_570": "PALADIN",
10+
"EX1_130": "PALADIN",
11+
"EX1_132": "PALADIN",
12+
"EX1_136": "PALADIN",
13+
"EX1_287": "MAGE",
14+
"EX1_289": "MAGE",
15+
"EX1_294": "MAGE",
16+
"EX1_295": "MAGE",
17+
"EX1_379": "PALADIN",
18+
"EX1_533": "HUNTER",
19+
"EX1_554": "HUNTER",
20+
"EX1_594": "MAGE",
21+
"EX1_609": "HUNTER",
22+
"EX1_610": "HUNTER",
23+
"EX1_611": "HUNTER",
24+
"FP1_018": "MAGE",
25+
"FP1_020": "PALADIN",
26+
"GIL_577": "HUNTER",
27+
"GIL_903": "PALADIN",
28+
"ICC_082": "MAGE",
29+
"ICC_200": "HUNTER",
30+
"KAR_004": "HUNTER",
31+
"LOE_021": "HUNTER",
32+
"LOE_027": "PALADIN",
33+
"LOOT_079": "HUNTER",
34+
"LOOT_101": "MAGE",
35+
"LOOT_204": "ROGUE",
36+
"LOOT_210": "ROGUE",
37+
"LOOT_214": "ROGUE",
38+
"TRL_400": "MAGE",
39+
"tt_010": "MAGE",
40+
"ULD_152": "HUNTER",
41+
"ULD_239": "MAGE",
42+
"UNG_024": "MAGE"
43+
}

src/data/secrets.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,7 @@ export const secretToClass: {[id: string]: SecretClass} =
5050
LOOT_214: SecretClass.Rogue,
5151
TRL_400: SecretClass.Mage,
5252
tt_010: SecretClass.Mage, // eslint-disable-line @typescript-eslint/camelcase
53+
ULD_152: SecretClass.Hunter,
54+
ULD_239: SecretClass.Mage,
5355
UNG_024: SecretClass.Mage
5456
};

0 commit comments

Comments
 (0)