# 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
    parse_vars: Replaces variables plugged into a string (prefixed by $) with
        the values from the character. Important values would be ${abil}_mod,
        $proficiency, ${Class}_level, $level, and $caster_level.
    write: Writes all changes to the file.
    """
    PROFICIENCY_DICE = False
    # Options:
    #   'fast': regain all HD on long rest
    #   'vanilla': regain all HP and half HD on long rest
    #   'slow': regain half HD on long rest
    HEALING = 'vanilla'

    def __init__(self, jf):
        self.record = jf
        self.name = jf.get('/name')
        self.abilities = jf.get('/abilities')
        self.skills = jf.get('/skills')
        self.saves = jf.get('/saves')
        # lv = jf.get('/level')
        # self.classes = cm.ClassMap(lv)
        # self.race = cm.RaceMap(jf.get('/race'))
        self.hp = HPHandler(self.record)
        # self.inventory = Inventory(self.record)
        self.features = self.get_features()
        # self.bonuses = self.get_bonuses()
        # self.spells = SpellsPrepared(jf, self)
        # self.attacks = self.register_attacks()
        # self.resources = self.get_resources()
        self.death_save_fails = 0
        self.conditions = set(self.record.get('/conditions') or [])

# 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

    parse_vars: Replaces variables plugged into a string (prefixed by $) with
        the values from the character. Important values would be ${abil}_mod,
        $proficiency, ${Class}_level, $level, and $caster_level.
    write: Writes all changes to the file.
    """
    PROFICIENCY_DICE = False
    # Options:
    #   'fast': regain all HD on long rest
    #   'vanilla': regain all HP and half HD on long rest
    #   'slow': regain half HD on long rest
    HEALING = 'vanilla'

    def __init__(self, jf):
        self.record = jf
        self.name = jf.get('/name')
        self.abilities = jf.get('/abilities')
        self.skills = jf.get('/skills')
        self.saves = jf.get('/saves')
        # lv = jf.get('/level')
        # self.classes = cm.ClassMap(lv)
        # self.race = cm.RaceMap(jf.get('/race'))
        self.hp = HPHandler(self.record)
        # self.inventory = Inventory(self.record)
        self.features = self.get_features()
        # self.bonuses = self.get_bonuses()
        # self.spells = SpellsPrepared(jf, self)
        # self.attacks = self.register_attacks()
        # self.resources = self.get_resources()
        self.death_save_fails = 0
        self.conditions = set(self.record.get('/conditions') or [])

        self.settings = Settings(self.record.get('/SETTINGS'))