diff --git a/bdd.db b/bdd.db new file mode 100644 index 0000000..092caf4 Binary files /dev/null and b/bdd.db differ diff --git a/main.py b/main.py index f9b083b..389030e 100644 --- a/main.py +++ b/main.py @@ -2,6 +2,7 @@ import random import cli import time import getkey +import sqlite3 class Animation: """ class de gestion des animations du personnage""" @@ -71,13 +72,29 @@ class Animation: class Personnage(Animation): """Class de base du personnage""" - def __init__(self, nom, x, y, xp): + def __init__(self, nom, x, y, categorie, xp=1): + + conn = sqlite3.connect('bdd.db') + c = conn.cursor() + c.execute("SELECT * from Personnage join Categorie on Personnage.categorie=Categorie.name join Profil on Categorie.profil=Profil.name where name = ?", (nom,)) + data = c.fetchone() + print(data) + if data is None: + c.execute("insert into Personnage(name, pdv, xp, max_pdv, categorie) Values(?, ?, ?, ?, ?) ", (nom, "20", str(xp), "20", categorie)) + conn.commit() + c.execute("SELECT * from Personnage join Categorie on Personnage.categorie=Categorie.name join Profil on Categorie.profil=Profil.name where name = ?", (nom,)) + data = c.fetchone() + + conn.close() + data = data[0] + print(data) + self.nom = nom self.coef_attack = 1 self.coef_defense = 1 - self.pdv = 20 - self.max_pdv = 20 - self.xp = xp + self.pdv = data[1] + self.max_pdv = data[3] + self.xp = data[2] self.inv = ['potion'for i in range(2)] self.shape = ['', ''] @@ -418,9 +435,11 @@ class App: name = input('=>') self.setting(name, 0) -app = App() -gui = cli.Cli(width=app.width, height=app.height) +# app = App() +# gui = cli.Cli(width=app.width, height=app.height) + +# app.menu() -app.menu() +# # guerrier.move(-10, 0) -# guerrier.move(-10, 0) +Personnage('Georges', 0, 0, "guerrier", 1)