-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
config.js
93 lines (88 loc) · 3.92 KB
/
config.js
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* CONFIG
*/
const CLASS_MAP = [
{ name: "Barbarian", spells: "SPELLS", id: 9 },
{ name: "Bard", spells: "SPELLS", id: 1 },
{ name: "Cleric", spells: "KNOWN", id: 2 },
{ name: "Druid", spells: "KNOWN", id: 3 },
{ name: "Fighter", spells: "SPELLS", id: 10 },
{ name: "Monk", spells: "SPELLS", id: 11 },
{ name: "Paladin", spells: "KNOWN", id: 4 },
{ name: "Ranger", spells: "SPELLS", id: 5 },
{ name: "Rogue", spells: "SPELLS", id: 12 },
{ name: "Sorcerer", spells: "SPELLS", id: 6 },
{ name: "Warlock", spells: "SPELLS", id: 7 },
{ name: "Wizard", spells: "SPELLS", id: 8 },
{ name: "Artificer", spells: "KNOWN", id: 252717 },
{ name: "Blood Hunter", spells: "SPELLS", id: 357975 },
{ name: "Graviturgy", spells: "SPELLS", id: 400661 },
{ name: "Chronurgy", spells: "SPELLS", id: 400659 },
];
const BAD_IMAGES = [
];
const CONFIG = {
badImages: BAD_IMAGES,
classMap: CLASS_MAP,
urls: {
authService: "https://auth-service.dndbeyond.com/v1/cobalt-token",
baseUrl: "https://character-service.dndbeyond.com/character/v5",
monsterBaseUrl: "https://monster-service.dndbeyond.com/v1/Monster",
characterUrl: (characterId) =>
`${CONFIG.urls.baseUrl}/character/${characterId}?includeCustomItems=true`,
spellsAPI: (classId, classLevel, campaignId) => {
let campaign = "";
if (campaignId) campaign = `&campaignId=${campaignId}`;
return `${CONFIG.urls.baseUrl}/game-data/spells?classId=${classId}&classLevel=${classLevel}&sharingSetting=2${campaign}`;
},
alwaysPreparedSpells: (classId, classLevel, campaignId, spellListIds=[]) => {
let campaign = "";
let spellLists = "";
spellListIds.forEach(list => spellLists += `&spellListIds[]=${list}`);
if (campaignId) campaign = `&campaignId=${campaignId}`;
return `${CONFIG.urls.baseUrl}/game-data/always-prepared-spells?classId=${classId}&classLevel=${classLevel}&sharingSetting=2${campaign}${spellLists}`;
},
alwaysKnownSpells: (classId, classLevel, campaignId, spellListIds = [], backgroundId = null) => {
let campaign = "";
let spellLists = "";
let backgroundIdAdd = spellListIds.length === 0 && backgroundId ? `&backgroundId=${backgroundId}` : "";
spellListIds.forEach((list) => (spellLists += `&spellListIds[]=${list}`));
if (campaignId) campaign = `&campaignId=${campaignId}`;
return `${CONFIG.urls.baseUrl}/game-data/always-known-spells?classId=${classId}&classLevel=${classLevel}&sharingSetting=2${campaign}${spellLists}${backgroundIdAdd}`;
},
itemsAPI: (campaignId) => {
let campaign = "";
if (campaignId) campaign = `&campaignId=${campaignId}`;
return `${CONFIG.urls.baseUrl}/game-data/items?sharingSetting=2${campaign}`;
},
monstersAPI: (skip, take, search="", homebrew=false, homebrewOnly=false, sources=[]) => {
let sourceSearch = sources.reduce((previous, current) => previous + `&sources=${current}`, "");
let useHomebrew = (homebrew) ? "" : "&showHomebrew=f";
if (homebrewOnly) {
sourceSearch = "";
useHomebrew = "&showHomebrew=t";
}
const url = `${CONFIG.urls.monsterBaseUrl}?search=${search}&skip=${skip}&take=${take}${useHomebrew}${sourceSearch}`;
console.log(url);
return url;
},
monsterIdsAPI: (ids) => {
const idString = ids.reduce((previous, current) => {
const pre = previous === "" ? "?ids=" : "&ids=";
return previous + `${pre}${current}`;
}, "");
const url = `${CONFIG.urls.monsterBaseUrl}${idString}`;
console.log(url);
return url;
},
classOptionsAPI: () => {
return `${CONFIG.urls.baseUrl}/game-data/class-feature/collection`;
},
racialTraitOptionsAPI: () => {
return `${CONFIG.urls.baseUrl}/game-data/racial-trait/collection`;
},
campaignsAPI: "https://www.dndbeyond.com/api/campaign/stt/user-campaigns",
configUrl: "https://www.dndbeyond.com/api/config/json",
},
};
module.exports = CONFIG;