I am working on a text adventure for my cis class. Just to let you know, the code is graphic, and may be offensive to those who might be a begger LOL. Anyways, my functions do not seem to work properly. I looked over them, they seem fine. where am i going wrong?
here is the code...it's alot.

# My goal is to make the most in-depth text adventure
# possible, where as much of the game world is interactive
# as possible. I plan to have butterfly catching, swimming races,
# jobs, schools, etc.
# I hope for this game to be a text based simulation of life.

######################################### SET THE GLOBALS ########################################################

global shoes
shoes = 0
global underwear
underwear = 0
global bottoms
bottoms = 0
global tops
tops = 0
global bags
bags = 0
global cellphones
cellphone = 0
global laptops
laptops = 0
global daggers
daggers = 0
global faith
faith = 100
global pens
pens = 0
global baseball_bat
baseball_bat = 0
global cars
cars = 0
global cash
cash = 1000
global guns
guns = 0
global houses
houses = 1
global hats
hats = 0
global sunglasses
sunglasses = 0
global earrings
earrings = 0
global tvs
tvs = 0
global tables
tables = 0
global fridges
fridges = 0
global stove
stove = 0
global sink
sink = 0
global movie_player
movie_player = 0
global food
food = 100
global bookshelves
bookshelves = 1
global books
books = 0
global toilet
toilet = 0
global xbox360
xbox360 = 0
global psp
psp = 0
global xbox_games
xbox_games = 0
global psp_games
psp_games = 0
global sex_toys
sex_toys = 0
global beds
beds = 0
global weed
weed = 0
global bubbler_bowl
bubbler_bowl = 0
global rolling_papers
rolling_papers = 0
global bullets
bullets = 0
global tutorial
tutorial = 1
global guide_card
guide_card = 0
global guide_man
guide_man = 0
global guide_anger
guide_anger = 0
#the most important global
global inventory
inventory = cash, 









######################################### THE MAIN SCREEN #####################################################





def game():
    print """Welcome to TEXTUAL LIFE version 1.0 alpha."""
    more = raw_input('Please Press Enter: ')
    if more == '':
        print ""
        print ""
        print """In this game you will live your life in a completely text based world, the world of Tekstovia."""
        more = raw_input('Please Press Enter: ')
        if more == '':
            print ""
            print ""
            print """You will start out with the birthing process, and then a brief tutorial to guide you
                in the ways of Tekstovia. I hope you thoroughly enjoy this world, as I have worked very hard
                to bring it to you. """
            main()
        else:
            main()
    else:
        print """You must press the enter button."""
        print ""
        print ""
        game()


############################################ START GAME #####################################################
def main():
    print ""
    print ""
    print """You are born into the land. You have nothing but a house which you will start out with. A guide
    has come to your house to teach you how to play the game."""
    print ""
    print ""
    more = raw_input('Press Enter to enter your House: ')
    if more == '':
        home_livingroom()
    else:
        print ""
        print ""
        print """You must press enter."""
        game()

#################################### THE FIRST ENTRY TO YOUR LIVING ROOM ######################################
def home_livingroom():
    global tutorial
    print "Your cash is..."
    print cash
    print ""
    print ""
    print """You are in your home. You see that you are in the living room. there is a man stabding in there and he gives
you 1000 dollers in cash he is a tall white man with black hair he is wearing jeens and a sweater he has working boots on.
Around you are bright blue walls. There is white carpeting on ther floor but there is a big stain in it. Looks like pen ink
was spilled on it. There is a white ceiling whit a brown fan with four blades. To the north is the bedroom and to the west
is the kitchen. But first you should 'talk to man'."""
    print ""
    print ""
    prompt_living()

def prompt_living():
    global cash
    print "Your cash is..."
    print cash
    prompt = raw_input('What do you do? ')
    if prompt == 'pick up man':
        print "You pick up the man, but he doesn't like it, you put him down."
        print ""
        print " 'Don't ever do that again!' the man says to you. "
        print ""
        prompt_living()
    elif prompt == 'kill the man':
        print "That is not a good idea."
        print ""
        prompt_living()
    elif prompt == 'talk to man':
        tutorial()
    elif prompt == 'kiss man':
        print ""
        print "You lay a big wet one on the mans lips. He smiles, obviously liking it."
        print ""
        prompt_living()
    elif prompt == 'kick man in the nuts':
        print ""
        print """ You kick the man hard in his nuts. He doubles over. You decide now might be the time to piss on him."""
        print ""
        prompt_living()
    elif prompt == 'piss on man':
        print ""
        print "You piss on the poor man. Why don't you leave him alone?"
        print ""
        prompt_living()
    elif prompt == 'shit on man':
        print ""
        print """You knock the man to the floor, and pull down your pants. You take a great big shit on his chest."""
        print ""
        prompt_living()
    elif prompt == 'put man in the fan':
        print ""
        print """You pick up the man, and you lift him towards the fan. You decide that chopping off his head is a
        bad idea, so you put him down.

        "Quit messing around," he says. """
        print ""
        prompt_living()
    elif prompt == 'suck mans dick':
        print ""
        print """You forcebly pull down his pants and begin to suck his little dick."""
        print ""
        print """He busts in your mouth. Looks like you got some toothpaste."""
        print ""
        prompt_living()
    elif prompt == 'beat the shit out of the man' or 'fuck man up' or 'kick mans ass':
        print ""
        print """You say hi to the man then you go to shake his hand then you grab it forcedley then you jam you knee
into his nuts. he starts to squeel like a pig then you pick him up by his hair then you take you right hand and you start
yo smash it into his nose,breaking it. you take his foot and bend it till it breaks then you shove it up his ass.
Now he is crying like a bitch then you take you index finger and gauge his eyes out. then you put him threw the wall.
Then you spit on him and GET THE FUCK OUT OF MY HOUSE butthen you take his wallet and get an extra 10000 dollers. """
        cash = cash + 10000
        prompt_living()
    else:
        print "I do not understand you. Please make some sense."
        prompt_living()

def tutorial():
    print ""
    print """You decide to talk to the man.

        "Hello," the man says.

        "Now it is time to teach you how to play the game. Follow me to the market."
        """
    print ""
    market_tut()

def market_tut():
    global cash, guide_card
    print ""
    print """The man tells you, "Welcome to the Market in Petoria. Here you have many shops. There is a Bank,
    The B&M Bank of Petoria, there is a strip club, called Daddy's Little Whores, a mall, named B&M Mall of Petoria,
    and a grocery store called Eat Our Meat. The mall has many stores inside of it, including Amunation, which has weapons,
    The Clothing District, called Where Our Shit, and many other stores you will find interesting."

    The man drops a card, and tells you to pick it up.

    "Just type 'pick up card' and you will pick it up."

    """
    prompt_market_tut()

def prompt_market_tut():
    global cash, guide_card
    print "Your cash is...$"
    print cash
    prompt = raw_input('What do you do? ')
    if prompt == 'pick up card':
        guide_card = guide_card + 1
        print ""
        print """You can call the number on this card if you have any questions. You will need a phone to do that.
        We should continue the tutorial now, but remember, you can pick up almost anything."""
        print ""
        market_tut2()
    else:
        print "Please pick up the card."

def market_tut2():
    global cash
    print "Your cash is ...$"
    print cash
    print ""
    print """The man tells you, "Other things you can do are 'buy', 'kill', 'hit', 'stab', 'shoot', 'kick', 'steal' or
    'steal from', 'rape', 'shove',  'steal', 'rape', and many others. Lets try these out on the begger sitting on the
    curb. Type a few of these commands towards the begger, such as 'hit begger'. Tell me 'I am done' when you are ready to
    continue."

    """
    prompt_market_tut2()

def prompt_market_tut2():
    global daggers, guns, cash
    print "Your cash is...$"
    print cash
    prompt = raw_input('What do you do? ')
           
    if prompt == 'buy begger':
        print ""
        print """The begger tells you, "For $50 I will do what ever you want me to." """
        print ""
        prompt_market_tut2()
    elif prompt == 'kill begger':
        print ""
        print """you go up to the begger and you give him 1000 dollers. he thanks you and you walk awy till he cant see you.
then you wait till he goes in to an alley wher he sleep then you sneek up on him and you grab him he yells for help then you
tak his arm and brake it be hind his back then he scream"please i wont tell anyone that you did this to me please let
me go" and then you say "SHUT THE FUCK UP and break his other arm. then youlet go and he falls to the groung and then
the find a pipe on the ground and you grab it then you break his knees. now you sit on his chest and start punching him
in the face. you get up take your money back then you take a piece of glass on theground and you cut his dick off and
then you cut his throat and walk away triumphent.

"""
        print ""
        prompt_market_tut2()
    elif prompt == 'hit begger':
        print ""
        print """You ball up your fists, and walk slowly up to the begger. "Do you want a sandwich?" You ask him.

    "Why yes, I haven't eaten in three..."

    You interupt him with you fist. You grab his long, nappy, homeless hair, and begin to pummel his nose. You don't stop
    until you see that his nose has permantly been pushed into his face.

    "Don't ever let me see your flea bag pussy ass on my streets again!" You say, and then kick him in the nuts. One of
    his balls falls out of his mouth."""
        print ""
        prompt_market_tut2()
    elif prompt == 'stab begger':
        if daggers == 0:
            print ""
            print "You have nothing to stab him with."
            prompt_market_tut2()
        else:
            print ""
            print """You stab the begger in the throat, and twist. Blood sprays everywhere.
        "You got blood on me asswipe!" You say, and stab him again."""
            prompt_market_tut2()
    elif prompt == 'shoot begger':
        if guns == 0:
            print ""
            print "You have nothing to shoot him with."
            print ""
            prompt_market_tut2()
    elif prompt == 'kick begger':
        print ""
        print """You walk up to the begger...he saes "well hello there" you say hi no you say how are you doing today
the begger says does it really look like i am doing ok you laugh then you yell at him its going to get worse then you kick
hisknee in so it breaks backwards the you stopm his face it crushing his nos the you put his head on the curb then youy stomp
on the back of his head breaking his neck."""
        print ""
        prompt_market_tut2()
    elif prompt == 'shove begger':
        print ""
        print """You look contemptously at the begger, flies buzzing around his nappy head. You notice that a steel bar
        juts out from a wall in the alley way. You grab him up by his jacket, and shove him towards it. The steel jabs into
        his back, just missing his spine. """
        print ""
        prompt_market_tut2()
    elif prompt == 'steal from begger':
        print ""
        print """You decide to steal from the begger, while he takes a piss. You notice a change jar sitting behind him.
        You kyfe that shit, and you get a dollar."""
        cash = cash + 1
        prompt_market_tut2()
    elif prompt == 'steal begger':
        print """You try to steal the begger, but you don't think he would be worth very much."""
        prompt_market_tut2()
    elif prompt == 'rape begger':
        print ""
        print """The begger is sound asleep. You walk up behind him quiet as a mouse. You knock him out with your fists.
        You then rip his pants off, and see he is not wearing any underwear. You think of the hottest girl around, grow hard
        and then put your dick in his ass. You continue to rape him for half of an hour.

        "Wish I could last that long, " The man says to you when you are done.
        """
        print ""
        prompt_market_tut2()
    elif prompt == 'i am done' or 'done':
        print ""
        print """The man tells you, "Alright, I hope you had fun. Let's move on with our tutorial." """
        print ""
        market_tut3()
    elif prompt == 'shoot begger':
        if guns == 0:
            print ""
            print """You have no gun to shoot him with."""
            print ""
        else:
            print ""
            print """You shoot the begger first in the feet, then in his ankles, then to his knees. You shoot
            him in the dick, then in his ears. Finally you shoot him in the hands. You decide to let him live
            in this bloody mess as long as he can.
            """
            print ""
            prompt_market_tut2()
    elif prompt == 'kiss begger':
        print ""
        print """You lay a big wet sloppy kiss on the begger. A smile breaks across his face."""
        print ""
        prompt_market_tut2()
    elif prompt == 'i am done' or 'done':
        market_tut3()

def market_tut3():
    global cash
    print "Your cash is...$"
    print cash
    print """The man tell you, "Now for your last lesson. You can walk to places by typing 'go' and the either
north, south, east, west, or southest, northeast, etc. You can shorten these to n, s, e, w, ne, nw, se, sw if you want,
this will make the game easier, too. Now, I will leave you to be. Go, have fun!"

    And with that, the man leaves. You are now on your own. Type 'help at anytime for a list of common commands.

    """
    market_petoria()

################################ THE START OF THE ACTUAL GAME ###########################################


# YOU START OFF IN THE PETORIA MARKET


def market_petoria():
    print ""
    print ""
    print ""
    print ""
    print ""
    print ""
    print ""
    print ""
    print ""
    print ""
    print ""
    print ""
    print ""
    print ""
    print ""
    print ""
    print """You are in the Market of Petoria """
    print ""
    print ""
    print ""
    print ""
    print "Your cash is...$"
    print cash
    print "Your guns are..."
    print guns
    market_main_prompt()


# The prompt for the main room of the market in petoria. Situated in the center of the market
# to the sw is the grocery store, to the nw is the strip club, to the se is the mall, and to the ne
# is the bank.

def market_main_prompt():
    global begger
    begger = 1
    global woman_music
    woman_music = 1
    global beer
    beer = 1
    global mp3_player
    mp3_player = 1
    global guns, clothes
    print "         You have $",cash
    prompt = raw_input('What do you do? ')

    ################### LOOK AROUND ###################

    if prompt == 'look around' or 'look':
        if begger == 1 and beer == 1:
            print
            print "There is a BEGGER dinking BEER in an alley."
            check_woman()
            market_main_prompt()
        elif begger == 1 and beer == 0:
            print
            print "There is a begger looking sad because somebody stole his beer."
            check_woman()
            market_main_prompt()
        elif begger == 0 and beer == 1:
            print
            print """There is a the body of a dead begger here, and a bottle of beer next to him."""
            check_woman()
            market_main_prompt()
        elif begger == 0 and beer == 0:
            print
            print """The dead body of a begger lay here."""
            check_woman()
            market_main_prompt()
        else:
            print "There has been an error."
            check_woman()
            market_main_prompt()
    

    ################### KILL BEGGER #####################

    elif prompt == 'kill begger':
        kill_begger()










def kill_begger():
    global begger, beer
    if begger == 1 and guns == 1:
        print
        print "You shoot the begger in the face. Blood splats everywhere."
        begger = begger - 1
        market_main_prompt()
    elif begger == 1 and guns == 0:
        print
        print """You walk up to the begger, and grab his head. You make him bite the curb, and then smash your foot down
upon his head. His teeth jam into his brain."""
        begger = begger - 1
        market_main_prompt()
    else:
        print "There has been an error in the code. Please tell the Creator."
        market_main_prompt()


##### WITHIN LOOK AROUND, CHECK IF woman_music == 0 ###########

def check_woman():
    if woman_music == 1 and mp3_player == 1:
        print
        print """There is a woman standing here, listening to her mp3 player."""
    elif woman_music == 1 and mp3_player == 0:
        print
        print "There is a woman standing here yelling about being robbed."
    elif woman_music == 0 and mp3_player == 1:
        print
        print "The dead body of a woman is laying here. An mp3 player is in her right hand."
    elif woman_music == 0 and mp3_player == 0:
        print
        print "The dead body of a woman is laying here."
    else:
        print "There has been an error, you should tell The Creator."

help would be appreciated.

okay, i know this is not exactly what you asked but in your code i noticed a lot of:

print ""

You dont need to do that as just going

print

