Building new test application.
This commit is contained in:
parent
909f20f207
commit
c43b17662d
8 changed files with 91 additions and 5 deletions
|
|
@ -1,4 +1,4 @@
|
|||
from sqlalchemy import Column, Integer, String, ForeignKey
|
||||
from sqlalchemy import Column, Integer, String, ForeignKey, Boolean
|
||||
from sqlalchemy.orm import relationship
|
||||
from crudkit.core.base import CRUDMixin, Base
|
||||
|
||||
|
|
@ -7,6 +7,7 @@ class Dbref(Base, CRUDMixin):
|
|||
|
||||
type = Column(String, nullable=False)
|
||||
name = Column(String, nullable=False)
|
||||
is_deleted = Column(Boolean, nullable=False, default=False)
|
||||
|
||||
owner_id = Column(Integer, ForeignKey("dbref.id"))
|
||||
location_id = Column(Integer, ForeignKey("dbref.id"))
|
||||
|
|
@ -21,3 +22,21 @@ class Dbref(Base, CRUDMixin):
|
|||
|
||||
def __str__(self):
|
||||
return f"#{self.id} ({self.type}): {self.name}"
|
||||
|
||||
def is_type(self, *types: str) -> bool:
|
||||
return self.type in types
|
||||
|
||||
@property
|
||||
def is_room(self): return self.is_type("room")
|
||||
|
||||
@property
|
||||
def is_thing(self): return self.is_type("thing")
|
||||
|
||||
@property
|
||||
def is_exit(self): return self.is_type("exit")
|
||||
|
||||
@property
|
||||
def is_player(self): return self.is_type("player")
|
||||
|
||||
@property
|
||||
def is_program(self): return self.is_type("programI ho")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue