Advertisement
Guest User

gen1

a guest
Dec 10th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.55 KB | None | 0 0
  1. # Dictionary of names and passwords, expanding on demand.
  2.  
  3.  
  4. charsAvailable = {'vyasa':'mypassword',
  5.                   'dhez':'mypassword',
  6.                   'destre':'mypassword'}
  7.  
  8.  
  9. # -----------------------> Functions <-----------------------
  10.  
  11. # Login with a char passed to this
  12. def charLogin(name):
  13.     if name in charsAvailable.keys():
  14.         passw = input('Welcome ' + name.title() + '. Please enter your password: ')
  15.         if passw == charsAvailable[name]:
  16.             print('Welcome back ' + name.title() + '.')
  17.         else:
  18.             for i in range(1,4):
  19.                 passtry = input('Chance ' + str(i) + ' out of 3. Please enter your password again: ')
  20.                 if passtry == charsAvailable[name]:
  21.                     print('Welcome back ' + name.title() + '.')
  22.                     break
  23.                 else:
  24.                     print('Wrong password.')
  25.     else:
  26.         print('There is no character by that name.')
  27.         welcomeScreen()
  28.  
  29. # Creates a new char and adds it to the dictionary
  30. def charCreate():  
  31.     chosenName = input('Please select a name for your character: ')
  32.     chosenPassW = input('Your name will be ' + chosenName + '. Please choose a password: ')
  33.     charsAvailable[chosenName] = chosenPassW
  34.     print('Account created. You may now login with your new character.\n')
  35.     welcomeScreen()
  36.  
  37. # The welcome screen from which we go
  38. def welcomeScreen():
  39.     print('Welcome to Genesis.')
  40.     choice = input('Please enter your name or type \'new\' to create a new character: ')
  41.     if choice.isalpha() == False:
  42.         print('Names may only contain letters')
  43.         welcomeScreen()
  44.     elif choice == 'new':
  45.         charCreate()
  46.     else:
  47.         charLogin(choice)
  48.  
  49. welcomeScreen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement