Exemple #1
0
    def render_process(self, ctx, data):
        request = inevow.IRequest(ctx)
        args = normalize_args(request.args)

        print 'args:', args
        self.args = args

        if args:
            for s in self.obj.settings:
                currval = self.obj.setting(s)
                if currval in (True, False):
                    # could be a bool, but could also be an int 0
                    # bool False *unchecked* will not be in args
                    val = args.get(s, False)
                    if val == 'on':
                        val = True
                    elif val == '':
                        # line input was left blank
                        val = currval

                else:
                    val = args.get(s, None)

                if val is None or val==currval:
                    continue

                if s == 'owner' and val != 'None':
                    val = '#%s' % val
                elif s == 'name_aka':
                    val = val.split('\n')
                    val = [v.strip() for v in val]

                try:
                    self.obj.setting(s, val)
                except ValueError:
                    args['_%s__error'%s] = val

            newname = args.get('name', '')
            if newname and newname != self.obj.name:
                self.obj.name = newname

            toroomid = args.get('room', None)
            if toroomid is not None:
                room_orig = args.get('room_orig', None)
                if room_orig is None or room_orig==toroomid:
                    # do not teleport, since the setting was not
                    # changed, but may be different from where the
                    # character is right now.
                    pass
                else:
                    toroomid = int(toroomid)
                    toroom = tzindex.get(toroomid)
                    room = self.obj.room
                    if toroom is not room:
                        roomid = room.tzid
                        print 'teleport from', room.name, 'to', toroom.name
                        self.obj.teleport(toroom)
                        self._toroomid = toroomid

        return ''
Exemple #2
0
    def render_process(self, ctx, data):
        request = ctx.locate(inevow.IRequest)
        args = normalize_args(request.args)

        roomid = int(args['roomid'])
        room = tzindex.get(roomid)

        xname = args['xname']
        xclass = args['xclass']

        bxname = args['bxname']
        bxclass = args['bxclass']

        destid = args['dest']
        if destid != 'None':
            destid = int(destid)
            dest = tzindex.get(destid)
        else:
            dest = None

        newroomcls = args['newroom']
        newroomname = args['newroomname']
        if newroomcls == 'None' and newroomname:
            newroomcls = 'Room'
        elif newroomcls == 'None':
            newroomcls = None

        if dest is None and newroomcls is None:
            self.goback(request, 'Choose existing room, or room type to clone.')
            return
        elif dest is not None and newroomcls is not None:
            self.goback(request, 'Choose only one target room: Existing room or New room.')
            return
        elif newroomcls and newroomcls in rooms.classes():
            cls = getattr(rooms, newroomcls)
            newroomname = args['newroomname']
            if newroomname:
                newroom = cls(newroomname)
            else:
                newroom = cls()
            dest = newroom
            print 'NR', dest, dest.name

        if xname and xclass in exits.classes():
            xcls = getattr(exits, xclass)
            if bxname and bxclass in exits.classes():
                bxcls = getattr(exits, xclass)
                bx = bxcls(bxname, room=dest)
                x = xcls(xname, room=room, destination=dest, return_name=bxname)
            else:
                x = xcls(xname, room=room, destination=dest)
            tzid = x.tzid
            editpage = '/edit/%s' % roomid
            request.redirect(editpage)
        else:
            self.goback(request, 'Give a name for the exit.')
Exemple #3
0
    def render_process(self, ctx, data):
        request = ctx.locate(inevow.IRequest)
        args = normalize_args(request.args)
        for arg, val in args.items():
            if arg.startswith('name'):
                unused, tzid = arg.split('_')
                tzid = int(tzid)
                name = val
                destfield = 'dest_%s' % tzid
                desttzid = args[destfield]
                if desttzid == 'None':
                    desttzid = None
                    dest = None
                else:
                    desttzid = int(desttzid)
                    dest = tzindex.get(desttzid)

                x = tzindex.get(tzid)
                if x is None:
                    continue

                origname = x.name
                if x.destination is not None:
                    origdesttzid = x.destination.tzid
                else:
                    origdesttzid = None

                if name == origname and desttzid == origdesttzid:
                    continue

                if name != origname:
                    x.name = name

                if desttzid != origdesttzid:
                    x.destination = dest

        self.goback(ctx)
Exemple #4
0
    def render_process(self, ctx, data):
        request = ctx.locate(inevow.IRequest)
        args = normalize_args(request.args)
        for arg, val in args.items():
            if arg.startswith('name'):
                unused, tzid = arg.split('_')
                tzid = int(tzid)
                name = val
                destfield = 'dest_%s' % tzid
                desttzid = args[destfield]
                if desttzid == 'None':
                    desttzid = None
                    dest = None
                else:
                    desttzid = int(desttzid)
                    dest = tzindex.get(desttzid)

                x = tzindex.get(tzid)
                if x is None:
                    continue

                origname = x.name
                if x.destination is not None:
                    origdesttzid = x.destination.tzid
                else:
                    origdesttzid = None

                if name==origname and desttzid==origdesttzid:
                    continue

                if name != origname:
                    x.name = name

                if desttzid != origdesttzid:
                    x.destination = dest

        self.goback(ctx)
Exemple #5
0
    def render_process(self, ctx, data):
        request = ctx.locate(inevow.IRequest)
        args = normalize_args(request.args)

        roomid = int(args['roomid'])
        room = tzindex.get(roomid)

        xname = args['xname']
        xclass = args['xclass']

        bxname = args['bxname']
        bxclass = args['bxclass']

        destid = args['dest']
        if destid != 'None':
            destid = int(destid)
            dest = tzindex.get(destid)
        else:
            dest = None

        newroomcls = args['newroom']
        newroomname = args['newroomname']
        if newroomcls == 'None' and newroomname:
            newroomcls = 'Room'
        elif newroomcls == 'None':
            newroomcls = None

        if dest is None and newroomcls is None:
            self.goback(request,
                        'Choose existing room, or room type to clone.')
            return
        elif dest is not None and newroomcls is not None:
            self.goback(
                request,
                'Choose only one target room: Existing room or New room.')
            return
        elif newroomcls and newroomcls in rooms.classes():
            cls = getattr(rooms, newroomcls)
            newroomname = args['newroomname']
            if newroomname:
                newroom = cls(newroomname)
            else:
                newroom = cls()
            dest = newroom
            print 'NR', dest, dest.name

        if xname and xclass in exits.classes():
            xcls = getattr(exits, xclass)
            if bxname and bxclass in exits.classes():
                bxcls = getattr(exits, xclass)
                bx = bxcls(bxname, room=dest)
                x = xcls(xname,
                         room=room,
                         destination=dest,
                         return_name=bxname)
            else:
                x = xcls(xname, room=room, destination=dest)
            tzid = x.tzid
            editpage = '/edit/%s' % roomid
            request.redirect(editpage)
        else:
            self.goback(request, 'Give a name for the exit.')