@ -1,7 +1,14 @@
"""
C ' est joli, mais il y aurait moyen de factoriser pas mal de choses!
Note : 10 / 10
"""
import random
import cli
import time
import getkey
import sqlite3
class Animation :
""" class de gestion des animations du personnage """
@ -71,16 +78,53 @@ class Animation:
class Personnage ( Animation ) :
""" Class de base du personnage """
def __init__ ( self , nom , x , y , xp ) :
self . nom = nom
self . coef_attack = 1
self . coef_defense = 1
self . pdv = 20
self . max_pdv = 20
self . xp = xp
self . inv = [ ' potion ' for i in range ( 2 ) ]
self . shape = [ ' ' , ' ' ]
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 . 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 . x = x
self . y = y
super ( ) . __init__ ( self . x , self . y , self . shape )
@ -93,81 +137,49 @@ class Personnage(Animation):
def change_xp ( self , 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 ) :
self . pdv + = nb_pdv
class Guerrier ( Personnage ) :
def __init__ ( self , nom , x , y , xp = 1 ) :
super ( ) . __init__ ( nom , x , y , xp )
self . weapon = " épée "
self . class_name = """ ██████ ██ ██ ███████ ██████ ██████ ██ ███████ ██████
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ """ .split( ' \n ' )
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 ⡀⡀⢰⡤⢒⣋⠰⠀⠀⠀⢀⠀⡼⠉⡐⠀⡀⠀ """ ]
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 ( )
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 remove_potion ( self ) :
""" Enlève 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 ) )
conn . commit ( )
c . close ( )
class App :
@ -186,13 +198,13 @@ class App:
: , ' `-. ' ` :
| |
: ;
\ /
\\ /
` . ___ . ' " " " .split( ' \n ' )
self . opponent = [ Guerrier ( " Guerrier " , 80 , 45 ) , Voleur ( " Voleur " , 80 , 45 ) , Magicien ( " Magicien " , 80 , 45 ) , Elf e( " Elfe " , 80 , 45 ) ]
self . title = """ ██ ███████ ██ ██ ██████ ███████ ██████ ██████ ██ ███████
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █
self . opponent = [ Personnage ( " Guerrier " , 80 , 45 , " guerrier " , 1 , True ) , Personnage ( " Voleur " , 80 , 45 , " voleur " , 1 , True ) , Personnage ( " Magicien " , 80 , 45 , " magicien " , 1 , True ) , Personnag e( " Elfe " , 80 , 45 , " elfe " , 1 , True ) ]
self . title = """ ██ ███████ ██ ██ ██████ ███████ ██████ ██████ ██ ███████
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ """ .split( ' \n ' )
def draw_arena ( self , ennemi , choice ) :
@ -201,14 +213,14 @@ class App:
self . character . display ( ' right ' , color = ' BLUE ' )
self . opponent [ ennemi ] . display ( ' left ' , color = ' GREEN ' )
gui . draw_bar ( self . character . pdv * 100 / / self . character . max_pdv , 5 , 25 , 30 , color = ' RED ' )
gui . draw_bar ( self . character . xp * 100 / / 20 , 5 , 27 , 30 , color = ' GREEN ' )
gui . draw ( self . character . nom , 15 , 2 , weight = ' BOLD ' )
gui . draw ( str ( self . character . pdv ) , 38 , 25 , color = ' RED ' )
gui . draw ( str ( self . character . xp ) , 38 , 27 , color = ' GREEN ' )
gui . draw_bar ( self . opponent [ ennemi ] . pdv * 100 / / self . opponent [ ennemi ] . max_pdv , 75 , 25 , 30 , color = ' RED ' )
gui . draw_bar ( self . opponent [ ennemi ] . xp * 100 / / 20 , 75 , 27 , 30 , color = ' GREEN ' )
gui . draw ( self . opponent [ ennemi ] . nom , 90 , 2 )
@ -235,14 +247,14 @@ class App:
gui . draw ( ' ' . join ( [ ' + ' + ' ' . join ( [ ' - ' for j in range ( 29 ) ] ) for k in range ( 4 ) ] ) , 0 , 1 + i )
else :
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
y = j / / 4
if [ x , y ] == position :
color_fill = ' YELLOW '
else :
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 ) ) :
gui . draw ( self . potion_shape [ i ] , 30 * x + 6 , 17 * y + 3 + i , color = color_fill )
gui . display ( )
@ -257,15 +269,16 @@ class App:
if self . opponent [ ennemi ] . pdv < = 0 :
self . opponent [ ennemi ] . move ( 40 , 0 , 4 )
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 ) )
if random . randint ( 0 , 5 ) == 0 :
self . character . inv . append ( ' potion ' )
self . character . add_potion ( )
ennemi = random . randint ( 0 , 3 )
self . opponent [ ennemi ] . __init__ ( self . opponent [ ennemi ] . nom , 120 , 5 , random . randint ( 1 , self . character . xp + 1 ) )
self . opponent [ ennemi ] . max_pdv = 20 + 5 * ( self . opponent [ ennemi ] . xp - 1 )
self . opponent [ ennemi ] . pdv = self . opponent [ ennemi ] . max_pdv
cat = [ ' guerrier ' , ' elfe ' , ' magicien ' , ' voleur ' ]
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 ] . 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 )
return ennemi
else :
@ -282,15 +295,16 @@ class App:
if self . opponent [ ennemi ] . pdv < = 0 :
self . opponent [ ennemi ] . move ( 40 , 0 , 4 )
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 ) )
if random . randint ( 0 , 5 ) == 0 :
self . character . inv . append ( ' potion ' )
self . character . add_potion ( )
ennemi = random . randint ( 0 , 3 )
self . opponent [ ennemi ] . __init__ ( self . opponent [ ennemi ] . nom , 120 , 5 , random . randint ( 1 , self . character . xp + 1 ) )
self . opponent [ ennemi ] . max_pdv = 20 + 5 * ( self . opponent [ ennemi ] . xp - 1 )
self . opponent [ ennemi ] . pdv = self . opponent [ ennemi ] . max_pdv
cat = [ ' guerrier ' , ' elfe ' , ' magicien ' , ' voleur ' ]
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 ] . 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 )
return ennemi
else :
@ -306,6 +320,9 @@ class App:
self . character . move ( - 40 , 0 , 4 , color = ' BLUE ' )
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 ' )
choice = 0
@ -328,7 +345,7 @@ class App:
if choice == 1 :
# affichage de l'inventaire
position = [ 0 , 0 ]
while True :
self . show_inventory ( position )
key = getkey . getkey ( )
@ -345,11 +362,11 @@ class App:
if position [ 0 ] > 0 :
position [ 0 ] - = 1
elif key == getkey . keys . ENTER :
if self . character . inv . count ( ' potion' ) > 0 :
self . character . pdv + = round ( ( self . character . max_pdv - self . character . pdv ) * 0.5 )
if self . character . potion > 0 :
self . character . change_pdv ( round ( ( self . character . max_pdv - self . character . pdv ) * 0.5 ) )
if self . character . pdv > self . character . max_pdv :
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 :
break
if choice == 2 :
@ -360,14 +377,22 @@ class App:
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 = """
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █
""" .split( ' \n ' )
for i in range ( len ( game_over ) ) :
gui . draw ( game_over [ i ] , 60 - len ( game_over [ i ] ) / / 2 , 12 + i , color = ' RED ' )
@ -377,10 +402,10 @@ class App:
def setting ( self , name , number_char ) :
""" permet de choisir son type de personnage """
gui . wipe ( )
characters = [ Guerrier ( name , 0 , 5 ) , Voleur ( name , 0 , 5 ) , Magicien ( name , 0 , 5 ) , Elf e( 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 ) , Personnag e( name , 0 , 5 , " elfe " , 1 , True ) ]
for char in characters :
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 ) ) :
gui . draw ( characters [ number_char ] . class_name [ i ] , 60 - ( len ( characters [ number_char ] . class_name [ 0 ] ) / / 2 ) , 25 + i , color = ' RED ' , weight = ' BOLD ' )
for i in range ( 2 ) :
gui . draw ( ' / ' , 4 - i , 17 + i )
@ -391,7 +416,7 @@ class App:
gui . draw ( ' Utilisez les flèche pour changer de personnage puis appuyez sur entrée ' , 30 , 1 )
gui . display ( )
while True :
key = getkey . getkey ( )
if key == getkey . keys . RIGHT :
@ -401,11 +426,12 @@ class App:
self . setting ( name , ( number_char - 1 ) % 4 )
break
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
self . play ( )
break
def menu ( self ) :
""" permet de choisir son nom """
for i in range ( len ( self . title ) ) :
@ -416,11 +442,20 @@ class App:
gui . draw ( ' < ' , 76 , 30 , color = ' RED ' )
gui . display ( )
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 ( )
gui = cli . Cli ( width = app . width , height = app . height )
app . menu ( )
# guerrier.move(-10, 0)