Advertisement
Guest User

code game beginner

a guest
May 17th, 2015
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. # role playing program
  2. #
  3. # spend 30 points on strenght, health, wisdom, dexterity
  4. # player can spend and take points from any attribute
  5.  
  6.  
  7. # library contains attribute and points
  8. attributes = {"strenght": int("0"),
  9. "health": "0",
  10. "wisdom": "0",
  11. "dexterity": "0"}
  12.  
  13. pool = int(30)
  14. choice = None
  15. print("The Making of a Hero !!!")
  16. print(attributes)
  17. print("\nYou have", pool, "points to spend.")
  18.  
  19. while choice != "0":
  20. # list of choices
  21. print(
  22. """
  23. Options:
  24.  
  25. 0 - End
  26. 1 - Add points to an attribute
  27. 2 - remove points from an attribute
  28. 3 - Show attributes
  29. """
  30. )
  31. choice = input("Choose option: ")
  32. if choice == "0":
  33. print("\nYour hero stats are:")
  34. print(attributes)
  35. print("Good-Bye.")
  36. elif choice == "1":
  37. print("\nADD POINTS TO AN ATTRIBUTE")
  38. print("You have", pool, "points to spend.")
  39. print(
  40. """
  41. Choose an attribute:
  42. strenght
  43. health
  44. wisdom
  45. dexterity
  46. """
  47. )
  48. at_choice = input("Your choice: ")
  49. if at_choice.lower() in attributes:
  50. points = int(input("How many points do you want to assign: "))
  51. if points <= pool:
  52. pool -= points
  53. result = int(attributes[at_choice]) + points
  54. attributes[at_choice] = result
  55. print("\nPoints have been added.")
  56. else:
  57. print("\nYou do not have that many points to spend")
  58. else:
  59. print("\nThat attribute does not exist.")
  60. elif choice == "2":
  61. print("\nREMOVE POINTS FROM AN ATTRIBUTE")
  62. print("You have", pool, "points to spend.")
  63. print(
  64. """
  65. Choose an attribute:
  66. strenght
  67. health
  68. wisdom
  69. dexterity
  70. """
  71. )
  72. at_choice = input("Your choice: ")
  73. if at_choice.lower() in attributes:
  74. points = int(input("How many points do you want to remove: "))
  75. if points <= int(attributes[at_choice]):
  76. pool += points
  77. result = int(attributes[at_choice]) - points
  78. attributes[at_choice] = result
  79. print("\nPoints have been removed.")
  80. else:
  81. print("\nThere are not that many points in that attribute")
  82. else:
  83. print("\nThat attribute does not exist.")
  84.  
  85. elif choice == "3":
  86. print("\n", attributes)
  87. print("Pool: ", pool)
  88. else:
  89. print(choice, "is not a valid option.")
  90.  
  91.  
  92.  
  93. input("\n\nPress the enter key to exit.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement