Skip to content

Commit

Permalink
compute renown information from covenant and covenant reward csv
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdekrieger committed Jan 28, 2023
1 parent 3868138 commit 96ade5e
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 8 deletions.
46 changes: 46 additions & 0 deletions dataimporter/factions.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,53 @@ def fix_types_data(self):
else:
faction['id'] = int(faction['id'])

def fix_max_renown(self):
# Add renown information to reputations with a renown system
# such as the main factions in Dragonflight.
dbc_faction_to_covenant = {
int(e['FactionID']): int(e['ID']) for e in self.dbc_get_table('covenant')
}

# Compute the maximum renown for each covenant
max_reward_for_covenant = {}
for row in self.dbc_get_table('renownrewards'):
covenant_id = int(row['CovenantID'])
if covenant_id not in max_reward_for_covenant:
max_reward_for_covenant[covenant_id] = int(row['Level'])
else:
max_reward_for_covenant[covenant_id] = max(int(row['Level']), max_reward_for_covenant[covenant_id])

# Populate the 'renown' object for every renown faction
for cat in self.factions:
for faction in cat['factions']:
faction_id = faction['id']

# DBC faction flag 2 indicates that it is a "renown faction".
# Some valid renown factions filtered from the self.dbc_faction
# (e.g. Maruuk Centaur and Valdrakken Accord which have child factions)
# but can still be computed automatically if they have a 'renown'
# property in the JSON.
if (
faction_id in dbc_faction_to_covenant
and (
(
faction_id in self.dbc_faction
and int(self.dbc_faction[faction_id]['Flags']) == 2
)

or 'renown' in faction
)
):
if 'renown' not in faction:
faction['renown'] = dict()

if faction_id in self.dbc_faction:
faction['renown']['step'] = int(self.dbc_faction[faction_id]['ReputationMax[0]'])

faction['renown']['max'] = max_reward_for_covenant[dbc_faction_to_covenant[faction_id]]

def run(self):
self.fix_missing_factions()
self.fix_types_data()
self.fix_max_renown()
return [self.factions]
28 changes: 20 additions & 8 deletions static/data/factions.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,35 @@
"factions": [
{
"id": 2507,
"maxRenown": 25,
"name": "Dragonscale Expedition"
"name": "Dragonscale Expedition",
"renown": {
"max": 25,
"step": 2500
}
},
{
"id": 2503,
"maxRenown": 25,
"name": "Maruuk Centaur"
"name": "Maruuk Centaur",
"renown": {
"max": 25,
"step": 2500
}
},
{
"id": 2511,
"maxRenown": 30,
"name": "Iskaara Tuskarr"
"name": "Iskaara Tuskarr",
"renown": {
"max": 30,
"step": 2500
}
},
{
"id": 2510,
"maxRenown": 30,
"name": "Valdrakken Accord"
"name": "Valdrakken Accord",
"renown": {
"max": 30,
"step": 2500
}
},
{
"id": 2523,
Expand Down

0 comments on commit 96ade5e

Please sign in to comment.