예제 #1
0
def cmd_get(ch, cmd, arg):
    '''Usage: get [the] <item> [[from] <other item>]

       Attempts to move an object from the room to your inventory. If an
       addition argument is supplied, the command assumes it is a container and
       instead tries to move an object from the container to your inventory.'''
    try:
        arg, cont = mud.parse_args(
            ch, True, cmd, arg, "[the] word(object) | [from] obj.room.inv.eq")
    except:
        return

    # are we doing get, or get-from?
    if cont != None:
        try_get_from(ch, cont, arg)
    else:
        # try to find the object in the room
        try:
            found, multi = mud.parse_args(ch, True, cmd, arg,
                                          "obj.room.multiple")
        except:
            return

        # pick up all the items we want
        if multi == False:
            do_get(ch, found, None)
        else:
            for obj in found:
                do_get(ch, obj, None)
예제 #2
0
파일: cmd_manip.py 프로젝트: KaSt/nereamud
def cmd_get(ch, cmd, arg):
    '''Usage: get [the] <item> [[from] <other item>]

       Attempts to move an object from the room to your inventory. If an
       addition argument is supplied, the command assumes it is a container and
       instead tries to move an object from the container to your inventory.'''
    try:
        arg,cont = mud.parse_args(ch, True, cmd, arg,
                                  "[the] word(object) | [from] obj.room.inv.eq")
    except: return
    
    # are we doing get, or get-from?
    if cont != None:
        try_get_from(ch, cont, arg)
    else:
        # try to find the object in the room
        try:
            found,multi= mud.parse_args(ch, True, cmd, arg, "obj.room.multiple")
        except: return

        # pick up all the items we want
        if multi == False:
            do_get(ch, found, None)
        else:
            for obj in found:
                do_get(ch, obj, None)
예제 #3
0
def cmd_remove(ch, cmd, arg):
    '''Usage: remove <item | all>

       Attempts to remove an item you have equipped. If you would like to
       remove everything you are wearing, you may instead specify \'all\'
       instead of a specific item. If you would like to remove all of a certain
       type of object (for instance, rings) you can use an all. prefix. For
       example:

       > remove all.ring

       This command will remove everything you are wearing with the \'ring\'
       keyword. If you would instead like to remove, say, the second thing you
       are wearing with the \'ring\' keyword, you can supply a numeric prefix.
       For example:

       > remove 2.ring'''
    try:
        found, multi = mud.parse_args(ch, True, cmd, arg,
                                      "[the] obj.eq.multiple")
    except:
        return

    # are we removing one thing, or multiple things?
    if multi == False:
        do_remove(ch, found)
    else:
        for obj in found:
            do_remove(ch, obj)
예제 #4
0
def cmd_give(ch, cmd, arg):
    '''Usage: give <object> [to] <person>

       Attempts to transfer an object from your inventory to the specified
       person. You can give multiple objects at a time by using the all.
       prefix. For example:

       > give all.cookie george

       Would give all of the cookies in your inventory to George. If you only
       want to give him the raisin cookie, which also happens to be the third
       cookie in your inventory, you can use a numeric prefix instead of
       the all prefix. For example:

       > give 3.cookie george'''
    try:
        to_give, multi, recv = mud.parse_args(
            ch, True, cmd, arg,
            "[the] obj.inv.multiple " + "[to] ch.room.noself")
    except:
        return

    if multi == False:
        do_give(ch, recv, to_give)
    else:
        for obj in to_give:
            do_give(ch, recv, obj)
예제 #5
0
파일: cmd_manip.py 프로젝트: KaSt/nereamud
def cmd_give(ch, cmd, arg):
    '''Usage: give <object> [to] <person>

       Attempts to transfer an object from your inventory to the specified
       person. You can give multiple objects at a time by using the all.
       prefix. For example:

       > give all.cookie george

       Would give all of the cookies in your inventory to George. If you only
       want to give him the raisin cookie, which also happens to be the third
       cookie in your inventory, you can use a numeric prefix instead of
       the all prefix. For example:

       > give 3.cookie george'''
    try:
        to_give, multi, recv = mud.parse_args(ch, True, cmd, arg,
                                              "[the] obj.inv.multiple " +
                                              "[to] ch.room.noself")
    except: return

    if multi == False:
        do_give(ch, recv, to_give)
    else:
        for obj in to_give:
            do_give(ch, recv, obj)
예제 #6
0
파일: cmd_manip.py 프로젝트: KaSt/nereamud
def cmd_remove(ch, cmd, arg):
    '''Usage: remove <item | all>

       Attempts to remove an item you have equipped. If you would like to
       remove everything you are wearing, you may instead specify \'all\'
       instead of a specific item. If you would like to remove all of a certain
       type of object (for instance, rings) you can use an all. prefix. For
       example:

       > remove all.ring

       This command will remove everything you are wearing with the \'ring\'
       keyword. If you would instead like to remove, say, the second thing you
       are wearing with the \'ring\' keyword, you can supply a numeric prefix.
       For example:

       > remove 2.ring'''
    try:
        found,multi= mud.parse_args(ch, True, cmd, arg, "[the] obj.eq.multiple")
    except: return

    # are we removing one thing, or multiple things?
    if multi == False:
        do_remove(ch, found)
    else:
        for obj in found:
            do_remove(ch, obj)
예제 #7
0
def cmd_goto(ch, cmd, arg):
    '''Usage: goto <person | place | thing>

       Transfer yourself to a specified room, object, or person in game. Rooms
       are referenced by their zone key.
       '''
    try:
        found, type = mud.parse_args(ch, True, cmd, arg,
                                     "{ room ch.world.noself }")
    except:
        return

    # what did we find?
    if type == "char":
        dest = found.room
    else:
        dest = found

    mud.message(ch, None, None, None, True, "to_room",
                "$n disappears in a puff of smoke.")
    ch.room = dest
    ch.act("look")
    mud.message(ch, None, None, None, True, "to_room",
                "$n appears in a puff of smoke.")
    hooks.run("enter", hooks.build_info("ch rm", (ch, ch.room)))
예제 #8
0
파일: cmd_admin.py 프로젝트: KaSt/nereamud
def cmd_instance(ch, cmd, arg):
    '''Create an instanced version of the specified room'''
    try:
        source, dest = mud.parse_args(ch, True, cmd, arg, "word(source) [as] word(dest)")
    except: return

    room = mudroom.instance(source, dest)
    ch.send("You instance " + source + " as " + room.proto + ".")
예제 #9
0
def cmd_instance(ch, cmd, arg):
    '''Create an instanced version of the specified room'''
    try:
        source, dest = mud.parse_args(ch, True, cmd, arg,
                                      "word(source) [as] word(dest)")
    except:
        return

    room = mudroom.instance(source, dest)
    ch.send("You instance " + source + " as " + room.proto + ".")
예제 #10
0
def cmd_sleep(ch, cmd, arg):
    '''If awake, attempts to lay down and sleep.'''
    try:
        obj, = mud.parse_args(ch, True, cmd, arg, "| [on] obj.room")
    except: return

    if obj == None:
        try_change_pos(ch, "sleeping")
    elif obj.istype("furniture"):
        try_use_furniture(ch, obj, "sleeping")
    else:
        ch.send("You cannot sleep on " + ch.see_as(obj) + ".")
예제 #11
0
def cmd_sit(ch, cmd, arg):
    '''If standing, attempts to sit on the ground.'''
    try:
        obj, = mud.parse_args(ch, True, cmd, arg, "| [on] obj.room")
    except: return

    if obj == None:
        try_change_pos(ch, "sitting")
    elif obj.istype("furniture"):
        try_use_furniture(ch, obj, "sitting")
    else:
        ch.send("You cannot sit on " + ch.see_as(obj) + ".")
예제 #12
0
def cmd_wear(ch, cmd, arg):
    '''Usage: wear <item> [where]

       Attempts to equip an item from your inventory. If you would like to
       equip it to a non-default location, you can supply where on your body
       you would like to wear it. For example, if you would like to equip a
       torch, but in your offhand instead of your mainhand:

       > wear torch offhand

       If an item covers multiple locations on your body, you can specify where
       all you would like to equip the item as a comma-separated list:

       > wear gloves left hand, right hand'''
    try:
        found, multi, where = mud.parse_args(
            ch, True, cmd, arg,
            "[the] obj.inv.multiple | [on] string(bodyparts)")
    except:
        return

    # Are the things we're looking for not body positions? Try to catch this!
    # it will happen when someone enters multiple arguments for the name without
    # supplying ' and ' around it. The mud will misinterpret it as an item
    if not multi and where != None and not "," in where:
        # reparse what we want!
        if not where in ch.bodyparts:
            where = None
            try:
                found, = mud.parse_args(ch, True, cmd, "'" + arg + "'",
                                        "[the] obj.inv")
            except:
                return

    # are we wearing one thing, or multiple things?
    if multi == False:
        do_wear(ch, found, where)
    else:
        for obj in found:
            do_wear(ch, obj, where)
예제 #13
0
def cmd_unlock(ch, cmd, arg):
    '''Usage: unlock <door | direction | container>

       Attempts to unlock the specified door, direction, or container.'''
    try:
        found, type = mud.parse_args(ch, True, cmd, arg,
                                     "[the] {obj.room.inv exit }")
    except:
        return

    # what did we find?
    if type == "exit":
        ex = found
        name = ex.name
        if ex.name == "":
            name = "the exit"

        if not ex.is_closed:
            ch.send(name + " is already open.")
        elif not ex.is_locked:
            ch.send(name + " is already unlocked.")
        elif ex.key == '':
            ch.send("You cannot figure out how " + name +
                    " would be unlocked.")
        elif not has_proto(ch, ex.key):
            ch.send("You cannot seem to find the key.")
        else:
            mud.message(ch, None, None, None, True, "to_char",
                        "You unlock " + name + ".")
            mud.message(ch, None, None, None, True, "to_room",
                        "$n unlocks " + name + ".")
            ex.unlock()
            # hooks.run("room_change", hooks.build_info("rm", (ch.room, )))
            try_manip_other_exit(ch.room, ex, ex.is_closed, False)

    # must be an object
    else:
        obj = found
        if not obj.istype("container"):
            ch.send(ch.see_as(obj) + " is not a container.")
        elif not obj.container_is_closed:
            ch.send(ch.see_as(obj) + " is already open.")
        elif not obj.container_is_locked:
            ch.send(ch.see_as(obj) + " is already unlocked.")
        elif obj.container_key == '':
            ch.send("You cannot figure out how to unlock " + ch.see_as(obj))
        elif not has_proto(ch, obj.container_key):
            ch.send("You cannot seem to find the key.")
        else:
            mud.message(ch, None, obj, None, True, "to_char", "You unlock $o.")
            mud.message(ch, None, obj, None, True, "to_room", "$n unlocks $o.")
            obj.container_is_locked = False
예제 #14
0
def cmd_sit(ch, cmd, arg):
    '''If standing, attempts to sit on the ground.'''
    try:
        obj, = mud.parse_args(ch, True, cmd, arg, "| [on] obj.room")
    except:
        return

    if obj == None:
        try_change_pos(ch, "sitting")
    elif obj.istype("furniture"):
        try_use_furniture(ch, obj, "sitting")
    else:
        ch.send("You cannot sit on " + ch.see_as(obj) + ".")
예제 #15
0
def cmd_page(ch, cmd, arg):
    '''Usage: page <person> <message>

       Paging a person will send them a message, as well as making a beeping
       sound on their computer to get their attention. Page can be used on
       anyone in the mud, regardless if you are in the same room as them or not.
       '''
    try:
        tgt, mssg = mud.parse_args(ch, True, cmd, arg,
                                   "ch.world.noself string(message)")
    except: return
    ch.send("\007\007You page " + ch.see_as(tgt))
    tgt.send("\007\007*" + tgt.see_as(ch) + "* " + mssg)
예제 #16
0
def cmd_sleep(ch, cmd, arg):
    '''If awake, attempts to lay down and sleep.'''
    try:
        obj, = mud.parse_args(ch, True, cmd, arg, "| [on] obj.room")
    except:
        return

    if obj == None:
        try_change_pos(ch, "sleeping")
    elif obj.istype("furniture"):
        try_use_furniture(ch, obj, "sleeping")
    else:
        ch.send("You cannot sleep on " + ch.see_as(obj) + ".")
예제 #17
0
파일: cmd_comm.py 프로젝트: KaSt/nereamud
def cmd_page(ch, cmd, arg):
    '''Usage: page <person> <message>

       Paging a person will send them a message, as well as making a beeping
       sound on their computer to get their attention. Page can be used on
       anyone in the mud, regardless if you are in the same room as them or not.
       '''
    try:
        tgt, mssg = mud.parse_args(ch, True, cmd, arg,
                                   "ch.world.noself string(message)")
    except: return
    ch.send("\007\007You page " + ch.see_as(tgt))
    tgt.send("\007\007*" + tgt.see_as(ch) + "* " + mssg)
예제 #18
0
파일: cmd_manip.py 프로젝트: KaSt/nereamud
def cmd_unlock(ch, cmd, arg):
    '''Usage: unlock <door | direction | container>

       Attempts to unlock the specified door, direction, or container.'''
    try:
        found,type=mud.parse_args(ch,True,cmd,arg, "[the] {obj.room.inv exit }")
    except: return

    # what did we find?
    if type == "exit":
        ex = found
        name = ex.name
        if ex.name == "":
            name = "the exit"
        
        if not ex.is_closed:
            ch.send(name + " is already open.")
        elif not ex.is_locked:
            ch.send(name + " is already unlocked.")
        elif ex.key == '':
            ch.send("You cannot figure out how " + name +
                    " would be unlocked.")
        elif not has_proto(ch, ex.key):
            ch.send("You cannot seem to find the key.")
        else:
            mud.message(ch, None, None, None, True, "to_char",
                        "You unlock " + name + ".")
            mud.message(ch, None, None, None, True, "to_room",
                        "$n unlocks " + name + ".")
            ex.unlock()
            # hooks.run("room_change", hooks.build_info("rm", (ch.room, )))
            try_manip_other_exit(ch.room, ex, ex.is_closed, False)

    # must be an object
    else:
        obj = found
        if not obj.istype("container"):
            ch.send(ch.see_as(obj) + " is not a container.")
        elif not obj.container_is_closed:
            ch.send(ch.see_as(obj) + " is already open.")
        elif not obj.container_is_locked:
            ch.send(ch.see_as(obj) + " is already unlocked.")
        elif obj.container_key == '':
            ch.send("You cannot figure out how to unlock "+ ch.see_as(obj))
        elif not has_proto(ch, obj.container_key):
            ch.send("You cannot seem to find the key.")
        else:
            mud.message(ch, None, obj, None, True, "to_char", "You unlock $o.")
            mud.message(ch, None, obj, None, True, "to_room", "$n unlocks $o.")
            obj.container_is_locked = False
예제 #19
0
파일: cmd_admin.py 프로젝트: KaSt/nereamud
def cmd_force(ch, cmd, arg):
    '''Usage: force <person> <command>
    
       Attempts to make the specified perform a command of your choosing.'''
    try:
        found, multi, arg = mud.parse_args(ch, True, cmd, arg,
                                           "ch.world.noself.multiple string(command)")
    except: return

    if multi == False:
        try_force(ch, found, arg)
    else:
        for vict in found:
            try_force(ch, vict, arg)
예제 #20
0
파일: cmd_admin.py 프로젝트: KaSt/nereamud
def cmd_disconnect(ch, cmd, arg):
    """Usage: disconnect <uid>

       Disconnects a socket with the given uid. Use 'connections' to see
       current connected sockets."""
    try:
        uid, = mud.parse_args(ch, True, cmd, arg, "int(uid)")
    except: return

    for sock in mudsock.socket_list():
        if sock.uid == uid:
            ch.send("You disconnect socket %d." % uid)
            sock.close()
            break
예제 #21
0
파일: cmd_manip.py 프로젝트: KaSt/nereamud
def cmd_drop(ch, cmd, arg):
    '''Usage: drop <item>

       Attempts to move an object from your inventory to the ground.'''
    try:
        found,multi=mud.parse_args(ch, True, cmd, arg, "[the] obj.inv.multiple")
    except: return

    # are we dropping a list of things, or just one?
    if multi == False:
        do_drop(ch, found)
    else:
        for obj in found:
            do_drop(ch, obj)
예제 #22
0
def cmd_open(ch, cmd, arg):
    '''Usage: open [the] <direction | door | container>

       Attempts to open the speficied door, direction, or container.'''
    try:
        found, type = mud.parse_args(ch, True, cmd, arg,
                                     "[the] {obj.room.inv exit }")
    except:
        return

    # is it an exit?
    if type == "exit":
        ex = found
        name = ex.name
        if name == "":
            name = "the exit"

        if not ex.is_closed:
            ch.send(name + " is already open.")
        elif ex.is_locked:
            ch.send(name + " must be unlocked first.")
        elif not ex.is_closable:
            ch.send(name + " cannot be opened.")
        else:
            mud.message(ch, None, None, None, True, "to_char",
                        "You open " + name + ".")
            mud.message(ch, None, None, None, True, "to_room",
                        "$n opens " + name + ".")
            ex.open()
            # hooks.run("room_change", hooks.build_info("rm", (ch.room, )))
            try_manip_other_exit(ch.room, ex, False, ex.is_locked)
            hooks.run("open_door", hooks.build_info("ch ex", (ch, ex)))

    # must be an object
    else:
        obj = found
        if not obj.istype("container"):
            ch.send(ch.see_as(obj) + " is not a container.")
        elif not obj.container_is_closed:
            ch.send(ch.see_as(obj) + " is already open.")
        elif obj.container_is_locked:
            ch.send(ch.see_as(obj) + " must be unlocked first.")
        elif not obj.container_is_closable:
            ch.send(ch.see_as(obj) + " cannot be opened.")
        else:
            mud.message(ch, None, obj, None, True, "to_char", "You open $o.")
            mud.message(ch, None, obj, None, True, "to_room", "$n opens $o.")
            obj.container_is_closed = False
            hooks.run("open_obj", hooks.build_info("ch obj", (ch, obj)))
예제 #23
0
파일: cmd_manip.py 프로젝트: KaSt/nereamud
def cmd_wear(ch, cmd, arg):
    '''Usage: wear <item> [where]

       Attempts to equip an item from your inventory. If you would like to
       equip it to a non-default location, you can supply where on your body
       you would like to wear it. For example, if you would like to equip a
       torch, but in your offhand instead of your mainhand:

       > wear torch offhand

       If an item covers multiple locations on your body, you can specify where
       all you would like to equip the item as a comma-separated list:

       > wear gloves left hand, right hand'''
    try:
        found, multi, where = mud.parse_args(ch, True, cmd, arg,
                                             "[the] obj.inv.multiple | [on] string(bodyparts)")
    except: return

    # Are the things we're looking for not body positions? Try to catch this!
    # it will happen when someone enters multiple arguments for the name without
    # supplying ' and ' around it. The mud will misinterpret it as an item
    if not multi and where != None and not "," in where:
        # reparse what we want!
        if not where in ch.bodyparts:
            where = None
            try:
                found, = mud.parse_args(ch,True,cmd,"'"+arg+"'","[the] obj.inv")
            except: return

    # are we wearing one thing, or multiple things?
    if multi == False:
        do_wear(ch, found, where)
    else:
        for obj in found:
            do_wear(ch, obj, where)
예제 #24
0
def cmd_disconnect(ch, cmd, arg):
    """Usage: disconnect <uid>

       Disconnects a socket with the given uid. Use 'connections' to see
       current connected sockets."""
    try:
        uid, = mud.parse_args(ch, True, cmd, arg, "int(uid)")
    except:
        return

    for sock in mudsock.socket_list():
        if sock.uid == uid:
            ch.send("You disconnect socket %d." % uid)
            sock.close()
            break
예제 #25
0
def cmd_force(ch, cmd, arg):
    '''Usage: force <person> <command>
    
       Attempts to make the specified perform a command of your choosing.'''
    try:
        found, multi, arg = mud.parse_args(
            ch, True, cmd, arg, "ch.world.noself.multiple string(command)")
    except:
        return

    if multi == False:
        try_force(ch, found, arg)
    else:
        for vict in found:
            try_force(ch, vict, arg)
예제 #26
0
파일: path.py 프로젝트: KaSt/nereamud
def cmd_path(ch, cmd, arg):
    '''Usage: path <room>

       Prints out a Python list of the directions needed to move from your
       current location to a specified destination.'''
    try:
        dest, = mud.parse_args(ch, True, cmd, arg, "room")
    except: return

    path = build_patrol([ch.room, dest])

    if len(path) == 0:
        ch.send("Path doesn't exist")
    else:
        ch.send(str(path))
예제 #27
0
def cmd_setaux(ch, cmd, arg):
    '''allows people to set a value stored in their aux data. If no value is
       specified, instead delete a key.'''
    try:
        key, val = mud.parse_args(ch, True, cmd, arg, "word(key) | string(val)")
    except: return

    # are we trying to delete a key?
    if val == None:
        if key in ch.aux("example_aux").pairs:
            del ch.aux("example_aux").pairs[key]
        ch.send("Key deleted.")
    else:
        ch.aux("example_aux").pairs[key] = val
        ch.send("Key '%s' set to '%s'." % (key, val))
예제 #28
0
def cmd_path(ch, cmd, arg):
    '''Usage: path <room>

       Prints out a Python list of the directions needed to move from your
       current location to a specified destination.'''
    try:
        dest, = mud.parse_args(ch, True, cmd, arg, "room")
    except:
        return

    path = build_patrol([ch.room, dest])

    if len(path) == 0:
        ch.send("Path doesn't exist")
    else:
        ch.send(str(path))
예제 #29
0
def cmd_greet(ch, cmd, arg):
    '''Usage: greet <person>

       NPCs with dialogs will often have something to say when you greet or
       approach then. Greeting an NPC is a way to get them talking.'''
    try:
        tgt, = mud.parse_args(ch, True, cmd, arg, "ch.room.noself")
    except: return

    mud.message(ch, tgt, None, None, False, "to_char", "You greet $N.")
    mud.message(ch, tgt, None, None, False, "to_vict", "$n greets you.")
    mud.message(ch, tgt, None, None, False, "to_room", "$n greets $N.")

    # run greet hooks
    hooks.run("greet",      hooks.build_info("ch ch", (ch, tgt)))
    hooks.run("post_greet", hooks.build_info("ch ch", (ch, tgt)))
예제 #30
0
def cmd_drop(ch, cmd, arg):
    '''Usage: drop <item>

       Attempts to move an object from your inventory to the ground.'''
    try:
        found, multi = mud.parse_args(ch, True, cmd, arg,
                                      "[the] obj.inv.multiple")
    except:
        return

    # are we dropping a list of things, or just one?
    if multi == False:
        do_drop(ch, found)
    else:
        for obj in found:
            do_drop(ch, obj)
예제 #31
0
파일: cmd_comm.py 프로젝트: KaSt/nereamud
def cmd_greet(ch, cmd, arg):
    '''Usage: greet <person>

       NPCs with dialogs will often have something to say when you greet or
       approach then. Greeting an NPC is a way to get them talking.'''
    try:
        tgt, = mud.parse_args(ch, True, cmd, arg, "ch.room.noself")
    except: return

    mud.message(ch, tgt, None, None, False, "to_char", "You greet $N.")
    mud.message(ch, tgt, None, None, False, "to_vict", "$n greets you.")
    mud.message(ch, tgt, None, None, False, "to_room", "$n greets $N.")

    # run greet hooks
    hooks.run("greet",      hooks.build_info("ch ch", (ch, tgt)))
    hooks.run("post_greet", hooks.build_info("ch ch", (ch, tgt)))
예제 #32
0
파일: cmd_manip.py 프로젝트: KaSt/nereamud
def cmd_open(ch, cmd, arg):
    '''Usage: open [the] <direction | door | container>

       Attempts to open the speficied door, direction, or container.'''
    try:
        found,type=mud.parse_args(ch,True,cmd,arg, "[the] {obj.room.inv exit }")
    except: return

    # is it an exit?
    if type == "exit":
        ex = found
        name = ex.name
        if name == "":
            name = "the exit"
        
        if not ex.is_closed:
            ch.send(name + " is already open.")
        elif ex.is_locked:
            ch.send(name + " must be unlocked first.")
        elif not ex.is_closable:
            ch.send(name + " cannot be opened.")
        else:
            mud.message(ch, None, None, None, True, "to_char",
                        "You open " + name + ".")
            mud.message(ch, None, None, None, True, "to_room",
                        "$n opens " + name + ".")
            ex.open()
            # hooks.run("room_change", hooks.build_info("rm", (ch.room, )))
            try_manip_other_exit(ch.room, ex, False, ex.is_locked)
            hooks.run("open_door", hooks.build_info("ch ex", (ch, ex)))

    # must be an object
    else:
        obj = found
        if not obj.istype("container"):
            ch.send(ch.see_as(obj) + " is not a container.")
        elif not obj.container_is_closed:
            ch.send(ch.see_as(obj) + " is already open.")
        elif obj.container_is_locked:
            ch.send(ch.see_as(obj) + " must be unlocked first.")
        elif not obj.container_is_closable:
            ch.send(ch.see_as(obj) + " cannot be opened.")
        else:
            mud.message(ch, None, obj, None, True, "to_char", "You open $o.")
            mud.message(ch, None, obj, None, True, "to_room", "$n opens $o.")
            obj.container_is_closed = False
            hooks.run("open_obj", hooks.build_info("ch obj", (ch, obj)))
예제 #33
0
파일: cmd_admin.py 프로젝트: KaSt/nereamud
def cmd_repeat(ch, cmd, arg):
    '''Usage: repeat <times> <command>

       Attempts to perform a single command multiple times. For example, one
       may want to load 20 copies of an item:

         > repeat 20 load obj beer@drinks
       '''
    try:
        times, arg = mud.parse_args(ch, True, cmd, arg, "int(times) string(command)")
    except: return

    if times < 1:
        ch.send("Commands may only be repeated a positive number of times.")
    else:
        for i in range(times):
            ch.act(arg, True)
예제 #34
0
def cmd_setaux(ch, cmd, arg):
    '''allows people to set a value stored in their aux data. If no value is
       specified, instead delete a key.'''
    try:
        key, val = mud.parse_args(ch, True, cmd, arg,
                                  "word(key) | string(val)")
    except:
        return

    # are we trying to delete a key?
    if val == None:
        if key in ch.aux("example_aux").pairs:
            del ch.aux("example_aux").pairs[key]
        ch.send("Key deleted.")
    else:
        ch.aux("example_aux").pairs[key] = val
        ch.send("Key '%s' set to '%s'." % (key, val))
예제 #35
0
def cmd_routine(ch, cmd, arg):
    '''Appends a routine onto a character. The second argument needs to be an
       evaluable list statement. Put it in parentheses to avoid being cut off
       as spaces, since parse treats it as a single word. Example:

         > routine man "[\'say hi\', (3, \'say I am a little teapot\')]" True

       this will say hi after the default delay, and I am a little teapot after
       a delay of 3. It will then loop through this process indefinitely.
       Alternatively, these commands can be replaced with function calls.
       '''
    try:
        tgt, routine, repeat = mud.parse_args(
            ch, True, cmd, arg, "ch.room.noself word(py_list) | bool(repeat)")
    except:
        return

    set_routine(tgt, eval(routine), repeat)
    ch.send("Routine set.")
예제 #36
0
파일: routine.py 프로젝트: KaSt/nereamud
def cmd_routine(ch, cmd, arg):
    '''Appends a routine onto a character. The second argument needs to be an
       evaluable list statement. Put it in parentheses to avoid being cut off
       as spaces, since parse treats it as a single word. Example:

         > routine man "[\'say hi\', (3, \'say I am a little teapot\')]" True

       this will say hi after the default delay, and I am a little teapot after
       a delay of 3. It will then loop through this process indefinitely.
       Alternatively, these commands can be replaced with function calls.
       '''
    try:
        tgt, routine, repeat = mud.parse_args(ch, True, cmd, arg,
                                              "ch.room.noself word(py_list) | bool(repeat)")
    except:
        return

    set_routine(tgt, eval(routine), repeat)
    ch.send("Routine set.")
예제 #37
0
파일: cmd_misc.py 프로젝트: KaSt/nereamud
def cmd_delay(ch, cmd, arg):
    '''Usage: delay <seconds> <command>

       Allows the user to prepare a command to be executed in the future. For
       example:

       > delay 2 say hello, world!

       Will make you say \'hello, world!\' two seconds after entering the
       delayed command.'''
    try:
        secs, to_delay = mud.parse_args(ch, True, cmd, arg, "double string")
    except: return

    if secs < 1:
        ch.send("You can only delay commands for positive amounts of time.")
    else:
        ch.send("You delay '%s' for %.2f seconds" % (to_delay, secs))
        event.start_event(ch, secs, event_delayed_cmd, None, to_delay)
예제 #38
0
def cmd_repeat(ch, cmd, arg):
    '''Usage: repeat <times> <command>

       Attempts to perform a single command multiple times. For example, one
       may want to load 20 copies of an item:

         > repeat 20 load obj beer@drinks
       '''
    try:
        times, arg = mud.parse_args(ch, True, cmd, arg,
                                    "int(times) string(command)")
    except:
        return

    if times < 1:
        ch.send("Commands may only be repeated a positive number of times.")
    else:
        for i in range(times):
            ch.act(arg, True)
예제 #39
0
def cmd_delay(ch, cmd, arg):
    '''Usage: delay <seconds> <command>

       Allows the user to prepare a command to be executed in the future. For
       example:

       > delay 2 say hello, world!

       Will make you say \'hello, world!\' two seconds after entering the
       delayed command.'''
    try:
        secs, to_delay = mud.parse_args(ch, True, cmd, arg, "double string")
    except:
        return

    if secs < 1:
        ch.send("You can only delay commands for positive amounts of time.")
    else:
        ch.send("You delay '%s' for %.2f seconds" % (to_delay, secs))
        event.start_event(ch, secs, event_delayed_cmd, None, to_delay)
예제 #40
0
파일: cmd_admin.py 프로젝트: KaSt/nereamud
def cmd_at(ch, cmd, arg):
    '''Usage: at <person | place> <command>

       Perform a command at another room or person while never leaving your
       current room.'''
    try:
        found, type, arg = mud.parse_args(ch, True, cmd, arg,
                                          "{ room ch.world.noself } string(command)")
    except: return

    # figure out what room we're doing the command at
    if type == "char":
        room = found.room
    else:
        room = found

    # transfer us over to the new room, do the command, then transfer back
    old_room = ch.room
    ch.room  = room
    ch.act(arg, True)
    ch.room  = old_room
예제 #41
0
def cmd_tell(ch, cmd, arg):
    '''Usage: tell <person> <message>

       This command sends a message to another character. Primarily intended
       for player-to-player communication. Players can tell other players
       things even if they are not in the same room.

       see also: reply'''
    try:
        tgt, mssg = mud.parse_args(ch, True, cmd, arg,
                                   "ch.world.noself string(message)")
    except: return

    mssg   = mssg.replace("$", "$$")
    tovict = "{r$n tells you, '" + mssg + "'{n"
    toch   = "{rYou tell $N, '" + mssg + "'{n"
    mud.message(ch, tgt, None, None, False, "to_vict", tovict)
    mud.message(ch, tgt, None, None, False, "to_char", toch)
    history.add_history(ch,   "tell", "{r%-10s: %s{n" % (ch.name, mssg))
    history.add_history(tgt,  "tell", "{r%-10s: %s{n" % (ch.name, mssg))
    hooks.run("tell", hooks.build_info("ch ch str", (ch, tgt, mssg)))
예제 #42
0
파일: cmd_admin.py 프로젝트: KaSt/nereamud
def cmd_transfer(ch, cmd, arg):
    '''Usage: transfer <person> [[to] room]

       The opposite of goto. Instead of moving to a specified location, it
       takes the target to the user. If an additional argument is supplied,
       instead transfers the target to the specifie room.'''
    try:
        found, multi, dest = mud.parse_args(ch, True, cmd, arg,
                                            "ch.world.multiple.noself | [to] room")
    except: return

    # if we didn't supply a room, use our own
    if dest == None:
        dest = ch.room

    # do our transfers
    if multi == False:
        do_transfer(ch, found, dest)
    else:
        for tgt in found:
            do_transfer(ch, tgt, dest)
예제 #43
0
파일: cmd_comm.py 프로젝트: KaSt/nereamud
def cmd_ask(ch, cmd, arg):
    '''Usage: ask <person> [about] <question>

       This command is used to pose a question to another character. Mostly,
       this is intended to be used to carry on dialogs with NPCs. Ask has a
       local range (i.e. you can only ask questions to people in the same room
       as you.
       '''
    try:
        tgt, question =mud.parse_args(ch, True, cmd, arg,
                                      "ch.room.noself [about] string(question)")
    except: return

    question = question.replace("$", "$$")
    mud.message(ch, tgt, None, None, False, "to_vict",
                "{w$n asks you, '" + question + "'{n")
    mud.message(ch, tgt, None, None, False, "to_char",
                "{wYou ask $N, '" + question + "'{n")

    # run our ask hooks
    hooks.run("ask", hooks.build_info("ch ch str", (ch, tgt, question)))
예제 #44
0
def cmd_ask(ch, cmd, arg):
    '''Usage: ask <person> [about] <question>

       This command is used to pose a question to another character. Mostly,
       this is intended to be used to carry on dialogs with NPCs. Ask has a
       local range (i.e. you can only ask questions to people in the same room
       as you.
       '''
    try:
        tgt, question =mud.parse_args(ch, True, cmd, arg,
                                      "ch.room.noself [about] string(question)")
    except: return

    question = question.replace("$", "$$")
    mud.message(ch, tgt, None, None, False, "to_vict",
                "{w$n asks you, '" + question + "'{n")
    mud.message(ch, tgt, None, None, False, "to_char",
                "{wYou ask $N, '" + question + "'{n")

    # run our ask hooks
    hooks.run("ask", hooks.build_info("ch ch str", (ch, tgt, question)))
