Пример #1
0
def __processKillList(dossierDescr, killList):
    if not killList:
        return 0
    cache = getCache()
    vehicles8p = cache['vehicles8+']
    vehiclesByTag = cache['vehiclesByTag']
    frags8p = 0
    killsByTag = {}
    vehTypeFrags = dossierDescr['vehTypeFrags']
    for _, vehTypeCompDescr, _ in killList:
        vehTypeFrags[vehTypeCompDescr] = min(
            vehTypeFrags.get(vehTypeCompDescr, 0) + 1, 60001)
        if vehTypeCompDescr in vehicles8p:
            frags8p += 1
        for tag, record in (('beast', 'fragsBeast'), ('sinai', 'fragsSinai'),
                            ('patton', 'fragsPatton')):
            if vehTypeCompDescr in vehiclesByTag[tag]:
                killsByTag[record] = killsByTag.get(record, 0) + 1

    if killsByTag:
        achievements = dossierDescr['achievements']
        for record, frags in killsByTag.iteritems():
            achievements[record] += frags

    return frags8p
 def _readLevelUpTotalValue(self, dossier):
     dossierCache = cache.getCache()
     if self._nationID != -1:
         return len(dossierCache[self._NATIONAL_VEHICLES].get(
             self._nationID, []))
     else:
         return len(self._getAllSuitableVehicles())
def _set_VEH_TYPE_FRAGS_DEPENDENCIES():
    global VEH_TYPE_FRAGS_DEPENDENCIES
    cache = getCache()
    VEH_TYPE_FRAGS_DEPENDENCIES.update({
        cache['mausTypeCompDescr']: [_updateMousebane],
        '_insert_': [_updateTankExpert]
    })
def getAllCollectorVehicles():
    cache = getCache()
    collectorVehicles = set()
    collectorVehiclesByNations = cache['collectorVehiclesByNations']
    for collectorVehiclesInNation in collectorVehiclesByNations.itervalues():
        collectorVehicles.update(collectorVehiclesInNation)

    return collectorVehicles
Пример #5
0
def getMechanicEngineerRequirements(defaultUnlocks, unlocks, nationID = -1):
    cache = getCache()
    vehiclesInTreesByNation = cache['vehiclesInTreesByNation']
    res = {'mechanicEngineer': cache['vehiclesInTrees'] - defaultUnlocks - unlocks}
    if nationID == -1:
        nationIDs = cache['nationsWithVehiclesInTree']
    else:
        nationIDs = [nationID]
    for nationIdx in nationIDs:
        res[''.join(['mechanicEngineer', str(nationIdx)])] = vehiclesInTreesByNation[nationIdx] - defaultUnlocks - unlocks

    return res
Пример #6
0
def getMechanicEngineerRequirements(defaultUnlocks, unlocks, nationID = -1):
    cache = getCache()
    vehiclesInTreesByNation = cache['vehiclesInTreesByNation']
    res = {'mechanicEngineer': cache['vehiclesInTrees'] - defaultUnlocks - unlocks}
    if nationID == -1:
        nationIDs = cache['nationsWithVehiclesInTree']
    else:
        nationIDs = [nationID]
    for nationIdx in nationIDs:
        res[''.join(['mechanicEngineer', str(nationIdx)])] = vehiclesInTreesByNation[nationIdx] - defaultUnlocks - unlocks

    return res
def getVehicleCollectorRequirements(inventoryVehicles, nationID=ALL_NATIONS_INDEX):
    cache = getCache()
    collectorVehicles = getAllCollectorVehicles()
    res = {'collectorVehicle': collectorVehicles - inventoryVehicles}
    collectorVehiclesByNations = cache['collectorVehiclesByNations']
    nationIDs = collectorVehiclesByNations.keys() if nationID == ALL_NATIONS_INDEX else [nationID]
    for nationIdx in nationIDs:
        achievementName = ''.join(['collectorVehicle', str(nationIdx)])
        collectorVehiclesByNation = collectorVehiclesByNations.get(nationIdx, set())
        if collectorVehiclesByNation:
            res[achievementName] = collectorVehiclesByNation - inventoryVehicles

    return res
Пример #8
0
def getAllCollectorVehicles(nationID=ALL_NATIONS_INDEX):
    cache = getCache()
    collectorVehicles = set()
    collectorVehiclesByNations = cache['collectorVehiclesByNations']
    if nationID == ALL_NATIONS_INDEX:
        for collectorVehiclesInNation in collectorVehiclesByNations.itervalues(
        ):
            collectorVehicles.update(collectorVehiclesInNation)

    else:
        collectorVehicles.update(
            collectorVehiclesByNations.get(nationID, set()))
    return collectorVehicles
Пример #9
0
def getTankExpertRequirements(vehTypeFrags, nationID=-1):
    cache = getCache()
    killedVehTypes = set(vehTypeFrags.iterkeys())
    res = {"tankExpert": cache["vehiclesInTrees"] - killedVehTypes}
    if nationID == -1:
        nationIDs = cache["nationsWithVehiclesInTree"]
    else:
        nationIDs = [nationID]
    vehiclesInTreesByNation = cache["vehiclesInTreesByNation"]
    for nationIdx in nationIDs:
        res["".join(["tankExpert", str(nationIdx)])] = vehiclesInTreesByNation[nationIdx] - killedVehTypes

    return res
Пример #10
0
def getTankExpertRequirements(vehTypeFrags, nationID = -1):
    cache = getCache()
    killedVehTypes = set(vehTypeFrags.iterkeys())
    res = {'tankExpert': cache['vehiclesInTrees'] - killedVehTypes}
    if nationID == -1:
        nationIDs = cache['nationsWithVehiclesInTree']
    else:
        nationIDs = [nationID]
    vehiclesInTreesByNation = cache['vehiclesInTreesByNation']
    for nationIdx in nationIDs:
        res[''.join(['tankExpert', str(nationIdx)])] = vehiclesInTreesByNation[nationIdx] - killedVehTypes

    return res
Пример #11
0
def getTankExpertRequirements(vehTypeFrags, nationID = -1):
    cache = getCache()
    killedVehTypes = set(vehTypeFrags.iterkeys())
    res = {'tankExpert': cache['vehiclesInTrees'] - killedVehTypes}
    if nationID == -1:
        nationIDs = cache['nationsWithVehiclesInTree']
    else:
        nationIDs = [nationID]
    vehiclesInTreesByNation = cache['vehiclesInTreesByNation']
    for nationIdx in nationIDs:
        res[''.join(['tankExpert', str(nationIdx)])] = vehiclesInTreesByNation[nationIdx] - killedVehTypes

    return res
Пример #12
0
def getMechanicEngineerRequirements(defaultUnlocks, unlocks, nationID=-1):
    cache = getCache()
    vehiclesInTreesByNation = cache["vehiclesInTreesByNation"]
    res = {"mechanicEngineer": cache["vehiclesInTrees"] - defaultUnlocks - unlocks}
    if nationID == -1:
        nationIDs = cache["nationsWithVehiclesInTree"]
    else:
        nationIDs = [nationID]
    for nationIdx in nationIDs:
        res["".join(["mechanicEngineer", str(nationIdx)])] = (
            vehiclesInTreesByNation[nationIdx] - defaultUnlocks - unlocks
        )

    return res
Пример #13
0
def _updateTankExpert(dossierDescr, dossierBlockDescr, key, value):
    cache = getCache()
    killedVehTypes = set(dossierBlockDescr.iterkeys())
    vehiclesInTrees = cache['vehiclesInTrees']
    if key not in vehiclesInTrees:
        return
    if not bool(vehiclesInTrees - killedVehTypes):
        dossierDescr['achievements']['tankExpert'] = True
        dossierDescr.addPopUp('achievements', 'tankExpert', True)
    nationID = getVehicleNationID(key)
    if not bool(cache['vehiclesInTreesByNation'][nationID] - killedVehTypes):
        record = ''.join(['tankExpert', str(nationID)])
        dossierDescr['achievements'][record] = True
        dossierDescr.addPopUp('achievements', record, True)
Пример #14
0
def _updateTankExpert(dossierDescr, dossierBlockDescr, key, value):
    cache = getCache()
    killedVehTypes = set(dossierBlockDescr.iterkeys())
    vehiclesInTrees = cache['vehiclesInTrees']
    if key not in vehiclesInTrees:
        return
    if not bool(vehiclesInTrees - killedVehTypes):
        dossierDescr['achievements']['tankExpert'] = True
        dossierDescr.addPopUp('achievements', 'tankExpert', True)
    nationID = getVehicleNationID(key)
    if not bool(cache['vehiclesInTreesByNation'][nationID] - killedVehTypes):
        record = ''.join(['tankExpert', str(nationID)])
        dossierDescr['achievements'][record] = True
        dossierDescr.addPopUp('achievements', record, True)
