Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- import string
- import platform
- import os
- import logo
- import pickle
- from recuperodati import *
- from colorama import init
- init(autoreset=True)
- utenti = {}
- def clear_screen():
- if platform.system() == 'Linux':
- os.system('clear')
- def registrazione():
- global utenti
- try:
- pkl_file = open('fantagol.pkl', 'r')
- utenti = pickle.load(pkl_file)
- except:
- pass
- print ('\033[37;1m' + "Per registarti inserisci i dati richiesti :\n")
- domanda = raw_input('\033[33;1m'"Inserisci un indirizzo email valido : ")
- ricerca = string.find(domanda, '@')
- if ricerca == -1 or len(domanda) <= 5:
- print
- print ('\033[31;1m' + "L'indirizzo mail inserito non è valido, riprova per favore \n")
- registrazione()
- if any(item for item in utenti.values() if domanda in item):
- print
- print ('\033[31;1m' + "Spiacente, l'indirizzo email inserito risulta già registrato, puoi recuperare "
- "i tuoi dati scegliendo 'Recupero dati' dal menù iniziale, ")
- raw_input('\033[31;1m' + "Premi un tasto per continuare ")
- menu()
- domanda2 = raw_input('\033[33;1m'"Reinserisci l'indirizzo email per favore : ")
- if domanda2.lower() == domanda.lower():
- domanda3 = raw_input('\033[33;1m'"Inserisci una password : ")
- if domanda3 in utenti.values():
- print('\033[31;1m' + "Spiacente, la password inserita non può essere accettata.")
- menu()
- domanda4 = raw_input('\033[33;1m' + "Sei sicuro di voler confermare " + '\033[34;1m' + "%s"
- % domanda3 + '\033[33;1m' + " come password? s/n : ")
- if domanda4.lower() == "s".lower():
- domanda7 = raw_input('\033[33;1m' + "Inserisci un Nickname : ")
- while domanda7 in utenti.keys():
- print raw_input('\033[31;1m' + "Spiacente, il nickname inserito non può essere accettato. Riprovare : ")
- domanda8 = raw_input('\033[33;1m' + "Sei sicuro di voler confermare " + '\033[34;1m' + "%s"
- % domanda7 + '\033[33;1m' + " come nickname? s/n : ")
- if domanda8.lower() == "s".lower():
- utenti[domanda7] = domanda2, domanda3
- print ('\033[34;1m' + "Utente registrato ! Riepilogo iscrizione : ")
- print ('\033[36;1m' + "Nome Utente : %s \nPassword : %s \nNickname : %s "
- % (domanda2, domanda3, domanda7))
- raw_input('\033[37;1m' + "Registrazione avvenuta con successo, premi invio per tornare "
- "al menù principale ")
- output = open('fantagol.pkl', 'w')
- pickle.dump(utenti, output)
- output.close()
- clear_screen()
- menu()
- else:
- while domanda4.lower() != "s".lower():
- domanda5 = raw_input('\033[33;1m' + "Inserisci una password : ")
- domanda6 = raw_input('\033[33;1m' + "Sei sicuro di voler confermare " + '\033[34;1m' + "%s"
- % domanda5 + '\033[33;1m' + " come password? s/n : ")
- if domanda6.lower() == "s".lower():
- domanda7 = raw_input('\033[33;1m' + "Inserisci un Nickname : ")
- while domanda7 in utenti.keys():
- print raw_input('\033[31;1m' + "Spiacente, il nickname inserito non può essere accettato. "
- "Riprovare : ")
- domanda8 = raw_input('\033[33;1m' + "Sei sicuro di voler confermare " + '\033[34;1m' + "%s" % (
- domanda7) + '\033[33;1m' + " come nickname? s/n : ")
- if domanda8.lower() == "s".lower():
- utenti[domanda7] = domanda2, domanda3
- print ('\033[34;1m' + "Utente registrato ! Riepilogo iscrizione : ")
- print ('\033[36;1m' + "Nome Utente : %s \nPassword : %s \nNickname : %s " % (
- domanda2, domanda3, domanda7))
- raw_input(
- '\033[37;1m' + "Registrazione avvenuta con successo, premi invio per tornare al menù "
- "principale ")
- output = open('fantagol.pkl', 'w')
- pickle.dump(utenti, output)
- output.close()
- clear_screen()
- menu()
- else:
- if domanda2.lower() != domanda.lower():
- print ('\033[31;1m'"Errore ! La mail inserita non combacia con la precedente, per favore riprova ")
- registrazione()
- def login():
- print ('\033[33;1m' + "Per entrare e giocare subito per favore inserisci la tua user e la tua password : \n")
- user = raw_input('\033[33;1m' + "User : ")
- if user in utenti.keys():
- password = raw_input('\033[33;1m' + "Password : ")
- if password in utenti.values():
- print ('\033[34;1m' + "Login Effettuato \n")
- menu()
- else:
- print ('\033[31;1m' + "Errore! Password inesistente! Per favore riprova \n")
- login()
- else:
- print ('\033[31;1m' + "Errore! User inesistente! Per favore riprova \n")
- login()
- def menu():
- logo.logo()
- print ('\033[37;1m' + "Benvenuto nel fantastico mondo del fantagol !! Seleziona un opzione dal "
- "menù sottostante : \n")
- print ('\033[33;1m' + "1.Registrazione\n" + "2.Login\n" + "3.Recupera Dati\n" + "4.SuperUser\n")
- opzione = raw_input(('\033[37;1m' + "Scegli la tua opzione scrivendo il numero corrispondente : "))
- print
- if opzione.lower() == "1":
- registrazione()
- elif opzione.lower() == "2":
- login()
- elif opzione.lower() == "3":
- recupero()
- elif opzione.lower() == "4":
- pkl_file = open('fantagol.pkl', 'r')
- utenti_load = pickle.load(pkl_file)
- for x in utenti_load:
- valori = utenti_load[x]
- print '\033[36;1m' + "%s - %s" % (x, valori)
- menu()
- else:
- while opzione.lower() != "1" or opzione.lower() != "2" or opzione.lower() != "3":
- print ('\033[31;1m' + "Errore! Seleziona una voce del menù scrivendo solo il relativo numero \n")
- menu()
- print menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement