Advertisement
VikkaLorel

stat setup

Aug 26th, 2019
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. from typing import Dict
  2. from enum import unique, IntEnum, auto
  3.  
  4.  
  5. @unique
  6. class TypeValue(IntEnum):
  7.     INTELLIGENCE = auto()
  8.     DEXTERITY = auto()
  9.     FORCE = auto()
  10.  
  11.  
  12. class Stat:
  13.     _v: int
  14.  
  15.     def __init__(self, v):
  16.         self._v = v
  17.  
  18.     @property
  19.     def v(self):
  20.         return self._v
  21.  
  22.     @v.setter
  23.     def v(self, value):
  24.         self._v = value
  25.  
  26.     def __iadd__(self, other: int):
  27.         return self._v + other
  28.  
  29.  
  30. class Test:
  31.     intelligence: Stat
  32.     dexterity: Stat
  33.     force: Stat
  34.  
  35.     def __init__(self, requirement: Dict[TypeValue, int]):
  36.         tmp_stat = dict({TypeValue.INTELLIGENCE: Stat(0), TypeValue.DEXTERITY: Stat(0), TypeValue.FORCE: Stat(0)})
  37.         for k, v in requirement.items():
  38.             tmp_stat[k] += v
  39.         self.intelligence = tmp_stat[TypeValue.INTELLIGENCE]
  40.         self.dexterity = tmp_stat[TypeValue.DEXTERITY]
  41.         self.force = tmp_stat[TypeValue.FORCE]
  42.  
  43.  
  44. if __name__ == '__main__':
  45.     test_e = {TypeValue.FORCE: 5}
  46.     test = Test(test_e)
  47.     print(test.force)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement