I'm trying to make it so in my game when you equip your dagger it will change the variable dagger so I can tell if its equipped or not.

from sys import exit
from random import randint

class Game(object):

dagger = 0

def __init__(self, start):
    self.quips = [
        "GAME OVER... TRY AGAIN?"
    ]
    self.start = start

def play(self):
    next_room_name = self.start

    while True:
        print "\n--------"
        room = getattr(self, next_room_name)
        next_room_name = room()

def death(self):
    print self.quips[randint(0, len(self.quips)-1)]
    exit(1)

def MENU(self):
    print "Welcome to Alpha 0.01"
    print "To play type 1. To quit type 0."
    print "NOTE: Do not try to equip or unequip"

    action = raw_input("> ")

    if action == "1":
        return 'The_Beginning'

    elif action == "0":
        return 'The_Beginning'

def The_Beginning(self):
    print "You are a hobbit!"
    print "You are currently wearing a leather tunic and a pair of leather pants."
    print "You have a flint dagger and a small sack containing three gold coins."
    print "Your village has been attacked at the dead of night by a dragon and "
    print "an orc battalion. You are in your bedroom. Inside the town there are"
    print "five buildings. There is your house, guard station, mess hall, city "
    print "hall, and the inn. Be wary of the orcs and their dragon."
    print ""
    print "Inside your room is a bed, a dresser, a window, and a door."
    print "The bed is east, dresser is south, window is west, and the door is"
    print "north."
    print ""
    print "To list your available options type list actions"

    action = raw_input("> ")

    if action == "list actions":
        print "go north, go east, go west, go south, list actions, equip ?, unequip ?."
        return 'The_Beginning'

    elif action == "go north":
        print "You walk towards the door cautiously."
        return 'door1'

    elif action == "go east":
        print "You move towards the bed."
        return 'bed1'

    elif action == "go west":
        print "You move cautiously towards the window."
        return 'window1'

    elif action == "go south":
        print "You move towards the dresser."
        return 'dresser1'

    elif action == "equip flint dagger":
    if dagger == 0:
            print "TEST MESSAGE: You equip the flint dagger."
            return 'The_Beginning'
        dagger = 1
        else:
            print "Dagger is already equipped."
            return 'The_Beginning'

    elif action == "unequip flint dagger":
        if dagger == 1:
            print "TEST MESSAGE: You unequip the dagger"
            return 'The_Beginning'
        dagger = 0
        else:
            print "Dagger is not equipped."
            return 'The_Beginning'

    else:
        print "You can't do that!"
        return 'The_Beginning'

a_game = Game("MENU")
a_game.play()

I don't understand why it won't work. Please help.

Recommended Answers

All 3 Replies

72 to 75 indention at least is messed up.

That indentation is a copy paste error. In the code it isn't wrongly indented.

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.