def reset_consumable(self, name): """Resets a consumable to its maximum value, if applicable. Returns the Character object.""" counter = self.get_consumable(name) if counter.get('reset') == 'none': raise NoReset() if counter.get('max') is None: raise NoReset() self.set_consumable(name, self.evaluate_cvar(counter.get('max'))) return self
def reset(self): """ Resets the counter to its target value. :returns CustomCounterResetResult: (new_value: int, old_value: int, target_value: int, delta: str) """ if self.reset_on == 'none': raise NoReset() old_value = self.value # reset to: fixed value if self.reset_to is not None: target_value = self.get_reset_to() new_value = self.set(target_value) delta = f"{new_value - old_value:+}" # reset by: modify current value elif self.reset_by is not None: roll_result = d20.roll(self.reset_by) target_value = old_value + roll_result.total new_value = self.set(target_value) delta = f"+{roll_result.result}" # go to max elif self.max is not None: target_value = self.get_max() new_value = self.set(target_value) delta = f"{new_value - old_value:+}" # no reset else: raise NoReset() return CustomCounterResetResult(new_value=new_value, old_value=old_value, target_value=target_value, delta=delta)
def reset(self): if self.reset_on == 'none' or self.max is None: raise NoReset() self.set(self.get_max())