5 Commits

Author SHA1 Message Date
barraux.a 424a9cdf0d 3.141592653589793238462643383279502884197169399375 2022-12-05 16:07:41 +01:00
barraux.a c7bd62c96f normalement ça marche 2022-12-02 14:50:23 +01:00
barraux.a 01e1ebc453 Ajout de la base 2022-11-30 14:08:38 +01:00
barraux.a 1649aaffb0 patch de l'invetaire 2022-09-21 11:23:28 +02:00
BARRAUX Arthur ff01ebff66 legère update 2022-09-21 07:06:32 +02:00
3 changed files with 142 additions and 102 deletions
BIN
View File
Binary file not shown.
+10
View File
@@ -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()
+132 -102
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,16 +72,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.nom = nom
self.coef_attack = 1 self.bot = bot
self.coef_defense = 1
self.pdv = 20 if not self.bot:
self.max_pdv = 20 conn = sqlite3.connect('bdd.db')
self.xp = xp c = conn.cursor()
self.inv = ['potion'for i in range(7)] 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.pdv = 20
self.xp = xp
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 +131,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')
c = conn.cursor()
c.execute("UPDATE Personnage SET pdv=? where name=?", (self.pdv, self.nom))
conn.commit()
c.close()
def change_max_pdv(self, pdv):
self.max_pdv = pdv
if not self.bot:
conn = sqlite3.connect('bdd.db')
c = conn.cursor()
c.execute("UPDATE Personnage SET max_pdv=? where name=?", (self.max_pdv, self.nom))
conn.commit()
c.close()
class Guerrier(Personnage): def add_potion(self):
""" Ajoute une potion à l'invetaire et à la base de donnée"""
self.potion += 1
if not self.bot:
conn = sqlite3.connect('bdd.db')
c = conn.cursor()
c.execute("UPDATE Personnage SET potion=? WHERE name=?", (self.potion, self.nom))
c.close()
def __init__(self, nom, x, y, xp=1): def remove_potion(self):
super().__init__(nom, x, y, xp) """ Enlève une potion à l'invetaire et à la base de donnée"""
self.potion -= 1
self.weapon = "épée" if not self.bot:
self.class_name = """ ██████ ██ ██ ███████ ██████ ██████ ██ ███████ ██████ conn = sqlite3.connect('bdd.db')
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ c = conn.cursor()
██ ███ ██ ██ █████ ██████ ██████ ██ █████ ██████ c.execute("UPDATE Personnage SET potion=? WHERE name=?", (self.potion, self.nom))
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ conn.commit()
██████ ██████ ███████ ██ ██ ██ ██ ██ ███████ ██ ██ """.split('\n') c.close()
self.coef_attack = 10
self.coef_defense = 8
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 Voleur(Personnage):
def __init__(self, nom, x, y, xp=1):
super().__init__(nom, x, y, xp)
self.coef_attack = 3
self.class_name = """██ ██ ██████ ██ ███████ ██ ██ ██████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ █████ ██ ██ ██████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██
████ ██████ ███████ ███████ ██████ ██ ██""".split('\n')
self.coef_defense = 9
self.weapon = "dague"
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 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 +192,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,17 +241,17 @@ 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()
def combat(self, ennemi): def combat(self, ennemi):
"""Simule l'attaque des joeurs""" """Simule l'attaque des joeurs"""
@@ -257,15 +263,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 +289,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 +314,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,10 +356,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:
self.character.pdv += round((self.character.max_pdv - self.character.pdv) * 0.5) if self.character.potion > 0:
if self.character.pdv > self.character.max_pdv: self.character.change_pdv(round((self.character.max_pdv - self.character.pdv) * 0.5))
self.character.pdv = self.character.max_pdv if self.character.pdv > self.character.max_pdv:
self.character.inv.remove('potion') self.character.change_pdv(self.character.max_pdv - self.character.pdv)
self.character.remove_potion()
elif key == getkey.keys.ESCAPE: elif key == getkey.keys.ESCAPE:
break break
if choice == 2: if choice == 2:
@@ -359,6 +371,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 = """
██████ █████ ███ ███ ███████ ██████ ██ ██ ███████ ██████ ██████ █████ ███ ███ ███████ ██████ ██ ██ ███████ ██████
██ ██ ██ ████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ████ ██ ██ ██ ██ ██ ██ ██ ██
@@ -376,7 +396,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)):
@@ -400,7 +420,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
@@ -415,11 +436,20 @@ class App:
gui.draw('<', 76, 30, color='RED') gui.draw('<', 76, 30, color='RED')
gui.display() gui.display()
name = input('=>') name = input('=>')
self.setting(name, 0) # 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)
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)