main.py now runs the intro and game!

Minor all-round changes
This commit is contained in:
nanometer5088
2022-09-02 21:19:36 -03:00
parent c7eeec25a4
commit 7927e8e8a9
5 changed files with 31 additions and 20 deletions

View File

@@ -0,0 +1,6 @@
def main():
from src.init import inicio
from src.cartelas import TUI_principal
inicio()
TUI_principal()
main()

View File

@@ -1,5 +1,5 @@
from constants import LOGGING, ERRORS, SELECTED
from funcoes import learquivo, escrevearquivo, cleanup
from src.constants import LOGGING, ERRORS, SELECTED
from src.funcoes import learquivo, escrevearquivo, cleanup
def listas():
i = 0
vazio = ''
@@ -24,7 +24,7 @@ def listas():
return vet
def cartelas_show():
from funcoes import aleatorio
from src.funcoes import aleatorio
cartelas = listas()
resultado = [0] * 4
randomold = 0
@@ -47,7 +47,7 @@ def donotabela(elemento_inicial):
***************************************************
""")
def maketable(elemento_inicial, lista, playerselect, backend_results):
from funcoes import aleatorio
from src.funcoes import aleatorio
from prettytable import PrettyTable, DOUBLE_BORDER
if elemento_inicial == "1":
donotabela(elemento_inicial)
@@ -121,5 +121,4 @@ def TUI_principal():
lista = cartelas_show()
while True:
os.system("cls || clear")
elemento_inicial = input(maketable(elemento_inicial, lista, playerselect, backend_results))
TUI_principal()
elemento_inicial = input(maketable(elemento_inicial, lista, playerselect, backend_results))

View File

@@ -7,9 +7,10 @@ TUTORIAL = {
Certifique-se que tenha as bibliotecas necessárias instaladas
As bibliotecas podem ser instaladas rodando o arquivo 'setup.py'
Pressione ENTER para instalar as bibliotecas necessárias
Pressione ENTER para prosseguir
As bibliotecas podem ser instaladas posteriormente rodando o
arquivo 'setup.py'
"""
}
SELECTED = {
@@ -22,4 +23,9 @@ ERRORS = {
LOGGING = {
"listas": "listas() executado com sucesso",
"cartelas_show": "cartelas_show() executado com sucesso"
}
}
SCOREBOARD = {
"win": """
Parabéns! Você venceu!!!
Entre o seu nome para constar no rol de vencedores:
"""}

View File

@@ -2,31 +2,31 @@ def aleatorio(x, y):
import random
return random.randint(x, y)
def criaarquivo():
def criaarquivo(x):
try:
arquivo = open('temp.json', 'r', encoding='utf-8')
arquivo = open(x, 'r', encoding='utf-8')
arquivo.close()
except FileNotFoundError:
arquivo = open('temp.json', 'w')
arquivo = open(x, 'w')
arquivo.close()
def learquivo(x,linha):
criaarquivo()
criaarquivo(x)
arquivo = open(x, 'r', encoding='utf-8')
x = arquivo.readlines(linha)
arquivo.close()
return x
def escrevearquivo(x,input):
criaarquivo()
criaarquivo(x)
arquivo = open(x, 'w')
arquivo.write(input)
arquivo.close()
def cleanup():
def cleanup(x):
import os
if os.path.exists("temp.json"):
os.remove("temp.json")
if os.path.exists(x):
os.remove(x)
else:
print("The file does not exist\n")

View File

@@ -1,6 +1,6 @@
from constants import TUTORIAL
from src.constants import TUTORIAL
def inicio():
import os
os.system("cls || clear")
input(TUTORIAL["start"])
inicio()
x = input(TUTORIAL["start"])
os.system("pip install -r requirements.txt")