Example #1
0
    def __updateAmmo(self, shellsData=None, historicalBattleID=-1):
        shells = []
        stateWarning = False
        if g_currentVehicle.isPresent():
            vehicle = g_currentVehicle.item
            isAmmoFull = vehicle.isAmmoFull or historicalBattleID != -1
            stateWarning = vehicle.isBroken or not isAmmoFull or not g_currentVehicle.isAutoLoadFull(
            ) or not g_currentVehicle.isAutoEquipFull()
            if shellsData is None:
                shellsData = map(lambda shell: (shell, shell.count),
                                 vehicle.shells)
            for shell, count in shellsData:
                shells.append({
                    'id':
                    shell.intCD,
                    'ammunitionType':
                    shell.type,
                    'label':
                    ITEM_TYPES.shell_kindsabbreviation(shell.type),
                    'icon':
                    '../maps/icons/ammopanel/ammo/%s' %
                    shell.descriptor['icon'][0],
                    'count':
                    count,
                    'historicalBattleID':
                    historicalBattleID,
                    'tooltip':
                    '',
                    'tooltipType':
                    TOOLTIPS_CONSTANTS.HANGAR_SHELL
                })

        self.as_setAmmoS(shells, stateWarning)
Example #2
0
    def __updateAmmo(self, shellsData = None, historicalBattleID = -1):
        ammo = {'gunName': '',
         'maxAmmo': 0,
         'defaultAmmoCount': 0,
         'vehicleLocked': True,
         'shells': [],
         'stateWarning': 0}
        if g_currentVehicle.isPresent():
            vehicle = g_currentVehicle.item
            default_ammo_count = 0
            default_ammo = dict(((s.intCD, s.defaultCount) for s in vehicle.shells))
            isAmmoFull = vehicle.isAmmoFull or historicalBattleID != -1
            stateWarning = vehicle.isBroken or not isAmmoFull or not g_currentVehicle.isAutoLoadFull() or not g_currentVehicle.isAutoEquipFull()
            for compactDescr, count in default_ammo.iteritems():
                default_ammo_count += count

            ammo.update({'gunName': vehicle.gun.longUserName,
             'maxAmmo': vehicle.ammoMaxSize,
             'defaultAmmoCount': default_ammo_count,
             'vehicleLocked': g_currentVehicle.isLocked(),
             'stateWarning': int(stateWarning)})
            if shellsData is None:
                shellsData = map(lambda shell: (shell, shell.count), vehicle.shells)
            shells = ammo.get('shells')
            for shell, count in shellsData:
                shells.append({'id': str(shell.intCD),
                 'type': shell.type,
                 'label': ITEM_TYPES.shell_kindsabbreviation(shell.type),
                 'icon': '../maps/icons/ammopanel/ammo/%s' % shell.descriptor['icon'][0],
                 'count': count,
                 'historicalBattleID': historicalBattleID})

        self.as_setAmmoS(ammo)
Example #3
0
    def __updateAmmo(self):
        shells = []
        stateWarning = False
        if g_currentVehicle.isPresent():
            vehicle = g_currentVehicle.item
            stateWarning = vehicle.isBroken or not vehicle.isAmmoFull or not g_currentVehicle.isAutoLoadFull(
            ) or not g_currentVehicle.isAutoEquipFull()
            for shell in vehicle.shells:
                if shell.isHidden:
                    continue
                shells.append({
                    'id':
                    str(shell.intCD),
                    'type':
                    shell.type,
                    'label':
                    ITEM_TYPES.shell_kindsabbreviation(shell.type),
                    'icon':
                    '../maps/icons/ammopanel/ammo/%s' %
                    shell.descriptor['icon'][0],
                    'count':
                    shell.count,
                    'tooltip':
                    '',
                    'tooltipType':
                    TOOLTIPS_CONSTANTS.HANGAR_SHELL
                })

        self.as_setAmmoS(shells, stateWarning)
    def _getHistoricalBattleData(self):
        historicalBattleData = None
        if self.preQueueFunctional.getQueueType() == QUEUE_TYPE.HISTORICAL:
            battleId = self.preQueueFunctional.getSetting(
                PREQUEUE_SETTING_NAME.BATTLE_ID)
            battle = g_eventsCache.getHistoricalBattles().get(battleId)
            if battle is not None:
                vehicle = g_currentVehicle.item
                if battle.canParticipateWith(vehicle.intCD):
                    shellsItems = battle.getShellsLayout(vehicle.intCD)
                    priceString = battle.getShellsLayoutFormatedPrice(
                        vehicle.intCD, self.app.colorManager, True, True)
                    historicalBattleData = {
                        'price': priceString,
                        'shells': [],
                        'battleID': battleId
                    }
                    shells = historicalBattleData['shells']
                    for shell, count in shellsItems:
                        shells.append({
                            'id':
                            str(shell.intCD),
                            'type':
                            shell.type,
                            'label':
                            ITEM_TYPES.shell_kindsabbreviation(shell.type),
                            'icon':
                            '../maps/icons/ammopanel/ammo/%s' %
                            shell.descriptor['icon'][0],
                            'count':
                            count
                        })

        return historicalBattleData
Example #5
0
    def getDisplayableData(self, battleID, vehicleID):
        battle = g_eventsCache.getHistoricalBattles().get(battleID)
        shellsItems = battle.getShellsLayout(int(vehicleID))
        priceString = battle.getShellsLayoutFormatedPrice(int(vehicleID), self.app.colorManager, True, True)
        data = {'price': priceString,
         'shells': []}
        shells = data['shells']
        for shell, count in shellsItems:
            shells.append({'id': str(shell.intCD),
             'type': shell.type,
             'label': ITEM_TYPES.shell_kindsabbreviation(shell.type),
             'icon': '../maps/icons/ammopanel/ammo/%s' % shell.descriptor['icon'][0],
             'count': count})

        return data
    def __updateAmmo(self, shellsData = None):
        shells = []
        stateWarning = False
        if g_currentVehicle.isPresent():
            vehicle = g_currentVehicle.item
            stateWarning = vehicle.isBroken or not vehicle.isAmmoFull or not g_currentVehicle.isAutoLoadFull() or not g_currentVehicle.isAutoEquipFull()
            if shellsData is None:
                shellsData = map(lambda shell: (shell, shell.count), vehicle.shells)
            for shell, count in shellsData:
                shells.append({'id': str(shell.intCD),
                 'type': shell.type,
                 'label': ITEM_TYPES.shell_kindsabbreviation(shell.type),
                 'icon': '../maps/icons/ammopanel/ammo/%s' % shell.descriptor['icon'][0],
                 'count': count,
                 'tooltip': '',
                 'tooltipType': TOOLTIPS_CONSTANTS.HANGAR_SHELL})

        self.as_setAmmoS(shells, stateWarning)
        return
    def _getHistoricalBattleData(self):
        historicalBattleData = None
        if self.preQueueFunctional.getQueueType() == QUEUE_TYPE.HISTORICAL:
            battleId = self.preQueueFunctional.getSetting(PREQUEUE_SETTING_NAME.BATTLE_ID)
            battle = g_eventsCache.getHistoricalBattles().get(battleId)
            if battle is not None:
                vehicle = g_currentVehicle.item
                if battle.canParticipateWith(vehicle.intCD):
                    shellsItems = battle.getShellsLayout(vehicle.intCD)
                    priceString = battle.getShellsLayoutFormatedPrice(vehicle.intCD, self.app.colorManager, True, True)
                    historicalBattleData = {'price': priceString,
                     'shells': [],
                     'battleID': battleId}
                    shells = historicalBattleData['shells']
                    for shell, count in shellsItems:
                        shells.append({'id': str(shell.intCD),
                         'type': shell.type,
                         'label': ITEM_TYPES.shell_kindsabbreviation(shell.type),
                         'icon': '../maps/icons/ammopanel/ammo/%s' % shell.descriptor['icon'][0],
                         'count': count})

        return historicalBattleData
