Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # character_creator.py
- # Role-Playing Game Character Attribute Creator
- #
- # Player uses program to create a character for an RPG, Atlantis.
- # 30 points for use on attributes: Strength, Health, Wisdom
- # and Dexterity. Player can mix and match points for any attribute.
- #
- # Heidi Heffelfinger
- # November 12, 2012
- # Programming Python for the Absolute Beginner 3rd Ed. Chapter 5
- # Challenge 2
- # welcome user and explain game
- print(
- """
- Welcome to Atlantis, Gaucherius!
- As a waif, your father disappeared on a journey to Atlantis.
- You have trained your entire life as a swordsman and now
- begin your journey to find the truth of his disappearance.
- You have saved 1000 gold and outfitted yourself with a basic
- broadsword, chainmail, leather greaves, leather bracers, and
- a leather helm.
- You have 30 skill points to assign skill attributes. Each
- attribute level costs 1 skill point to set.
- """
- )
- # initialize variables
- points = 30
- choice = None
- # create dictionary of character skills
- skills = {"Strength": 0, "Health": 0, "Dexterity": 0, "Wisdom": 0}
- while choice != 0:
- print(
- """
- Attribute Setting:
- 0 - Exit
- 1 - Add Attribute Level
- 2 - Remove Attribute Level
- 3 - Show Attributes
- """
- )
- choice = input("What would you like to do?: ")
- print()
- # exit
- if choice == "0":
- print("You are now ready to play Atlantis! Go avenge your "\
- "father!")
- break
- # choose an attribute and add levels
- elif choice == "1":
- if points > 0:
- add_choice = input("Which attribute would you like to add to. "\
- "\nStrength = 1, Health = 2, Dexterity = 3, "\
- "and Wisdom = 4: ")
- if add_choice == "1":
- spend_points = int(input("\nOK, Strength. How many points do "\
- "you want too spend?: "))
- skills["Strength"] += spend_points
- points -= spend_points
- print("\nYou now have", points, "points remaining.")
- elif add_choice == "2":
- spend_points = int(input("\nOK, Health. How many points do "\
- "you want too spend?: "))
- skills["Health"] += spend_points
- points -= spend_points
- print("\nYou now have", points, "points remaining.")
- elif add_choice == "3":
- spend_points = int(input("\nOK, Dexterity. How many points do "\
- "you want too spend?: "))
- skills["Dexterity"] += spend_points
- points -= spend_points
- print("\nYou now have", points, "points remaining.")
- elif add_choice == "4":
- spend_points = int(input("\nOK, Wisdom. How many points do "\
- "you want too spend?: "))
- skills["Wisdom"] += spend_points
- points -= spend_points
- print("\nYou now have", points, "points remaining.")
- else:
- print("\nSorry, but", add_choice, "isn't a valid choice.")
- else:
- print("Sorry, you do not have enough points available.")
- # choose an attribute and remove levels
- elif choice == "2":
- remove_choice = input("Which attribute would you like to lower? "\
- "Choose: Strength = 1, Health = 2, Dexterity "\
- "= 3, and Wisdom = 4: ")
- if remove_choice == "1":
- remove_points = int(input("\nOK, Strength. How many points do you "\
- "want too remove?: "))
- skills["Strength"] -= remove_points
- points += remove_points
- print("\nYou now have", points, "points remaining.")
- elif remove_choice == "2":
- spend_points = int(input("\nOK, Health. How many points do you "\
- "want too remove?: "))
- skills["Health"] -= remove_points
- points += remove_points
- print("\nYou now have", points, "points remaining.")
- elif remove_choice == "3":
- spend_points = int(input("\nOK, Dexterity. How many points do you "\
- "want too remove?: "))
- skills["Dexterity"] -= remove_points
- points += remove_points
- print("\nYou now have", points, "points remaining.")
- elif remove_choice == "4":
- spend_points = int(input("\nOK, Wisdom. How many points do you "\
- "want too remove?: "))
- skills["Wisdom"] -= remove_points
- points += remove_points
- print("\nYou now have", points, "points remaining.")
- else:
- print("\nSorry, but", remove_choice, "isn't a valid choice.")
- # Show attributes
- elif choice == "3":
- for key, value in skills.items():
- print(key, value)
- # some unknown choice
- else:
- print("\nSorry, but", choice, "isn't a valid choice.")
- # wait for user
- input("\n\nPress the enter key to exit.")
Advertisement
Add Comment
Please, Sign In to add comment