Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- # define variables
- you_hp = 20
- you_atk = 2
- you_def = 1
- you = [you_hp, you_atk, you_def]
- it_hp = 20
- it_atk = 2
- it_def = 1
- it = [it_hp, it_atk, it_def]
- end = 0 #if 1, ends game
- condition = 0 #0 is your turn, 1 is the monsters, 3 is after one of you have died
- #processes
- while end == 0:
- while condition == 0: # Your turn
- print "\nThe monster has "+`it[0]`+" health left and you have "+`you[0]`
- print "1.Attack\n2.Battle Cry\n3.Heal\n4.Check stats"
- x = raw_input("\nWhat do you do? ")
- if x == "1": # You attacking it
- you_chance = randint(1,1000) #random used for crit/miss/hit
- if you_chance > 900: #Crit
- it[0] = it[0] - you[1]
- print "\nYou lands a CRITICAL HIT on your foe for " + `you[1]` + " damage"
- print "\nThe monster loses " + `you[1]` + " health.."
- if it[0] <= 0:
- print "And falls, defeated, to the ground."
- print "\nYOU ARE VICTORIOUS!"
- condition = 2
- else:
- condition = 1
- raw_input("<enter>\n")
- elif you_chance < 300: #Miss
- print "\nYour attacked completely missed!"
- condition = 1
- raw_input("<enter>\n")
- else: #Hit
- print "\nYou attack for " + `you[1]` + " damage"
- print "but the monster blocked " + `it[2]` + " of it."
- your_damage = (you[1] - it[2])
- if your_damage > 0:
- it[0] = it[0] - your_damage
- print "\nThe monster loses " + `your_damage` + " health.."
- if it[0] <= 0:
- print "And falls, defeated, to the ground."
- print "\nYOU ARE VICTORIOUS!"
- condition = 2
- else:
- condition = 1
- raw_input("<enter>\n")
- else:
- condition = 1
- print "\nYour attack did nothing."
- raw_input("<enter>\n")
- elif x == "2": # Using Battle Cry
- you[1] = you[1] + 1
- you[2] = you[2] + 1
- print "\nYou let out a heroic battle cry!"
- print "(Your attack and defence are increased)"
- condition = 1
- raw_input("<enter>\n")
- elif x == "3": # Using Heal
- you[0] = 20
- you[1] = you[1] - 2
- you[2] = you[2] - 2
- print "\nYou use bitter medicene to restore your health."
- print "(Health imcreased. Attack and defence decreased.)"
- if you[2] <= 0:
- you[1] = 1
- you[2] = 0
- print "(Attack and defence now at minimum)"
- else:
- condition = 1
- raw_input("<enter>\n")
- elif x == "4": # Check Stats
- print "\nThe monster's attack is " + `it[1]`
- print "and its defence is " + `it[2]` + "."
- print "Your attack is " + `you[1]`
- print "and your defence is " + `you[2]` + "."
- else:
- print"Invalid choice. Enter 1-4"
- while condition == 1: #It's turn
- y = randint(1,1000)
- z = y % 2 #gets random 0 or 1 to choose monsters action
- if z == 0: #It attacking you
- its_chance = randint(1,1000) # random used for crit/miss/hit
- if its_chance > 750: #Crit
- print "\nThe monster lands a CRITICAL HIT on you for " + `it[1]` + " damage"
- print "\nYou lose " + `it[1]` + " health.."
- print "\nThe monster is getting tired."
- print "(Its attack and defence greatly decrease)"
- you[0] = you[0] - it[1]
- it[1] = it[1] - 2
- it[2] = it[2] - 2
- if you[0] <= 0:
- print "And, with nothing left in you, you collapse."
- print "\nYOU HAVE BEEN DEFEATED!"
- condition = 2
- else:
- if it[2] <= 0:
- it[1] = 1
- it[2] = 0
- condition = 0
- else:
- condition = 0
- elif its_chance < 250: #Miss
- print "\nThe monster swings, but misses!"
- condition = 0
- else: #Hit
- print "\nThe monster hits you for " + `it[1]` + " damage"
- print "but you block " + `you[2]` + " of it."
- its_damage = (it[1] - you[2])
- if its_damage > 0:
- you[0] = you[0] - its_damage
- print "\nYou lose " + `its_damage` + " health.."
- if you[0] <= 0:
- print "And, with nothing left in you, you collapse."
- print "\nYOU HAVE BEEN DEFEATED!"
- condition = 2
- else:
- condition = 0
- else:
- condition = 0
- print "\nIts attack did nothing."
- else: #Monster uses Battle cry
- it[1] = it[1] + 2
- it[2] = it[2] + 1
- print "\nThe monster bellows with rage!"
- print "(Its attack increases greatly and its defence increases)"
- condition = 0
- while condition == 2: #Game over
- q = raw_input("Play again? y/n? ")
- if q == "y":
- you = [20,2,1]
- it = [20,2,1]
- condition = 0
- elif q == "n":
- condition = 3
- while condition == 3:
- end = 1
- break
- print "\n\nThanks for playing."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement