HeidiHeff

RPG Character Creator

Nov 12th, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.24 KB | None | 0 0
  1. # character_creator.py
  2. # Role-Playing Game Character Attribute Creator
  3. #
  4. # Player uses program to create a character for an RPG, Atlantis.
  5. # 30 points for use on attributes: Strength, Health, Wisdom
  6. # and Dexterity. Player can mix and match points for any attribute.
  7. #
  8. # Heidi Heffelfinger
  9. # November 12, 2012
  10. # Programming Python for the Absolute Beginner 3rd Ed. Chapter 5
  11. # Challenge 2
  12.  
  13. # welcome user and explain game
  14. print(
  15. """
  16.    Welcome to Atlantis, Gaucherius!
  17.    
  18.    As a waif, your father disappeared on a journey to Atlantis.
  19.    You have trained your entire life as a swordsman and now
  20.    begin your journey to find the truth of his disappearance.
  21.    You have saved 1000 gold and outfitted yourself with a basic
  22.    broadsword, chainmail, leather greaves, leather bracers, and
  23.    a leather helm.
  24.  
  25.    You have 30 skill points to assign skill attributes. Each
  26.    attribute level costs 1 skill point to set.
  27. """
  28. )
  29.  
  30. # initialize variables
  31. points = 30
  32. choice = None
  33.  
  34. # create dictionary of character skills
  35. skills = {"Strength": 0, "Health": 0, "Dexterity": 0, "Wisdom": 0}
  36.  
  37. while choice != 0:
  38.     print(
  39.     """
  40.    Attribute Setting:
  41.  
  42.    0 - Exit
  43.    1 - Add Attribute Level
  44.    2 - Remove Attribute Level
  45.    3 - Show Attributes
  46.    """
  47.     )
  48.  
  49.     choice = input("What would you like to do?: ")
  50.     print()
  51.  
  52.     # exit
  53.     if choice == "0":
  54.         print("You are now ready to play Atlantis! Go avenge your "\
  55.               "father!")
  56.         break
  57.  
  58.     # choose an attribute and add levels
  59.     elif choice == "1":
  60.         if points > 0:
  61.             add_choice = input("Which attribute would you like to add to. "\
  62.                                "\nStrength = 1, Health = 2, Dexterity = 3, "\
  63.                                "and Wisdom = 4: ")
  64.             if add_choice == "1":
  65.                 spend_points = int(input("\nOK, Strength. How many points do "\
  66.                                          "you want too spend?: "))
  67.                 skills["Strength"] += spend_points
  68.                 points -= spend_points
  69.                 print("\nYou now have", points, "points remaining.")
  70.             elif add_choice == "2":
  71.                 spend_points = int(input("\nOK, Health. How many points do "\
  72.                                          "you want too spend?: "))
  73.                 skills["Health"] += spend_points
  74.                 points -= spend_points
  75.                 print("\nYou now have", points, "points remaining.")
  76.             elif add_choice == "3":
  77.                 spend_points = int(input("\nOK, Dexterity. How many points do "\
  78.                                          "you want too spend?: "))
  79.                 skills["Dexterity"] += spend_points
  80.                 points -= spend_points
  81.                 print("\nYou now have", points, "points remaining.")
  82.             elif add_choice == "4":
  83.                 spend_points = int(input("\nOK, Wisdom. How many points do "\
  84.                                          "you want too spend?: "))
  85.                 skills["Wisdom"] += spend_points
  86.                 points -= spend_points
  87.                 print("\nYou now have", points, "points remaining.")
  88.             else:
  89.                 print("\nSorry, but", add_choice, "isn't a valid choice.")
  90.         else:
  91.             print("Sorry, you do not have enough points available.")
  92.  
  93.     # choose an attribute and remove levels
  94.     elif choice == "2":
  95.         remove_choice = input("Which attribute would you like to lower? "\
  96.                               "Choose: Strength = 1, Health = 2, Dexterity "\
  97.                               "= 3, and Wisdom = 4: ")
  98.         if remove_choice == "1":
  99.             remove_points = int(input("\nOK, Strength. How many points do you "\
  100.                                      "want too remove?: "))
  101.             skills["Strength"] -= remove_points
  102.             points += remove_points
  103.             print("\nYou now have", points, "points remaining.")
  104.         elif remove_choice == "2":
  105.             spend_points = int(input("\nOK, Health. How many points do you "\
  106.                                      "want too remove?: "))
  107.             skills["Health"] -= remove_points
  108.             points += remove_points
  109.             print("\nYou now have", points, "points remaining.")
  110.         elif remove_choice == "3":
  111.             spend_points = int(input("\nOK, Dexterity. How many points do you "\
  112.                                      "want too remove?: "))
  113.             skills["Dexterity"] -= remove_points
  114.             points += remove_points
  115.             print("\nYou now have", points, "points remaining.")
  116.         elif remove_choice == "4":
  117.             spend_points = int(input("\nOK, Wisdom. How many points do you "\
  118.                                      "want too remove?: "))
  119.             skills["Wisdom"] -= remove_points
  120.             points += remove_points
  121.             print("\nYou now have", points, "points remaining.")
  122.         else:
  123.             print("\nSorry, but", remove_choice, "isn't a valid choice.")
  124.  
  125.     # Show attributes
  126.     elif choice == "3":
  127.         for key, value in skills.items():
  128.             print(key, value)
  129.  
  130.     # some unknown choice
  131.     else:
  132.         print("\nSorry, but", choice, "isn't a valid choice.")
  133.  
  134. # wait for user
  135. input("\n\nPress the enter key to exit.")
Advertisement
Add Comment
Please, Sign In to add comment