Ejemplo n.º 1
0
def FinalRegist(dynamicId,username,password,nickname,profession):
    '''最终注册'''
    email = '*****@*****.**'
    if len(username)<4 or len(username)>8:
        return {'result':False,'message':Lg().g(20)}
    result = registered.addPlayer(username, password, email)
    if result==1:
        return {'result':False,'message':Lg().g(22)}
    elif result==2:
        return {'result':False,'message':Lg().g(23)}
    userId = dbaccess.getUserIdByUserNamePassword(username ,password)
    userNew = User.User(userId, username, dynamicId)
    UsersManager().addUser(userNew)
    result = userNew.creatNewCharacter(nickname, profession)
    if not result.get('result',False):
        return {'result':False,'message':Lg().g(24)}
    data = result.get('data',None)
    if not data:
        return {'result':False,'message':Lg().g(24)}
    characterId = data.get('newCharacterId',0)
    player = PlayerCharacter(characterId,dynamicId=dynamicId)
#    player.pack.putNewItemsInPackage(27, 1)#放置新手引导中获得的的物品
#    player.pack.putNewItemsInPackage(28, 1)#放置新手引导中获得的的物品
    PlayersManager().addPlayer(player)
    data = {}
    data['userId'] = userId
    data['characterId'] = characterId
    data['placeId'] = player.baseInfo.getTown()
    return {'result':True,'message':Lg().g(25),'data':data}
Ejemplo n.º 2
0
def FinalRegist(dynamicId, username, password, nickname, profession):
    '''最终注册'''
    email = '*****@*****.**'
    if len(username) < 4 or len(username) > 8:
        return {'result': False, 'message': Lg().g(20)}
    result = registered.addPlayer(username, password, email)
    if result == 1:
        return {'result': False, 'message': Lg().g(22)}
    elif result == 2:
        return {'result': False, 'message': Lg().g(23)}
    userId = dbaccess.getUserIdByUserNamePassword(username, password)
    userNew = User.User(userId, username, dynamicId)
    UsersManager().addUser(userNew)
    result = userNew.creatNewCharacter(nickname, profession)
    if not result.get('result', False):
        return {'result': False, 'message': Lg().g(24)}
    data = result.get('data', None)
    if not data:
        return {'result': False, 'message': Lg().g(24)}
    characterId = data.get('newCharacterId', 0)
    player = PlayerCharacter(characterId, dynamicId=dynamicId)
    #    player.pack.putNewItemsInPackage(27, 1)#放置新手引导中获得的的物品
    #    player.pack.putNewItemsInPackage(28, 1)#放置新手引导中获得的的物品
    PlayersManager().addPlayer(player)
    data = {}
    data['userId'] = userId
    data['characterId'] = characterId
    data['placeId'] = player.baseInfo.getTown()
    return {'result': True, 'message': Lg().g(25), 'data': data}
Ejemplo n.º 3
0
def loginToServer(dynamicId, username, password):
    '''登陆服务器
    @param dynamicId: int 客户端动态ID
    @param username: str 用户名
    @param password: str 用户密码
    '''

    did = dbaccess.getUserIdByUserNamePassword(username, password)
    if not did:
        return {'result': False, 'message': Lg().g(149)}
    user = UsersManager().getUserByID(did)
    if user:
        user.disconnectClient()
        UsersManager().dropUser(user)
    userNew = User.User(did, username, dynamicId)
    UsersManager().addUser(userNew)
    UserCharacterList = userNew.getUserCharacterListInfo()
    lastCharacter = userNew.getLastCharacter()
    data = {
        'len': len(UserCharacterList),
        'userId': did,
        'defaultId': lastCharacter,
        'UserCharacterList': UserCharacterList
    }
    return {'result': True, 'message': Lg().g(25), 'data': data}
Ejemplo n.º 4
0
def loginToServer(dynamicId,username ,password):
    '''登陆服务器
    @param dynamicId: int 客户端动态ID
    @param username: str 用户名
    @param password: str 用户密码
    '''
    
    did = dbaccess.getUserIdByUserNamePassword(username ,password)
    if not did:
        return{'result':False,'message':Lg().g(149)}
    user=UsersManager().getUserByID(did)
    if user:
        user.disconnectClient()
        UsersManager().dropUser(user)
    userNew = User.User(did, username, dynamicId)
    UsersManager().addUser(userNew)
    UserCharacterList = userNew.getUserCharacterListInfo()
    lastCharacter = userNew.getLastCharacter()
    data = {'len':len(UserCharacterList),'userId':did,'defaultId':lastCharacter,'UserCharacterList':UserCharacterList}
    return{'result':True,'message':Lg().g(25),'data':data}