Example #1
0
def examine(player, args, ex):

    # look to see if this is an attr examine command
    args = args.split('/', 1)
    args[0] = evalString(args[0], player.dbref)

    dbref = findDbref(player, args[0])
    if (dbref == None):
        mush.message(player.dbref,
                     f"Could not find an object with id {args[0]}.")
        return

    if (len(args) > 1):
        examineAttr(player, dbref, evalString(args[1], player.dbref))
        return

    o = mush.db[dbref]
    mush.message(player.dbref, f"{o['NAME']}(#{dbref})")
    mush.message(
        player.dbref,
        f"Type: {mush.db[dbref].typeString()} Flags: {' '.join([x.name for x in ObjectFlags if o.flags & x])}"
    )
    mush.message(
        player.dbref,
        f"Owner: {mush.db[o.owner].name}(#{mush.db[o.owner].dbref}) Location: {mush.db[o.location].name}(#{mush.db[o.location].dbref})"
    )

    if not o.flags & (ObjectFlags.ROOM):
        mush.message(
            player.dbref,
            f"Home: {mush.db[o.home].name}(#{mush.db[o.home].dbref})")
    mush.message(player.dbref, f"Created: {time.ctime(o.creationTime)}")
    mush.message(player.dbref, f"Modified: {time.ctime(o.lastModified)}")
    if (o.flags & ObjectFlags.JUNK):
        mush.message(player.dbref, f"Destroyed: {time.ctime(o.destroyedTime)}")

    if ex == "ALL":
        mush.message(
            player.dbref,
            "\n".join([f"{x} [#{o.getAttrOwner(x)}]: {o[x]}" for x in o]))

    # filter into content and exits and show. Right now all (even DARK) are shown. Should check
    # for see_all or similar.
    contents = [
        f"{mush.db[x]['NAME']} (#{mush.db[x].dbref})" for x in o.contents
        if not mush.db[x].flags & ObjectFlags.EXIT
    ]
    exits = [
        f"{mush.db[x]['NAME']} (#{mush.db[x].dbref})" for x in o.contents
        if mush.db[x].flags & ObjectFlags.EXIT
    ]

    if len(contents):
        s = '\n'.join(contents)
        mush.message(player.dbref, f"\nContents:\n{s}")
    if len(exits):
        s = '\n'.join(exits)
        mush.message(player.dbref, f"\nExits:\n{s}")
Example #2
0
def lemit(player, args, ex):
    args = args.split('=', 1)
    if (len(args) != 2):
        mush.message(player.dbref, "huh? Usage @LEMIT <location>=<msg>.")
        return

    loc = findDbref(player, evalString(args[0], player.dbref))
    mush.message(loc, args[1])
Example #3
0
def dig(player, args, ex):

    name = None
    eout = None
    eback = None

    # unpack command string to name and exits if they exist
    l = args.split("=", 1)
    name = evalString(l[0], player.dbref)

    if (len(l) > 1):
        l2 = l[1].split(",", 1)
        eout = evalString(l2[0], player.dbref)
        if (len(l2) > 1):
            eback = evalString(l2[1], player.dbref)

    doDig(player, name, eout, eback)
Example #4
0
def teleport(player, args, ex):

    args = args.upper()
    args = args.split('=', 1)

    if (len(args) > 1):
        to = findDbref(player, evalString(args[1], player.dbref))
        obj = findDbref(player, evalString(args[0], player.dbref))
    else:
        to = findDbref(player, evalString(args[0], player.dbref))
        obj = player.dbref

    # Need to be a WIZARD or own an object in order to telpeort to it.
    if player.flags & ObjectFlags.WIZARD or mush.db[to].owner == player.dbref:
        moveObject(obj, to)
        if (mush.db[obj].flags & ObjectFlags.PLAYER):
            look(mush.db[obj], "", "")
        else:
            mush.message(player.dbref, "Teleported.")
Example #5
0
def take(player, args, ex):

    args = evalString(args, player.dbref)
    dbref = findDbref(player, args)
    if dbref not in mush.db[player.location].contents:
        mush.message(player.dbref, "You don't see that here.")
        return

    if (testLock(player, dbref)):
        moveObject(dbref, player.dbref)
Example #6
0
def setfn(player, args, ex):

    l = args.split('=', 1)
    if (len(l) == 1):
        mush.message(player.dbref, "Huh?")
        return

    if (l[0].find('/') != -1):
        # BUGBUG implement set attrflag here...
        return

    if (l[1].find(':') != -1):
        #BUGBUG implmeent set attribute here...
        return

    # set flag value.
    l[0] = evalString(l[0], player.dbref)
    dbref = findDbref(player, l[0])
    if (dbref == None):
        mush.message(player.dbref, f"Could not find an object with id {l[0]}.")
        return

    # find the flag name to set, and see if we are setting or clearing.
    l[1] = evalString(l[1], player.dbref).upper()
    clear = l[1][0] == '!'
    if (clear):
        l[1] = l[1][1:]

    for flag in ObjectFlags:
        if flag.name == l[1]:
            if (clear):
                mush.db[dbref].flags = mush.db[dbref].flags & ~flag
                mush.message(
                    player.dbref,
                    f"Flag {flag.name} reset on {mush.db[dbref].name} (#{dbref})"
                )
            else:
                mush.db[dbref].flags |= flag
                mush.message(
                    player.dbref,
                    f"Flag {flag.name} set on {mush.db[dbref].name} (#{dbref})"
                )
Example #7
0
def delete(player, args, ex):
    args = evalString(args, player.dbref)
    dbref = findDbref(player, args)
    if dbref != None and (player.dbref == mush.db[dbref].owner
                          or player.flags & ObjectFlags.WIZARD):
        mush.message(player.dbref,
                     f"You delete object {mush.db[dbref].name} (#{dbref})")
        if dbref == player.location:
            mush.message(player.dbref,
                         f"You delete the room you are in! Sending you home!")
            moveObject(player.dbref, player.home)
        del mush.db[dbref]
Example #8
0
def create(player, args, ex):
    args = evalString(args, player.dbref)
    dbref = mush.db.newObject(player)
    mush.db[dbref]["NAME"] = args
    mush.message(player.dbref,
                 f"Object named {args} created with ref #{dbref}.")
    mush.log(
        2,
        f"{player.name}(#{player.dbref}) created object named {args} (#{dbref})."
    )

    return dbref
Example #9
0
def link(player, args, ex):

    args = args.upper()
    args = args.split('=', 1)

    if (len(args) != 2):
        mush.message(player.dbref, "huh? Usage: @LINK <obj>=<destination>.")
        return

    obj = findDbref(player, evalString(args[0], player.dbref))
    to = findDbref(player, evalString(args[1], player.dbref))

    if (player.flags & ObjectFlags.WIZARD or \
     (player.dbref == mush.db[obj].owner and (player.dbref == mush.db[to].owner or mush.db[to].flags & LINK_OK))):
        if (mush.db[obj].flags & (ObjectFlags.ROOM | ObjectFlags.EXIT)):
            mush.db[obj].location = to
        else:
            mush.db[obj].home = to

        mush.message(player.dbref, "Linked.")
    else:
        mush.message(plsyer.dbref, "You don't have permission to do that.")
Example #10
0
def drop(player, args, ex):

    args = evalString(args, player.dbref)
    dbref = findDbref(player, args)
    if dbref not in player.contents:
        mush.message(player.dbref, "You don't have that.")
        return

    # drop the object
    moveObject(dbref, player.location)

    mush.message(player.dbref, evalAttribute(dbref, "DROP", player.dbref))
    mush.message(player.location, evalAttribute(dbref, "ODROP", player.dbref),
                 player.dbref)
Example #11
0
def enter(player, args, ex):

    args = evalString(args, player.dbref)
    dbref = findDbref(player, args)
    if (dbref == None):
        mush.message(player.dbref, f"Could not find an object with id {args}.")
        return

    o = mush.db[dbref]

    if (o.flags & ObjectFlags.ENTER_OK):
        moveObject(player.dbref, dbref)
        look(player, "", None)
    else:
        mush.message(player.dbref, "You can't enter that.")
Example #12
0
def attrset(player, args, attr):

    args = args.split('=', 1)

    if (len(args) < 2):
        mush.message(player.dbref, "huh?")
        return

    args[0] = evalString(args[0], player.dbref)
    dbref = findDbref(player, args[0])

    if (dbref == None):
        mush.message(player.dbref,
                     f"You don't see anything named {args[0]} here.")
        return

    if mush.db[
            dbref].owner != player.dbref and not player.flags & ObjectFlags.WIZARD:
        mush.message(player.dbref, f"You don't own that.")
        return

    mush.db[dbref][attr] = evalString(args[1], player.dbref)
    mush.db[dbref].setAttrOwner(attr, player.dbref)
    mush.message(player.dbref, "Set.")
Example #13
0
def look(player, args, ex):

    args = evalString(args, player.dbref)
    dbref = findDbref(player, args)

    if (dbref == player.location):
        lookRoom(player, dbref, None)
        return

    if (dbref == None):
        mush.message(player.dbref,
                     f"You don't see anything named {args} here.")
        return

    o = mush.db[dbref]
    mush.message(player.dbref, o.name)
    mush.message(player.dbref, o["DESCRIPTION"])
Example #14
0
def think(player, args, ex):
    mush.message(player.dbref, evalString(args, player.dbref))
Example #15
0
def say(player, args, ex):
    args = evalString(args, player.dbref)
    mush.message(player.location, f"{player.name} says \"{args}\"",
                 player.dbref)
    mush.message(player.dbref, f"You say \"{args}\"")