Ajout de la base

This commit is contained in:
barraux.a
2022-11-30 14:08:38 +01:00
parent 1649aaffb0
commit 01e1ebc453
2 changed files with 27 additions and 8 deletions
BIN
View File
Binary file not shown.
+27 -8
View File
@@ -2,6 +2,7 @@ import random
import cli import cli
import time import time
import getkey import getkey
import sqlite3
class Animation: class Animation:
""" class de gestion des animations du personnage""" """ class de gestion des animations du personnage"""
@@ -71,13 +72,29 @@ class Animation:
class Personnage(Animation): class Personnage(Animation):
"""Class de base du personnage""" """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.nom = nom
self.coef_attack = 1 self.coef_attack = 1
self.coef_defense = 1 self.coef_defense = 1
self.pdv = 20 self.pdv = data[1]
self.max_pdv = 20 self.max_pdv = data[3]
self.xp = xp self.xp = data[2]
self.inv = ['potion'for i in range(2)] self.inv = ['potion'for i in range(2)]
self.shape = ['', ''] self.shape = ['', '']
@@ -418,9 +435,11 @@ class App:
name = input('=>') name = input('=>')
self.setting(name, 0) self.setting(name, 0)
app = App() # app = App()
gui = cli.Cli(width=app.width, height=app.height) # 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)