Example #1
0
def cmd_unset(s, r):
    '''unset <setting> on <object>

    Change the setting on the object to False.

    For a list of available settings, use @info <object>

    '''

    obj = find(r, s.room, s.player, s.room)
    if obj is None:
        s.message('You do not see that here.')
        return

    setting = r['setting']

    val = obj.setting(setting)
    if val in (True, False):
        value = 'False'
    else:
        value = ''

    try:
        success = obj.setting(setting, value)
    except ValueError, e:
        s.message('Error:', e)
Example #2
0
def cmd_set(s, r):
    '''set <setting> on <object> [to|=|+=|-= <value>]

    Change the setting on the object. Value defaults to True if
        not specified.

    For a list of available settings, use @info <object>

    For list settings (with [square brackets]) setting a value will
        add the given value to the list. You can also use += to add
        an item to the list or -= to remove an item.

    '''

    obj = find(r, s.room, s.player, s.room)
    if obj is None:
        s.message('You do not see that here.')
        return

    setting = r['setting']
    value = r.get('value', "True")
    setop = r.get('setop', '=')
    if setop=='to':
        setop = '='

    try:
        if setop == '-=':
            value = '-DEL-' + value
        success = obj.setting(setting, value)
    except ValueError, e:
        s.message('Error:', e)
Example #3
0
def cmd_destroy(s, r):
    '''destroy <object>

    Destroy the specified object.

    '''

    objname = r.get('objname', '')
    objtzid = r.get('objtzid', 0)
    if not objname and not objtzid:
        s.message('Try: @destroy <object>')
        raise SyntaxError

    player = s.player
    room = s.room
    obj = find(r, room, player)
    if obj is None:
        obj = rooms.getname(objname) or \
                rooms.get(objtzid) or \
                tzindex.get(objtzid)

    if obj is not None:
        s.message('You speak a word of power and ...')
        s.room.action(dict(act="destroy", actor=player))
        obj.destroy()

    else:
        s.message('Object not found.')
Example #4
0
def cmd_get(s, r):
    '''get [the] <item>

    Pick up something and put it in your inventory.

    Alternate: take

    '''

    objname = r.get('objname', '')
    objtzid = r.get('objtzid', '')
    if not objname and not objtzid:
        s.message('Try: get <item>')
        raise SyntaxError

    if objname == 'all':
        for item in filter(s.player.can_see, s.room.items()):
            if s.player.get_item(item, s.room):
                s.player.message('You get the', item, '.')
        return

    item = find(r, s.room)
    if not s.player.can_see(item):
        allitems = find(r, s.room, all=True)
        if allitems is not None:
            iis = filter(s.player.can_see, allitems)
            if iis:
                item = iis[0]
            else:
                item = None
        else:
            item = None
    have = s.player.itemname(objname) or s.player.item(objtzid)

    if item:
        if item.gettable:
            if s.player.get_item(item, s.room):
                s.player.message('You get the', item, '.')
        else:
            s.message('You cannot get that.')

    elif have:
        s.message('You already have that.')

    else:
        s.message('You do not see that here.')
Example #5
0
def cmd_info(s, r):
    '''info [<item>|<player>|<mob>|<room>|<exit>]

    Get more info about given object or about own player if none given

    '''

    objs = find(r, s.room, s.player, s.player, all=True)

    if not objs:
        # Try to find the object close by, but if nothing is
        #   found, try the search globally.
        objs = find(r, s.room, s.player, s.player, all=True, g=True)

    if objs:
        for obj in objs:
            s.mlmessage(obj.wizinfo())
    else:
        s.message('That does not exist.')
Example #6
0
def cmd_info(s, r):
    '''info [<item>|<player>|<mob>|<room>|<exit>]

    Get more info about given object or about own player if none given

    '''

    objs = find(r, s.room, s.player, s.player, all=True)
    objs = filter(s.player.can_see, objs)

    if objs:
        for obj in objs:
            s.mlmessage(obj.info())
    else:
        s.message('You do not see that here.')
Example #7
0
def cmd_long(s, r):
    '''long [for] [<object>] is <text>

    Set the long description for the given object
        or for the current room if no object given.

    '''

    obj = find(r, s.room, s.player, s.room)
    newlong = r['new']

    if obj is not None:
        obj.long = newlong
        s.message('Long description set on', obj, '.')

    else:
        s.message('No such object to rename.')
Example #8
0
def cmd_short(s, r):
    '''short [for] [<object>] is <text>

    Set the short description for the given object
        or for the current room if no object given.

    '''

    obj = find(r, s.room, s.player, s.room)
    newshort = r['new']

    if obj is not None:
        obj.short = newshort
        s.message('Short description set on', obj, '.')

    else:
        s.message('No such object to rename.')
Example #9
0
def cmd_rename(s, r):
    '''rename [<object>] to <new name>

    Set the name for the given object
        or for the current room if no object given.

    '''

    obj = find(r, s.room, s.player, s.room)
    newname = r['new']

    if obj is not None:
        oldname = obj.name
        obj.name = newname
        s.message(oldname, 'renamed to', newname, '.')

    else:
        s.message('No such object to rename.')
Example #10
0
def cmd_study(s, r):
    '''study <object>|<object type>

    Learn more information about an object, or one of
        the different types of clonable objects that
        are available.

    See the lists of cloneables using the @list command.

    '''

    objname = r.get('objname', '')
    objtzid = r.get('objtzid', 0)
    if not objname and not objtzid:
        s.message('Try: @study <object>')
        raise SyntaxError

    obj = find(r, s.room, s.player, s.room)
    if obj is not None:
        doc = obj.__doc__
        name = class_as_string(obj)
        found = obj
    else:
        found = False
        for mod in items, mobs, rooms:
            for name in mod.classes():
                if objname == name:
                    found = name
                    cls = getattr(mod, name)
                    doc = cls.__doc__

        if not found:
            s.message('No such thing to study.')
            return

    if doc is None:
        doc = '... but it is still a mystery'

    name = colors.white(name)
    s.message('You study the', found)
    msgs = doc.split('\n')
    s.mlmessage(msgs, indent=4)
Example #11
0
def cmd_look(s, r):
    '''look  [[at] <item>|<player>|<mob>|<room>|<exit>]

    Examine some object, player, room, etc more closely.

    You can also say:   look [at] self | myself | me   or
        look around | look about | look [at] the room

    Alternate: l

    '''

    player = s.player
    room = s.room
    obj = find(r, room, player, room)

    if obj is None:
        objname = r.get('objname', '')
        if objname.lower() in ('self', 'myself', 'me'):
            obj = player
        elif objname.lower() in ('around', 'about', 'the room'):
            obj = room

    if obj is not None and player.can_see(obj):
        if obj is not player:
            s.message('You look at the', obj, '.')
        else:
            s.message('You look at yourself.')
        msg = player.look_at(obj)
        if msg:
            s.mlmessage(msg)
        else:
            s.message('Nothing special.')
        s.room.action(dict(act='look', actor=player, actee=obj))
    else:
        s.message('You do not see that here.')
Example #12
0
def cmd_use(s, r):
    '''use <item> [on <object>]

    Use the given item, if that makes sense. Use it on the
        given object, if given.

    '''

    objname = r.get('objname', '')
    objtzid = r.get('objtzid', 0)
    if not objname and not objtzid:
        s.message('Try: use <item>')
        raise SyntaxError

    obj2name = r.get('obj2name', '')
    obj2tzid = r.get('obj2tzid', 0)

    player = s.player

    item = player.itemname(objname) or player.item(objtzid)
    if item is None:
        s.message('You do not have that.')
        return
    else:
        use = getattr(item, 'use', None)
        if use is None:
            s.message('You cannot use that.')
            return
        else:
            findr = dict(objname=obj2name, objtzid=obj2tzid)
            obj = find(findr, s.room, player)
            if (obj2name or obj2tzid) and obj is None:
                s.message("You cannot use it on that. It's not here.")
                return
            else:
                use(player, obj)
Example #13
0
def cmd_teleport(s, r=None):
    '''teleport [to [<room>|<character>]] OR teleport <object> to <room>

    Teleport self to the named room or character, or if no name is given
        teleport self to home, OR

    Teleport the object to the room.

    '''

    room = s.room
    player = s.player
    if room is not None:
        room.action(dict(act='teleport', actor=player))

    objname = r.get('objname', '')
    objtzid = r.get('objtzid', 0)

    destname = r.get('obj2name', '')
    desttzid = r.get('obj2tzid', 0)

    if (objname or objtzid) and (destname or desttzid):
        destination = rooms.getname(destname) or rooms.get(desttzid)
        if destination is None:
            s.message('No such place.')
            return

        obj = find(r, room, player, room) or \
                players.getname(objname) or players.get(objtzid) or \
                mobs.getname(objname) or mobs.get(objtzid) or \
                tzindex.get(objtzid)
        if obj is None:
            s.message('No such object.')
        elif obj._bse == 'Room':
            s.message('You cannot teleport a room.')
        else:
            obj.teleport(destination)
            s.message('You teleport', obj, '.')

    elif not (destname or desttzid):
        # send the player home
        player.teleport()

    else:
        destination = rooms.getname(destname) or \
                        rooms.get(desttzid)

        if destination is None:
            toplayer = players.getname(destname) or \
                        players.get(desttzid)

            if toplayer is not None:
                destination = toplayer.room
                if destination is None:
                    s.message('Player is not logged in.')
                    return
            else:
                tomob = mobs.getname(destname) or \
                        mobs.get(desttzid)

                if tomob is not None:
                    destination = tomob.room
                else:
                    s.message('No such room or character.')
                    return

        player.teleport(destination)