Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.24 KB | None | 0 0
  1. # In this one I want to create a full character, using the following example
  2. # as characteristics:
  3.  
  4. charVyasa = {'name':'Vyasa',
  5.              'password':'mypassword',
  6.              'race':'elf',
  7.              'gender':'male',
  8.              'adj1':'venerable',
  9.              'adj2': 'long-bearded',
  10.              'height':'tall',
  11.              'weight':'skinny',
  12.              'mortal-level':'myth'}
  13.  
  14. # For this, the only function I'll have to change is charCreate()
  15. # We keep the charsAvailable dictionary for login, but we create an individual one
  16. # for each char with their characteristics
  17.  
  18. charsAvailable = {'vyasa':'mypassword',
  19.                   'dhez':'mypassword',
  20.                   'destre':'mypassword'}
  21.  
  22.  
  23. # -----------------------> Functions <-----------------------
  24.  
  25. # Login with a char passed to this
  26. def charLogin(name):
  27.     if name in charsAvailable.keys():
  28.         passw = input('Welcome ' + name.title() + '. Please enter your password: ')
  29.         if passw == charsAvailable[name]:
  30.             print('Welcome back ' + name.title() + '.')
  31.         else:
  32.             for i in range(1,4):
  33.                 passtry = input('Chance ' + str(i) + ' out of 3. Please enter your password again: ')
  34.                 if passtry == charsAvailable[name]:
  35.                     print('Welcome back ' + name.title() + '.')
  36.                     break
  37.                 else:
  38.                     print('Wrong password.')
  39.     else:
  40.         print('\nThere is no character by that name. Returning to login screen\n')
  41.         welcomeScreen()
  42.  
  43. # Creates a new char and adds it to the dictionary
  44. # Creates a dictionary with individual characteristics. Can also be expanded
  45. # to present the user with a list of options to choose from instead of entering them
  46. # on his own, since he may well mess it up ;-)
  47. # For now, we still need to fix it with a lot of try/excepts
  48.  
  49. def charCreate():
  50.     global newChar
  51.     newChar = {'mortal-level':'beginner'}
  52.     NewcharName = input('Please select a name for your character: ')
  53.     newChar['name'] = NewcharName
  54.     newCharPassword = input('Your name will be ' + newChar['name'].title() + '. Please choose a password: ')
  55.     newChar['password'] = newCharPassword
  56.     newChar['race'] = input('Please choose a race for your character: ')
  57.     newChar['gender'] = input('Please choose a gender for your character: ')
  58.     newChar['adj1'] = input('Please choose a word to describe your character: ')
  59.     newChar['adj2'] = input('Please choose another word to describe your character: ')
  60.     newChar['height'] = input('Please tell me how tall your character is: ')
  61.     newChar['weight'] = input('Please choose how fat or skinny your character is: ')
  62.     charsAvailable[NewcharName] = newChar['password']
  63.     print('Account created.')
  64.     print('You are a ' + newChar['adj1'] + ' ' + newChar['adj2'] + ' ' + newChar['race'] + '. Presenting yourself as: \n' + str(newChar['name']).title() + ' ' + newChar['mortal-level'] + ', ' + newChar['gender'] + ' ' + newChar['race'] + '\n')
  65.     print('You may now login with your new character.\n')
  66.     welcomeScreen()
  67.  
  68.  
  69.  
  70.  
  71.  
  72. # The welcome screen from which we go
  73. def welcomeScreen():
  74.     print('Welcome to Genesis.')
  75.     choice = input('Please enter your name or type \'new\' to create a new character: ')
  76.     if choice.isalpha() == False:
  77.         print('Names may only contain letters')
  78.         welcomeScreen()
  79.     elif choice == 'new':
  80.         charCreate()
  81.     else:
  82.         charLogin(choice)
  83.  
  84. welcomeScreen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement