Compare commits

...

4 Commits

  1. BIN
      bdd.db
  2. 10
      cli.py
  3. BIN
      getkey/__pycache__/__init__.cpython-38.pyc
  4. BIN
      getkey/__pycache__/keynames.cpython-38.pyc
  5. BIN
      getkey/__pycache__/platforms.cpython-38.pyc
  6. BIN
      getkey/__pycache__/unikeys.cpython-38.pyc
  7. 235
      main.py

BIN
bdd.db

Binary file not shown.

10
cli.py

@ -1,6 +1,7 @@
import os import os
import platform import platform
import shutil import shutil
import time
""" ANSI color codes """ """ ANSI color codes """
@ -131,3 +132,12 @@ class Layer():
self.cli.screen[self.y+i][self.x+j] = ' ' self.cli.screen[self.y+i][self.x+j] = ' '
except: except:
pass pass
if __name__ == '__main__':
"""Exemple d'affichage de Hello World"""
gui = Cli()
gui.draw("Hello World", 10, 5, color="YELLOW")
time.sleep(1)
Layer(15, 5, ["World"]).refresh()
gui.display()

BIN
getkey/__pycache__/__init__.cpython-38.pyc

Binary file not shown.

BIN
getkey/__pycache__/keynames.cpython-38.pyc

Binary file not shown.

BIN
getkey/__pycache__/platforms.cpython-38.pyc

Binary file not shown.

BIN
getkey/__pycache__/unikeys.cpython-38.pyc

Binary file not shown.

235
main.py

