def activeNewPlayer(dynamicId, userId, nickName, profession): ''' 创建角色 arguments=(userId,nickName,profession) userId用户ID nickName角色昵称 profession职业选择 ''' user = UsersManager().getUserByID(userId) if user is None: return {'result': False, 'message': Lg().g(18)} result = user.creatNewCharacter(nickName, profession) return result
def activeNewPlayer(dynamicId,userId,nickName,profession): ''' 创建角色 arguments=(userId,nickName,profession) userId用户ID nickName角色昵称 profession职业选择 ''' user=UsersManager().getUserByID(userId) if user is None: return {'result':False,'message':Lg().g(18)} result = user.creatNewCharacter(nickName, profession) return result
def deleteRole(dynamicId,userId,characterId,password): '''删除角色 @param userId: int 用户id @param characterId: 角色的id @param password: string 用户的密码 ''' user=UsersManager().getUserByID(userId) if dynamicId != user.getDynamicId(): return {'result':False,'message':Lg().g(18)} if user is None: return {'result':False,'message':Lg().g(18)} res = dbaccess.checkUserPassword(userId, password) if not res: return {'result':False,'message':Lg().g(150)} data = user.deleteCharacter(characterId) return data
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}
def deleteRole(dynamicId, userId, characterId, password): '''删除角色 @param userId: int 用户id @param characterId: 角色的id @param password: string 用户的密码 ''' user = UsersManager().getUserByID(userId) if dynamicId != user.getDynamicId(): return {'result': False, 'message': Lg().g(18)} if user is None: return {'result': False, 'message': Lg().g(18)} res = dbaccess.checkUserPassword(userId, password) if not res: return {'result': False, 'message': Lg().g(150)} data = user.deleteCharacter(characterId) return data
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}
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}
def roleLogin(dynamicId, userId, characterId): '''角色登陆 @param userId: int 用户id @param characterId: 角色的id ''' user = UsersManager().getUserByID(userId) if dynamicId != user.getDynamicId(): return {'result': False, 'message': Lg().g(18)} if not user: return {'result': False, 'message': Lg().g(18)} user.dropAllCharacter() PlayersManager().dropPlayerByID(characterId) player = PlayerCharacter(characterId, dynamicId=dynamicId) PlayersManager().addPlayer(player) if not player.status.getLifeStatus(): player.status.updateLifeStatus(1) player.attribute.updateHp(int(player.attribute.getMaxHp() * 0.01) + 1) player.attribute.updateMp(int(player.attribute.getMaxMp() * 0.01) + 1) data = {} data['placeId'] = player.baseInfo.getTown() # player.quest.pushPlayerQuestProcessList() user.updateLastCharacter(characterId) return {'result': True, 'message': Lg().g(25), 'data': data}
def roleLogin(dynamicId,userId,characterId): '''角色登陆 @param userId: int 用户id @param characterId: 角色的id ''' user=UsersManager().getUserByID(userId) if dynamicId != user.getDynamicId(): return {'result':False,'message':Lg().g(18)} if not user: return {'result':False,'message':Lg().g(18)} user.dropAllCharacter() PlayersManager().dropPlayerByID(characterId) player = PlayerCharacter(characterId,dynamicId=dynamicId) PlayersManager().addPlayer(player) if not player.status.getLifeStatus(): player.status.updateLifeStatus( 1) player.attribute.updateHp(int(player.attribute.getMaxHp()*0.01)+1) player.attribute.updateMp(int(player.attribute.getMaxMp()*0.01)+1) data = {} data['placeId'] = player.baseInfo.getTown() # player.quest.pushPlayerQuestProcessList() user.updateLastCharacter(characterId) return {'result':True,'message':Lg().g(25),'data':data}