示例#1
0
def move(controller, direction, what=None):
    """Moves an object from one position to another"""
    # XXX Player shouldn't see his own movements
    pos = controller.character.position
    pos2 = controller.world.next(pos, direction)
    print pos, pos2, direction
    if pos2:
        controller.broadcast(
            YELLOW_TXT("\n{} walks away {}.".format(
                    controller.character.name,
                    get_direction_name(direction))),
            protocol=controller, send2self=False)

        # Change position
        controller.character.position = pos2

        controller.broadcast(
            YELLOW_TXT("{} arrives from the {}.".format(
                    controller.character.name,
                    get_direction_name(direction, invert=True))),
            protocol=controller, send2self=False)

        # When a person enters your room, list updated occupants
        common.list_occupants(controller, broadcast=True)
        l(controller) # Performs 'look' on client
示例#2
0
def l(controller):
    """Displays the contents and description of the room
    controller.character is in. Passively + privately examine the
    state of the world without side effect
    """
    room = controller.character.get_room(controller.world)
    controller.sendLine("\n{}".format(BLUE_TXT(room.name)))
    controller.sendLine(room.description)
    controller.sendLine("{} {}".format(
            LIGHTBLUE_TXT("exits:"),
            controller.character.get_room(controller.world).get_exits()))    
    common.list_occupants(controller)