Ejemplo n.º 1
0
    def new_character(ts):
        while True:
            name = ts.prompt('New Character Name: ').lower()

            if ' ' in name:
                ts.sendtext('Invalid Name.\n')
                continue

            try:
                oid = Object_ID('/players/%s/player' % name)
                player = ObjectCache().get(oid)
                ts.sendtext('That name is already in use.\n')
            except DoesNotExist:
                break

        while True:
            with NoEcho(ts):
                pass1 = ts.prompt('Password: '******'\n')
                pass2 = ts.prompt('Password (verify): ')
                ts.sendtext('\n')

            if pass1 == pass2:
                break

            ts.sendtext('Passwords do not match!\n')

        email = ts.prompt('EMail Address: ')

        logging.info('Creating new player: {}', name)

        d = {
            'name' : name,
            'password' : passwd_tool.passwd(pass1),
            'email' : email
            }

        player = ObjectCache().get(oid, Player, d)
        player.save()
        getcurrent().hub.spawn(player.telnet_attach, ts)
Ejemplo n.º 2
0
def new_connection(conn, addr):
    try:
        logging.info('New connection from: {}', addr[0])

        ts = PlayerTelnetStream(conn)

        while True:
            name = ts.prompt('Character Name (or "new"): ').lower()

            if name == 'new':
                Player.new_character(ts)
                return
            else:
                if Player.login(ts, name):
                    return
    except LineTooLong:
        logging.info('Connection closed due to buffer overrun: {}',
                     addr[0])
        conn.close()
    except ConnectionClosed:
        logging.info('Connection closed: {}', addr[0])
        conn.close()