예제 #45
0
파일: cmd_comm.py 프로젝트: KaSt/nereamud
def cmd_tell(ch, cmd, arg):
    '''Usage: tell <person> <message>

       This command sends a message to another character. Primarily intended
       for player-to-player communication. Players can tell other players
       things even if they are not in the same room.

       see also: reply'''
    try:
        tgt, mssg = mud.parse_args(ch, True, cmd, arg,
                                   "ch.world.noself string(message)")
    except: return

    mssg   = mssg.replace("$", "$$")
    tovict = "{r$n tells you, '" + mssg + "'{n"
    toch   = "{rYou tell $N, '" + mssg + "'{n"
    mud.message(ch, tgt, None, None, False, "to_vict", tovict)
    mud.message(ch, tgt, None, None, False, "to_char", toch)
    history.add_history(ch,   "tell", "{r%-10s: %s{n" % (ch.name, mssg))
    history.add_history(tgt,  "tell", "{r%-10s: %s{n" % (ch.name, mssg))
    hooks.run("tell", hooks.build_info("ch ch str", (ch, tgt, mssg)))
예제 #46
0
def cmd_transfer(ch, cmd, arg):
    '''Usage: transfer <person> [[to] room]

       The opposite of goto. Instead of moving to a specified location, it
       takes the target to the user. If an additional argument is supplied,
       instead transfers the target to the specifie room.'''
    try:
        found, multi, dest = mud.parse_args(
            ch, True, cmd, arg, "ch.world.multiple.noself | [to] room")
    except:
        return

    # if we didn't supply a room, use our own
    if dest == None:
        dest = ch.room

    # do our transfers
    if multi == False:
        do_transfer(ch, found, dest)
    else:
        for tgt in found:
            do_transfer(ch, tgt, dest)
예제 #47
0
def cmd_at(ch, cmd, arg):
    '''Usage: at <person | place> <command>

       Perform a command at another room or person while never leaving your
       current room.'''
    try:
        found, type, arg = mud.parse_args(
            ch, True, cmd, arg, "{ room ch.world.noself } string(command)")
    except:
        return

    # figure out what room we're doing the command at
    if type == "char":
        room = found.room
    else:
        room = found

    # transfer us over to the new room, do the command, then transfer back
    old_room = ch.room
    ch.room = room
    ch.act(arg, True)
    ch.room = old_room
예제 #48
0
파일: cmd_manip.py 프로젝트: KaSt/nereamud
def cmd_put(ch, cmd, arg):
    '''Usage: put [the] <item> [in the] <container>

       Attempts to move an object from your inventory into a specified
       container. The container must be in the room, in your inventory, or
       worn.'''
    try:
        found, multi, cont = mud.parse_args(ch, True, cmd, arg,
                                            "[the] obj.inv.multiple " +
                                            "[in] [the] obj.room.inv")
    except: return

    # make sure we have a container
    if not cont.istype("container"):
        ch.send(ch.see_as(cont) + " is not a container.")
    elif cont.container_is_closed:
        ch.send(ch.see_as(cont) + " is currently closed.")
    # do we have one or multiple items?
    elif multi == False:
        do_put(ch, found, cont)
    else:
        for obj in found:
            do_put(ch, obj, cont)
예제 #49
0
파일: cmd_admin.py 프로젝트: KaSt/nereamud
def cmd_goto(ch, cmd, arg):
    '''Usage: goto <person | place | thing>

       Transfer yourself to a specified room, object, or person in game. Rooms
       are referenced by their zone key.
       '''
    try:
        found, type = mud.parse_args(ch, True, cmd, arg, "{ room ch.world.noself }")
    except: return

    # what did we find?
    if type == "char":
        dest = found.room
    else:
        dest = found

    mud.message(ch, None, None, None, True, "to_room",
                "$n disappears in a puff of smoke.")
    ch.room = dest
    ch.act("look")
    mud.message(ch, None, None, None, True, "to_room",
                "$n appears in a puff of smoke.")
    hooks.run("enter", hooks.build_info("ch rm", (ch, ch.room)))
예제 #50
0
def cmd_put(ch, cmd, arg):
    '''Usage: put [the] <item> [in the] <container>

       Attempts to move an object from your inventory into a specified
       container. The container must be in the room, in your inventory, or
       worn.'''
    try:
        found, multi, cont = mud.parse_args(
            ch, True, cmd, arg,
            "[the] obj.inv.multiple " + "[in] [the] obj.room.inv")
    except:
        return

    # make sure we have a container
    if not cont.istype("container"):
        ch.send(ch.see_as(cont) + " is not a container.")
    elif cont.container_is_closed:
        ch.send(ch.see_as(cont) + " is currently closed.")
    # do we have one or multiple items?
    elif multi == False:
        do_put(ch, found, cont)
    else:
        for obj in found:
            do_put(ch, obj, cont)