Exemple #1
0
    def createUser(self, session, pname, ppass):
        self.salty = self.generate_salt()
        self.truepass = self.encpass(ppass, self.salty)

        self.test = (pname, self.email, self.truepass, self.salty, self.ansi)
        Insert.newPlayer(self.test)

        session.push(tpl.NEW_PLAYER + tpl.PRESS_ENTER)
Exemple #2
0
    def do_clone(self, session, line):
        self.obj = Select.getItemNameId(line.lower())
        self.npc = Select.getNpc(line.lower())

        if self.obj:
            Insert.cloneItem(self.obj[0], session.p_id, time.time())
            session.push(tpl.CLONE % str(self.obj[1]))
        elif self.npc:
            Insert.cloneItem(self.obj[0], session.p_id, time.time())
            session.push(tpl.CLONE % str(self.npc[1]))
        else: session.push(tpl.CLONE_ERR)
Exemple #3
0
 def do_addlink(self, session, line):
     if not line: session.push(tpl.ADDLINK_ERR)
     self.argu = line.lower()
     if not self.argu.strip(): session.push("> ")
     self.parts = self.argu.split(' ', 3)
     try:
         self.roomnum = int(self.parts[0])
         self.exitnum = int(self.parts[1])
         self.direction = str(self.parts[2])
         
         Insert.addLink(self.roomnum, self.exitnum, self.direction)
         session.push(tpl.ADDLINK)
     except:
         session.push(tpl.ADDLINK_ERR)
Exemple #4
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 #5
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 #6
0
 def do_addroom(self, session, line):
     try:
         self.rid = Insert.addRoom()
         session.push(tpl.ADDROOM % self.rid)
     except:
         session.push(tpl.ADDROOM_ERR)
Exemple #7
0
 def do_addnpc(self, session, line):
     if not line: session.push(tpl.ADDNPC_ERR)
     else:
         self.nid = Insert.addNpc(line.lower())
         session.push(tpl.ADDNPC % (line.lower(),self.nid))
Exemple #8
0
 def do_additem(self, session, line):
     if not line: session.push(tpl.ADDITEM_ERR)
     else:
         self.iid = Insert.addItem(line.lower())
         session.push(tpl.ADDITEM % (line.lower(), self.iid))