Skip to content

Commit

Permalink
v0.0.19
Browse files Browse the repository at this point in the history
  • Loading branch information
MrPrimate committed Aug 6, 2022
1 parent 38bb5eb commit 1fd1898
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.0.19

* Prevent legacy checkbox excluding homebrew.
* If homebrew was disabled on the character, it would still add homebrew spells to the characters available selection.

# 0.0.18

* Some more clauses to try and stop issue #18 when it can't find a cobalt.
Expand Down
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ app.post(["/proxy/character", "/proxy/v5/character"], cors(), express.json(), (r
: [];
return spells.getSpellAdditions(result, spellListIds, cobaltId);
})
.then((result) => {
const includeHomebrew = result.character.preferences.useHomebrewContent;
return spells.filterHomebrew(result, includeHomebrew);
})
.then((data) => {
data = filterModifiers(data);
return { success: true, messages: ["Character successfully received."], ddb: data };
Expand Down Expand Up @@ -258,7 +262,7 @@ app.post(getMonsterProxyRoutes, cors(), express.json(), (req, res) => {
.extractMonsters(cacheId, searchTerm, homebrew, homebrewOnly, sources)
.then((data) => {
if (excludeLegacy) {
const filteredMonsters = data.filter((monster) => !monster.isHomebrew && !monster.isLegacy);
const filteredMonsters = data.filter((monster) => !monster.isLegacy);
return filteredMonsters;
} else {
return data;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ddb-proxy",
"version": "0.0.18",
"version": "0.0.19",
"main": "index.js",
"license": "MIT",
"scripts": {
Expand Down
18 changes: 18 additions & 0 deletions spells.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,5 +263,23 @@ function getSpellAdditions(data, spellListIds, cacheId) {
});
}

function filterHomebrew(data, includeHomebrew) {
if (includeHomebrew) {
return data;
} else {
data.character.classSpells = data.character.classSpells.map((classSpells) => {
classSpells.spells = classSpells.spells.filter(spell => !spell.definition.isHomebrew);
return classSpells;
});
data.character.spells.class = data.character.spells.class.filter(spell => !spell.definition.isHomebrew);
data.character.spells.race = data.character.spells.race.filter(spell => !spell.definition.isHomebrew);
data.character.spells.feat = data.character.spells.feat.filter(spell => !spell.definition.isHomebrew);
data.character.spells.item = data.character.spells.item.filter(spell => !spell.definition.isHomebrew);
return data;
}
}


exports.loadSpells = loadSpells;
exports.getSpellAdditions = getSpellAdditions;
exports.filterHomebrew = filterHomebrew;

0 comments on commit 1fd1898

Please sign in to comment.