From 30ba418bd87b654876b3b102952a851663b90d07 Mon Sep 17 00:00:00 2001 From: HeBatalha Date: Fri, 1 Dec 2023 12:29:08 -0300 Subject: [PATCH] #23: Consulta Local do Personagem e Update Local do Personagem --- game/Banco/Local.py | 15 ++++++++++++++- game/Banco/Pc.py | 15 ++++++++++++++- game/Banco/__pycache__/Local.cpython-310.pyc | Bin 2815 -> 3117 bytes game/Banco/__pycache__/Pc.cpython-310.pyc | Bin 2966 -> 2966 bytes game/__pycache__/game.cpython-310.pyc | Bin 904 -> 824 bytes game/main.py | 2 +- 6 files changed, 29 insertions(+), 3 deletions(-) diff --git a/game/Banco/Local.py b/game/Banco/Local.py index 862f78b..b4ded27 100644 --- a/game/Banco/Local.py +++ b/game/Banco/Local.py @@ -76,4 +76,17 @@ def getLocal(self,coordena:int): finally: cursor.close() - \ No newline at end of file + def getLocalPc(self,personagem:int): + try: + conexao = self.db.conexao + cursor = conexao.cursor() + cursor.execute(f"select l.coordenada , l.descricao , l.nome , l.tipo , l.regiao from local l join pc p on l.coordenada = p.local where p.personagem = {personagem};") + consultaLocal = cursor.fetchall() + if(consultaLocal == []): + return None + else: + return consultaLocal + except psycopg2.Error as e: + print("Erro ao consultar local", e) + finally: + cursor.close() \ No newline at end of file diff --git a/game/Banco/Pc.py b/game/Banco/Pc.py index 4d8de88..cd510e7 100644 --- a/game/Banco/Pc.py +++ b/game/Banco/Pc.py @@ -81,5 +81,18 @@ def deletarNPC(self, IDpersonagem:int): finally: cursor.close() - + def updatePcLocal(self,Personagem:int, Local:int): + try: + conexao = self.db.conexao + cursor = conexao.cursor() + cursor.execute(f"""update pc set local = {Local} where personagem = {Personagem}; """) + consultarNPC = cursor.fetchall() + if(consultarNPC == []): + print("Não existe nenhum PC com esse ID ") + else: + return consultarNPC + except psycopg2.Error as e: + print("Erro ao cosultar os PC's", e ) + finally: + cursor.close() \ No newline at end of file diff --git a/game/Banco/__pycache__/Local.cpython-310.pyc b/game/Banco/__pycache__/Local.cpython-310.pyc index ecf5ce0a79830adc1f20bf42d88cf11d8803ac79..61256575b1fc0fb44b545fe5b40a08563d635931 100644 GIT binary patch delta 343 zcmew_x>kZOpO=@50SNd$W~SEhOypa_STb>Qx=<=h8dHi$if9W<6iqkXEu=inbU;l7FR)PQE`4=VtQ)sWC0e*`XWuBahfcCRjtLTIjPAd z3ORbo`T0dDsd7Nu$cxd<02*eVps0^L)j03x(NE@La= z0I_u^@8eY0q6gp{8q?_@15KQ?WU61~ZlT#8~sKqdzR X2O|@c91|Z82M-?*2=Px|#}x*Z{+IX1^_Dj1YrOG diff --git a/game/__pycache__/game.cpython-310.pyc b/game/__pycache__/game.cpython-310.pyc index bc9294c6deb1c4afc1272242a95d20b489dc380e..0b07ba026ba29e782eacb8fe25a53a665f912b49 100644 GIT binary patch delta 157 zcmeBR-@(S4&&$ij00d@lGgD7*!Bm)R9WMpKhVM$>q zWh}A<%dnuxu!3d0z%r~TGHhU(@W}y8B9qIQrm83a?P6hMW8{NE7Df(cAw~`+1ZH8G IY|b1A0Ll&>NdN!< delta 246 zcmdnN*1^u3&&$ij00i0wnW@J&^5!x!{+e9P7*KCn!@hv2hB<{