def test_modifier(): _ = sValue('1+1') assert _.low == 2 assert _.high == 2 _ = sValue('1d4+4,(t+1),3+2') assert _.low == 12 assert _.high == 15
def test_range(): _ = sValue('16,1d3,(t-1)d2') assert _.low == 17 assert _.high == 19 _ = sValue('16,1d3,(t-1)d2', level=5) assert _.low == 18 assert _.high == 21
def test_iteration(): _ = sValue('1d5,1d5') assert _.low == 2 assert _.high == 10 assert min(_) == 2 assert max(_) == 10 _ = sValue('5') assert len(_) == 1 _ = sValue('(t)d100') assert min(_) == 1 assert max(_) == 100 assert len(_) == 100
def attribute_helper(self, attr: str, mode: str = '') -> Union[str, int]: # TODO: fix that this can return str or int, then fix type annotation above """Helper for retrieving attributes (Strength, etc.)""" val = None if self.inherits_from('Creature') or self.inherits_from('ActivePlant'): if getattr(self, f'stat_{attr}_sValue'): val = str( sValue(getattr(self, f'stat_{attr}_sValue'), level=int(self.lv))) elif getattr(self, f'stat_{attr}_Value'): val = getattr(self, f'stat_{attr}_Value') boost = getattr(self, f'stat_{attr}_Boost') if boost: val += f'+{boost}' elif self.inherits_from('Armor'): val = getattr(self, f'part_Armor_{attr}') if mode in ['Average', 'Modifier']: val = DiceBag(val).average() # calculate average stat value val = int(val * (0.8 if self.role == 'Minion' else 1)) # Minions lose 20% to all stats if mode == 'Modifier': val = (val - 16) // 2 # return stat modifier for average roll return val
def test_creation(): _ = sValue('16,1d3,(t-1)d2') assert _.__repr__() == 'sValue 16,1d3,(t-1)d2'
def test_simple(): _ = sValue('16') assert _.low == 16 assert _.high == 16