def getAmmo(shells):
    outcome = []
    for shell in shells:
        if shell.isHidden:
            continue
        outcome.append({
            'id':
            str(shell.intCD),
            'type':
            shell.type,
            'label':
            ITEM_TYPES.shell_kindsabbreviation(shell.type),
            'icon':
            '../maps/icons/ammopanel/ammo/%s' % shell.descriptor.icon[0],
            'count':
            shell.count,
            'tooltip':
            '',
            'tooltipType':
            TOOLTIPS_CONSTANTS.HANGAR_SHELL
        })

    return outcome
Example #9
0
    def __updateAmmo(self):
        Waiting.show('updateAmmo')
        credits = g_itemsCache.items.stats.credits
        shopRqs = yield ShopRequester().request()
        ammo = {'gunName': '',
         'maxAmmo': 0,
         'reserved1': False,
         'reserved2': False,
         'defaultAmmoCount': 0,
         'reserved3': 0,
         'vehicleLocked': True,
         'stateMsg': '',
         'stateLevel': 'info',
         'shells': [],
         'stateWarning': 0}
        if g_currentVehicle.isPresent():
            vehicle = g_currentVehicle.item
            default_ammo_count = 0
            default_ammo = dict(((s.intCD, s.defaultCount) for s in vehicle.shells))
            stateWarning = vehicle.isBroken or not vehicle.isCrewFull or not vehicle.isAmmoFull or not g_currentVehicle.isAutoLoadFull() or not g_currentVehicle.isAutoEquipFull()
            for compactDescr, count in default_ammo.iteritems():
                default_ammo_count += count

            msg, msgLvl = g_currentVehicle.getHangarMessage()
            ammo.update({'gunName': vehicle.gun.longUserName,
             'maxAmmo': vehicle.ammoMaxSize,
             'reserved1': not g_currentVehicle.isLocked(),
             'reserved2': not g_currentVehicle.isBroken(),
             'defaultAmmoCount': default_ammo_count,
             'reserved3': 0,
             'vehicleLocked': g_currentVehicle.isLocked(),
             'stateMsg': msg,
             'stateLevel': msgLvl,
             'stateWarning': int(stateWarning)})
            iAmmo = yield Requester('shell').getFromInventory()
            sAmmo = yield Requester('shell').getFromShop()
            iVehicles = yield Requester('vehicle').getFromInventory()
            oldStyleVehicle = None
            for v in iVehicles:
                if v.inventoryId == vehicle.invID:
                    oldStyleVehicle = v
                    break

            shells = ammo.get('shells')
            for shell in oldStyleVehicle.shells:
                shopShell = sAmmo[sAmmo.index(shell)] if shell in sAmmo else None
                goldAmmoForCredits = shopRqs.isEnabledBuyingGoldShellsForCredits
                if shopShell:
                    iCount = iAmmo[iAmmo.index(shell)].count if shell in iAmmo else 0
                    sPrice = (yield shopShell.getPrice()) if shell is not shopShell else (0, 0)
                    if goldAmmoForCredits:
                        shopShell.priceOrder = (sPrice[0] + sPrice[1] * shopRqs.exchangeRateForShellsAndEqs, sPrice[1])
                    shells.append({'id': gui_items.compactItem(shopShell),
                     'type': shell.type,
                     'label': ITEM_TYPES.shell_kindsabbreviation(shell.type),
                     'icon': '../maps/icons/ammopanel/ammo/%s' % shell.descriptor['icon'][0],
                     'count': shell.count,
                     'defaultCount': shell.default,
                     'inventoryCount': iCount,
                     'price': sPrice[0 if not sPrice[1] else 1],
                     'currentcy': 'credits' if not sPrice[1] else 'gold',
                     'ammoName': shell.longName,
                     'tableName': shell.tableName})

        self.as_setAmmoS(ammo)
        Waiting.hide('updateAmmo')
        return