import random

global health

global gold

global you

def attacker ( health = [ 20 ] ) :

damage = random . randrange ( - 10 , 0 )

prob = random . randrange ( 0 , 10 )

ch = raw_input ( "You are met by an attacker

1 to engage

2 to flee

" ) #what you see when an attacker comes

if ( int ( ch ) == 1 ) :

print "You took %s damage" % damage

health. append ( damage )

health = sum ( health )

if ( health < 1 ) :

raw_input ( "You died" ) #what you see when you die

quit ( )

else :

pass

print "You have %s health" % health

elif ( int ( ch ) == 2 ) :

if ( prob < 5 ) :

print "You rolled a %s out of ten could not flee, you took no damage, but your pride is hurt

-1000 pride" % prob #you lost a LOT of pride

elif ( prob >= 5 ) :

print "You rolled a %s out of ten, and successfully avoided your attacker" % prob #you still have pride

else :

pass

raw_input ( "Press Enter to continue" )

def NPC ( you = [ ] , npch = 5 , gold = [ 200 ] ) :

npcgt = random . randrange ( 1 , 5 )

ch = raw_input ( "Hello fellow travler! I bring goods, would you like to buy some?

1 to see his inventory

2 to pass on goods

" ) #this guy is fucking annoying

if ( int ( ch ) == 1 ) :

if ( int ( npcgt ) == 1 ) :

ch1 = raw_input ( "I have a sword! Would you like to buy it? The sword is 50 gold

1 to buy

2 to pass

" )

if ( int ( ch ) == 1 ) :

print "Thank you for the gold!"

gold. append ( - 50 )

gold = sum ( gold )

you. append ( "sword" )

print "

These are your items:"

for i in you:

print i

print "

You now have %s gold" % gold

elif ( int ( ch1 ) == 2 ) :

print "Alright, good travels to you!"

elif ( int ( npcgt ) == 2 ) :

ch2 = raw_input ( "I have loaves of bread, 4 of them. Would you like to buy them? They are 25 gold

1 to buy

2 to pass

" )

if ( int ( ch2 ) == 1 ) :

print "Thank you for the gold!"

gold. append ( - 25 )

gold = sum ( gold )

you. append ( "4 bread" )

print "

These are your items:"

for i in you:

print i

print "

You now have %s gold" % gold

elif ( int ( ch2 ) == 2 ) :

print "Alright, good travels to you!"

elif ( int ( npcgt ) == 3 ) :

ch3 = raw_input ( "I have apples, 5 of them. Would you like to buy them? They are 15 gold

1 to buy

2 to pass

" )

if ( int ( ch3 ) == 1 ) :

print "Thank you for the gold!"

gold. append ( - 15 )

gold = sum ( gold )

you. append ( "5 apples" )

print "

These are your items:"

for i in you:

print i

print "

You now have %s gold" % gold

elif ( int ( ch3 ) == 3 ) :

print "Alright, good travels to you!"

elif ( int ( npcgt ) == 4 ) :

print "I have no items"

elif ( int ( npcgt ) == 5 ) :

ch4 = raw_input ( "I have books, 2 of them. Would you like to buy them? They are 10 gold

1 to buy

2 to pass

" )

if ( int ( ch4 ) == 1 ) :

print "Thank you for the gold!"

gold. append ( - 10 )

gold = sum ( gold )

you. append ( "2 books" )

print "

These are your items:"

for i in you:

print i

print "

You now have %s gold" % gold

elif ( int ( ch4 ) == 2 ) :

print "Alright, good travels to you!"

elif ( int ( ch ) == 2 ) :

print "Alright fellow traveler, good luck!"

else :

pass

raw_input ( "Press enter to continue" )

path = random . randrange ( 0 , 4 )

n = raw_input ( "Hello there! You are a traveler embarking on a long journey, you will face many obstacles, and meet many people. What is your name?

" )

print "Hello %s! Good luck on your travels!

" % n

raw_input ( "Press enter to begin your journey

" )

if ( int ( path ) == 0 ) :

attacker ( )

NPC ( )

NPC ( )

NPC ( )

attacker ( )

elif ( int ( path ) == 1 ) :

NPC ( )

attacker ( )

NPC ( )

attacker ( )

attacker ( )

elif ( int ( path ) == 2 ) :

NPC ( )

attacker ( )

NPC ( )

NPC ( )

attacker ( )

elif ( int ( path ) == 3 ) :

attacker ( )

attacker ( )

NPC ( )

NPC ( )

attacker ( )

else :

NPC ( )

NPC ( )

attacker ( )

NPC ( )