diff --git a/data_persistance/data/answer.py b/data_persistance/data/answer.py index 4a7c58b..864373f 100644 --- a/data_persistance/data/answer.py +++ b/data_persistance/data/answer.py @@ -1,5 +1,44 @@ from tables import Answer ANSWERS = [ - + Answer(1,0,1,1), + Answer(2,0,1,2), + Answer(3,1,1,3), + Answer(4,1,1,4), + Answer(5,0,2,6), + Answer(6,0,2,7), + Answer(7,1,2,8), + Answer(8,1,2,9), + Answer(9,0,3,11), + Answer(10,0,3,12), + Answer(11,1,3,13), + Answer(12,1,3,14), + Answer(13,0,4,16), + Answer(14,0,4,17), + Answer(15,1,4,18), + Answer(16,1,4,19), + Answer(17,0,5,21), + Answer(18,0,5,22), + Answer(19,1,5,23), + Answer(20,1,5,24), + Answer(21,0,6,26), + Answer(22,0,6,27), + Answer(23,1,6,28), + Answer(24,1,6,29), + Answer(25,0,7,31), + Answer(26,0,7,32), + Answer(27,1,7,33), + Answer(28,1,7,34), + Answer(29,0,8,36), + Answer(30,0,8,37), + Answer(31,1,8,38), + Answer(32,1,8,39), + Answer(33,0,9,41), + Answer(34,0,9,42), + Answer(35,1,9,43), + Answer(36,1,9,44), + Answer(37,0,10,46), + Answer(38,0,10,47), + Answer(39,1,10,48), + Answer(40,1,10,49) ] \ No newline at end of file diff --git a/data_persistance/data/locales.py b/data_persistance/data/locales.py index 1ca2da1..7d72462 100644 --- a/data_persistance/data/locales.py +++ b/data_persistance/data/locales.py @@ -1,5 +1,82 @@ from tables import Locale LOCALES = [ - Locale(0,"EN", "Hello World"), + Locale(0,"FR","Le Médecin"), + Locale(1,"FR","Il y avait {SALLE} ça m'a intrigué."), + Locale(2,"FR","{SALLE} avait l'air sympa donc j'y suis allé."), + Locale(3,"FR","Il me semble qu'il y avait {NPC}."), + Locale(4,"FR","Je suis pratiquement sûr que j'étais avec {NPC}."), + Locale(5,"FR","Le Baron"), + Locale(6,"FR","{SALLE}"), + Locale(7,"FR","{SALLE}"), + Locale(8,"FR","{NPC}"), + Locale(9,"FR","{NPC}"), + Locale(10,"FR","Le Diplomate"), + Locale(11,"FR","Je profitais d'une collation dans {SALLE}."), + Locale(12,"FR","J'admirais la décoration subtile de {SALLE} ... je m'en inspirerais pour chez moi."), + Locale(13,"FR","Je m'instruisais auprès de {NPC}."), + Locale(14,"FR","Avec {NPC} pour exposer nos différents points de vus sur divers sujets."), + Locale(15,"FR","Le Combattant"), + Locale(16,"FR","{SALLE} nous a servi de salle de duel."), + Locale(17,"FR","J'ai festoillé dans {SALLE}."), + Locale(18,"FR","On faisait un bras de fer avec {NPC}."), + Locale(19,"FR","{NPC} et moi nous sommes engagés dans une joute verbale des plus palpitante."), + Locale(20,"FR","L'Artiste"), + Locale(21,"FR","J'ai surement piqué un somme dans {SALLE}."), + Locale(22,"FR","{SALLE} ... definitivement {SALLE}."), + Locale(23,"FR","Avec {NPC}, c'est vraiment une personne désopilante."), + Locale(24,"FR","{NPC} est assez souple vous savez ?"), + Locale(25,"FR","La Duchesse"), + Locale(26,"FR","Pour votre gouverne je me trouvais dans {SALLE}."), + Locale(27,"FR","s'il vous faut savoir ... j'étais en train de me reposer dans {SALLE}."), + Locale(28,"FR","{NPC} me tenait compagnie."), + Locale(29,"FR","J'était avec {NPC}."), + Locale(30,"FR","La Diva"), + Locale(31,"FR","{SALLE} me semblait être la plus belle pièce de la maison."), + Locale(32,"FR","Je buvais un verre dans {SALLE}."), + Locale(33,"FR","Je profitais de la compagnie de {NPC}."), + Locale(34,"FR","J'étais avec {NPC} à partager une délicieuse conversation ainsi qu'une coupe de champagne."), + Locale(35,"FR","La Parieuse"), + Locale(36,"FR","J'avis monté une table de jeu dans {SALLE}."), + Locale(37,"FR","{SALLE} est tout de même plus agréable une fois changé en casino."), + Locale(38,"FR","Vous saviez que {NPC} était incroyable avec des cartes à la mains?"), + Locale(39,"FR","Si vous tenez à votre argent ne jouez jamisa au poker avec {NPC}."), + Locale(40,"FR","L'Agent"), + Locale(41,"FR","On pouvait me retrouver dans {SALLE}."), + Locale(42,"FR","{SALLE}"), + Locale(43,"FR","J'étais avec {NPC} au moment des faits."), + Locale(44,"FR","{NPC}"), + Locale(45,"FR","La Voyageuse"), + Locale(46,"FR","{SALLE}"), + Locale(47,"FR","{SALLE}"), + Locale(48,"FR","{NPC}"), + Locale(49,"FR","{NPC}"), + Locale(100,"FR","Ce manoir est plutôt grand ... vous pouvez me dire où vous étiez?"), + Locale(101,"FR","Vous étiez où au moment des faits?"), + Locale(102,"FR","Dans quelle salle étiez vous?"), + Locale(105,"FR","-- Avec qui etiez vous?"), + Locale(120,"FR","méfiant"), + Locale(110,"FR","deffinir méfiant"), + Locale(121,"FR","surpris"), + Locale(111,"FR","deffinir surpris"), + Locale(122,"FR","chagrin"), + Locale(112,"FR","deffinir chagrin"), + Locale(123,"FR","rejouie"), + Locale(113,"FR","deffinir rejouie"), + Locale(124,"FR","menteur"), + Locale(114,"FR","deffinir menteur"), + Locale(125,"FR","honnête"), + Locale(115,"FR","deffinir honnête"), + Locale(126,"FR","géné"), + Locale(116,"FR","deffinir géné"), + Locale(127,"FR","défencif"), + Locale(117,"FR","deffinir défencif"), + Locale(128,"FR","ennuyé"), + Locale(118,"FR","deffinir ennuyé"), + Locale(130,"FR","Le salon"), + Locale(131,"FR","La salle de reception"), + Locale(132,"FR","Le hall d'entrée"), + Locale(133,"FR","La cuisine"), + Locale(134,"FR","La chambre du maitre"), + Locale(135,"FR","Le jarin") ] diff --git a/data_persistance/data/npc.py b/data_persistance/data/npc.py index e2ce341..e91958a 100644 --- a/data_persistance/data/npc.py +++ b/data_persistance/data/npc.py @@ -1,5 +1,14 @@ from tables import Npc NPCS = [ - + Npc(1,0), + Npc(2,5), + Npc(3,10), + Npc(4,15), + Npc(5,20), + Npc(6,25), + Npc(7,30), + Npc(8,35), + Npc(9,40), + Npc(10,45), ] \ No newline at end of file diff --git a/data_persistance/data/places.py b/data_persistance/data/places.py index 57b77fe..044e746 100644 --- a/data_persistance/data/places.py +++ b/data_persistance/data/places.py @@ -1,5 +1,10 @@ from tables import Place PLACES = [ - + Place(1,130), + Place(2,131), + Place(3,132), + Place(4,133), + Place(5,134), + Place(6,135) ] \ No newline at end of file diff --git a/data_persistance/data/questions.py b/data_persistance/data/questions.py index c6bfebc..6a40cd2 100644 --- a/data_persistance/data/questions.py +++ b/data_persistance/data/questions.py @@ -1,5 +1,8 @@ from tables import Question QUESTIONS = [ - + Question(1,0,100), + Question(2,0,101), + Question(3,0,102), + Question(4,1,105) ] \ No newline at end of file diff --git a/data_persistance/data/reactions.py b/data_persistance/data/reactions.py index 534be94..f518b76 100644 --- a/data_persistance/data/reactions.py +++ b/data_persistance/data/reactions.py @@ -1,5 +1,94 @@ from tables import Reaction REACTIONS = [ - + Reaction(1,110,1,1), + Reaction(2,110,2,1), + Reaction(3,110,3,1), + Reaction(4,110,4,1), + Reaction(5,110,5,1), + Reaction(6,110,6,1), + Reaction(7,110,7,1), + Reaction(8,110,8,1), + Reaction(9,110,9,1), + Reaction(10,110,10,1), + Reaction(11,111,1,2), + Reaction(12,111,2,2), + Reaction(13,111,3,2), + Reaction(14,111,4,2), + Reaction(15,111,5,2), + Reaction(16,111,6,2), + Reaction(17,111,7,2), + Reaction(18,111,8,2), + Reaction(19,111,9,2), + Reaction(20,111,10,2), + Reaction(21,112,1,3), + Reaction(22,112,2,3), + Reaction(23,112,3,3), + Reaction(24,112,4,3), + Reaction(25,112,5,3), + Reaction(26,112,6,3), + Reaction(27,112,7,3), + Reaction(28,112,8,3), + Reaction(29,112,9,3), + Reaction(30,112,10,3), + Reaction(31,113,1,4), + Reaction(32,113,2,4), + Reaction(33,113,3,4), + Reaction(34,113,4,4), + Reaction(35,113,5,4), + Reaction(36,113,6,4), + Reaction(37,113,7,4), + Reaction(38,113,8,4), + Reaction(39,113,9,4), + Reaction(40,113,10,4), + Reaction(41,114,1,5), + Reaction(42,114,2,5), + Reaction(43,114,3,5), + Reaction(44,114,4,5), + Reaction(45,114,5,5), + Reaction(46,114,6,5), + Reaction(47,114,7,5), + Reaction(48,114,8,5), + Reaction(49,114,9,5), + Reaction(50,114,10,5), + Reaction(51,115,1,6), + Reaction(52,115,2,6), + Reaction(53,115,3,6), + Reaction(54,115,4,6), + Reaction(55,115,5,6), + Reaction(56,115,6,6), + Reaction(57,115,7,6), + Reaction(58,115,8,6), + Reaction(59,115,9,6), + Reaction(60,115,10,6), + Reaction(61,116,1,7), + Reaction(62,116,2,7), + Reaction(63,116,3,7), + Reaction(64,116,4,7), + Reaction(65,116,5,7), + Reaction(66,116,6,7), + Reaction(67,116,7,7), + Reaction(68,116,8,7), + Reaction(69,116,9,7), + Reaction(70,116,10,7), + Reaction(71,117,1,8), + Reaction(72,117,2,8), + Reaction(73,117,3,8), + Reaction(74,117,4,8), + Reaction(75,117,5,8), + Reaction(76,117,6,8), + Reaction(77,117,7,8), + Reaction(78,117,8,8), + Reaction(79,117,9,8), + Reaction(80,117,10,8), + Reaction(81,118,1,9), + Reaction(82,118,2,9), + Reaction(83,118,3,9), + Reaction(84,118,4,9), + Reaction(85,118,5,9), + Reaction(86,118,6,9), + Reaction(87,118,7,9), + Reaction(88,118,8,9), + Reaction(89,118,9,9), + Reaction(90,118,10,9) ] \ No newline at end of file diff --git a/data_persistance/data/traits.py b/data_persistance/data/traits.py index 0eed597..2514932 100644 --- a/data_persistance/data/traits.py +++ b/data_persistance/data/traits.py @@ -1,5 +1,13 @@ from tables import Trait TRAITS = [ - + Trait(1,120), + Trait(2,121), + Trait(3,122), + Trait(4,123), + Trait(5,124), + Trait(6,125), + Trait(7,126), + Trait(8,127), + Trait(9,128) ] \ No newline at end of file diff --git a/data_persistance/remote.py b/data_persistance/remote.py index 54ee469..acf5fd4 100644 --- a/data_persistance/remote.py +++ b/data_persistance/remote.py @@ -27,50 +27,53 @@ engine = create_engine(url_object) # Reset data tables with Session(engine) as session: - - - session.execute("SELECT CONCAT('DROP TABLE IF EXISTS `', TABLE_SCHEMA, '`.`', TABLE_NAME, '`;') FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'mydb'") + Base.metadata.drop_all(engine) Base.metadata.create_all(engine) print("adding locales") for locale in LOCALES: print(locale) - session.add_all(LOCALES) + session.add(locale) + session.commit() print("adding places") for place in PLACES: print(place) - session.add_all(PLACES) + session.add(place) + session.commit() print("adding NPCS") for npc in NPCS: print(npc) - session.add_all(NPCS) + session.add(npc) + session.commit() print("adding trait") for trait in TRAITS: print(trait) - session.add_all(TRAITS) + session.add(trait) + session.commit() print("adding questions") for question in QUESTIONS: print(question) - session.add_all(QUESTIONS) + session.add(question) + session.commit() print("adding answers") for answer in ANSWERS: print(answer) - session.add_all(ANSWERS) + session.add(answer) + session.commit() print("adding reactions") - for reactions in REACTIONS: - print(reactions) - session.add_all(REACTIONS) - - session.commit() + for reaction in REACTIONS: + print(reaction) + session.add(reaction) + session.commit() \ No newline at end of file diff --git a/data_persistance/tables.py b/data_persistance/tables.py index a8ac5aa..26bebca 100644 --- a/data_persistance/tables.py +++ b/data_persistance/tables.py @@ -1,4 +1,4 @@ -from sqlalchemy import Column, Integer, Text, ForeignKey +from sqlalchemy import Column, Integer, Text, ForeignKey, VARCHAR from sqlalchemy.orm import declarative_base, relationship Base = declarative_base() @@ -7,17 +7,16 @@ Base = declarative_base() class Locale(Base): __tablename__ = 'T_LOCALE' TEXT_ID = Column(Integer, primary_key=True) - LANG = Column(Text) + LANG = Column(VARCHAR(2), primary_key=True) TEXT = Column(Text) def __init__(self, TEXT_ID, LANG, TEXT): - self.PLACE_ID = TEXT_ID + self.TEXT_ID = TEXT_ID self.LANG = LANG self.TEXT = TEXT def __str__(self): - return f"{self.PLACE_ID} {self.LANG} {self.TEXT}" - + return f"{self.TEXT_ID} {self.LANG} {self.TEXT}" class Place(Base): __tablename__ = 'T_PLACE' @@ -32,7 +31,6 @@ class Place(Base): def __str__(self): return f"{self.PLACE_ID} {self.NAME_LID}" - class Question(Base): __tablename__ = "T_QUESTION" QUESTION_ID = Column(Integer, primary_key=True) @@ -48,16 +46,17 @@ class Question(Base): def __str__(self): return f"{self.QUESTION_ID} {self.QUESTION_TYPE} {self.TEXT_LID}" - class Answer(Base): __tablename__ = "T_ANSWER" ANSWER_ID = Column(Integer, primary_key=True) QA_TYPE = Column(Integer) NPC_ID = Column(Integer, ForeignKey("T_NPC.NPC_ID")) TEXT_LID = Column(Integer, ForeignKey("T_LOCALE.TEXT_ID")) + LOCALE = relationship("Locale") + NPC = relationship("Npc") - def __init__(self, ANSWSER_ID, QA_TYPE, NPC_ID, TEXT_LID): - self.ANSWSER_ID = ANSWSER_ID + def __init__(self, ANSWER_ID, QA_TYPE, NPC_ID, TEXT_LID): + self.ANSWER_ID = ANSWER_ID self.QA_TYPE = QA_TYPE self.NPC_ID = NPC_ID self.TEXT_LID = TEXT_LID @@ -75,7 +74,7 @@ class Npc(Base): self.NAME_LID = NAME_LID def __str__(self) -> str: - return f"{self.NPC_ID} {self.NAME_LID}" + return f"{self.NPC_ID} {self.NAME_LID}" class Trait(Base): __tablename__ = "T_TRAIT" @@ -92,9 +91,12 @@ class Trait(Base): class Reaction(Base): __tablename__ = "T_REACTION" REACTION_ID = Column(Integer, primary_key=True) + NPC_ID = Column(Integer, ForeignKey("T_NPC.NPC_ID"),primary_key=True) + TRAIT_ID = Column(Integer, ForeignKey("T_TRAIT.TRAIT_ID"),primary_key=True) DESC_LID = Column(Integer, ForeignKey("T_LOCALE.TEXT_ID")) - NPC_ID = Column(Integer, ForeignKey("T_NPC.NPC_ID")) - TRAIT_ID = Column(Integer, ForeignKey("T_TRAIT.TRAIT_ID")) + LOCALE = relationship("Locale") + NPC = relationship("Npc") + TRAIT = relationship("Trait") def __init__(self, REACTION_ID, DESC_LID, NPC_ID, TRAIT_ID): self.REACTION_ID = REACTION_ID @@ -103,4 +105,4 @@ class Reaction(Base): self.TRAIT_ID = TRAIT_ID def __str__(self) -> str: - return f"{self.REACTION_ID} {self.DESC_LID} {self.NPC_ID} {self.TRAIT_ID}" \ No newline at end of file + return f"{self.REACTION_ID} {self.DESC_LID} {self.NPC_ID} {self.TRAIT_ID}"