Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from typing import Dict
- from enum import unique, IntEnum, auto
- @unique
- class TypeValue(IntEnum):
- INTELLIGENCE = auto()
- DEXTERITY = auto()
- FORCE = auto()
- class Stat:
- _v: int
- def __init__(self, v):
- self._v = v
- @property
- def v(self):
- return self._v
- @v.setter
- def v(self, value):
- self._v = value
- def __iadd__(self, other: int):
- return self._v + other
- class Test:
- intelligence: Stat
- dexterity: Stat
- force: Stat
- def __init__(self, requirement: Dict[TypeValue, int]):
- tmp_stat = dict({TypeValue.INTELLIGENCE: Stat(0), TypeValue.DEXTERITY: Stat(0), TypeValue.FORCE: Stat(0)})
- for k, v in requirement.items():
- tmp_stat[k] += v
- self.intelligence = tmp_stat[TypeValue.INTELLIGENCE]
- self.dexterity = tmp_stat[TypeValue.DEXTERITY]
- self.force = tmp_stat[TypeValue.FORCE]
- if __name__ == '__main__':
- test_e = {TypeValue.FORCE: 5}
- test = Test(test_e)
- print(test.force)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement