Example #1
0
 def validate(self, update=False):
     """
     Validates vehicles selected in unit if player is in slot now
     Args:
         update: is this unit update
     """
     items = g_itemsCache.items
     invVehicles = items.getVehicles(REQ_CRITERIA.INVENTORY)
     vehCDs = invVehicles.keys()
     pInfo = self.__entity.getPlayerInfo()
     if pInfo.isInSlot:
         _, unit = self.__entity.getUnit()
         roster = unit.getRoster()
         if not roster.checkVehicleList(
                 vehCDs, pInfo.slotIdx) and not pInfo.isCommander():
             self.__entity.request(
                 AssignUnitCtx(pInfo.dbID, UNIT_SLOT.REMOVE,
                               'prebattle/assign'))
         elif self.__entity.getEntityType() != PREBATTLE_TYPE.FALLOUT:
             resultCtx = self.__entity.invalidateSelectedVehicles(vehCDs)
             if resultCtx is not None:
                 self.__entity.request(resultCtx)
             elif update:
                 self.__entity.unit_onUnitPlayerVehDictChanged(
                     getAccountDatabaseID())
     elif update:
         self.__entity.unit_onUnitPlayerVehDictChanged(
             getAccountDatabaseID())
     return
Example #2
0
 def clanRole(self):
     user = self.usersStorage.getUser(getAccountDatabaseID())
     if user:
         role = user.getClanRole()
     else:
         role = 0
     return role
Example #3
0
 def _extractSettings(self, unit):
     kwargs = super(PublicDynamicRosterSettings,
                    self)._extractSettings(unit)
     if kwargs and unit.getCommanderDBID(
     ) == account_helpers.getAccountDatabaseID():
         kwargs['maxEmptySlots'] = kwargs['maxSlots'] - 1
     return kwargs
Example #4
0
 def unit_onUnitPlayerRoleChanged(self, playerID, prevRoleFlags,
                                  nextRoleFlags):
     super(EpicSquadEntity,
           self).unit_onUnitPlayerRoleChanged(playerID, prevRoleFlags,
                                              nextRoleFlags)
     if playerID == account_helpers.getAccountDatabaseID():
         self.unit_onUnitRosterChanged()
Example #5
0
 def __init__(self):
     StaticFormationStaffViewMeta.__init__(self)
     UsersInfoHelper.__init__(self)
     ClubPage.__init__(self)
     self.__openCloseCallbackID = None
     self.__viewerDbID = getAccountDatabaseID()
     self.addListener(events.CoolDownEvent.CLUB, self.__handleClubCooldown, scope=EVENT_BUS_SCOPE.LOBBY)
Example #6
0
 def unit_onUnitPlayerRoleChanged(self, playerID, prevRoleFlags,
                                  nextRoleFlags):
     super(SortieEntity,
           self).unit_onUnitPlayerRoleChanged(playerID, prevRoleFlags,
                                              nextRoleFlags)
     if playerID == account_helpers.getAccountDatabaseID():
         self.__isLegionary = self.getPlayerInfo().isLegionary()
Example #7
0
    def _vehicleStateCondition(self, v):
        result = True
        if self._isUseSPGValidateRule and v.type == VEHICLE_CLASS_NAME.SPG:
            isHaveSPG = False
            accountDbID = account_helpers.getAccountDatabaseID()
            spgDifferenceCount = self.getMaxSPGCount(
            ) - self.getCurrentSPGCount()
            if self.getMaxSPGCount() == 0:
                return (False, None)
            elif self.isCommander(accountDbID):
                return (result, None)
            elif spgDifferenceCount == 0:
                _, _ = self.getUnit()
                vInfos = self.getVehiclesInfo()
                for vInfo in vInfos:
                    if vInfo.vehClassIdx == VEHICLE_CLASS_INDICES['SPG']:
                        isHaveSPG = True

                if isHaveSPG:
                    return (result, None)
                return (False, None)
            elif spgDifferenceCount > 0:
                return (result, None)
            else:
                return (False, None)
        return super(EpicSquadEntity, self)._vehicleStateCondition(v)
Example #8
0
    def _vehicleStateCondition(self, v):
        result = True
        if self._isBalancedSquad:
            result = v.level in self._rosterSettings.getLevelsRange()
            if not result:
                return False
        if self._isUseSPGValidateRule and v.type == VEHICLE_CLASS_NAME.SPG:
            isHaveSPG = False
            accountDbID = account_helpers.getAccountDatabaseID()
            spgDifferenceCount = self.getMaxSPGCount(
            ) - self.getCurrentSPGCount()
            if self.getMaxSPGCount() == 0:
                return False
            elif self.isCommander(accountDbID):
                return result
            elif spgDifferenceCount == 0:
                _, _ = self.getUnit()
                vInfos = self.getVehiclesInfo()
                for vInfo in vInfos:
                    if vInfo.vehClassIdx == VEHICLE_CLASS_INDICES['SPG']:
                        isHaveSPG = True

                if isHaveSPG:
                    return result
                return False
            elif spgDifferenceCount > 0:
                return result
            else:
                return False
        return super(RandomSquadEntity, self)._vehicleStateCondition(v)
Example #9
0
 def clanRole(self):
     user = self.usersStorage.getUser(getAccountDatabaseID())
     if user:
         role = user.getClanRole()
     else:
         role = 0
     return role
Example #10
0
 def canLeaveClub(self, profile, club=None):
     stateID = profile.getState().getStateID()
     if stateID != _CCB.HAS_CLUB:
         return error(_CCR.HAS_NO_CLUB)
     if club is not None:
         if not club.hasMember(getAccountDatabaseID()):
             return error(_CCR.NOT_A_CLUB_MEMBER)
     return self._isClubRequestValid(_CRT.LEAVE_CLUB, club, 'canLeaveClub')
Example #11
0
 def unit_onUnitPlayerRoleChanged(self, playerID, prevRoleFlags,
                                  nextRoleFlags):
     super(RandomSquadEntity,
           self).unit_onUnitPlayerRoleChanged(playerID, prevRoleFlags,
                                              nextRoleFlags)
     if self._isBalancedSquad and playerID == account_helpers.getAccountDatabaseID(
     ):
         self.unit_onUnitRosterChanged()
Example #12
0
 def wasInBattle(self, dbID = 0):
     """Was player in the battle?
     :param dbID: long containing account database ID or 0.
     :return: True if player was in the battle, otherwise - False.
     """
     if not dbID:
         dbID = getAccountDatabaseID()
     return self.__players.getPlayerInfo(dbID).wasInBattle
Example #13
0
 def _onUnitMemberVehiclesChanged(self, accoundDbID):
     """
     Routine that holds additional logic related to vehicles list change
     for player
     """
     self.invalidateVehicleStates()
     if self._isBalancedSquad and accoundDbID != account_helpers.getAccountDatabaseID():
         self.unit_onUnitRosterChanged()
Example #14
0
 def canLeaveClub(self, profile, club = None):
     stateID = profile.getState().getStateID()
     if stateID != _CCB.HAS_CLUB:
         return error(_CCR.HAS_NO_CLUB)
     if club is not None:
         if not club.hasMember(getAccountDatabaseID()):
             return error(_CCR.NOT_A_CLUB_MEMBER)
     return self._isClubRequestValid(_CRT.LEAVE_CLUB, club, 'canLeaveClub')
Example #15
0
def _makeAchievements(dossier, club):
    achievements = dossier.getTotalStats().getAchievements()
    mergedList = list(itertools.chain(*achievements))
    isForClubMember = club.hasMember(getAccountDatabaseID())
    return AchievementsUtils.packAchievementList(mergedList,
                                                 dossier.getDossierType(),
                                                 dumpDossier(dossier),
                                                 isForClubMember, True)
Example #16
0
 def _createCache(self):
     databaseID = getAccountDatabaseID()
     if databaseID:
         self._cache = _StorageForSellCache(databaseID)
         self._cache.read()
         return self._cache
     else:
         return None
Example #17
0
 def _extractSettings(self, unit):
     kwargs = super(BalancedSquadDynamicRosterSettings, self)._extractSettings(unit)
     if kwargs and unit.getCommanderDBID() != getAccountDatabaseID():
         vehicles = unit.getMemberVehicles(unit.getCommanderDBID())
         if vehicles:
             levels = [ vehInfo.vehLevel for vehInfo in vehicles ]
             kwargs['minLevel'] = max(MIN_VEHICLE_LEVEL, min(levels) + self._lowerBound)
             kwargs['maxLevel'] = min(MAX_VEHICLE_LEVEL, max(levels) + self._upperBound)
     return kwargs
