# Path: DnD/modules/lib/interface.py
# class DataInterface:
#     class JsonPointerCache:
#         def __init__(self):
#             self.cache = {}
# 
#         def __getitem__(self, key: str) -> jsonpointer.JsonPointer:
#             if key not in self.cache:
#                 self.cache[key] = jsonpointer.JsonPointer(key)
#             return self.cache[key]
# 
#     def __init__(self, data: Union[list, Dict[str, Any]], readonly=False, basepath=""):
#         self.data = data
#         self.basepath = basepath.rstrip('/')
#         self.readonly = readonly
#         self._cache = type(self).JsonPointerCache()
# 
#     def __iter__(self):
#         obj = self.get('/')
#         if isinstance(obj, dict):
#             yield from obj.items()
#         elif isinstance(obj, list):
#             yield from obj
# 
#     def get(self, path: str):
#         if self.basepath + path == '/':
#             return self.data
#         if path == '/':
#             path = ''
#         pointer = self._cache[self.basepath + path]
#         return pointer.resolve(self.data, None)
# 
#     def delete(self, path):
#         if self.readonly:
#             raise ex.ReadonlyError('{} is readonly'.format(self.data))
#         if self.basepath + path == '/':
#             self.data = {}
#             return
#         if path == '/':
#             path = ''
#         pointer = self._cache[self.basepath + path]
#         subdoc, key = pointer.to_last(self.data)
#         del subdoc[key]
# 
#     def set(self, path, value):
#         if self.readonly:
#             raise ex.ReadonlyError('{} is readonly'.format(self.data))
#         if self.basepath + path == '/':
#             self.data = value
#             return
#         if path == '/':
#             path = ''
#         pointer = self._cache[self.basepath + path]
#         pointer.set(self.data, value)
# 
#     def cd(self, path, readonly=False):
#         return DataInterface(self.data, readonly=self.readonly or readonly,
#                              basepath=self.basepath + path)
# 
# Path: DnD/modules/lib/settingsLib.py
# class RestLength(enum.IntEnum):
#     LONG = 100
#     SHORT = 10
#     TURN = 1
#     NOTHING = 0
# 
#     @classmethod
#     def from_string(cls, value):
#         if value == 'long' or value == 'long rest':
#             return RestLength.LONG
#         elif value == 'short' or value == 'short rest':
#             return RestLength.SHORT
#         elif value == 'turn':
#             return RestLength.TURN
#         else:
#             return RestLength.NOTHING
# 
# class HealingMode(enum.Enum):
#     FAST = 'fast'
#     VANILLA = 'vanilla'
#     SLOW = 'slow'


from math import ceil
from dndice import basic
from . import abilitiesLib as abil
from . import characterLib as char
from . import resourceLib as res
from .interface import DataInterface
from .settingsLib import RestLength, HealingMode
                self.temp += delta
                return 0
        else:
            # healing
            if self.current + delta > self.max:
                delta = self.max - self.current
            self.current += delta
            return delta

    def add_temp(self, amount):
        """Add some temp HP

        :param amount: A rollable amount
        :return: The actual change in HP (always 0 because temp HP is not real)
        """
        delta = basic(amount)
        if delta > self.temp:
            self.temp = delta
        return 0


class OwnedHP(HP):
    def __init__(self, jf: DataInterface, character: 'char.Character'):
        super().__init__(jf)
        self.owner = character
        self.hd = {size: OwnedHD(self.record.cd('/HD/' + size), size, character)
                   for size in self.record.get('/HD')}

    def rest(self, length: RestLength):
        if length == RestLength.LONG:

# Path: DnD/modules/lib/interface.py
# class DataInterface:
#     class JsonPointerCache:
#         def __init__(self):
#             self.cache = {}
# 
#         def __getitem__(self, key: str) -> jsonpointer.JsonPointer:
#             if key not in self.cache:
#                 self.cache[key] = jsonpointer.JsonPointer(key)
#             return self.cache[key]
# 
#     def __init__(self, data: Union[list, Dict[str, Any]], readonly=False, basepath=""):
#         self.data = data
#         self.basepath = basepath.rstrip('/')
#         self.readonly = readonly
#         self._cache = type(self).JsonPointerCache()
# 
#     def __iter__(self):
#         obj = self.get('/')
#         if isinstance(obj, dict):
#             yield from obj.items()
#         elif isinstance(obj, list):
#             yield from obj
# 
#     def get(self, path: str):
#         if self.basepath + path == '/':
#             return self.data
#         if path == '/':
#             path = ''
#         pointer = self._cache[self.basepath + path]
#         return pointer.resolve(self.data, None)
# 
#     def delete(self, path):
#         if self.readonly:
#             raise ex.ReadonlyError('{} is readonly'.format(self.data))
#         if self.basepath + path == '/':
#             self.data = {}
#             return
#         if path == '/':
#             path = ''
#         pointer = self._cache[self.basepath + path]
#         subdoc, key = pointer.to_last(self.data)
#         del subdoc[key]
# 
#     def set(self, path, value):
#         if self.readonly:
#             raise ex.ReadonlyError('{} is readonly'.format(self.data))
#         if self.basepath + path == '/':
#             self.data = value
#             return
#         if path == '/':
#             path = ''
#         pointer = self._cache[self.basepath + path]
#         pointer.set(self.data, value)
# 
#     def cd(self, path, readonly=False):
#         return DataInterface(self.data, readonly=self.readonly or readonly,
#                              basepath=self.basepath + path)
# 
# Path: DnD/modules/lib/settingsLib.py
# class RestLength(enum.IntEnum):
#     LONG = 100
#     SHORT = 10
#     TURN = 1
#     NOTHING = 0
# 
#     @classmethod
#     def from_string(cls, value):
#         if value == 'long' or value == 'long rest':
#             return RestLength.LONG
#         elif value == 'short' or value == 'short rest':
#             return RestLength.SHORT
#         elif value == 'turn':
#             return RestLength.TURN
#         else:
#             return RestLength.NOTHING
# 
# class HealingMode(enum.Enum):
#     FAST = 'fast'
#     VANILLA = 'vanilla'
#     SLOW = 'slow'


# Path: DnD/modules/lib/hpLib.py
from math import ceil
from dndice import basic
from . import abilitiesLib as abil
from . import characterLib as char
from . import resourceLib as res
from .interface import DataInterface
from .settingsLib import RestLength, HealingMode

                self.temp += delta
                return 0
        else:
            # healing
            if self.current + delta > self.max:
                delta = self.max - self.current
            self.current += delta
            return delta

    def add_temp(self, amount):
        """Add some temp HP

        :param amount: A rollable amount
        :return: The actual change in HP (always 0 because temp HP is not real)
        """
        delta = basic(amount)
        if delta > self.temp:
            self.temp = delta
        return 0


class OwnedHP(HP):
    def __init__(self, jf: DataInterface, character: 'char.Character'):
        super().__init__(jf)
        self.owner = character
        self.hd = {size: OwnedHD(self.record.cd('/HD/' + size), size, character)
                   for size in self.record.get('/HD')}

    def rest(self, length: RestLength):
        if length == RestLength.LONG:

            if self.owner.settings.healing in (HealingMode.VANILLA, HealingMode.FAST):