コード例 #1
0
ファイル: wizard.py プロジェクト: cryptixman/tzmud
def _clone_mob(s, objname, objtzid, newname=''):
    # next, try to clone a mob
    # look first in the room
    # then at existing mobs
    orig = s.room.mobname(objname) or \
            s.room.mob(objtzid) or \
            mobs.getname(objname) or \
            mobs.get(objtzid)

    # if it is not there, it might be a mob class
    if orig is None:
        if objname in mobs.classes():
            cls = getattr(mobs, objname)
            obj = cls()
        else:
            obj = None
    else:
        obj = copy.copy(orig)

    if obj:
        if newname:
            obj.name = newname
        s.message(obj, 'created.')
        obj.move(s.room)
        obj.home = s.room
        s.room.action(dict(act='clone_mob', actor=s.player, mob=obj))
        return obj
コード例 #2
0
ファイル: wizard.py プロジェクト: cryptixman/tzmud
def cmd_summon(s, r):
    '''summon <character>|<mob class>

    If the name or id# given is an existing player or mob, this
        will act like: teleport <character> to <here>.

    If the name does not exist already, but is a mob class, this
        will be like: clone <mobclass>.

    '''

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

    char = players.getname(objname) or players.get(objtzid) or \
                mobs.getname(objname) or mobs.get(objtzid)

    if char is not None:
        char.teleport(room)
        s.message('You summon', char, '.')

    elif objname in mobs.classes():
        mob = _clone_mob(s, objname, objtzid)
        s.message('You summon', mob, '.')

    else:
        iden = objname if objname else '#%s' % objtzid
        s.message('Unable to summon', iden, '.')
コード例 #3
0
ファイル: items.py プロジェクト: cryptixman/tzmud
    def near_arrive(self, info):
        wearer = players.get(self._wearerid) or mobs.get(self._wearerid)
        if wearer is not None:
            arriver = info['actor']
            if arriver is wearer:
                self.near_look(info)

            else:
                if not arriver.visible:
                    wearer.message('Someone invisible just arrived.')
コード例 #4
0
ファイル: wizard.py プロジェクト: cryptixman/tzmud
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)