From c7bd62c96fa2ed76f2ab3ac2d7bea3939f328f62 Mon Sep 17 00:00:00 2001 From: "barraux.a" Date: Fri, 2 Dec 2022 14:50:23 +0100 Subject: [PATCH] =?UTF-8?q?normalement=20=C3=A7a=20marche?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bdd.db | Bin 53248 -> 53248 bytes main.py | 255 +++++++++++++++++++++++++++++--------------------------- 2 files changed, 132 insertions(+), 123 deletions(-) diff --git a/bdd.db b/bdd.db index 092caf47a8e5b2773afebbd6cda1b0c61a223231..74debbfb500258dc661a102aa850d34975ccb9b8 100644 GIT binary patch delta 2411 zcmZuyZA?>V6u!5gw57curL{l@w1Oboia5X6hE>tv4+Pz2aB&W_)*@1Ei;nmMsvsYN z!j3IazKTrbLr_4IO}ET#W;5zcnDK|1%SJbs%pV$-X*NT$z307DVHr2~;d!5P-gDmf zoO7WvAgl}sn_?ro7=}@jH;lXj^1jx*I78pXn6__LDz7t=@C^cGCU;NuK-Cw%LFG^t zs0v0swQ{-gx?rW&Y-W#JU|g|~6~GUQ42V!=M;Hz|+;&H)L6(#IcJ`+1t*}+Km3Xsh z+QdZmcskrt#w{aDG2NWuE-WhXxFe+0NLSW8tJCEuEiJUoVgmS8dFX#bL#DD?M2>wC zZYaHRmPm>A9W%?=OZQkmbR8jPHC>RF3xk6LXjvpSu2t5ZPauc+*{ zm;Xl}qyRUfvtP^R&q*`hza@otAvkatHjE;mN1$4Ui5!1^O z>e!k5o2(9}&FY%9NshZB7>0W$;C>(VObf=tjDLkE%ekARZ`WAv8uyI*nY+*3p^u02 zaO1BY(zk6~1#w+RS{6lqufZP8BP5+~N+hAlv^#}bt?*l8g(gO5!h5U^pVs@uZTmw- zFc=KMKqbS3Khn2te1DIH@}Ru;dkvM;^S%HRp-pLB$f0pAq>-Jtd-aMMHFpuqE1Bve$||2nI<1 z%AlpM(uwLBG(uC2i7@Qtk2T9@*wR|cs^Z{S?dwFdw8y}`TDo4_aU2zhzj^aa#<_1)bQM^wvr4f~*6njXX zM~#>#@f50)RmtE#l}1=$eF{81l{&-Lo#t68_)ez~?fU5~IURLTCnM?{^*BTsiaK2j z=c_pED6y6~`7u`<*7@uq2}|tzKqNt_fcGNll3?wS2riw$pt$- zfwUdR*3yn~CURn6q#Z4jReBJ0V3V5%;-R1e_u&W(@>)X-yy!qbPj?h-?8M9`Ixzx% z=gWZ&780@6Pdk zF+hADo-VHs&)!S%ImMjwd_B}~={#S}7?Abj8S#d@`uWNj;gkMQhou92^mrH^h=Ae& z!%Ws;ULU}CSk?T&G&(Q6gQ0oJYLmdnm&eOI=NR*;6#>53XtPBGios8)p zW;EFGOJLh^ZGjbL&8C$8DVHgoD4lM;*kDaZmEi*H_nm@u`UgQ;`Pr5D^L|%VGKPy}j zuH?OjYMoYi$ZoTEJZ%5Vpw~Ug3b0pK3r|Rky#5l?^tuN!daLLCQ0L*+o?usZYfs>C zXRy`V>iwTfMDc2L6H_ZfNWYs^f=`TS!vR5M*}k3a7vU8_hTp_qxTx^NGa(|zVz)rsou!(CL_z5f}QUM1IOFcT5QNlUbe8T+=hef{%>6Y|MzO;K)g6rQ` zYq3PEQq3sUx$r|2{o1-9C6{j|<2RFi^y|9lFBeFdbc;cUe?o`9md^T1;Kr$Hu7}}z za^d$leN3a|O)+JR)bD~&V-*-GO5o>@%i#yN1G+2CuruO>@(LL$My$xzfOCY0p@>oO z)=@}AS}-;#o;gi+K=J$O7LuaI&A}T3UShAksDjMEE@D3zs3U9~q?{tO!Ny=c@>}8Q zAs?a%28RydJFX3pus`5?96#>Rd!} z?j*yV%!Ru+LyYHmIVMF<(e7h~cfgOIR*|!Xc`ZDCp61_*X`#1h`v){|?L3V!MC)+w zmWUDFjFN}OqonQ)iiQ}L*#>j5deWr_v3-OM6B>9mj%ByP9XAijIF{K2>+u7Gz6r`v zLNlyQ;5WdXv_aD}O}II2hXR_cQ4)qPh~kEXqcWU4izFwvOOYs&aQT2mTc8QlXK9i4+~e8n+7W zr05XVAY~5DdT{1rv!uQi3gaBv1?OzWkgDxHK)PIgP_?(41C5D(!vL{Eakeeq{z1B*VE3 w9#tFsk-_p=p>C0g99kr0uTq#kC%blvFDURNIkF_#p)C17n{8oT7cZCp3pMc#9RL6T diff --git a/main.py b/main.py index 389030e..4477eb4 100644 --- a/main.py +++ b/main.py @@ -72,32 +72,53 @@ class Animation: class Personnage(Animation): """Class de base du personnage""" - def __init__(self, nom, x, y, categorie, xp=1): + def __init__(self, nom, x, y, categorie, xp=1, bot=False): - 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.bot = bot - self.nom = nom - self.coef_attack = 1 - self.coef_defense = 1 - self.pdv = data[1] - self.max_pdv = data[3] - self.xp = data[2] - self.inv = ['potion'for i in range(2)] + 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.shape = ['', ''] self.x = x self.y = y super().__init__(self.x, self.y, self.shape) @@ -110,81 +131,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: @@ -203,9 +192,9 @@ class App: :,' `-.' `: | | : ; - \ / + \\ / `.___.' """.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 = """ ██ ███████ ██ ██ ██████ ███████ ██████ ██████ ██ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ █████ ██ ██ ██ ██ █████ ██████ ██ ██ ██ █████ @@ -252,14 +241,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() @@ -274,15 +263,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: @@ -299,15 +289,15 @@ 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 + self.opponent[ennemi].__init__(self.opponent[ennemi].nom, 120, 5, 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].max_pdv) self.opponent[ennemi].move(-40, 0, 4) return ennemi else: @@ -323,6 +313,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 @@ -362,11 +355,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: @@ -377,6 +370,14 @@ 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 = """ ██████ █████ ███ ███ ███████ ██████ ██ ██ ███████ ██████ ██ ██ ██ ████ ████ ██ ██ ██ ██ ██ ██ ██ ██ @@ -394,7 +395,7 @@ 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), 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: char.x = 60 - len(char.shape[0].split('\n')[0])//2 for i in range(len(characters[number_char].class_name)): @@ -418,7 +419,8 @@ 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 @@ -433,13 +435,20 @@ class App: gui.draw('<', 76, 30, color='RED') gui.display() name = input('=>') - self.setting(name, 0) - -# app = App() -# gui = cli.Cli(width=app.width, height=app.height) - -# app.menu() + # 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() -# # guerrier.move(-10, 0) +app = App() +gui = cli.Cli(width=app.width, height=app.height) -Personnage('Georges', 0, 0, "guerrier", 1) +app.menu()