-
-
Save stubb/c807ce3774b7808b7eb7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_unit_tooltip(self, unit_id): | |
"""Tries to identify unit properties to display as tooltip. | |
#TODO Should be extended later to also include movement speed, etc.""" | |
helptexts = [] # collects all information we will find | |
unit = Entities.units[unit_id] | |
try: | |
comp = unit.get_component_template('StorageComponent') | |
print 'a' | |
print type(comp) | |
print 'b' | |
storage = comp['PositiveTotalNumSlotsStorage'] | |
# Ship storage properties | |
helptext = _('{slotnum} slots, {limit}t') | |
helptext = helptext.format(slotnum=storage['slotnum'], | |
limit=storage['limit']) | |
helptexts.append(helptext) | |
except KeyError: # Component not found, ignore this part | |
pass | |
try: | |
comp = unit.get_component_template('HealthComponent') | |
helptext = _('Health: {health}') | |
helptext = helptext.format(health=comp['maxhealth']) | |
helptexts.append(helptext) | |
except KeyError: # Component not found, ignore this part | |
pass | |
return u'\\n'.join(helptexts) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment