# Path: DnD/modules/lib/exceptionsLib.py
# class OutOfSpells(SpellError):
#     def __init__(self, spell):
#         self.spell = spell
# 
#     def __str__(self):
#         formatstr = 'You have no spell slots of level {lv} remaining.'
#         return formatstr.format(lv=(self.spell if isinstance(self.spell, int)
#                                     else self.spell.level))
# 
# class OutOfItems(DnDError):
#     def __init__(self, name):
#         self.name = name
# 
#     def __str__(self):
#         formatstr = 'You have no {item}s remaining.'
#         return formatstr.format(item=self.name)
# 
# class LowOnResource(DnDError):
#     def __init__(self, resource):
#         self.resource = resource
# 
#     def __str__(self):
#         formatstr = 'You have no {rs} remaining.'
#         return formatstr.format(rs=self.resource.name)
# 
# Path: DnD/modules/lib/settingsLib.py
# class Settings:
#     def __init__(self, jf: JsonInterface):
#         self.record = jf
# 
#     @property
#     def healing(self) -> 'HealingMode':
#         return self.record.get('/HEALING') or HealingMode.VANILLA
# 
#     @healing.setter
#     def healing(self, value: 'HealingMode'):
#         self.record.set('/HEALING', value)
# 
#     @property
#     def spellPoints(self) -> bool:
#         return self.record.get('/SPELL_POINTS') or False
# 
#     @spellPoints.setter
#     def spellPoints(self, value: bool):
#         self.record.set('/SPELL_POINTS', value)
# 
#     @property
#     def proficiencyDice(self) -> bool:
#         return self.record.get('/PROFICIENCY_DICE') or False
# 
#     @proficiencyDice.setter
#     def proficiencyDice(self, value: bool):
#         self.record.set('/PROFICIENCY_DICE', value)
# 
#     def serialize(self):
#         rv = {}
#         if self.healing != HealingMode.VANILLA:
#             rv['HEALING'] = self.healing
#         if self.spellPoints:
#             rv['SPELL_POINTS'] = True
#         if self.proficiencyDice:
#             rv['PROFICIENCY_DICE'] = True
#         return rv


import re
import dndice as r
from collections import OrderedDict
from functools import wraps
from math import ceil
from . import helpers as h
from . import interface as iface
from .exceptionsLib import OutOfSpells, OutOfItems, LowOnResource
from .settingsLib import Settings
        else:
            self.value = v
        self.recharge = self.definition.get(self.defpath + '/recharge')

    @property
    def number(self):
        return self.record.get(self.path + '/number')

    @number.setter
    def number(self, value):
        self.record.set(self.path + '/number', value)

    @property
    def maxnumber(self):
        val = self.record.get(self.path + '/maxnumber')
        if val is not None:
            if self.character is not None:
                return self.character.parse_vars(val)
            return val
        if self.character is not None:
            mx = self.definition.get(self.defpath + '/maxnumber')
            return self.character.parse_vars(mx)
        return self.definition.get(self.defpath + '/maxnumber')

    @maxnumber.setter
    def maxnumber(self, value):
        self.record.set(self.path + '/maxnumber', value)

    def use(self, howmany):
        if self.number < howmany:

# Path: DnD/modules/lib/exceptionsLib.py
# class OutOfSpells(SpellError):
#     def __init__(self, spell):
#         self.spell = spell
# 
#     def __str__(self):
#         formatstr = 'You have no spell slots of level {lv} remaining.'
#         return formatstr.format(lv=(self.spell if isinstance(self.spell, int)
#                                     else self.spell.level))
# 
# class OutOfItems(DnDError):
#     def __init__(self, name):
#         self.name = name
# 
#     def __str__(self):
#         formatstr = 'You have no {item}s remaining.'
#         return formatstr.format(item=self.name)
# 
# class LowOnResource(DnDError):
#     def __init__(self, resource):
#         self.resource = resource
# 
#     def __str__(self):
#         formatstr = 'You have no {rs} remaining.'
#         return formatstr.format(rs=self.resource.name)
# 
# Path: DnD/modules/lib/settingsLib.py
# class Settings:
#     def __init__(self, jf: JsonInterface):
#         self.record = jf
# 
#     @property
#     def healing(self) -> 'HealingMode':
#         return self.record.get('/HEALING') or HealingMode.VANILLA
# 
#     @healing.setter
#     def healing(self, value: 'HealingMode'):
#         self.record.set('/HEALING', value)
# 
#     @property
#     def spellPoints(self) -> bool:
#         return self.record.get('/SPELL_POINTS') or False
# 
#     @spellPoints.setter
#     def spellPoints(self, value: bool):
#         self.record.set('/SPELL_POINTS', value)
# 
#     @property
#     def proficiencyDice(self) -> bool:
#         return self.record.get('/PROFICIENCY_DICE') or False
# 
#     @proficiencyDice.setter
#     def proficiencyDice(self, value: bool):
#         self.record.set('/PROFICIENCY_DICE', value)
# 
#     def serialize(self):
#         rv = {}
#         if self.healing != HealingMode.VANILLA:
#             rv['HEALING'] = self.healing
#         if self.spellPoints:
#             rv['SPELL_POINTS'] = True
#         if self.proficiencyDice:
#             rv['PROFICIENCY_DICE'] = True
#         return rv


# Path: DnD/modules/lib/classes.py
import re
import dndice as r
from collections import OrderedDict
from functools import wraps
from math import ceil
from . import helpers as h
from . import interface as iface
from .exceptionsLib import OutOfSpells, OutOfItems, LowOnResource
from .settingsLib import Settings

        else:
            self.value = v
        self.recharge = self.definition.get(self.defpath + '/recharge')

    @property
    def number(self):
        return self.record.get(self.path + '/number')

    @number.setter
    def number(self, value):
        self.record.set(self.path + '/number', value)

    @property
    def maxnumber(self):
        val = self.record.get(self.path + '/maxnumber')
        if val is not None:
            if self.character is not None:
                return self.character.parse_vars(val)
            return val
        if self.character is not None:
            mx = self.definition.get(self.defpath + '/maxnumber')
            return self.character.parse_vars(mx)
        return self.definition.get(self.defpath + '/maxnumber')

    @maxnumber.setter
    def maxnumber(self, value):
        self.record.set(self.path + '/maxnumber', value)

    def use(self, howmany):
        if self.number < howmany:

            raise LowOnResource(self)