Without the "" marks will do the exact same thing. Or you could use

print """\n\nIn this game you will live your life in a completely text based world, the world of Tekstovia."""

and that will stop the need for those other prints.

Also, put this whole thing through some kind of spellchecker because there are so many spelling mistakes.

What functions dont work? I mean there are a lot of functions you need to be a bit more specific then to just say my functions dont work. Do all of them not work, or just one or two?

basically, after the tutorial ends (The user types in 'done' or 'i am done', the command 'kill begger' doesn't work.
The goal is to be able to kill the begger global, and when the player next views the room description, it shows that the global begger has been killed.

For example;

(user types 'look')

there is a begger here with a beer.

(user types 'kill begger')
(user types 'look')
there is a dead begger here. A beer is by his hand.

Does this make more sense? if you run the code you will see that the kill begger command only repeats the function called by 'look' command.

Just a tip. If you want other people to be able to play this game you need to fix a few things. The one that instantly comes to mind is that you spell beggar like "begger" when the actuall spelling is beggar. For this reason some people will find it more difficult to play your game.

and the problem is on line 467. There you say

if prompt == 'look around' or 'look':
    #do stuff

The problem is that python will check if prompt is equal to "look around" and then for the next one is does not check if prompt is equal to look. If you wanted this to work then you would have to go

if prompt == "look around" or prompt == "look":

Cause at the moment it checks the first statement and it returns false because prompt does not equal "look around" but then seeing there is nothing being compared to "look" the program returns True becuase "Look" is not an empty string and therefore returns true in the case of an if statement when nothing is being compared.

Thank you for the help. I will change my source code. As for the spelling errors, My 14 year old brother wrote most of the story line, and after I realized that he wasn't that good, (plus my teacher wants me to write the WHOLE thing), I fired him. I have to yet fix all the errors. Thank you for all the help.

karim abu NuH

if prompt == "look around" or prompt == "look":

Another solution for this problem that will help if you had a third option would be this:

if prompt in [ 'look around', 'look', 'observe', 'admire' ]:

So if you use the in keyword, it'll match it to any value within the iterable container (list). This can clean up a lot of statements like that.

Thank you jlm699, I will keep that in mind. I have fixed the spelling errors. The biggest concern now though is that after you type in 'done' or 'i am done', you are just in the market place. In this function, at least market_petoria or below, when you look around, you see the begger is holding a beer. When you kill the begger, and type look around, it doesn't say that the begger is dead, as my code says it should.

I think the problem is with the way I use the globals. Can someone look at this code and tell me what I should do to fix it, or at least give me some advice on how to make it better?

Okay, I will keep that in mind. Another problem is that after market_petoria() it should go like this:

look around:

"There is a beggar here, drinking a beer."

kill beggar:

you kill the beggar

look around:

There is a dead begger here.

I set the global begger to 0 when you kill the beggar,

and if beggar == 0 it should print "The begger is dead" after user types look around.
But, it doesn't show that the beggar is dea,d he is still drinking his beer.
What is going on? Am I using globals wrong?

There are many ways to avoid all the global declarations in your program, for example you could put this at the top of your program

class var(object):
    shoes = 0
    underwear = 0
    bottoms = 0
    tops = 0
    bags = 0
    # etc

Then in the rest of the code, you could use var.shoes = 2 for example. This would drop all the global declarations from your program.

Thank you, I will play around with that. I still wonder what is wroong with this code,
in prompt_market_main(),

if prompt == 'look':

doesn't function.
this is basically what it is:

def prompt():
    global begger
    more = raw_input('What do you do? ')
    if more == 'look':
        if begger == 1:
            print "The begger is alive"
        elif begger == 0:
            print "the begger is dead."
     elif more == 'kill beggar':
            print "You kill the begger."
            begger = begger - 1
            prompt()

I have gotten the code to work by itself, in another program, but can't find the problem in the code posted above. When you kill the begger, and look, it still shows him as alive.

NOTE: The code i just posted is only an example, the problem code is in a previous post in this thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.