Example #18
0
 def assignSlotRequest(self, slotIndex, playerId):
     if playerId == -1:
         if self.unitFunctional.getPlayerInfo().isCreator():
             LOG_DEBUG('Request to assign is ignored. Creator can not move to another slots')
             return
         playerId = account_helpers.getAccountDatabaseID()
     elif not self.isPlayerInUnit(playerId):
         return
     self.requestToAssign(playerId, slotIndex)
 def assignSlotRequest(self, slotIndex, playerId):
     if playerId == -1:
         if self.unitFunctional.getPlayerInfo().isCreator():
             LOG_DEBUG('Request to assign is ignored. Creator can not move to another slots')
             return
         playerId = account_helpers.getAccountDatabaseID()
     elif not self.isPlayerInUnit(playerId):
         return
     self.requestToAssign(playerId, slotIndex)
Example #20
0
 def validate(self, update = False):
     items = g_itemsCache.items
     invVehicles = items.getVehicles(REQ_CRITERIA.INVENTORY)
     vehCDs = invVehicles.keys()
     pInfo = self.__functional.getPlayerInfo()
     if pInfo.isInSlot:
         _, unit = self.__functional.getUnit()
         roster = unit.getRoster()
         if not roster.checkVehicleList(vehCDs, pInfo.slotIdx) and not pInfo.isCreator():
             self.__functional.request(unit_ctx.AssignUnitCtx(pInfo.dbID, UNIT_SLOT.REMOVE, 'prebattle/assign'))
         else:
             resultCtx = self.__functional.invalidateSelectedVehicles(vehCDs)
             if resultCtx is not None:
                 self.__functional.request(resultCtx)
             elif update:
                 self.__functional.unit_onUnitPlayerVehDictChanged(getAccountDatabaseID())
     elif update:
         self.__functional.unit_onUnitPlayerVehDictChanged(getAccountDatabaseID())
     return
Example #21
0
 def goToLobby(self):
     databaseID = account_helpers.getAccountDatabaseID()
     raise databaseID or AssertionError('Acoount database ID is not defined')
     isFirstStart = databaseID not in self.__loggedDBIDs
     self.__loggedDBIDs.add(databaseID)
     state = {'isFirstStart': isFirstStart,
      'isAfterBattle': self.__afterBattle}
     self.__setDispatcher(_LOBBY_DISPATCHER)
     self.__restoreID = _SETTINGS.QUESTS.id
     self.__doAutoRun((_SETTINGS.OFFBATTLE, _SETTINGS.QUESTS), state)
     self.__hintsManager = HintsManager()
     self.__hintsManager.start()
Example #22
0
 def goToLobby(self):
     databaseID = account_helpers.getAccountDatabaseID()
     raise databaseID or AssertionError('Acoount database ID is not defined')
     isFirstStart = databaseID not in self.__loggedDBIDs
     self.__loggedDBIDs.add(databaseID)
     state = {'isFirstStart': isFirstStart,
      'isAfterBattle': self.__afterBattle}
     self.__setDispatcher(_LOBBY_DISPATCHER)
     self.__restoreID = _SETTINGS.QUESTS.id
     self.__doAutoRun((_SETTINGS.OFFBATTLE, _SETTINGS.QUESTS), state)
     self.__hintsManager = HintsManager()
     self.__hintsManager.start()
 def validate(self, update=False):
     items = self.itemsCache.items
     invVehicles = items.getVehicles(REQ_CRITERIA.INVENTORY)
     vehCDs = invVehicles.keys()
     pInfo = self.__entity.getPlayerInfo()
     if pInfo.isInSlot:
         _, unit = self.__entity.getUnit(safe=False)
         roster = unit.getRoster()
         if not roster.checkVehicleList(vehCDs, pInfo.slotIdx) and not pInfo.isCommander():
             self.__entity.request(AssignUnitCtx(pInfo.dbID, UNIT_SLOT.REMOVE, 'prebattle/assign'))
     elif update:
         self.__entity.unit_onUnitPlayerVehDictChanged(getAccountDatabaseID())
    def _getRoleByDatabaseID(self, dbID=None, team=None):
        if dbID is None:
            dbID = account_helpers.getAccountDatabaseID()
        rosters = prb_getters.getPrebattleRosters()
        possibleRosters = PREBATTLE_ROSTER.getRange(self.getEntityType(), team)
        for roster in possibleRosters:
            if roster in rosters:
                for data in rosters[roster].itervalues():
                    if data['dbID'] == dbID:
                        return data.get('role', 0)

        return 0
