fixed code to use new model
This commit is contained in:
parent
278ed41630
commit
51edb750ce
@ -49,7 +49,7 @@ def get_npc_random_answer(npc_id:int, qa_type:int) -> Answer :
|
|||||||
:param qa_type: the type of the question
|
:param qa_type: the type of the question
|
||||||
:return: an Answer object
|
: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)
|
return random.choice(answers)
|
||||||
|
|
||||||
def get_random_question(qa_type: int) -> QuestionType :
|
def get_random_question(qa_type: int) -> QuestionType :
|
||||||
|
@ -78,7 +78,7 @@ class QuestionType(Base):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
__tablename__ = "T_QUESTION_TYPE"
|
__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")
|
TEXT_LID = Column(Integer, ForeignKey("T_LOCALE.LID"), comment="Question text")
|
||||||
LOCALE = relationship("Locale")
|
LOCALE = relationship("Locale")
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ class Answer(Base):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
__tablename__ = "T_ANSWER"
|
__tablename__ = "T_ANSWER"
|
||||||
QUESTION_TYPE_ID = Column(Integer, ForeignKey("T_QUESTION_TYPE.QUESTION_TYPE_ID"), primary_key=True, comment="Question type ID")
|
QUESTION_TYPE_ID = Column(Integer,ForeignKey("T_QUESTION_TYPE.QUESTION_TYPE_ID"),primary_key=True, comment="Question type ID")
|
||||||
NPC_ID = Column(Integer, ForeignKey("T_NPC.NPC_ID"), primary_key=True, comment="ID of the NPC that will say this answer")
|
NPC_ID = Column(Integer, ForeignKey("T_NPC.NPC_ID"), primary_key=True, comment="ID of the NPC that will say this answer")
|
||||||
TEXT_LID = Column(Integer, ForeignKey("T_LOCALE.LID"), comment="Text of the answer")
|
TEXT_LID = Column(Integer, ForeignKey("T_LOCALE.LID"), comment="Text of the answer")
|
||||||
LOCALE = relationship("Locale")
|
LOCALE = relationship("Locale")
|
||||||
@ -125,7 +125,7 @@ class Npc(Base):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
__tablename__ = "T_NPC"
|
__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")
|
NAME_LID = Column(Integer, ForeignKey("T_LOCALE.LID"), comment="Name of this Npc")
|
||||||
LOCALE = relationship("Locale")
|
LOCALE = relationship("Locale")
|
||||||
|
|
||||||
@ -153,15 +153,13 @@ class Trait(Base):
|
|||||||
Desc = relationship("Locale",foreign_keys=[DESC_LID])
|
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.TRAIT_ID = TRAIT_ID
|
||||||
self.NAME_LID = NAME_LID
|
self.NAME_LID = NAME_LID
|
||||||
|
self.DESC_LID = DESC_LID
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return f"Trait(TRAIT_ID={self.TRAIT_ID}, NAME_LID={self.NAME_LID})"
|
return f"{self.TRAIT_ID} {self.NAME_LID}"
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
|
||||||
return self.__str__()
|
|
||||||
|
|
||||||
|
|
||||||
class Reaction(Base):
|
class Reaction(Base):
|
||||||
|
Loading…
Reference in New Issue
Block a user