fixed code to use new model

This commit is contained in:
Djalim Simaila 2023-03-14 19:00:14 +01:00
parent 278ed41630
commit 51edb750ce
2 changed files with 7 additions and 9 deletions

View File

@ -49,7 +49,7 @@ def get_npc_random_answer(npc_id:int, qa_type:int) -> Answer :
:param qa_type: the type of the question
:return: an Answer object
"""
answers = db.session.query(Answer).filter_by(QA_TYPE=qa_type,NPC_ID=npc_id.NPC_ID).all()
answers = db.session.query(Answer).filter_by(QUESTION_TYPE_ID=qa_type,NPC_ID=npc_id.NPC_ID).all()
return random.choice(answers)
def get_random_question(qa_type: int) -> QuestionType :

View File

@ -78,7 +78,7 @@ class QuestionType(Base):
"""
__tablename__ = "T_QUESTION_TYPE"
QUESTION_TYPE_ID = Column(Integer, primary_key=True, comment="ID of this question type.")
QUESTION_TYPE_ID = Column(Integer, default=0, primary_key=True, comment="ID of this question type.")
TEXT_LID = Column(Integer, ForeignKey("T_LOCALE.LID"), comment="Question text")
LOCALE = relationship("Locale")
@ -125,7 +125,7 @@ class Npc(Base):
"""
__tablename__ = "T_NPC"
NPC_ID = Column(Integer, primary_key=True, comment="ID of this Npc")
NPC_ID = Column(Integer, autoincrement=True, primary_key=True, comment="ID of this Npc")
NAME_LID = Column(Integer, ForeignKey("T_LOCALE.LID"), comment="Name of this Npc")
LOCALE = relationship("Locale")
@ -153,15 +153,13 @@ class Trait(Base):
Desc = relationship("Locale",foreign_keys=[DESC_LID])
def __init__(self, TRAIT_ID, NAME_LID):
def __init__(self, TRAIT_ID, NAME_LID, DESC_LID):
self.TRAIT_ID = TRAIT_ID
self.NAME_LID = NAME_LID
self.DESC_LID = DESC_LID
def __str__(self) -> str:
return f"Trait(TRAIT_ID={self.TRAIT_ID}, NAME_LID={self.NAME_LID})"
def __repr__(self) -> str:
return self.__str__()
return f"{self.TRAIT_ID} {self.NAME_LID}"
class Reaction(Base):