diff --git a/Cartelas.txt b/Cartelas.txt new file mode 100644 index 0000000..aaca2b6 --- /dev/null +++ b/Cartelas.txt @@ -0,0 +1,40 @@ +20,29,42,43,49 +10,11,29,31,48 +8,15,18,32,34 +10,27,30,40,41 +6,16,30,38,41 +18,23,31,39,49 +8,9,17,27,30 +12,13,15,27,48 +4,9,10,18,20 +6,11,23,33,50 +11,17,23,24,35 +1,6,11,15,47 +1,2,11,25,34 +1,38,40,46,50 +6,12,20,27,29 +1,16,29,33,46 +2,36,37,41,47 +1,18,22,25,28 +22,28,42,44,45 +7,19,28,42,46 +12,22,31,43,47 +18,19,27,29,32 +6,19,34,38,45 +4,17,25,38,49 +12,23,31,39,45 +6,9,17,30,48 +10,11,13,35,47 +3,7,20,42,45 +1,20,33,44,46 +18,25,34,43,44 +23,35,37,45,47 +7,17,19,33,37 +5,7,30,31,35 +5,11,14,26,50 +5,17,19,26,46 +4,16,40,45,49 +2,6,9,25,47 +6,17,20,26,37 +14,17,19,25,41 +10,20,31,39,40 \ No newline at end of file diff --git a/Vencedores.txt b/Vencedores.txt new file mode 100644 index 0000000..e69de29 diff --git a/bingo.py b/bingo.py new file mode 100644 index 0000000..a9c8966 --- /dev/null +++ b/bingo.py @@ -0,0 +1,128 @@ +import datetime as dt +import random as r + +def intro(): + Intro = ''' + Bem Vindo Ao/Welcome to + _ _ + | |__ (_)_ __ __ _ ___ + | '_ \| | '_ \ / _` |/ _ \ + | |_) | | | | | (_| | (_) | + |_.__/|_|_| |_|\__, |\___/ + |___/ + + Versão Atual / Current Version: 0.5 + + Isso é um trabalho feito para minha Faculdade, pretendo posteriormente melhorar o código e fazer um bingo normal com colunas nas cartelas + This is a College homework that I have developed and I pretend to further improve the code + ''' + return Intro +#essa função registra o tempo e horario e formata para uma saida de data em Ingles seguindo um padrão determinado + +def pega_tempo(): + data_atual = dt.datetime.now() + string_tempo = data_atual.strftime('%A, %B %d, %Y, %H:%M:%S') + return string_tempo +#essa função sorteia a cartela dentre do arquivo Cartelas.txt + +def sorteia_cartela(): + a = open('Cartelas.txt', 'r', encoding='utf-8') + b = a.readlines() + c = [0]*4 + for i in range(4): + d=b[r.randint(0,len(b)-1)] + d = d.strip('\n') + c[i] = d.split(',') + for j in range(5): + c[i][j] = int(c[i][j]) + a.close() + return c, 0 + +#Essa função Devolve a cartela atual do jogador e as demais cartelas + +def dev_cartela(c, atual): + print(f'Cartela ATUAL:\n{c[atual]}\n') + print('As demais cartelas:\n') + for i in range(4): + if i == atual: + pass + else: + print(f'{c[i]}\n') +#Essa função permite ao jogador a trocar a cartela dele +# +def troca_cartela(c,atual): + print('Favor responder a pergunta com S, s , Sim, sim ou em caso de não qualquer outro valor') + a = input('Você deseja trocar de cartela: ') + a = a.lower() + if a == 's' or a == 'sim': + while True: + for i in range(4): + if i == atual: + pass + else: + print(f'Cartela {i+1}:\n{c[i]}\n') + b = int(input('Favor Escolha uma das cartelas apresentadas: ')) + b -= 1 + if b == 0: + print('Opção Invalida, escolha outra cartela') + else: + break + return b + else: + return atual +#Essa função sorteia o numero, verifica a existencia desse numero nas cartelas e se encontrar o numero troca por X para indicar q o numero ja foi sorteado + +def sorteio(c): + ''' + n = r.randint(1,50) + for i in range(4): + for j in range(5): + if c[i][j] == n: + c[i][j] = 'X' + + return c + ''' + return gera_lista_al(50, 50) + +#essa função verifica o ganhador + +def verif_ganha(c, atual): + x = 0 + for i in range(5): + if c[atual][i] == 'X': + x +=1 + if x == 5: + print('Parabens Jogador, você ganhou e tera seu nome gravado no rol dos vencedores') + return True, 1 + exit() + for i in range(4): + x = 0 + for j in range(5): + if i == atual: + pass + if c[i][j] == 'X': + x += 1 + if x == 5: + print('Temos um ganhador, mas infelizmente não foi sua vez Jogador') + return True, 0 + exit() + return False, 0 + +def master(): + cartela,atual = sorteia_cartela() + f = False + while f == False: + dev_cartela(cartela, atual) + atual = troca_cartela(cartela, atual) + cartela = sorteio(cartela) + f, j = verif_ganha(cartela, atual) + if j == 1: + a = input('Favor Insira o nome do Campeão: ') + v = open('Vencedores.txt', 'a', encoding='utf-8') + v.write(f'{a} - {pega_tempo()}') + v.close() + print('Fim do Bingo') +def gera_lista_al(x,y): + return r.sample(range(x),k=y) +cartela,atual = sorteia_cartela() +print(sorteio(cartela)) \ No newline at end of file