def deleteFriend(self, characterId, friendId): '''删除好友 @param playerId: 角色的id ''' if friendId in self.getFriends(): #如果在好友列表中 self._friends.remove(friendId) result = dbFriend.deletePlayerFriend(characterId, friendId) if not result: return {'result': False, 'message': Lg().g(325)} return {'result': True, 'message': Lg().g(326)}
def addFriend(self, characterId, playerId): '''添加一个好友或者黑名单 @param characterId: int 角色的id @param playerId: int 好友或者黑名单角色id ''' if len(self.getFriends()) >= self._friendCount: return {'result': False, 'message': Lg().g(317)} if playerId == self._owner.baseInfo.id: return {'result': False, 'message': Lg().g(318)} elif playerId in self.getFriends(): #如果角色在好友中 return {'result': False, 'message': Lg().g(320)} else: dbFriend.addFriend(self._owner.baseInfo.id, playerId, 1, 0) self._friends.add(playerId) return {'result': True, 'message': Lg().g(321)}
def updateMatrix(self, petId, chatype, operationType, fromEyeNo, toEyeNo): """更新阵法位置信息 @param petId: int 宠物的ID 为0时表示是角色自身 @param operationType: int 操作类型0从宠物列表到阵法1从阵法到宠物列表2从阵法到阵法 @param fromPos: int 起始位置 @param toPos: int 结束位置 """ if operationType == 0: if chatype == 3: pet = self._owner.pet._pets.get(petId) if not pet: return {'result': False, 'message': Lg().g(159)} petlevel = pet.level.getLevel() leveldelta = petlevel - self._owner.level.getLevel() if leveldelta >= 5: return { 'result': False, 'message': Lg().g(366) % (petlevel) } else: if not petId in self._owner.friend._guyong: return {'result': False, 'message': Lg().g(159)} if petId in self._matrixSetting.values(): return {'result': False, 'message': Lg().g(367)} if self._matrixSetting.get('eyes_%d' % toEyeNo) == 0: return {'result': False, 'message': Lg().g(368)} topetId = self._matrixSetting.get('eyes_%d' % toEyeNo) nowcnt = self.getNowCnt() maxcnt = self.getMatrixMaxEyesCnt() if nowcnt >= maxcnt: if topetId == -1 or (topetId not in self._owner.pet._pets.keys()): return {'result': False, 'message': Lg().g(369)} self._matrixSetting['eyes_%d' % (toEyeNo)] = petId return {'result': True} elif operationType == 1: petId = self._matrixSetting.get('eyes_%d' % fromEyeNo) if petId == -1: return {'result': False, 'message': Lg().g(370)} if petId == 0: return {'result': False, 'message': Lg().g(368)} self._owner.pet.addLastRemove(petId) self._matrixSetting['eyes_%d' % (fromEyeNo)] = -1 return {'result': True} else: fromPid = self._matrixSetting.get('eyes_%d' % fromEyeNo, -1) toPid = self._matrixSetting.get('eyes_%d' % toEyeNo, -1) if fromPid == -1: return {'result': False, 'message': Lg().g(370)} self._matrixSetting['eyes_%d' % (toEyeNo)] = fromPid self._matrixSetting['eyes_%d' % (fromEyeNo)] = toPid return {'result': True}
def getGuyongRecord(dynamicId,characterId): '''获取雇用记录 ''' player = PlayersManager().getPlayerByID(characterId) # 根据角色id获取玩家角色实例 if not player or not player.CheckClient(dynamicId): return {'result':False,'message':Lg().g(18)} response = player.friend.GetGuyongRecord() # 获取雇用记录 return response
def GuYongHaoYou(dynamicId,characterId,tid): '''雇佣好友 ''' player = PlayersManager().getPlayerByID(characterId) # 根据角色id获取玩家角色实例 if not player or not player.CheckClient(dynamicId): return {'result':False,'message':Lg().g(18)} response = player.friend.GuYongHaoYou(tid) # 雇用好友 return response
def GetFriendList(dynamicId,characterId,tag,index): '''获取好友排行信息 ''' player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result':False,'message':Lg().g(18)} response = player.friend.getFriendTop(tag,index) # 获取好友的排行信息 return response
def getGuyongRecord(dynamicId, characterId): """获取雇用记录 """ player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': Lg().g(18)} response = player.friend.GetGuyongRecord() return response
def GuYongHaoYou(dynamicId, characterId, tid): """雇佣好友 """ player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result': False, 'message': Lg().g(18)} response = player.friend.GuYongHaoYou(tid) return response
def GetSingleCharacterInfo(dynamicId,characterId,chtype,tid): '''获取单个角色的信息 @param chtype: int 角色的类型 1角色自身 2好友 3宠物 ''' player = PlayersManager().getPlayerByID(characterId) if not player or not player.CheckClient(dynamicId): return {'result':False,'message':Lg().g(18)} if chtype in [1,2]: # 角色自身或者好友 return _getOtherCharacterInfo(tid) # 获取其他玩家的信息 else: # 宠物 return _getOnePetInfo(characterId,tid) # 获取宠物的信息