Exemple #1
0
    def do_import(self, session, line):		
        self.splitarg = line.split(' ', 2)
        if len(self.splitarg) < 3: session.push(tpl.IMPORT_ERR1)
        else:
            self.map = self.splitarg[0]
            self.start = self.splitarg[1]
            self.dir = self.splitarg[2]			# Need to check if this exit already exists in this room

            # Not really secure.. remove all from inside the string instead
            self.file = open(self.map.strip('./'), "r")

            from mapper import Mapper
            get_this = Mapper(self.file)
            got_this = get_this.MapThis()

            self.lab = got_this[self.start]
            if self.start in got_this:

                for i in got_this:
                    Insert.addRoom(int(i))

                Insert.addLink(session.is_in, self.start, self.dir)
                Insert.addLink(self.start, session.is_in, self.twoway[self.dir])

                for i in got_this.items():
                    for j in i[1]:
                        Insert.addLink(str(i[0]), str(j[1]), str(j[0]))

                session.push(tpl.IMPORT)

            else: session.push(tpl.IMPORT_ERR2)
Exemple #2
0
    def do_edig(self, session, line):
        c = C(session)
        if not line: session.push(tpl.EDIG_ERR1)
        else:
            self.splitarg = line.split(' ', 1)
            self.exists = Select.getExitsInRoom(session.is_in)

            try:
                self.flat = c.flatten(self.exists)
                if self.splitarg[1] in self.flat:
                    session.push(tpl.EDIG_ERR2)
                else:
                    self.count = Insert.addRoom(self.splitarg[0])
                    Insert.addLink(session.is_in, self.count, self.splitarg[1])
                    Insert.addLink(self.count, session.is_in, self.twoway[self.splitarg[1]])
                    session.push(tpl.EDIG % self.splitarg[1])
            except:
                session.push(tpl.EDIG_ERR1)
Exemple #3
0
 def do_addroom(self, session, line):
     try:
         self.rid = Insert.addRoom()
         session.push(tpl.ADDROOM % self.rid)
     except:
         session.push(tpl.ADDROOM_ERR)