Skip to content

Commit

Permalink
add support for maxRenown property in factions
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdekrieger committed Jan 17, 2023
1 parent 46ca922 commit d748d31
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
16 changes: 15 additions & 1 deletion src/api/reputations.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ function parseFactions(all_factions, my_reputations) {
var calculatedPerc = (rep.standing.value / rep.standing.max) * 100;

standing[rep.faction.id] = {
level: rep.standing.tier,
// tier is called renown_level for renown factions such as those in dragonflight
level: rep.standing.tier != undefined ? rep.standing.tier : rep.standing.renown_level,
perc: (isNaN(calculatedPerc) ? 100 : calculatedPerc),
value: rep.standing.value,
max: rep.standing.max
Expand All @@ -70,6 +71,11 @@ function parseFactions(all_factions, my_reputations) {
levels: levelsAsList(faction.levels ? faction.levels : defaultLevels),
};

// If it's a faction with renown such as Dragonflight factions
if (faction.maxRenown) {
f.levels = maxRenownToLevels(faction.maxRenown);
}

var stand = standing[faction.id];
if (stand)
{
Expand Down Expand Up @@ -102,3 +108,11 @@ function levelsAsList(levelsDict) {
}
return items;
}

function maxRenownToLevels(maxRenown, step = 2500) {
var items = [];
for (i = 0; i <= maxRenown; i++) {
items.push([i * step, "Renown 0" + i])
}
return items;
}
6 changes: 4 additions & 2 deletions static/data/factions.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
"factions": [
{
"id": 2507,
"name": "Dragonscale Expedition"
"name": "Dragonscale Expedition",
"maxRenown": 25
},
{
"id": 2511,
"name": "Iskaara Tuskarr"
"name": "Iskaara Tuskarr",
"maxRenown": 30
},
{
"id": 2523,
Expand Down

0 comments on commit d748d31

Please sign in to comment.