def __processKillList(dossierDescr, killList):
    if not killList:
        return 0
    cache = getCache()
    vehicles8p = cache["vehicles8+"]
    vehiclesByTag = cache["vehiclesByTag"]
    frags8p = 0
    killsByTag = {}
    vehTypeFrags = dossierDescr["vehTypeFrags"]
    for _, vehTypeCompDescr, _ in killList:
        vehTypeFrags[vehTypeCompDescr] = min(vehTypeFrags.get(vehTypeCompDescr, 0) + 1, 60001)
        if vehTypeCompDescr in vehicles8p:
            frags8p += 1
        for tag, record in (("beast", "fragsBeast"), ("sinai", "fragsSinai"), ("patton", "fragsPatton")):
            if vehTypeCompDescr in vehiclesByTag[tag]:
                killsByTag[record] = killsByTag.get(record, 0) + 1

    if killsByTag:
        achievements = dossierDescr["achievements"]
        for record, frags in killsByTag.iteritems():
            achievements[record] += frags

    return frags8p
def __processKillList(dossierDescr, killList):
    if not killList:
        return 0
    cache = getCache()
    vehicles8p = cache['vehicles8+']
    vehiclesByTag = cache['vehiclesByTag']
    frags8p = 0
    killsByTag = {}
    vehTypeFrags = dossierDescr['vehTypeFrags']
    for _, vehTypeCompDescr, _ in killList:
        vehTypeFrags[vehTypeCompDescr] = min(vehTypeFrags.get(vehTypeCompDescr, 0) + 1, 60001)
        if vehTypeCompDescr in vehicles8p:
            frags8p += 1
        for tag, record in (('beast', 'fragsBeast'), ('sinai', 'fragsSinai'), ('patton', 'fragsPatton')):
            if vehTypeCompDescr in vehiclesByTag[tag]:
                killsByTag[record] = killsByTag.get(record, 0) + 1

    if killsByTag:
        achievements = dossierDescr['achievements']
        for record, frags in killsByTag.iteritems():
            achievements[record] += frags

    return frags8p
 def __getDisabledStatusBlock(self):
     nationID = nations.INDICES.get(self.__nationName)
     align = BLOCKS_TOOLTIP_TYPES.ALIGN_CENTER
     if helper.isAllCollectionPurchased(nationID):
         block = formatters.packAlignedTextBlockData(
             text=text_styles.middleTitle(
                 backport.text(R.strings.tooltips.collectibleVehicleTooltip.
                               status.purchased())),
             align=align)
     else:
         maxUnlockedLevel = self.__itemsCache.items.stats.getMaxResearchedLevelByNations(
         ).get(nationID, MIN_VEHICLE_LEVEL)
         vehicleLevels = getCache()['collectorVehiclesLevelsByNations'].get(
             nationID, set())
         if not vehicleLevels:
             raise SoftException(
                 'There are not collectible vehicles in the nation tree of {}'
                 .format(self.__nationName))
         if min(vehicleLevels) <= maxUnlockedLevel:
             header = R.strings.tooltips.collectibleVehicleTooltip.status.purchaseAvailable(
             )
             text = R.strings.tooltips.collectibleVehicleTooltip.status.condition(
             )
             styleGetter = text_styles.middleTitle
         else:
             header = R.strings.tooltips.collectibleVehicleTooltip.status.purchaseUnavailable(
             )
             text = R.strings.tooltips.collectibleVehicleTooltip.status.condition(
             )
             styleGetter = text_styles.statusAttention
         block = formatters.packAlignedTextBlockData(
             text=text_styles.concatStylesToMultiLine(
                 styleGetter(backport.text(header)),
                 text_styles.main(backport.text(text))),
             align=BLOCKS_TOOLTIP_TYPES.ALIGN_CENTER)
     return formatters.packBuildUpBlockData(
         blocks=[block], padding=formatters.packPadding(top=5))
Пример #18
0
def _set_VEH_TYPE_FRAGS_DEPENDENCIES():
    global VEH_TYPE_FRAGS_DEPENDENCIES
    cache = getCache()
    VEH_TYPE_FRAGS_DEPENDENCIES.update({cache['mausTypeCompDescr']: [_updateMousebane],
     '_insert_': [_updateTankExpert]})