diff --git a/README.md b/README.md index 2fb58fa..2da9876 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,4 @@ Diferenciais: * Detecção e instalação de dependências, caso necessário. * Tutorial - apenas é mostrado na primeira vez * Flexível - Cartelas podem ser adicionadas ou substituídas, dado que seja seguido o modelo. -* Não usa nenhuma função predefinida do python para trabalhar com listas (com exceção de len) - -Pendente: -* Achar e tratar erros - tudo adicionado ou alterado com o commit "Now in English!" -* idioma em arquivo? \ No newline at end of file +* Não usa nenhuma função predefinida do python para trabalhar com listas (com exceção de len) \ No newline at end of file diff --git a/main.py b/main.py index b8e2e4e..d76f44b 100644 --- a/main.py +++ b/main.py @@ -1,19 +1,28 @@ def main(): + import os from src.init import inicio, idioma from src.cartelas import TUI_principal - - language = idioma() - if language == "BR": - x = 'src.constants.constants' - elif language == "EN": - x = 'src.constants.constantsen' - + #Lógica da seleção de idiomas - outras partes do programa dependem + #das variáveis language e locale para apresentar o idioma correto + language = "" + while language == "": + language = idioma() + if language == "BR": + x = 'src.constants.constants' + elif language == "EN": + x = 'src.constants.constantsen' + elif language == "": + os.system("cls || clear") + input("Valor de entrada inválido\nPressione ENTER para continuar\n\nInvalid input value\nPress ENTER to continue") import importlib locale = importlib.import_module(x) - + #Introdução, verifica / instala dependências + #verifica/cria arquivo de configuração + #comentado em mais detalhes em init() x = inicio(locale) if x == "instalado": print(locale.START["librariesinstalled"]) return None + #Inicia o jogo TUI_principal(locale, language) main() \ No newline at end of file diff --git a/src/cartelas.py b/src/cartelas.py index ff75af1..76e7861 100644 --- a/src/cartelas.py +++ b/src/cartelas.py @@ -1,4 +1,3 @@ -#from src.constants import ERRORS, SELECTED, SCOREBOARD, GAME from src.funcoes import aleatorio def listas(): #Geração de listas a partir do arquivo de cartelas. Essas listas são separadas em @@ -126,8 +125,7 @@ def maketable(elemento_inicial, lista, playerselect, backend_results, modelovito #Determina se a entrada do usuário é inválida, e aje de acordo elif elemento_inicial != "1" or elemento_inicial != "2" or elemento_inicial != "3" or elemento_inicial != "4" or elemento_inicial != "": print(f""" - {locale.ERRORS["invalid"]} - Valores possíveis: [1, 2, 3, 4] +{locale.ERRORS["invalid"]}[1, 2, 3, 4] """) #Montagem e apresentação da tabela usando PrettyTable diff --git a/src/constants/constants.py b/src/constants/constants.py index 036840f..ad81d61 100644 --- a/src/constants/constants.py +++ b/src/constants/constants.py @@ -123,7 +123,7 @@ SELECTED = { "notplayer": " "} ERRORS = { - "invalid": "Valor de entrada inválido",} + "invalid": "Valor de entrada inválido. Possíveis valores são: ",} WARNING = { "firstime": """ diff --git a/src/constants/constantsen.py b/src/constants/constantsen.py index 7296de7..c0c809e 100644 --- a/src/constants/constantsen.py +++ b/src/constants/constantsen.py @@ -10,10 +10,10 @@ START = { """, "libraries": """ - The program detected that dependencies are not installed - Press ENTER to install the necessary libraries + The program detected dependencies are not installed + Press ENTER to install the necessary libraries - (Note that you will need to open the program again after completion) + (You will need to open the program again after completion) """, "librariesinstalled": "Dependencies installed successfully.\nOpen the program again\n"} INTRO = { @@ -123,11 +123,11 @@ SELECTED = { "notplayer": " "} ERRORS = { - "invalid": "Invalid input value",} + "invalid": "Invalid input value. Possible values are: ",} WARNING = { "firstime": """ - The program has detected that this is the first time it is playing. + The program has detected this is the first time you're playing. Press ENTER to watch the tutorial. Alternatively, press 1 to skip the tutorial (Recommended for experienced players) diff --git a/src/init.py b/src/init.py index 0b7e27a..7ad1135 100644 --- a/src/init.py +++ b/src/init.py @@ -1,17 +1,20 @@ import os def idioma(): + #Apresenta idiomas disponíveis ao usuário os.system("cls || clear") - x = int(input(""" + x = input(""" Selecione seu idioma Select your language 1 = Português Brasileiro 2 = English - """)) - if x == 1: + """) + if x == "1": return "BR" - elif x == 2: + elif x == "2": return "EN" + else: + return "" def tutorial(locale): #Tutorial - Busca as informações do constants.py e apresenta na tela em