@ -1,7 +1,14 @@
"""
C'est joli, mais il y aurait moyen de factoriser pas mal de choses!
Note : 10 / 10
"""
import random 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,16 +78,53 @@ 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, bot=False):
self.bot = bot
if not self.bot:
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 Personnage.name = ?", (nom,))
data = c.fetchone()
if data is None:
c.execute("insert into Personnage(name, pdv, xp, max_pdv, potion, categorie) Values(?, ?, ?, ?, ?, ?) ", (nom, "20", str(xp), "20", "2", categorie))
conn.commit()
c.execute("SELECT * from Personnage join Categorie on Personnage.categorie=Categorie.name join Profil on Categorie.profil=Profil.name where Personnage.name = ?", (nom,))
data = c.fetchone()
conn.close()
# Affectation du résultat de la requête aux attributs correspondants
self.nom = nom
self.pdv = data[1]
self.xp = data[2]
self.max_pdv = data[3]
self.weapon = data[7]
self.coef_attack = data[8]
self.coef_defense = data[9]
self.class_name = data[11].split('\n')
self.shape = [data[13].replace('%', '\n'), data[14].replace('%', '\n')]
self.potion = data[5]
else:
# récupération des attributs de la catégorie
conn = sqlite3.connect('bdd.db')
c = conn.cursor()
c.execute("SELECT * from Categorie join Profil on Categorie.profil=Profil.name where Categorie.name = ?", (categorie,))
data = c.fetchone()
conn.close()
self.nom = nom self.nom = nom
self.coef_attack = 1
self.coef_defense = 1
self.pdv = 20 self.pdv = 20
self.max_pdv = 20
self.xp = xp self.xp = xp
self.inv = ['potion'for i in range(2)] self.max_pdv = 20
self.weapon = data[1]
self.coef_attack = data[2]
self.coef_defense = data[3]
self.class_name = data[5].split('\n')
self.shape = [data[7].replace('%', '\n'), data[8].replace('%', '\n')]
self.potion = 2
self.shape = ['', '']
self.x = x self.x = x
self.y = y self.y = y
super().__init__(self.x, self.y, self.shape) super().__init__(self.x, self.y, self.shape)
@ -93,81 +137,49 @@ class Personnage(Animation):
def change_xp(self, nb_xp): def change_xp(self, nb_xp):
self.xp += nb_xp self.xp += nb_xp
if not self.bot:
conn = sqlite3.connect('bdd.db')
c = conn.cursor()
c.execute("UPDATE Personnage SET xp=? where name=?", (self.xp, self.nom))
conn.commit()
c.close()
def change_pdv(self, nb_pdv): def change_pdv(self, nb_pdv):
self.pdv += nb_pdv self.pdv += nb_pdv
if not self.bot:
conn = sqlite3.connect('bdd.db')
class Guerrier(Personnage): c = conn.cursor()
c.execute("UPDATE Personnage SET pdv=? where name=?", (self.pdv, self.nom))
def __init__(self, nom, x, y, xp=1): conn.commit()
super().__init__(nom, x, y, xp) c.close()
self.weapon = "épée" def change_max_pdv(self, pdv):
self.class_name = """ ██████ ██ ██ ███████ ██████ ██████ ██ ███████ ██████ self.max_pdv = pdv
if not self.bot:
conn = sqlite3.connect('bdd.db')
c = conn.cursor()
""".split('\n') c.execute("UPDATE Personnage SET max_pdv=? where name=?", (self.max_pdv, self.nom))
self.coef_attack = 10 conn.commit()
self.coef_defense = 8 c.close()
self.inv.append(self.weapon)
self.shape = ["""⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⡤⠤⢶⣒⠢⢤⣤⡀⠀⠀⠀⠀⠀⠀⠀⣴⠛⡆\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡟⠁⠀⠀⢰⠛⠛⢶⣤⠟⠀⠀⠀⠀⠀⠀⢸⡏⠀⢹\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⡎⠀⠀⣀⣠⣞⣀⡔⠉⠀⠀⠀⠀⠀⠀⠀⠀⠸⣇⠀⡸\n⠀⠀⠀⠀⠀⢀⣀⣠⣤⣇⣴⢊⡵⠶⣵⣲⢧⣀⡀⠀⠀⠀⠀⠀⠀⠀⢠⣾⣿⣶\n⠀⠀⠀⠀⡠⠊⠉⠉⠑⢌⠻⡏⠀⡀⠈⠁⢀⡏⠙⢦⡀⠀⠀⠀⠀⠀⠈⣿⠉⡇\n⠀⠀⢠⡖⢅⠀⠀⠀⠀⡸⠀⡇⠀⠈⢹⢸⠁⣏⢢⣸⢷⠀⠀⠀⠀⠀⠀⣿⠀⡇\n⠀⠀⡾⠳⣤⣙⠲⢶⡴⠃⣾⠋⠲⢦⣼⣿⡴⠃⢧⣷⣧⢗⡶⠲⢦⣤⠶⠻⡶⡷\n⠀⢐⡶⢂⠀⠉⠙⢢⢄⡰⠁⠀⠀⠀⢸⣇⠀⠀⣜⣁⠁⡏⠀⠀⠀⠘⢴⣶⠤⢟\n⠀⡟⠐⣾⢄⡀⢀⢎⡀⡏⠓⠦⠒⣉⠡⠌⢉⠏⠁⠙⠦⣱⡀⢀⣠⠜⢼⣷⠭⡝\n⢀⣿⡿⠷⢦⣼⡏⢠⡿⣍⣛⣫⣭⣤⣤⣤⡾⡄⠀⠀⠀⠀⠈⠉⠀⠀⠀⣿⠉⡇\n⢇⠀⠀⠀⠀⢸⠃⢨⣏⣀⠀⢈⠑⢄⣠⣾⠳⡃⠀⠀⠀⠀⠀⠀⠀⠀⠀⣻⠀⡇\n⠀⣷⠀⠀⠀⠣⡀⣨⠋⠀⠻⣮⢦⠀⢹⢯⠀⢱⡀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⡇\n⠀⡇⠀⢀⠈⣞⡿⣇⡴⠶⣄⡼⢻⣠⣟⢈⣳⠋⢹⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⡇\n⠀⠻⢿⣷⣑⣌⡿⡸⣀⢀⣿⡇⠀⣀⠼⣽⢇⣀⠎⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⡇\n⠀⠀⠀⠀⠀⠀⠀⢧⠈⠋⣼⠇⠀⣳⣸⠃⡼⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⡇\n⠀⠀⠀⠀⠀⠀⠀⢏⡤⠤⣽⠇⠀⡿⣿⣻⣷⢄⣀⡀⠀⠀⠀⠀⠀⠀⠀⣿⠀⡇\n⠀⠀⠀⠀⠀⠀⢰⡟⠛⣽⢿⡇⠀⢱⣾⣿⣷⣷⣿⣿⡄⠀⠀⠀⠀⠀⠀⣿⣀⡇\n⠀⠀⠀⠀⠀⠀⠘⠿⣿⣭⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠀""", def add_potion(self):
"""⡆⠛⣴⠀⠀⠀⠀⠀⠀⠀⡀⣤⢤⠢⣒⢶⠤⡤⣠⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⢹⠀⡏⢸⠀⠀⠀⠀⠀⠀⠟⣤⢶⠛⠛⢰⠀⠀⠁⡟⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⡸⠀⣇⠸⠀⠀⠀⠀⠀⠀⠀⠀⠉⡔⣀⣞⣠⣀⠀⠀⡎⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⣶⣿⣾⢠⠀⠀⠀⠀⠀⠀⠀⡀⣀⢧⣲⣵⠶⡵⢊⣴⣇⣤⣠⣀⢀⠀⠀⠀⠀⠀\n⡇⠉⣿⠈⠀⠀⠀⠀⠀⡀⢦⠙⡏⢀⠁⠈⡀⠀⡏⠻⢌⠑⠉⠉⠊⡠⠀⠀⠀⠀\n⡇⠀⣿⠀⠀⠀⠀⠀⠀⢷⣸⢢⣏⠁⢸⢹⠈⠀⡇⠀⡸⠀⠀⠀⠀⢅⡖⢠⠀⠀\n⡷⡶⠻⠶⣤⢦⠲⡶⢗⣧⣷⢧⠃⡴⣿⣼⢦⠲⠋⣾⠃⡴⢶⠲⣙⣤⠳⡾⠀⠀\n⢟⠤⣶⢴⠘⠀⠀⠀⡏⠁⣁⣜⠀⠀⣇⢸⠀⠀⠀⠁⡰⢄⢢⠙⠉⠀⢂⡶⢐⠀\n⡝⠭⣷⢼⠜⣠⢀⡀⣱⠦⠙⠁⠏⢉⠌⠡⣉⠒⠦⠓⡏⡀⢎⢀⡀⢄⣾⠐⡟⠀\n⡇⠉⣿⠀⠀⠀⠉⠈⠀⠀⠀⠀⡄⡾⣤⣤⣤⣭⣫⣛⣍⡿⢠⡏⣼⢦⠷⡿⣿⢀\n⡇⠀⣻⠀⠀⠀⠀⠀⠀⠀⠀⠀⡃⠳⣾⣠⢄⠑⢈⠀⣀⣏⢨⠃⢸⠀⠀⠀⠀⢇\n⡇⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⡀⢱⠀⢯⢹⠀⢦⣮⠻⠀⠋⣨⡀⠣⠀⠀⠀⣷⠀\n⡇⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⢹⠋⣳⢈⣟⣠⢻⡼⣄⠶⡴⣇⡿⣞⠈⢀⠀⡇⠀\n⡇⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠎⣀⢇⣽⠼⣀⠀⡇⣿⢀⣀⡸⡿⣌⣑⣷⢿⠻⠀\n⡇⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⡼⠃⣸⣳⠀⠇⣼⠋⠈⢧⠀⠀⠀⠀⠀⠀⠀\n⡇⠀⣿⠀⠀⠀⠀⠀⠀⠀⡀⣀⢄⣷⣻⣿⡿⠀⠇⣽⠤⡤⢏⠀⠀⠀⠀⠀⠀⠀\n⡇⣀⣿⠀⠀⠀⠀⠀⠀⡄⣿⣿⣷⣷⣿⣾⢱⠀⡇⢿⣽⠛⡟⢰⠀⠀⠀⠀⠀⠀\n⠀⠉⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠃⣿⣭⣿⠿⠘⠀⠀⠀"""] """ Ajoute une potion à l'invetaire et à la base de donnée"""
self.potion += 1
if not self.bot:
class Voleur(Personnage): conn = sqlite3.connect('bdd.db')
c = conn.cursor()
def __init__(self, nom, x, y, xp=1): c.execute("UPDATE Personnage SET potion=? WHERE name=?", (self.potion, self.nom))
super().__init__(nom, x, y, xp) c.close()
self.coef_attack = 3 def remove_potion(self):
self.class_name = """██ ██ ██████ ██ ███████ ██ ██ ██████ """ Enlève une potion à l'invetaire et à la base de donnée"""
self.potion -= 1
if not self.bot:
conn = sqlite3.connect('bdd.db')
""".split('\n') c = conn.cursor()
self.coef_defense = 9 c.execute("UPDATE Personnage SET potion=? WHERE name=?", (self.potion, self.nom))
self.weapon = "dague" conn.commit()
self.inv.append(self.weapon) c.close()
self.shape = ["""⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡤⠦⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡎⣀⣠⣤⠭⢶⡄⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠟⢉⣕⣒⣒⣪⢹⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⢤⣣⠥⢔⡪⠤⣻⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⡈⢎⠒⠁⠈⢒⠎⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⢀⠔⠒⠉⠉⠀⠀⣈⢱⡣⢄⣠⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⢀⠇⠀⠀⠀⠀⠀⡜⢀⠏⠈⡆⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠘⡄⠀⠀⠀⠀⡜⠊⢁⠗⠊⠁⢠⢣⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠑⠢⣀⡠⡞⠤⠒⠁⠀⠀⢠⠣⡀⠱⡀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⡸⠑⠢⠤⣀⣀⣀⠎⠀⠑⢄⢈⠦⣀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⢠⠃⠀⠀⠀⠀⠀⠘⢄⠀⠀⠀⠹⣐⡤⢭⣢⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⡸⠉⠉⠢⡀⠀⠑⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⡎⠀⢰⠁⠀⠀⠀⠈⢢⠀⠘⡄⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⢰⠁⠀⡜⠀⠀⠀⠀⠀⢸⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⢸⠀⠀⡇⠀⠀⠀⠀⠀⢸⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⡸⡄⣀⡇⠀⠀⠀⠀⠀⡸⠒⠲⠃⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠙⣎⢹⣁⠀⠀⠀⠀⠀⠙⣆⢸⣀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠈⠶⠿⠀⠀⠀⠀⠀⠀⠈⠶⠿⠀""",
"""⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⠦⡤⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⡄⢶⠭⣤⣠⣀⡎⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⢹⣪⣒⣒⣕⢉⠟⢠⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⣻⠤⡪⢔⠥⣣⢤⠘⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠎⢒⠈⠁⠒⢎⡈⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠃⣠⢄⡣⢱⣈⠀⠀⠉⠉⠒⠔⢀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⡆⠈⠏⢀⡜⠀⠀⠀⠀⠀⠇⢀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⢣⢠⠁⠊⠗⢁⠊⡜⠀⠀⠀⠀⡄⠘⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⡀⠱⡀⠣⢠⠀⠀⠁⠒⠤⡞⡠⣀⠢⠑⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⣀⠦⢈⢄⠑⠀⠎⣀⣀⣀⠤⠢⠑⡸⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⣢⢭⡤⣐⠹⠀⠀⠀⢄⠘⠀⠀⠀⠀⠀⠃⢠⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⡄⠑⠀⡀⠢⠉⠉⡸⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⡄⠘⠀⢢⠈⠀⠀⠀⠁⢰⠀⡎⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⢸⠀⠀⠀⠀⠀⡜⠀⠁⢰⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⢸⠀⠀⠀⠀⠀⡇⠀⠀⢸⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠃⠲⠒⡸⠀⠀⠀⠀⠀⡇⣀⡄⡸⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⣀⢸⣆⠙⠀⠀⠀⠀⠀⣁⢹⣎⠙⠀⠀⠀⠀⠀⠀\n ⠀⠿⠶⠈⠀⠀⠀⠀⠀⠀⠿⠶⠈⠀⠀"""]
class Magicien(Personnage):
def __init__(self, nom, x, y, xp=1):
super().__init__(nom, x, y, xp)
self.coef_attack = 10
self.class_name = """███ ███ █████ ██████ ██ ██████ ██ ███████ ███ ██
""".split('\n')
self.coef_defense = 7
self.weapon = "bâton"
self.inv.append(self.weapon)
self.shape = ["""⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡄⣤⣤⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡄⢣⠀⣤⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⡏⠉⠀⠀⡸⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡆⠁⣀⠶⠶⠷⡸⢀⠀⠀⠀⠀⠀⠀⠀⠀\n⣀⠲⢦⠶⡰⢀⠀⠀⠀⠀⠀⡅⠀⣁⠖⠶⠶⠷⠾⠶⠔⢀⠀⠀⠀⠀⠀\n⣿⠀⠂⠐⠃⡜⠀⠀⠀⠀⡄⣧⠒⠀⠀⣤⠀⡤⣤⠀⣤⠘⠀⠀⠀⠀⠀\n⠀⠛⠛⡜⢠⡇⠀⠀⠀⡇⢸⠀⡄⣤⠛⢸⠀⡆⡿⠛⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠃⠜⣛⠤⣀⠀⠃⠛⡛⠤⣀⣀⣀⣀⢇⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠉⠶⣉⠰⣀⢆⠁⠀⠿⢉⠉⡏⢾⣀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠉⡱⢏⡸⠀⠀⠀⠸⠀⡇⢸⠉⠦⠶⠶⡢⠶⠶⣶\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⡄⢢⡔⠂⠒⣤⢸⠀⠇⢸⠀⠀⠀⠀⠀⡆⠂⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⢸⠃⡄⣤⠛⢠⠀⡃⢠⣿⠛⠘⢠⠀⡇⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡅⢘⠀⠀⣟⠢⠜⠠⠄⣿⠀⠀⠜⠠⠇⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⢸⠀⠀⣿⣁⣎⣱⢎⣿⠀⠀⠀⠁⠈⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⢸⠀⠀⣿⣉⣏⣹⣎⣉⠶⢀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⢢⠑⠈⠀⠀⣿⠉⠋⠟⢹⠉⠒⣨⡔⢠⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠃⠛⠛⠛⠛⠛⠛⠛⠚⠋⠛⠛⠀⠛⠘""",
"""⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣤⣤⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⣤⠀⢣⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡸⠀⠀⠉⡏⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⢀⡸⠷⠶⠶⣀⠁⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⢀⠔⠶⠾⠷⠶⠶⠖⣁⠀⡅⠀⠀⠀⠀⠀⢀⡰⠶⢦⠲⣀\n⠀⠀⠀⠀⠀⠘⣤⠀⣤⡤⠀⣤⠀⠀⠒⣧⡄⠀⠀⠀⠀⡜⠃⠐⠂⠀⣿\n⠀⠀⠀⠀⠀⠀⠀⠛⡿⡆⠀⢸⠛⣤⡄⠀⢸⡇⠀⠀⠀⡇⢠⡜⠛⠛⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⢇⣀⣀⣀⣀⠤⡛⠛⠃⠀⣀⠤⣛⠜⠃⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⣀⢾⡏⠉⢉⠿⠀⠁⢆⣀⠰⣉⠶⠉⠀⠀⠀⠀⠀⠀\n⣶⠶⠶⡢⠶⠶⠦⠉⢸⡇⠀⠸⠀⠀⠀⡸⢏⡱⠉⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠂⡆⠀⠀⠀⠀⠀⢸⠇⠀⢸⣤⠒⠂⡔⢢⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⡇⠀⢠⠘⠛⣿⢠⡃⠀⢠⠛⣤⡄⠃⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠇⠠⠜⠀⠀⣿⠄⠠⠜⠢⣟⠀⠀⢘⡅⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠈⠁⠀⠀⠀⣿⢎⣱⣎⣁⣿⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⢀⠶⣉⣎⣹⣏⣉⣿⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⢠⡔⣨⠒⠉⢹⠟⠋⠉⣿⠀⠀⠈⠑⢢⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠘⠛⠀⠛⠛⠋⠚⠛⠛⠛⠛⠛⠛⠛⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀"""]
class Elfe(Personnage):
def __init__(self, nom, x, y, xp=1):
super().__init__(nom, x, y, xp)
self.coef_attack = 8
self.class_name = """███████ ██ ███████ ███████
""".split('\n')
self.coef_defense = 10
self.weapon = "arc"
self.inv.append(self.weapon)
self.shape = ["""⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠎⠢⡀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠌⠀⠀⠙⣀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⢀⡀⢀⠀⠀⠀⠀⠀⠌⠀⠀⠀⠀⠐⡥⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⡠⢠⠁⢀⢀⢃⡀⠀⠀⠌⠀⠀⠀⠀⠀⠀⠐⡡⠀⠀⠀⠀\n⠀⡀⠄⠒⠈⠀⢠⠐⢫⠙⠼⠃⠀⡜⠀⠀⠀⠀⠀⠀⠀⠀⢁⢃⠀⠀⠀\n⡸⠮⡀⠄⣠⠀⠤⢐⡙⢵⢚⣵⣜⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠘⠀⠀⠀\n⠀⠀⠀⢈⡠⠐⢈⡡⢅⡤⠚⠸⣄⣍⣀⣐⣶⣶⣶⣶⡶⠤⡎⡕⣷⣀⠤\n⠀⠀⠀⠧⠀⠀⠨⠥⠌⠒⠮⠹⢸⠘⡀⠀⠀⠀⠀⠀⠀⠀⠈⡏⠃⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠀⠉⠳⡇⠀⠀⠀⠀⠀⠀⠀⢀⢰⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣃⣰⣶⡊⢄⠀⠀⠀⠀⠀⠀⠘⠆⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠜⠀⢀⣤⣈⠄⠢⡀⠀⠀⠀⢀⡛⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡟⣹⡿⣿⡋⠀⠀⠐⢄⠀⠀⡜⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⣌⡺⠟⠀⡇⡄⠀⠀⠀⠈⠢⠜⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⠏⠀⠀⠇⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⣰⡿⠃⠀⠀⢠⣰⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⣰⡟⠁⠀⠀⠀⢸⡅⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⢀⡾⠏⠀⠀⠀⠀⠠⣾⠅⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⡀⠀⡐⠉⡼⠀⢀⠀⠀⠀⠰⣋⢒⡤⢰⡀⡀""",
"""⠀⠀⠀⠀⠀⠀⠀⡀⠢⠎⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⣀⠙⠀⠀⠌⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⡥⠐⠀⠀⠀⠀⠌⠀⠀⠀⠀⠀⢀⡀⢀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⡡⠐⠀⠀⠀⠀⠀⠀⠌⠀⠀⡀⢃⢀⢀⠁⢠⡠⠀⠀⠀⠀⠀\n⠀⠀⠀⢃⢁⠀⠀⠀⠀⠀⠀⠀⠀⡜⠀⠃⠼⠙⢫⠐⢠⠀⠈⠒⠄⡀⠀\n⠀⠀⠀⠘⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⣜⣵⢚⢵⡙⢐⠤⠀⣠⠄⡀⠮⡸\n⠤⣀⣷⡕⡎⠤⡶⣶⣶⣶⣶⣐⣀⣍⣄⠸⠚⡤⢅⡡⢈⠐⡠⢈⠀⠀⠀\n⠀⠀⠃⡏⠈⠀⠀⠀⠀⠀⠀⠀⡀⠘⢸⠹⠮⠒⠌⠥⠨⠀⠀⠧⠀⠀⠀\n⠀⠀⠀⢰⢀⠀⠀⠀⠀⠀⠀⠀⡇⠳⠉⠀⠘⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠆⠘⠀⠀⠀⠀⠀⠀⢄⡊⣶⣰⣃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⡛⢀⠀⠀⠀⡀⠢⠄⣈⣤⢀⠀⠜⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⡜⠀⠀⢄⠐⠀⠀⡋⣿⡿⣹⡟⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠜⠢⠈⠀⠀⠀⡄⡇⠀⠟⡺⣌⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠇⠇⠀⠀⠏⣿⣸⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⢠⠀⠀⠃⡿⣰⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡅⢸⠀⠀⠀⠁⡟⣰⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠅⣾⠠⠀⠀⠀⠀⠏⡾⢀⠀⠀⠀⠀\n ⡀⡀⢰⡤⢒⣋⠰⠀⠀⠀⢀⠀⡼⠉⡐⠀⡀⠀"""]
class App: class App:
@ -186,9 +198,9 @@ class App:
:,' `-.' `: :,' `-.' `:
| | | |
: ; : ;
\ / \\ /
`.___.' """.split('\n') `.___.' """.split('\n')
self.opponent = [Guerrier("Guerrier", 80, 45), Voleur("Voleur", 80, 45), Magicien("Magicien", 80, 45), Elfe("Elfe", 80, 45)] self.opponent = [Personnage("Guerrier", 80, 45, "guerrier", 1, True), Personnage("Voleur", 80, 45, "voleur", 1, True), Personnage("Magicien", 80, 45, "magicien", 1, True), Personnage("Elfe", 80, 45, "elfe", 1, True)]
self.title = """ ██ ███████ ██ ██ ██████ ███████ ██████ ██████ ██ ███████ self.title = """ ██ ███████ ██ ██ ██████ ███████ ██████ ██████ ██ ███████
@ -235,14 +247,14 @@ class App:
gui.draw(''.join(['+'+''.join(['-' for j in range(29)]) for k in range(4)]), 0, 1+i) gui.draw(''.join(['+'+''.join(['-' for j in range(29)]) for k in range(4)]), 0, 1+i)
else: else:
gui.draw(''.join(['|'+''.join([' ' for j in range(29)]) for k in range(4)]), 0, 1+i) gui.draw(''.join(['|'+''.join([' ' for j in range(29)]) for k in range(4)]), 0, 1+i)
for j in range(self.character.inv.count('potion')): for j in range(self.character.potion):
x = j % 4 x = j % 4
y = j // 4 y = j // 4
if [x, y] == position: if [x, y] == position:
color_fill = 'YELLOW' color_fill = 'YELLOW'
else: else:
color_fill = 'WHITE' color_fill = 'WHITE'
gui.draw('Eau de vie', 30*x+10, 17*y+2, color=color_fill) gui.draw('Cidre fermier', 30*x+10, 17*y+2, color=color_fill)
for i in range(len(self.potion_shape)): for i in range(len(self.potion_shape)):
gui.draw(self.potion_shape[i], 30*x+6, 17*y+3+i, color=color_fill) gui.draw(self.potion_shape[i], 30*x+6, 17*y+3+i, color=color_fill)
gui.display() gui.display()
@ -257,15 +269,16 @@ class App:
if self.opponent[ennemi].pdv <= 0: if self.opponent[ennemi].pdv <= 0:
self.opponent[ennemi].move(40, 0, 4) self.opponent[ennemi].move(40, 0, 4)
self.character.change_xp(1) self.character.change_xp(1)
self.character.max_pdv += 5 self.character.change_max_pdv(self.character.max_pdv + 5)
self.character.change_pdv(round(self.character.max_pdv * 0.2)) self.character.change_pdv(round(self.character.max_pdv * 0.2))
if random.randint(0,5) == 0: if random.randint(0,5) == 0:
self.character.inv.append('potion') self.character.add_potion()
ennemi = random.randint(0, 3) ennemi = random.randint(0, 3)
self.opponent[ennemi].__init__(self.opponent[ennemi].nom, 120, 5, random.randint(1, self.character.xp+1)) cat = ['guerrier', 'elfe', 'magicien', 'voleur']
self.opponent[ennemi].max_pdv = 20 + 5 * (self.opponent[ennemi].xp-1) self.opponent[ennemi].__init__(self.opponent[ennemi].nom, 120, 5, cat[ennemi], random.randint(max(1, self.character.xp - 2), self.character.xp+1), True)
self.opponent[ennemi].pdv = self.opponent[ennemi].max_pdv self.opponent[ennemi].change_max_pdv(20 + 5 * (self.opponent[ennemi].xp-1))
self.opponent[ennemi].change_pdv(self.opponent[ennemi].max_pdv - self.opponent[ennemi].pdv)
self.opponent[ennemi].move(-40, 0, 4) self.opponent[ennemi].move(-40, 0, 4)
return ennemi return ennemi
else: else:
@ -282,15 +295,16 @@ class App:
if self.opponent[ennemi].pdv <= 0: if self.opponent[ennemi].pdv <= 0:
self.opponent[ennemi].move(40, 0, 4) self.opponent[ennemi].move(40, 0, 4)
self.character.change_xp(1) self.character.change_xp(1)
self.character.max_pdv += 5 self.character.change_max_pdv(self.character.max_pdv + 5)
self.character.change_pdv(round(self.character.max_pdv * 0.2)) self.character.change_pdv(round(self.character.max_pdv * 0.2))
if random.randint(0,5) == 0: if random.randint(0,5) == 0:
self.character.inv.append('potion') self.character.add_potion()
ennemi = random.randint(0, 3) ennemi = random.randint(0, 3)
self.opponent[ennemi].__init__(self.opponent[ennemi].nom, 120, 5, random.randint(1, self.character.xp+1)) cat = ['guerrier', 'elfe', 'magicien', 'voleur']
self.opponent[ennemi].max_pdv = 20 + 5 * (self.opponent[ennemi].xp-1) self.opponent[ennemi].__init__(self.opponent[ennemi].nom, 120, 5, cat[ennemi], random.randint(max(self.character.xp - 3, 1), self.character.xp+1), True)
self.opponent[ennemi].pdv = self.opponent[ennemi].max_pdv self.opponent[ennemi].change_max_pdv(20 + 5 * (self.opponent[ennemi].xp-1))
self.opponent[ennemi].change_pdv(self.opponent[ennemi].max_pdv - self.opponent[ennemi].pdv)
self.opponent[ennemi].move(-40, 0, 4) self.opponent[ennemi].move(-40, 0, 4)
return ennemi return ennemi
else: else:
@ -306,6 +320,9 @@ class App:
self.character.move(-40, 0, 4, color='BLUE') self.character.move(-40, 0, 4, color='BLUE')
ennemi = random.randint(0, 3) ennemi = random.randint(0, 3)
self.opponent[ennemi].xp = random.randint(max(1, self.character.xp-3), self.character.xp + 1)
self.opponent[ennemi].change_max_pdv(20 + 5 * (self.opponent[ennemi].xp-1))
self.opponent[ennemi].pdv = self.opponent[ennemi].max_pdv
self.opponent[ennemi].move(0, -40, 4, color='GREEN') self.opponent[ennemi].move(0, -40, 4, color='GREEN')
choice = 0 choice = 0
@ -345,11 +362,11 @@ class App:
if position[0] > 0: if position[0] > 0:
position[0] -= 1 position[0] -= 1
elif key == getkey.keys.ENTER: elif key == getkey.keys.ENTER:
if self.character.inv.count('potion') > 0: if self.character.potion > 0:
self.character.pdv += round((self.character.max_pdv - self.character.pdv) * 0.5) self.character.change_pdv(round((self.character.max_pdv - self.character.pdv) * 0.5))
if self.character.pdv > self.character.max_pdv: if self.character.pdv > self.character.max_pdv:
self.character.pdv = self.character.max_pdv self.character.change_pdv(self.character.max_pdv - self.character.pdv)
self.character.inv.remove('potion') self.character.remove_potion()
elif key == getkey.keys.ESCAPE: elif key == getkey.keys.ESCAPE:
break break
if choice == 2: if choice == 2:
@ -360,6 +377,14 @@ class App:
gui.wipe() gui.wipe()
#suppression du joueur de la bdd
conn = sqlite3.connect('bdd.db')
c = conn.cursor()
c.execute("DELETE FROM Personnage where name=?", (self.character.nom,))
conn.commit()
c.close()
game_over = """ game_over = """
@ -377,7 +402,7 @@ class App:
def setting(self, name, number_char): def setting(self, name, number_char):
"""permet de choisir son type de personnage""" """permet de choisir son type de personnage"""
gui.wipe() gui.wipe()
characters = [Guerrier(name, 0, 5), Voleur(name, 0, 5), Magicien(name, 0, 5), Elfe(name, 0, 5)] characters = [Personnage(name, 0, 5, "guerrier", 1, True), Personnage(name, 0, 5, "voleur", 1, True), Personnage(name, 0, 5, "magicien", 1, True), Personnage(name, 0, 5, "elfe", 1, True)]
for char in characters: for char in characters:
char.x = 60 - len(char.shape[0].split('\n')[0])//2 char.x = 60 - len(char.shape[0].split('\n')[0])//2
for i in range(len(characters[number_char].class_name)): for i in range(len(characters[number_char].class_name)):
@ -401,7 +426,8 @@ class App:
self.setting(name, (number_char-1) % 4) self.setting(name, (number_char-1) % 4)
break break
elif key == getkey.keys.ENTER: elif key == getkey.keys.ENTER:
self.character = characters[number_char] self.character = Personnage(name, 0, 5, ['guerrier', 'voleur', 'magicien', 'elfe'][number_char])
self.character.x = 60 - len(self.character.shape[0].split('\n')[0])//2
del characters del characters
self.play() self.play()
break break
@ -416,11 +442,20 @@ class App:
gui.draw('<', 76, 30, color='RED') gui.draw('<', 76, 30, color='RED')
gui.display() gui.display()
name = input('=>') name = input('=>')
# test si le joueur à déjà joué
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 Personnage.name = ?", (name,))
data = c.fetchone()
c.close()
if data is None:
self.setting(name, 0) self.setting(name, 0)
else:
self.character = Personnage(name, 0, 5, data[4])
self.character.x = 60 - len(self.character.shape[0].split('\n')[0])//2
self.play()
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)

Loading…
Cancel
Save