Skip to content

Commit

Permalink
#23: Consulta Local do Personagem e Update Local do Personagem
Browse files Browse the repository at this point in the history
  • Loading branch information
HeBatalha committed Dec 1, 2023
1 parent b3e49ab commit 30ba418
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 3 deletions.
15 changes: 14 additions & 1 deletion game/Banco/Local.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,17 @@ def getLocal(self,coordena:int):
finally:
cursor.close()


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()
15 changes: 14 additions & 1 deletion game/Banco/Pc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Binary file modified game/Banco/__pycache__/Local.cpython-310.pyc
Binary file not shown.
Binary file modified game/Banco/__pycache__/Pc.cpython-310.pyc
Binary file not shown.
Binary file modified game/__pycache__/game.cpython-310.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion game/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
case'3':
jogador=game.CarregarJogo()
lc=Local()
posicao=lc.getLocal(jogador[9])
posicao=lc.getLocalPc(jogador[0])

print("\n--------------------------------------------------------------------------------\n")
print(f"\033[1;32m{jogador[1]}\nLocal: {posicao[0][2]}\nDescrição: {posicao[0][1]}\nCoordenada: {posicao[0][0]}\033[0m")
Expand Down

0 comments on commit 30ba418

Please sign in to comment.