2024-02-08 01:14:35 -08:00
|
|
|
import enum
|
|
|
|
|
2024-01-28 00:46:19 -08:00
|
|
|
from sqlalchemy import Column
|
|
|
|
from sqlalchemy import Integer
|
|
|
|
from sqlalchemy import String
|
|
|
|
from sqlalchemy import ForeignKey
|
2024-02-08 01:14:35 -08:00
|
|
|
from sqlalchemy import Enum
|
|
|
|
from sqlalchemy import Text
|
|
|
|
|
|
|
|
from ttfrog.db.base import Bases, BaseObject, IterableMixin
|
|
|
|
from ttfrog.db.base import multivalue_string_factory
|
|
|
|
|
|
|
|
|
|
|
|
STATS = ['STR', 'DEX', 'CON', 'INT', 'WIS', 'CHA']
|
|
|
|
|
|
|
|
CREATURE_TYPES = ['aberation', 'beast', 'celestial', 'construct', 'dragon', 'elemental', 'fey', 'fiend', 'Giant',
|
|
|
|
'humanoid', 'monstrosity', 'ooze', 'plant', 'undead']
|
|
|
|
|
|
|
|
# enums for db schemas
|
|
|
|
StatsEnum = enum.Enum("StatsEnum", ((k, k) for k in STATS))
|
|
|
|
CreatureTypesEnum = enum.Enum("CreatureTypesEnum", ((k, k) for k in CREATURE_TYPES))
|
|
|
|
|
|
|
|
CharacterClassMixin = multivalue_string_factory('character_class', Column(String, nullable=False))
|
|
|
|
SavingThrowsMixin = multivalue_string_factory('saving_throws')
|
|
|
|
SkillsMixin = multivalue_string_factory('skills')
|
|
|
|
|
|
|
|
|
|
|
|
class Skill(*Bases):
|
|
|
|
__tablename__ = "skill"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
|
|
name = Column(String, index=True, unique=True)
|
|
|
|
description = Column(Text)
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return str(self.name)
|
|
|
|
|
2024-01-28 00:46:19 -08:00
|
|
|
|
2024-02-08 01:14:35 -08:00
|
|
|
class Proficiency(*Bases):
|
|
|
|
__tablename__ = "proficiency"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
|
|
name = Column(String, index=True, unique=True)
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return str(self.name)
|
2024-01-28 00:46:19 -08:00
|
|
|
|
2024-01-31 22:39:54 -08:00
|
|
|
|
|
|
|
class Ancestry(*Bases):
|
2024-01-30 01:25:02 -08:00
|
|
|
__tablename__ = "ancestry"
|
2024-02-08 01:14:35 -08:00
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
|
|
name = Column(String, index=True, unique=True)
|
|
|
|
creature_type = Column(Enum(CreatureTypesEnum))
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return str(self.name)
|
|
|
|
|
2024-01-28 00:46:19 -08:00
|
|
|
|
2024-02-08 01:14:35 -08:00
|
|
|
class CharacterClass(*Bases, SavingThrowsMixin, SkillsMixin):
|
|
|
|
__tablename__ = "character_class"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
|
|
name = Column(String, index=True, unique=True)
|
|
|
|
hit_dice = Column(String, default='1d6')
|
|
|
|
hit_dice_stat = Column(Enum(StatsEnum))
|
|
|
|
proficiencies = Column(String)
|
2024-02-04 11:40:30 -08:00
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return str(self.name)
|
2024-01-30 01:25:02 -08:00
|
|
|
|
|
|
|
|
2024-02-08 01:14:35 -08:00
|
|
|
class Character(*Bases, CharacterClassMixin, SavingThrowsMixin, SkillsMixin):
|
2024-01-30 01:25:02 -08:00
|
|
|
__tablename__ = "character"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
2024-01-31 22:39:54 -08:00
|
|
|
ancestry = Column(String, ForeignKey("ancestry.name"), nullable=False)
|
|
|
|
name = Column(String(255), nullable=False)
|
|
|
|
level = Column(Integer, nullable=False, info={'min': 1, 'max': 20})
|
2024-02-08 01:14:35 -08:00
|
|
|
armor_class = Column(Integer, nullable=False, info={'min': 1, 'max': 99})
|
|
|
|
hit_points = Column(Integer, nullable=False, info={'min': 0, 'max': 999})
|
|
|
|
max_hit_points = Column(Integer, nullable=False, info={'min': 0, 'max': 999})
|
|
|
|
temp_hit_points = Column(Integer, nullable=False, info={'min': 0})
|
|
|
|
passive_perception = Column(Integer, nullable=False)
|
|
|
|
passive_insight = Column(Integer, nullable=False)
|
|
|
|
passive_investigation = Column(Integer, nullable=False)
|
|
|
|
speed = Column(String, nullable=False, default="30 ft.")
|
2024-02-02 15:40:45 -08:00
|
|
|
str = Column(Integer, info={'min': 0, 'max': 30})
|
|
|
|
dex = Column(Integer, info={'min': 0, 'max': 30})
|
|
|
|
con = Column(Integer, info={'min': 0, 'max': 30})
|
|
|
|
int = Column(Integer, info={'min': 0, 'max': 30})
|
|
|
|
wis = Column(Integer, info={'min': 0, 'max': 30})
|
|
|
|
cha = Column(Integer, info={'min': 0, 'max': 30})
|
2024-02-08 01:14:35 -08:00
|
|
|
proficiencies = Column(String)
|
|
|
|
|
|
|
|
|
|
|
|
class TransactionLog(BaseObject, IterableMixin):
|
|
|
|
__tablename__ = "transaction_log"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
|
|
source_table_name = Column(String, index=True, nullable=False)
|
|
|
|
primary_key = Column(Integer, index=True)
|
|
|
|
diff = Column(Text)
|