def __pe_onClanMembersListChanged(self): clanMembers = getattr(BigWorld.player(), 'clanMembers', {}) LOG_DEBUG('setClanMembersList', clanMembers) if not self.__initSteps & _INIT_STEPS.MEMBERS_LIST_RECEIVED: self.__initSteps |= _INIT_STEPS.MEMBERS_LIST_RECEIVED clanAbbrev = self.playerCtx.getClanAbbrev() members = [] if self.__clanChannel is not None: getter = self.__clanChannel.getMember else: getter = lambda dbID: None playerID = getPlayerDatabaseID() for dbID, (name, roleFlags) in clanMembers.iteritems(): if getter(dbID) is None: gos = GAME_ONLINE_STATUS.UNDEFINED else: gos = GAME_ONLINE_STATUS.ONLINE if playerID == dbID: user = CurrentUserEntity(dbID, name=name, clanInfo=ClanInfo( 0, clanAbbrev, roleFlags)) else: user = SharedUserEntity(dbID, name=name, clanInfo=ClanInfo( 0, clanAbbrev, roleFlags), gos=gos, tags={USER_TAG.CLAN_MEMBER}) members.append(user) self.usersStorage.setClanMembersList(members) if self.__initSteps & _INIT_STEPS.LIST_INITED != 0: g_messengerEvents.users.onClanMembersListChanged() return
def __pe_onClanMembersListChanged(self): """Listener for event _PlayerEvents.onClanMembersListChanged. """ clanMembers = getattr(BigWorld.player(), 'clanMembers', {}) LOG_DEBUG('setClanMembersList', clanMembers) clanAbbrev = self.playerCtx.getClanAbbrev() clanDBID = self.playerCtx.getClanDbID() members = [] if self.__clanChannel is not None: getter = self.__clanChannel.getMember else: def getter(dbID): return None playerID = getPlayerDatabaseID() for dbID, (name, roleFlags) in clanMembers.iteritems(): if getter(dbID) is None: gos = GAME_ONLINE_STATUS.UNDEFINED else: gos = GAME_ONLINE_STATUS.ONLINE if playerID == dbID: user = XMPPUserEntity(dbID, name=name, clanInfo=ClanInfo(clanDBID, clanAbbrev, roleFlags)) else: user = XMPPUserEntity(dbID, name=name, clanInfo=ClanInfo(clanDBID, clanAbbrev, roleFlags), gos=gos, tags={USER_TAG.CLAN_MEMBER}) members.append(user) self.usersStorage.setClanMembersList(members) return
def SearchResultIterator(value): value = dict(value) if 'strArg1' in value: result = cPickle.loads(value['strArg1']) else: result = [] for name, dbID, clanAbbrev in result: if not name: continue yield SharedUserEntity(long(dbID), name=name, clanInfo=ClanInfo(abbrev=clanAbbrev))
def initPersonalAccount(self): dbID, name, clanAbbrev = _getInfo4AccountPlayer() if dbID: if self.usersStorage.getUser(dbID) is None: user = CurrentLobbyUserEntity(dbID, name, ClanInfo(abbrev=clanAbbrev)) user.addTags({USER_TAG.CLAN_MEMBER}) self.usersStorage.addUser(user) else: _logger.error('Current player is not found') return
def onAvatarShowGUI(self): dbID, name, clanAbbrev = _getInfo4AvatarPlayer() user = self.usersStorage.getUser(dbID) if dbID: if user is None: from messenger.proto.entities import CurrentUserEntity self.usersStorage.addUser(CurrentUserEntity(dbID, name, clanInfo=ClanInfo(abbrev=clanAbbrev))) else: LOG_ERROR('Current player is not found') return
def onAvatarShowGUI(self): dbID, name, clanAbbrev = _getInfo4AvatarPlayer() user = self.usersStorage.getUser(dbID) if dbID: if user is None: self.usersStorage.addUser( CurrentLobbyUserEntity( dbID, name, clanInfo=ClanInfo(abbrev=clanAbbrev))) else: _logger.error('Current player is not found') return
def initPersonalAccount(self): dbID, name, clanAbbrev = _getInfo4AccountPlayer() if dbID: if self.usersStorage.getUser(dbID) is None: from messenger.proto.entities import CurrentUserEntity user = CurrentUserEntity(dbID, name, ClanInfo(abbrev=clanAbbrev)) user.addTags({USER_TAG.CLAN_MEMBER}) self.usersStorage.addUser(user) else: LOG_ERROR('Current player is not found') return
def makeClanInfo(*args): if len(args) < 2: return dbID, abbrev = args[:2] if dbID and dbID.isdigit(): dbID = long(dbID) else: dbID = 0 info = None if dbID and abbrev: info = ClanInfo(dbID, abbrev, 0) return info
def __pc_onClanInfoChanged(self): self.__clanAbbrev = self.playerCtx.getClanAbbrev() self.__clanDBID = self.playerCtx.getClanDbID() if self.__clanAbbrev and self.__clanDBID: self.__checkForJoin() else: self.__checkForLeave() userClanInfo = ClanInfo(dbID=self.__clanDBID, abbrev=self.__clanAbbrev) for user in self.usersStorage.getClanMembersIterator(): user.update(clanInfo=userClanInfo) g_messengerEvents.users.onClanMembersListChanged()
def updateUser(item, tags): dbID = item.getAccountDBID() user = userGetter(dbID) if user: user.addTags(tags) if USER_TAG.INVALID_NAME in user.getTags(): user.update(name=item.getNickName()) else: userSetter( SharedUserEntity( dbID, name=item.getNickName(), tags=tags, clanInfo=ClanInfo(abbrev=item.getClanAbbrev())))
def __pc_onClanInfoChanged(self): clanInfo = self.playerCtx.getClanInfo() if clanInfo: isInClan = clanInfo.isInClan() clanAbbrev = clanInfo.abbrev else: isInClan = False clanAbbrev = '' if not self.__initSteps & _INIT_STEPS.CLAN_INFO_RECEIVED and isInClan: self.__initSteps |= _INIT_STEPS.CLAN_INFO_RECEIVED for user in self.usersStorage.getClanMembersIterator(): user.update(clanInfo=ClanInfo(abbrev=clanAbbrev)) if self.__initSteps & _INIT_STEPS.LIST_INITED != 0: g_messengerEvents.users.onClanMembersListChanged()
def __setClanInfo(self, info): if info: length = len(info) else: length = 0 if length > 1: abbrev = info[1] else: abbrev = '' if length > 3: role = info[3] else: role = 0 clanInfo = ClanInfo(abbrev=abbrev, role=role) self.playerCtx._setClanInfo(clanInfo) user = self.usersStorage.getUser(getPlayerDatabaseID()) if user: user.update(clanInfo=clanInfo) user.addTags({USER_TAG.CLAN_MEMBER})
def onAccountShowGUI(self): from gui.shared.utils.requesters import DeprecatedStatsRequester dbID, name, clanAbbrev = _getInfo4AccountPlayer() if dbID: if self.usersStorage.getUser(dbID) is None: from messenger.proto.entities import CurrentUserEntity user = CurrentUserEntity(dbID, name, ClanInfo(abbrev=clanAbbrev)) user.addTags({USER_TAG.CLAN_MEMBER}) self.usersStorage.addUser(user) else: LOG_ERROR('Current player is not found') accountAttrs = yield DeprecatedStatsRequester().getAccountAttrs() self.__setAccountAttrs(accountAttrs) clanInfo = yield DeprecatedStatsRequester().getClanInfo() self.__setClanInfo(clanInfo) g_clientUpdateManager.addCallbacks({ 'account.attrs': self.__setAccountAttrs, 'stats.clanInfo': self.__setClanInfo })
def __setClanInfo(self, info): if info: length = len(info) else: length = 0 if length > _CLAN_INFO_ABBREV_INDEX: abbrev = info[_CLAN_INFO_ABBREV_INDEX] else: abbrev = '' if length > _CLAN_INFO_ROLE_INDEX: role = info[_CLAN_INFO_ROLE_INDEX] else: role = 0 clanDBID = self.itemsCache.items.stats.clanDBID clanInfo = ClanInfo(dbID=clanDBID, abbrev=abbrev, role=role) self.playerCtx.setClanInfo(clanInfo) user = self.usersStorage.getUser(getPlayerDatabaseID()) if user: user.update(clanInfo=clanInfo) user.addTags({USER_TAG.CLAN_MEMBER})