Skip to content

Commit

Permalink
feat: also show kingdom with new secret feature
Browse files Browse the repository at this point in the history
  • Loading branch information
maduck committed Nov 7, 2020
1 parent daea730 commit 6b08b8b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
15 changes: 11 additions & 4 deletions data_source/game_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ def populate_traitstones(self):
'name': rune['name'],
'troop_ids': [],
'class_ids': [],
'kingdom_ids': [],
'total_amount': rune['amount'],
}
if 'ClassCode' in traits:
Expand All @@ -432,9 +433,12 @@ def populate_traitstones(self):
else:
self.troops[traits['Troop']]['traitstones'] = runes
self.traitstones[rune['name']]['troop_ids'].append(traits['Troop'])
for kingdom_id, runes in self.user_data['pEconomyModel']['Explore_RunePerKingdom'].items():
for rune_id in runes:
rune_name = self.get_rune_name_from_id(rune_id)
self.traitstones[rune_name]['kingdom_ids'].append(kingdom_id)

@staticmethod
def extract_runes(runes):
def extract_runes(self, runes):
result = {}
for trait in runes:
for rune in trait:
Expand All @@ -444,8 +448,11 @@ def extract_runes(runes):
else:
result[rune_id] = {
'id': rune['Id'],
'name': f'[RUNE{rune["Id"]:02d}_NAME]',
'name': self.get_rune_name_from_id(rune['Id']),
'amount': rune['Required'],
}

return list(result.values())

@staticmethod
def get_rune_name_from_id(rune_id):
return f'[RUNE{rune_id:02d}_NAME]'
8 changes: 8 additions & 0 deletions team_expando.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,17 @@ def translate_traitstone(self, traitstone, lang):
classes.append([_(self.classes[class_id]['name'], lang), amount])
traitstone['classes'] = classes

kingdoms = []
for kingdom_id in traitstone['kingdom_ids']:
kingdoms.append(_(self.kingdoms[int(kingdom_id)]['name'], lang))
if not traitstone['kingdom_ids']:
kingdoms.append(_('[ALL_KINGDOMS]', lang))
traitstone['kingdoms'] = kingdoms

traitstone['name'] = _(traitstone['name'], lang)
traitstone['troops_title'] = _('[TROOPS]', lang)
traitstone['classes_title'] = _('[CLASS]', lang)
traitstone['kingdoms_title'] = _('[KINGDOMS]', lang)

def translate_spell(self, spell_id, lang):
spell = self.spells[spell_id]
Expand Down
2 changes: 2 additions & 0 deletions templates/traitstone.jinja
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{% if kingdoms %}<T>{{ traitstone.kingdoms_title }}</T>
{{ kingdoms }}{% endif %}
{% if troops %}<T>{{ traitstone.troops | length }} {{ traitstone.troops_title }}</T>
{{ troops }}{% endif %}
{% if classes %}<T>{{ traitstone.classes | length }} {{ traitstone.classes_title }}</T>
Expand Down
5 changes: 4 additions & 1 deletion views.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ def render_traitstone(self, traitstone, shortened):
troops = self.trim_text_to_length(", ".join(sorted(troop_list)), 900, ',', ', ...')
class_list = ['{0} ({1})'.format(*_class) for _class in traitstone['classes']]
classes = self.trim_text_to_length(", ".join(sorted(class_list)), 900, ',', ', ...')
return self.render_embed(e, 'traitstone.jinja', traitstone=traitstone, troops=troops, classes=classes)
kingdom_list = [k for k in traitstone['kingdoms']]
kingdoms = self.trim_text_to_length(", ".join(sorted(kingdom_list)), 900, ',', ', ...')
return self.render_embed(e, 'traitstone.jinja',
traitstone=traitstone, troops=troops, classes=classes, kingdoms=kingdoms)

def render_talent(self, tree, shortened):
e = discord.Embed(color=self.WHITE)
Expand Down

0 comments on commit 6b08b8b

Please sign in to comment.