Spaces:
Runtime error
Runtime error
File size: 780 Bytes
c145eab |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
from gr.components.talents import TalentsComponent
from assets.constant import MAX_TALENTS
class Talents:
def __init__(self):
self.talents = ["" for _ in range(MAX_TALENTS)]
def __getitem__(self, item):
return self.talents[item]
def __setitem__(self, key, value):
self.talents[key] = value
@property
def gains(self):
return [talent for talent in self.talents if talent]
def talents_script(talents_component: TalentsComponent):
talents = Talents()
def talent_changed(i):
def inner(talent):
talents[i] = talent
return inner
for n, talent_component in enumerate(talents_component.values()):
talent_component.change(talent_changed(n), talent_component)
return talents
|