Example #25
0
 def getConfirmDialogMeta(self, ctx):
     if self.__errorCount == 0 and self.hasLockedState():
         meta = super(StrongholdEntity, self).getConfirmDialogMeta(ctx)
     else:
         pDbID = account_helpers.getAccountDatabaseID()
         members, clanMembers = self._getClanMembers()
         if ctx.hasFlags(FUNCTIONAL_FLAG.EXIT) or pDbID in members:
             isFirstBattle = self.__strongholdSettings.isFirstBattle()
             isLastClanMember = len(clanMembers) == 1 and clanMembers[0] == pDbID
             subKey = 'Defeat' if isLastClanMember and not isFirstBattle else ''
             meta = StrongholdConfirmDialogMeta(key='leave', subKey=subKey)
         else:
             meta = None
     return meta
Example #26
0
 def validate(self, update=False):
     items = g_itemsCache.items
     invVehicles = items.getVehicles(REQ_CRITERIA.INVENTORY)
     vehCDs = invVehicles.keys()
     pInfo = self.__functional.getPlayerInfo()
     if pInfo.isInSlot:
         _, unit = self.__functional.getUnit()
         roster = unit.getRoster()
         if not roster.checkVehicleList(
                 vehCDs, pInfo.slotIdx) and not pInfo.isCreator():
             self.__functional.request(
                 unit_ctx.AssignUnitCtx(pInfo.dbID, UNIT_SLOT.REMOVE,
                                        'prebattle/assign'))
         else:
             vInfo = self.__functional.getVehicleInfo()
             resultCtx = vInfo.updateInventory(vehCDs)
             if resultCtx is not None:
                 self.__functional.request(resultCtx)
             elif update:
                 self.__functional.unit_onUnitPlayerVehDictChanged(
                     getAccountDatabaseID())
     elif update:
         self.__functional.unit_onUnitPlayerVehDictChanged(
             getAccountDatabaseID())
Example #27
0
    def _extractSettings(self, unit):
        kwargs = super(BalancedSquadDynamicRosterSettings, self)._extractSettings(unit)
        accountDbID = getAccountDatabaseID()
        if kwargs and unit.getCommanderDBID() != accountDbID:
            vehicles = unit.getMemberVehicles(unit.getCommanderDBID())
            if not vehicles:
                unitVehicles = unit.getVehicles()
                for accDbID, vInfos in unitVehicles.iteritems():
                    if accDbID != accountDbID:
                        vehicles.extend(vInfos)

            minLevel, maxLevel = self._getVehicleLevels(vehicles)
            kwargs['minLevel'] = minLevel
            kwargs['maxLevel'] = maxLevel
        return kwargs
Example #28
0
 def getRoles(self, pDatabaseID = None, clanDBID = None, team = None):
     result = 0
     if self._settings is None:
         return result
     if pDatabaseID is None:
         pDatabaseID = account_helpers.getAccountDatabaseID()
     roles = self._settings['roles']
     if pDatabaseID in roles:
         result = roles[pDatabaseID]
     if not result and clanDBID:
         roles = self._settings['clanRoles']
         if clanDBID in roles:
             result = roles[clanDBID]
     if not result and team:
         roles = self._settings['teamRoles']
         if team in roles:
             result = roles[team]
     return result
    def isVehcleOfClassAvailable(self):
        accountDbID = account_helpers.getAccountDatabaseID()
        availableVehicles = self.getMaxVehiclesOfClass(
        ) - self.getCurrentVheiclesOfClassCount()
        if self.getMaxVehiclesOfClass() == 0:
            return False
        if self.__unitEntity.isCommander(accountDbID):
            return True
        if availableVehicles == 0:
            _, _ = self.__unitEntity.getUnit()
            vInfos = self.__unitEntity.getVehiclesInfo()
            for vInfo in vInfos:
                if vInfo.vehClassIdx == VEHICLE_CLASS_INDICES[
                        self._VEHICLE_CLASS_NAME]:
                    return True

            return False
        return availableVehicles > 0
 def _makeVO(self, memberData):
     memberDBID = memberData.getDbID()
     contactEntity = self.userStorage.getUser(memberDBID)
     if contactEntity:
         userVO = ContactConverter().makeVO(contactEntity)
         userVO['userProps']['clanAbbrev'] = ''
     else:
         userVO = {'userProps': {'userName': self.__getMemberName(memberData)}}
     return {'dbID': memberDBID,
      'userName': self.__getMemberName(memberData),
      'post': items.formatField(getter=memberData.getRoleString),
      'postIcon': memberData.getRoleIcon(),
      'personalRating': items.formatField(getter=memberData.getGlobalRating, formatter=BigWorld.wg_getIntegralFormat),
      'battlesCount': items.formatField(getter=memberData.getBattlesCount, formatter=BigWorld.wg_getIntegralFormat),
      'wins': items.formatField(getter=memberData.getBattlesPerformanceAvg, formatter=lambda x: BigWorld.wg_getNiceNumberFormat(x) + '%'),
      'awgExp': items.formatField(getter=memberData.getBattleXpAvg, formatter=BigWorld.wg_getIntegralFormat),
      'daysInClan': items.formatField(getter=memberData.getDaysInClan, formatter=BigWorld.wg_getIntegralFormat),
      'canShowContextMenu': memberDBID != getAccountDatabaseID(),
      'contactItem': userVO}
Example #31
0
 def getRoles(self, pDatabaseID = None, clanDBID = None, team = None):
     result = 0
     if self._settings is None:
         return result
     else:
         if pDatabaseID is None:
             pDatabaseID = account_helpers.getAccountDatabaseID()
         roles = self._settings['roles']
         if pDatabaseID in roles:
             result = roles[pDatabaseID]
         if not result and clanDBID:
             roles = self._settings['clanRoles']
             if clanDBID in roles:
                 result = roles[clanDBID]
         if not result and team:
             roles = self._settings['teamRoles']
             if team in roles:
                 result = roles[team]
         return result
 def _makeVO(self, memberData):
     memberDBID = memberData.getDbID()
     contactEntity = self.userStorage.getUser(memberDBID)
     if contactEntity:
         userVO = ContactConverter().makeVO(contactEntity)
         userVO['userProps']['clanAbbrev'] = ''
     else:
         userVO = {'userProps': {'userName': self.__getMemberName(memberData)}}
     return {'dbID': memberDBID,
      'userName': self.__getMemberName(memberData),
      'post': items.formatField(getter=memberData.getRoleString),
      'postIcon': memberData.getRoleIcon(),
      'personalRating': items.formatField(getter=memberData.getGlobalRating, formatter=BigWorld.wg_getIntegralFormat),
      'battlesCount': items.formatField(getter=memberData.getBattlesCount, formatter=BigWorld.wg_getIntegralFormat),
      'wins': items.formatField(getter=memberData.getBattlesPerformanceAvg, formatter=lambda x: BigWorld.wg_getNiceNumberFormat(x) + '%'),
      'awgExp': items.formatField(getter=memberData.getBattleXpAvg, formatter=BigWorld.wg_getIntegralFormat),
      'daysInClan': items.formatField(getter=memberData.getDaysInClan, formatter=BigWorld.wg_getIntegralFormat),
      'canShowContextMenu': memberDBID != getAccountDatabaseID(),
      'contactItem': userVO}
Example #33
0
 def goToLobby(self):
     databaseID = account_helpers.getAccountDatabaseID()
     if not databaseID:
         raise SoftException('Acoount database ID is not defined')
     isFirstStart = databaseID not in self.__loggedDBIDs
     self.__loggedDBIDs.add(databaseID)
     state = {'isFirstStart': isFirstStart,
      'isAfterBattle': self.__afterBattle}
     self.__setDispatcher(_LOBBY_DISPATCHER)
     self.__restoreID = _SETTINGS.QUESTS.id
     bootcampController = dependency.instance(IBootcampController)
     isInBootcampAccount = bootcampController.isInBootcampAccount()
     if isInBootcampAccount:
         selectedSettings = self.__doAutoRun((_SETTINGS.OFFBATTLE, _SETTINGS.QUESTS, _SETTINGS.BOOTCAMP_LOBBY), state)
     else:
         selectedSettings = None
     if selectedSettings is None or selectedSettings.hintsEnabled:
         self.__hintsManager = HintsManager()
         self.__hintsManager.start()
     return
 def onUnitVehiclesChanged(self, dbID, vInfos):
     if dbID == account_helpers.getAccountDatabaseID():
         self.__updateVehicles()
         self._proxy.onVehiclesChanged()
Example #35
0
 def isCurrentPlayer(self):
     return self.dbID == getAccountDatabaseID()
Example #36
0
 def isCurrentPlayer(self):
     if self.dbID > 0:
         result = self.dbID == getAccountDatabaseID()
     else:
         result = self.accID == getPlayerID()
     return result
 def __init__(self, clansCtrl):
     stats = g_itemsCache.items.stats
     ClanAccountProfile.__init__(self, clansCtrl, getAccountDatabaseID(), stats.clanDBID, stats.clanInfo)
Example #38
0
 def onUnitVehiclesChanged(self, dbID, vInfos):
     if dbID != account_helpers.getAccountDatabaseID():
         self._updateRallyData()
Example #39
0
 def hasSlotForSPG(self):
     accountDbID = account_helpers.getAccountDatabaseID()
     return self.getMaxSPGCount() > 0 and (
         self.getCurrentSPGCount() < self.getMaxSPGCount()
         or self.isCommander(accountDbID))
Example #40
0
 def getAccountDbID(self):
     return getAccountDatabaseID()
Example #41
0
 def canAssignToSlot(self, dbID):
     return self._roles & UNIT_ROLE.ADD_REMOVE_MEMBERS > 0 or dbID == account_helpers.getAccountDatabaseID()
 def __getButtonInfo(self, club):
     dbID = account_helpers.getAccountDatabaseID()
     if club.hasMember(dbID):
         return self.__getMemberBtnInfo(club)
     else:
         return self.__getNotMemberBtnInfo(club)
Example #43
0
 def isPromoAutoViewsEnabled(cls):
     return getAccountDatabaseID() % cls.PROMO_AUTO_VIEWS_TEST_VALUE != 0 and g_lobbyContext.getServerSettings().isPromoAutoViewsEnabled()
Example #44
0
 def __init__(self, success = None):
     super(PlayerFortRequester, self).__init__(success)
     self._databaseID = getAccountDatabaseID()
     self._individualRqIDs = set()
Example #45
0
def getPlayerDatabaseID():
    return getAccountDatabaseID() or getAvatarDatabaseID()
Example #46
0
 def unit_onUnitPlayerRemoved(self, playerID, playerData):
     super(EpicSquadEntity,
           self).unit_onUnitPlayerRemoved(playerID, playerData)
     if playerID == account_helpers.getAccountDatabaseID():
         self.unit_onUnitRosterChanged()
Example #47
0
 def reportBug(self):
     reportBugOpenConfirm(getAccountDatabaseID() or getAvatarDatabaseID())
Example #48
0
 def _onUnitMemberVehiclesChanged(self, accoundDbID):
     self.invalidateVehicleStates()
     if accoundDbID != account_helpers.getAccountDatabaseID():
         self.unit_onUnitRosterChanged()
Example #49
0
def _makeAchievements(dossier, club):
    achievements = dossier.getTotalStats().getAchievements()
    mergedList = list(itertools.chain(*achievements))
    isForClubMember = club.hasMember(getAccountDatabaseID())
    return AchievementsUtils.packAchievementList(mergedList, dossier.getDossierType(), dumpDossier(dossier), isForClubMember, True)
Example #50
0
 def getAccountDbID(self):
     return getAccountDatabaseID()
 def _takeLeadership(self):
     yield self.prbDispatcher.sendUnitRequest(unit_ctx.GiveLeadershipCtx(getAccountDatabaseID(), 'prebattle/takeLeadership'))