11

私はPythonTheHard Wayに取り組んでいますが、上記のエラーが発生し、理由がわかりません。できると思ったフィラーテキストのほとんどを取り出しました。少し長ければごめんなさい。

from sys import exit
from random import randint

class Game(object):

    def __int__(self, start):
        self.quips = [
             "You died. You kinda suck at this.",
             "Your mom would be proud. If shw were smarter.",
             "Suck a loser.",
             "I have a small puppy that's better at this."
        ]
        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 central_corridor(self):
        print "The Gothons of Planet Percal #25 have invaded your ship and destroyed"


        action = raw_input("> ")

        if action == "shoot!":
            print "Quick on the draw you yank out your blaster and fire it at the Gothon."
            return 'death'

        elif action == "dodge!":

            print "Like a world class boxer you dodge, weave, slip and slide right"
            return 'death'

        elif action == "tell a joke":

            print "Lucky for you they made you learn Gothon insults in the academy."
            return 'laser_weapon_armory'

        else:
            print "DOES NOT COMPUTE!"
            return "central_corridor"

    def laser_weapon_armory(self):
        print "You do a dive roll into the Weapon Armory, crouch and scan the room"
        print "for more Gothons that might be hiding. It's dead quiet, to quiet,"
        print "You stand up and run to the far side of the room and find the"
        print "neutron bomb in its container. There's a keypad lock on the box"
        print "and you need the code to get the bomb out. If you get the code"
        print "get the bomb. The code is 3 digits."
        code = "%d%d%d" % (randint(1,9), randint(1,9), randint(1,9))
        guess = raw_input("[keypad]")
        guesses = 0

        while guess != code and guesses < 10:
            print "BZZZZEDDD!"
            guesses += 1
            guess = raw_input("[keypad]> ")

        if guess == code:
            print "The container clicks open and seal breaks, letting gas out."
            print "You grab the neutron bomb and run as fast as you can to the"
            print "bridge where you must place it in the right spot."
            return 'the_bridge'

        else:
            print "The lock buzzes one last time and then you hear a sickening"
            print "melting sound as the mechanism is fused together."
            print "You decide to sit there, and finally the Gothons blow up"
            print "ship from their ship and you die."
            return 'death'

    def the_bridge(self):
        print "You burst onto the Bridge with the netron destruct bomb"


        action = raw_input("> ")

        if action == "throw the bomb":
            print "In a panic you throw the bomb at the group of Gothons"
            return 'death'

        elif action == "slowly place the bomb":
            print "You point your blaster at the bomb under your arm"
            return 'escape_pod'

        else:
            print "DOES NOT COMPUTE!"
            return "the_bridge"

    def escape_pod(self):
        print "You rush through the ship desperately trying to make it to"


        good_pod = randint(1,5)
        guess = raw_input("[pod #]> ")

        if int(guess) != good_pod:
            print "You jump into pod %s and hit the eject button." % guess
            return 'death'

        else:
            print "You jump into pod %s and hit the eject button." % guess
            print "time. You won!"
            exit(0)

a_game = Game("central_corridor")
a_game.play()
4

1 に答える 1

18

スペルを間違えました__init__

def __int__(self, start):
        ^ no "i"
于 2012-08-15T06:33:49.810 に答える