view gamelib/scenes/scene_widgets.py @ 252:dfc89bc64fdb

Start of walkthrough "unit test" and associated fixes and tweaks.
author Jeremy Thurgood <firxen@gmail.com>
date Fri, 27 Aug 2010 16:45:47 +0200
parents 12c4f87ea424
children 3b4a78422201
line wrap: on
line source

"""Generic, game specific widgets"""

import random

from gamelib.state import Thing, Result


class Door(Thing):
    """A door somewhere"""

    DEST = "map"
    SCENE = None

    def __init__(self):
        self.NAME = self.SCENE + '.door'
        Thing.__init__(self)

    def is_interactive(self):
        return True

    def interact_without(self):
        """Go to map."""
        self.state.set_current_scene("map")

    def get_description(self):
        return 'An open doorway leads to the rest of the ship.'

    def interact_default(self, item):
        return Result(random.choice([
            "Sadly, this isn't that sort of game.",
            "Your valiant efforts are foiled by the Evil Game Designer.",
            "Waving that in the doorway does nothing. Try something else, perhaps?",
            ]))