Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #RPG
- #User random to create attributes for your character and the computer's character
- #Strength: 1 - 20
- #Intelligence: 1 - 10
- #Magic: 1 - 30
- #Have the user choose Fight, Steal, or Magic
- #The stronger character wins a fight
- #The smarter character can steal from the other
- #The more magical character can defeat the other
- import os
- import random
- def print_header():
- print ("Welcome to the Labyrinth...prepare to die!")
- def generate_stats():
- global user_strength
- global user_intelligence
- global user_magic
- global computer_strength
- global computer_intelligence
- global computer_magic
- #Generate user stats
- user_strength = random.randint(1, 20)
- user_intelligence = random.randint(1, 10)
- user_magic = random.randint(1, 30)
- #Generate computer stats
- computer_strength = random.randint(1, 20)
- computer_intelligence = random.randint(1, 10)
- computer_magic = random.randint(1, 30)
- def print_fight_type(type):
- if type == "F":
- print ("""
- ___________ ____________
- | )._______.-'
- `----------'
- You decide to fight with your knife...
- """)
- elif type == "S":
- print ("""
- {O-
- //\\===+-
- \\
- ))
- ||
- You decide to steal from this vagabond...
- """)
- elif type == "M":
- print ("""
- *
- * *
- * \\\\* / *
- * --.:. *
- * * :\\\\ -
- .* | \\\\
- \\\\
- \\\\
- You decide to use your magic to fight...
- """)
- def print_fight_result(type):
- global user_health
- global computer_health
- if type == "F":
- if user_strength > computer_strength:
- print ("You win the fight!")
- computer_health -= 20
- else:
- print ("You fight well, but ultimately lose.")
- user_health -= 20
- elif type == "S":
- if user_intelligence > computer_intelligence:
- print ("You steal the Jewel of Power and weaken your enemy.")
- computer_health -= 10
- else:
- print ("You fail...and are lightly injured.")
- user_health -= 10
- elif type == "M":
- if user_magic > computer_magic:
- print ("You cast a spell and injure your enemy!")
- computer_health -= 30
- else:
- print ("Your enemy turns your spell against you...you feel undescribable pain!")
- user_health -= 30
- else:
- print ("That was not one of the choices.")
- def print_stats():
- print ("")
- print ("User Stats")
- print ("Strength: " + str(user_strength))
- print ("Intelligence: " + str(user_intelligence))
- print ("Magic: " + str(user_magic))
- print ("Health: " + str(user_health))
- print("")
- print ("Computer Stats")
- print ("Strength: " + str(computer_strength))
- print ("Intelligence: " + str(computer_intelligence))
- print ("Magic: " + str(computer_magic))
- print ("Health: " + str(computer_health))
- print ("")
- def is_player_dead(health):
- if health <= 0:
- return True
- else:
- return False
- def is_computer_dead(health):
- if health <= 0:
- return True
- else:
- return False
- user_health = 100
- computer_health = 100
- while True:
- os.system("clear")
- #Generate user stats
- generate_stats()
- #Header
- print_header()
- #Choose which type of battle: (F)ight, (S)teal, (M)agic
- user_choice = input("What type of battle? (F)ight, (S)teal, (M)agic > ").upper()
- print_fight_type(user_choice)
- #Determine the winner
- print_fight_result(user_choice)
- #Print stats
- print_stats()
- #Check for player death
- if is_player_dead(user_health):
- print ("Your enemy finally defeats you - you are dead!")
- if is_computer_dead(computer_health):
- print ("You finally defeat your enemy - he dies cursing your name!")
- #Ask for a replay
- if is_player_dead(user_health) or is_computer_dead(computer_health):
- replay = input("Please type (Y)es to replay, or (N)o to finish. > ")
- if replay == "Y":
- user_health = 100
- computer_health = 100
- continue
- else:
- break
- delay = input("Press enter to continue. ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement