Skip to content

Commit cf997d8

Browse files
fix(py): handle npc choice
1 parent 5dc8856 commit cf997d8

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

source/interface.py

+24-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import psycopg2
44
from colorama import Fore, Style, init
55
from create_character import Character
6-
from queries.query import get_subregions_character, list_all_characters, list_npcs_subregion, list_item_inventory, list_enemys_subregion, get_enemy_info
6+
from queries.query import get_subregions_character, list_all_characters, list_npcs_subregion, list_item_inventory, list_enemys_subregion, get_enemy_info, get_civilian_info
77
from utils import debug
88
from combat import Combate, verificar_percepcao, Inimigo
99
import time
@@ -178,6 +178,22 @@ def display_npcs(conn, character):
178178

179179
return npcs
180180

181+
def display_npc_info(npc_nome, npc_tipo, conn):
182+
descricao = get_civilian_info(conn, npc_nome)
183+
print(Fore.CYAN + "\n--- Ficha do Personagem ---" + Style.RESET_ALL)
184+
print(Fore.GREEN + f"Nome: {descricao['nome']}" + Style.RESET_ALL)
185+
print(Fore.GREEN + f"Descrição: {descricao['descricao']}" + Style.RESET_ALL)
186+
print(Fore.MAGENTA + "\n.." + Style.RESET_ALL)
187+
time.sleep(1)
188+
189+
if npc_tipo == "Quester":
190+
get_quest(npc_nome)
191+
input("Pressione Enter para continuar...")
192+
else:
193+
print(Fore.RED + f"{npc_nome} não tem nada a dizer." + Style.RESET_ALL)
194+
print(Fore.MAGENTA + "Pressione 0 para voltar ao menu." + Style.RESET_ALL)
195+
input()
196+
181197
def handle_player_choice(conn, character, subregions, npcs, enemys):
182198
try:
183199
choice_interaction = input("\nO que você deseja fazer agora?\n0-Voltar\n1-Continuar caminhando\n2-Interagir com um personagem\n3-Lutar: \n")
@@ -203,11 +219,12 @@ def handle_player_choice(conn, character, subregions, npcs, enemys):
203219
navigate(conn, character)
204220

205221
elif choice_interaction == "2": # Interact with npcs
222+
npcs = list_npcs_subregion(conn, character.sub_regiao_id)
206223
if npcs:
207224
npc_choice = int(input("Escolha um personagem (número): "))
208225
if 1 <= npc_choice <= len(npcs):
209-
print(f"Você interagiu com {npcs[npc_choice - 1][0]}")
210-
# NPCS TO INTERACT
226+
npc_nome, npc_tipo = npcs[npc_choice - 1]
227+
display_npc_info(npc_nome, npc_tipo, conn)
211228
else:
212229
print("\nOpção inválida!")
213230
else:
@@ -266,6 +283,10 @@ def get_subregion_description(conn, character):
266283
conn.rollback()
267284
return "Erro ao acessar a descrição."
268285

286+
def get_quest(npc_nome):
287+
print(f"Você recebeu uma missão de {npc_nome}.")
288+
# Adicione mais lógica conforme necessário
289+
269290
# Main game loop
270291
def game_loop(conn):
271292
ok = False

0 commit comments

Comments
 (0)