- Code: Select all
import random, time, sys, os
global player_health
global gold
global monster_health
global player_damage
global player_armor
global player_items
player_items = ""
player_armor = ""
player_damage = ""
player_health = 100
monster_health = 100
gold = 0
def cls():
print('\n')
def monster_attack():
global player_health
global player_armor
print "The Ogre is attacking..."
time.sleep(3)
if player_armor == "Plate Armor":
terms = []
for i in range(2):
terms.append(random.randint(1, 89))
k = terms[0]
print "Ogre attacks you for " + str(k) + " damage."
player_health = player_health - k
PlayerAlive()
if player_armor == "Chain Armor":
terms = []
for i in range(2):
terms.append(random.randint(1, 92))
l = terms[0]
print "Ogre attacks you for " + str(l) + " damage."
player_health = player_health - l
PlayerAlive()
if player_armor == "Wood Armor":
terms = []
for i in range(2):
terms.append(random.randint(1, 96))
m = terms[0]
print "Ogre attacks you for " + str(m) + " damage."
player_health = player_health - m
PlayerAlive()
if player_armor == "Sweater Armor":
terms = []
for i in range(2):
terms.append(random.randint(1, 98))
n = terms[0]
print "Ogre attacks you for " + str(n) + " damage."
player_health = player_health - n
PlayerAlive()
if player_armor == "":
terms = []
for i in range(2):
terms.append(random.randint(1, 99))
o = terms[0]
print "Ogre attacks you for " + str(o) + " damage."
player_health = player_health - o
PlayerAlive()
terms = []
for i in range(2):
terms.append(random.randint(1, 99))
j = terms[0]
print "Ogre attacks you for " + str(j) + " damage."
player_health = player_health-j
print "You have " + str(player_health) + " health left"
PlayerAlive()
def player_attack():
global monster_health
global player_damage
print "You are attacking..."
time.sleep(3)
if player_damage == "Sword":
terms = []
for i in range(2):
terms.append(random.randint(12, 111))
k = terms[0]
print "You attack for " + str(k) + " damage."
monster_health = monster_health - k
MonsterAlive()
MidFight()
if player_damage == "Battle Axe":
terms = []
for i in range(2):
terms.append(random.randint(5, 104))
l = terms[0]
print "You attack for " + str(l) + " damage."
monster_health = monster_health - l
MonsterAlive()
MidFight()
if player_damage == "Club":
terms = []
for i in range(2):
terms.append(random.randint(3, 102))
m = terms[0]
print "You attack for " + str(m) + " damage."
monster_health = monster_health - m
MonsterAlive()
if player_damage == "Stick":
terms = []
for i in range(2):
terms.append(random.randint(2, 100))
n = terms[0]
print "You attack for " + str(n) + " damage."
monster_health = monster_health - n
MonsterAlive()
if player_damage == "":
terms = []
for i in range(2):
terms.append(random.randint(1, 99))
j = terms[0]
print "You attack for " + str(j) + " damage."
monster_health = monster_health -j
MonsterAlive()
def Beggenning():
print "Welcome to your simple rpg!"
time.sleep(5)
cls()
pn = raw_input("Let's start with the basics, what's your name? ")
cls()
print "Welcome " + pn + " we hope you enjoy your adventures here!"
time.sleep(3)
cls()
Main()
def Main():
global player_health
global monster_health
player_health = 100
monster_health = 100
cls()
print "What would you like to do?"
print "1: Fight"
print "2: Look for burried treasure"
print "3: Store"
print "4: Inventory"
print "5: Help"
print "6: Quit"
main_choice = raw_input("")
if main_choice == "1":
FightChoice()
if main_choice == "attack":
FightChoice()
if main_choice == "Attack":
FightChoice()
if main_choice == "2":
TreasureFind()
if main_choice == "Look for burried treasure":
TreasureFind()
if main_choice == "look for burried treasure":
TreasureFind()
if main_choice == "3":
StoreMain()
if main_choice == "Store":
StoreMain()
if main_choice == "store":
StoreMain()
if main_choice == "4":
print "You currently have " + str(player_armor) + " equipped"
print "You also have a " + str(player_damage) + " equipped"
print "You have " + str(player_items) + " equipped"
print "And you have " + str(gold) + " gold"
Main()
if main_choice == "Inventory":
print "You currently have " + str(player_armor) + " equipped"
print "You also have a " + str(player_damage) + " equipped"
print "You have " + str(player_items) + " equipped"
print "And you have " + str(gold) + " gold"
Main()
if main_choice == "inventory":
print "You currently have " + str(player_armor) + " equipped"
print "You also have a " + str(player_damage) + " equipped"
print "You have " + str(player_items) + " equipped"
print "And you have " + str(gold) + " gold"
Main()
if main_choice == "Help":
Help()
if main_choice == "5":
Help()
if main_choice == "help":
Help()
if main_choice == "6":
sys.exit
if main_choice == "quit":
sys.exit
if main_choice == "Quit":
sys.exit
def StoreMain():
print "Welcome to the store!"
print "Here you can get things like potions, weapons, or armor!"
print "What would you like to do?"
print "1: Browse Selection"
print "2: Leave"
store_choice = raw_input("")
if store_choice == "1":
StoreBrowse()
if store_choice == "Browse Selection":
StoreBrowse()
if store_choice == "browse selection":
StoreBrowse()
if store_choice == "2":
Main()
if store_choice == "Leave":
Main()
if store_choice == "leave":
Main()
def StoreBrowse():
print "Here is the our store! Feel free to browse our selection!"
print "1: Weapons"
print "2: Armor"
print "3: Potions"
print "4: Leave"
browse_choice = raw_input("")
if browse_choice == "1":
StoreWeapons()
if browse_choice == "weapons":
StoreWeapons()
if browse_choice == "Weapons":
StoreWeapons()
if browse_choice == "2":
ArmorBrowse()
if browse_choice == "Armor":
ArmorBrowse()
if browse_choice == "armor":
ArmorBrowse()
if browse_choice == "3":
PotionBrowse()
if browse_choice == "Potions":
PotionBrowse()
if browse_choice == "potions":
PotionBrowse()
if browse_choice == "4":
StoreMain()
if browse_choice == "Leave":
StoreMain()
if browse_choice == "leave":
StoreMain()
def PotionBrowse():
print "1: Super Potion (Heals for 100) 200 gold"
print "2: Potion (Heals for 75) 150 gold"
print "3: Small Potion (Heals for 50) 100 gold"
print "4: Minor Potion (Heals for 25) 50 gold"
print "5: Leave"
potion_choice = raw_input("")
if potion_choice == "1":
SuperPotion()
if potion_choice == "Super Potion":
SuperPotion()
if potion_choice == "super potion":
SuperPotion()
if potion_choice == "2":
Potion()
if potion_choice == "Potion":
Potion()
if potion_choice == "potion":
Potion()
if potion_choice == "3":
SmallPotion()
if potion_choice == "Small Potion":
SmallPotion()
if potion_choice == "small potion":
SmallPotion()
if potion_choice == "4":
MinorPotion()
if potion_choice == "Minor Potion":
MinorPotion()
if potion_choice == "mionr potion":
MinorPotion()
if potion_choice == "5":
StoreBrowse()
if potion_choice == "leave":
StoreBrowse()
if potion_choice == "Leave":
StoreBrowse()
def SuperPotion():
global player_items
global gold
global player_health
gold = gold - 200
if gold > 0:
print "Congratz on the new Super Potion!"
print "You have " + str(gold) + " gold left"
player_items = "Super Potion"
time.sleep(2)
PotionBrowse()
else:
print "You don't have enough money!"
time.sleep(3)
PotionBrowse()
def Potion():
global gold
global player_health
global player_items
gold = gold - 150
if gold > 0:
print "Congratz on the new Potion!"
print "You have " + str(gold) + " gold left"
player_items = "Potion"
time.sleep(2)
PotionBrowse()
else:
print "You don't have enough money!"
time.sleep(3)
PotionBrowse()
def SmallPotion():
global player_items
global gold
global player_health
gold = gold - 100
if gold > 0:
print "Congratz on the new Small Potion!"
print "You have " + str(gold) + " gold left"
player_items = "Small Potion"
time.sleep(2)
PotionBrowse()
else:
print "You don't have enough money!"
time.sleep(3)
PotionBrowse()
def MinorPotion():
global gold
global player_health
global player_items
gold = gold - 50
if gold > 0:
print "Congratz on the new Minor Potion!"
print "You have " + str(gold) + " gold left"
player_items = "Minor Potion"
time.sleep(2)
PotonBrowse()
else:
print "You don't have enough money!"
time.sleep(3)
PotionBrowse()
def UseItems():
global player_health
global player_items
if player_items == "Super Potion":
player_health = player_health + 100
player_items = ""
print "You now have " + str(player_health) + " health."
MidFight()
if player_items == "Potion":
player_health = player_health + 75
player_items = ""
print "You now have " + str(player_health) + " health."
MidFight()
if player_items == "Small Potion":
player_health = player_health + 50
player_items = ""
print "You now have " + str(player_health) + " health."
MidFight()
if player_items == "Minor Potion":
player_health = player_health
player_items = ""
print "You now have " + str(player_health) + " health."
MidFight()
def UseItemsSelection():
global player_health
global player_items
print "You currently have " + player_items + "."
print "1: Use"
print "2: Leave"
use_items = raw_input("")
if use_items == "1":
UseItems()
if use_items == "Use":
UseItems()
if use_items == "use":
UseItems()
if use_items == "2":
MidFight()
if use_items == "Leave":
Midfight()
if use_items == "leave":
MidFight
def ArmorBrowse():
print "1: Plate Armor (+10 armor) 450 gold"
print "2: Chain Armor (+7 armor) 300 gold"
print "3: Wood Armor (+3 armor) 150 gold"
print "4: An extra sweater (+1 armor) 50 gold"
print "5: Leave"
armor_choice = raw_input("")
if armor_choice == "1":
ArmorPlate()
if armor_choice == "Plate Armor":
ArmorPlate()
if armor_choice == "plate armor":
ArmorPlate()
if armor_choice == "2":
ArmorChain()
if armor_choice == "Chain Armor":
ArmorChain()
if armor_choice == "chain armor":
ArmorChain()
if armor_choice == "3":
ArmorWood()
if armor_choice == "Wood Armor":
ArmorWood()
if armor_choice == "wood armor":
ArmorWood()
if armor_choice == "4":
ArmorSweater()
if armor_choice == "An Extra Sweater":
ArmorSweater()
if armor_choice == "an extra sweater":
ArmorSweater()
if armor_choice == "5":
StoreBrowse()
if armor_choice == "Leave":
StoreBrowse()
if armor_choice == "leave":
StoreBrowse()
def ArmorPlate():
global gold
global player_armor
gold = gold - 450
if gold > 0:
print "Congratz on the new Plate Armor!"
player_armor = "Plate Armor"
print "You have " + str(gold) + " gold left."
time.sleep(2)
ArmorBrowse()
else:
print "You don't have enough money!"
time.sleep(3)
ArmorBrowse()
def ArmorChain():
global gold
global player_armor
gold = gold - 300
if gold > 0:
print "Congratz on the new Chain Armor!"
player_armor = "Chain Armor"
print "You have " + str(gold) + " gold left."
time.sleep(2)
ArmorBrowse()
else:
print "You don't have enough money!"
time.sleep(3)
ArmorBrowse()
def ArmorWood():
global gold
global player_armor
gold = gold - 150
if gold > 0:
print "Contratz on the new Wood Armor!"
player_armor = "Wood Armor"
print "You have " + str(gold) + " gold left."
time.sleep(2)
ArmorBrowse()
else:
print "You don't have enough money!"
time.sleep(3)
ArmorBrowse()
def ArmorSweater():
global gold
global player_armor
gold = gold - 50
if gold > 0:
print "Congratz on the new Sweater!"
player_armor = "Sweater armor"
print "You have " + str(gold) + " gold left."
time.sleep(2)
ArmorBrowse()
else:
print "You don't have enough money!"
time.sleep(3)
ArmorBrowse
def WeaponSword():
global gold
global player_damage
gold = gold - 550
if gold > 0:
print "Congratz on your new Sword!"
player_damage = "Sword"
print "You have " + str(gold) + " gold left!"
time.sleep(2)
StoreWeapons()
else:
print "You don't have enough money!"
time.sleep(3)
StoreWeapons()
def WeaponBattleaxe():
global gold
global player_damage
gold = gold - 300
if gold > 0:
print "Congratz on the new Battle Axe!"
player_damage = "Battle Axe"
print "You have " + str(gold) + " gold left!"
time.sleep(2)
StoreWeapons()
else:
print "You don't have enough money!"
time.sleep(3)
StoreWeapons()
def WeaponClub():
global gold
global player_damage
gold = gold - 150
if gold > 0:
print "Congratz on the new Club!"
player_damage = "Club"
print "You have " + str(gold) + " gold left!"
time.sleep(2)
StoreWeapons()
else:
print "You don't have enough money!"
time.sleep(3)
StoreWeapons()
def WeaponStick():
global gold
global player_damage
gold = gold - 50
if gold > 0:
print "Congratz on the new Stick!"
player_damage = "Stick"
print "You have " + str(gold) + " gold left!"
time.sleep(2)
StoreWeapons()
else:
print "You don't have enough money!"
time.sleep(3)
StoreWeapons()
def StoreWeapons():
global gold
print "1: Sword (+12 damage) 550 gold"
print "2: Battle Axe (+5 damage) 300 gold"
print "3: Club (+3 damage) 150 gold"
print "4: Stick (+1 damage) 50 gold"
print "5: Leave"
weapon_choice = raw_input("")
if weapon_choice == "1":
WeaponSword()
if weapon_choice == "sword":
WeaponSword()
if weapon_choice == "Sword":
WeaponSword()
if weapon_choice == "2":
WeaponBattleaxe()
if weapon_choice == "Battle Axe":
WeaponBattleaxe()
if weapon_choice == "battle axe":
WeaponBattleaxe()
if weapon_choice == "3":
WeaponClub()
if weapon_choice == "club":
WeaponClub()
if weapon_choice == "Club":
WeaponClub()
if weapon_choice == "4":
WeaponStick()
if weapon_choice == "stick":
WeaponStick()
if weapon_choice == "Stick":
WeaponStick()
if weapon_choice == "5":
StoreBrowse()
if weapon_choice == "leave":
StoreBrowse()
if weapon_choice == "Leave":
StoreBrowse()
def Help():
print "Welcome to your simple RPG! It's really kinda sad if YOU of all people have to go to the help section... I mean, this"
print "thing is your own creationg.... and besides it's uber self explanitory anyway.. Just for that, this is not happening"
print "You arn't getting crap."
time.sleep(10)
Main()
def PlayerAlive():
global player_health
if player_health <=0:
print "Sorry, You've died. GAME OVER"
time.sleep(4)
Beggenning()
else:
print "You have " + str(player_health) + " health left"
MidFight()
def MonsterAlive():
global monster_health
global gold
if monster_health <=0:
print"Congratz! You've killed an Ogre!! You get 10 gold for your valient efforts!"
gold = gold + 10
time.sleep(2)
Main()
else:
print "Ogre had " + str(monster_health) + " health left!"
monster_attack()
def Fight():
global player_health
global monster_health
if player_health >0:
player_attack()
monster_attack()
MidFight()
def MidFight():
global player_health
global monster_health
cls()
print "What would you like to do?"
print "1: Attack"
print "2: Use Items"
print "3: Run"
fight_choice = raw_input("")
if fight_choice == "1":
Fight()
if fight_choice == "attack":
Fight()
if fight_choice == "Attack":
Fight()
if fight_choice == "2":
UseItemsSelection()
if fight_choice == "use items":
UseItemsSelection()
if fight_choice == "Use Items":
USeItemsSelection()
if fight_choice == "3":
Run()
if fight_choice == "run":
Run()
if fight_choice == "Run":
Run()
def Run():
terms = []
for i in range(2):
terms.append(random.randint(1, 99))
j = terms[0]
if j >= 50:
print "You've run successfully!"
Main()
else:
print "Running failed!"
FightChoice()
def FightChoice():
global player_health
global monster_health
print "You've found an Ogre!"
print "What would you like to do?"
print "1: Attack"
print "2: Use Items"
print "3: Run"
fight_choice = raw_input("")
if fight_choice == "1":
Fight()
if fight_choice == "attack":
Fight()
if fight_choice == "Attack":
Fight()
if fight_choice == "2":
UseItemsSelection()
if fight_choice == "use items":
UseItemsSelection()
if fight_choice == "Use Items":
UseItemsSelection
if fight_choice == "3":
Run()
if fight_choice == "run":
Run()
if fight_choice == "Run":
Run()
def TreasureFind():
global gold
terms = []
for i in range(2):
terms.append(random.randint(1, 99))
j = terms[0]
if j >= 50:
terms = []
for i in range(2):
terms.append(random.randint(1, 99))
k = terms[0]
print "You have found the treasure!"
print "You have earned " + str(k) + " gold!"
gold = gold + k
Main()
else:
print "Sorry no treasure this time..."
Main()
Beggenning()
Atm it include fighting, treasure finding, shopping. I give you all permission to do whatever you want with this, as long as you tell me how I can inprove it in any form (Or just post your on version of it




