Browse Source

Ajout de la base

sql_version
BARRAUX Arthur 2 years ago
parent
commit
01e1ebc453
  1. BIN
      bdd.db
  2. 35
      main.py

BIN
bdd.db

Binary file not shown.

35
main.py

@ -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)

Loading…
Cancel
Save