def __showActiveTankmen(self, criteria):
        tankmen = self.itemsCache.items.getTankmen().values()
        tankmenInBarracks = 0
        tankmenList = [_packBuyBerthsSlot()]
        for tankman in sorted(tankmen,
                              cmp=TankmenComparator(
                                  self.itemsCache.items.getVehicle)):
            if not tankman.isInTank:
                tankmenInBarracks += 1
            if not criteria(tankman):
                continue
            tankmanData = _packTankmanData(tankman)
            if tankmanData is not None:
                if tankman.isInTank:
                    actionBtnLabel = MENU.BARRACKS_BTNUNLOAD
                    actionBtnTooltip = TOOLTIPS.BARRACKS_TANKMEN_UNLOAD
                else:
                    actionBtnLabel = MENU.BARRACKS_BTNDISSMISS
                    actionBtnTooltip = TOOLTIPS.BARRACKS_TANKMEN_DISMISS
                tankmanData.update({
                    'isRankNameVisible': True,
                    'recoveryPeriodText': None,
                    'actionBtnLabel': actionBtnLabel,
                    'actionBtnTooltip': actionBtnTooltip,
                    'skills': None,
                    'isSkillsVisible': False
                })
                tankmenList.append(tankmanData)

        tankmenInSlots = len(tankmenList) - 1
        slots = self.itemsCache.items.stats.tankmenBerthsCount
        if tankmenInBarracks < slots:
            tankmenList.insert(1, {
                'empty': True,
                'freePlaces': slots - tankmenInBarracks
            })
        tankmenCountStr = _ms(MENU.BARRACKS_TANKMENCOUNT,
                              curValue=tankmenInSlots,
                              total=len(tankmen))
        placeCountStr = _ms(MENU.BARRACKS_PLACESCOUNT,
                            free=max(slots - tankmenInBarracks, 0),
                            total=slots)
        self.as_setTankmenS({
            'tankmenCount':
            text_styles.playerOnline(tankmenCountStr),
            'placesCount':
            text_styles.playerOnline(placeCountStr),
            'placesCountTooltip':
            None,
            'tankmenData':
            tankmenList,
            'hasNoInfoData':
            False
        })
        return
Exemplo n.º 2
0
    def __getReturnOperationData(self, vehicle):
        crew = vehicle.crew
        lastCrewIDs = vehicle.lastCrew
        tankmen = g_itemsCache.items.getTankmen().values()
        berths = g_itemsCache.items.stats.tankmenBerthsCount
        tankmenInBarracks = 0
        for tankman in sorted(tankmen, TankmenComparator(g_itemsCache.items.getVehicle)):
            if not tankman.isInTank:
                tankmenInBarracks += 1

        freeBerths = berths - tankmenInBarracks
        tankmenToBarracksCount = 0
        for i in xrange(len(crew)):
            if crew[i][1] is not None:
                tankmenToBarracksCount += 1

        demobilizedMembersCounter = 0
        isCrewAlreadyInCurrentVehicle = True
        if lastCrewIDs is not None:
            for i in xrange(len(lastCrewIDs)):
                lastTankmenInvID = lastCrewIDs[i]
                actualLastTankman = g_itemsCache.items.getTankman(lastTankmenInvID)
                if actualLastTankman is not None:
                    if actualLastTankman.isInTank:
                        lastTankmanVehicle = g_itemsCache.items.getVehicle(actualLastTankman.vehicleInvID)
                        if lastTankmanVehicle:
                            if lastTankmanVehicle.isLocked:
                                return self.__getInitCrewOperationObject(OPERATION_RETURN, None, CREW_OPERATIONS.RETURN_WARNING_MEMBERSINBATTLE_TOOLTIP)
                            if lastTankmanVehicle.invID != vehicle.invID:
                                isCrewAlreadyInCurrentVehicle = False
                            elif lastTankmanVehicle.invID == vehicle.invID:
                                tankmenToBarracksCount -= 1
                    else:
                        isCrewAlreadyInCurrentVehicle = False
                else:
                    demobilizedMembersCounter += 1

            if tankmenToBarracksCount > freeBerths:
                return self.__getInitCrewOperationObject(OPERATION_RETURN, None, CREW_OPERATIONS.DROPINBARRACK_WARNING_NOSPACE_TOOLTIP)
        else:
            return self.__getInitCrewOperationObject(OPERATION_RETURN, 'noPrevious')
        if demobilizedMembersCounter > 0 and demobilizedMembersCounter == len(lastCrewIDs):
            return self.__getInitCrewOperationObject(OPERATION_RETURN, 'allDemobilized')
        if isCrewAlreadyInCurrentVehicle:
            return self.__getInitCrewOperationObject(OPERATION_RETURN, 'alreadyOnPlaces')
        if demobilizedMembersCounter > 0 and demobilizedMembersCounter < len(lastCrewIDs):
            return self.__getInitCrewOperationObject(OPERATION_RETURN, None, CREW_OPERATIONS.RETURN_WARNING_MEMBERDEMOBILIZED_TOOLTIP, True)
        return self.__getInitCrewOperationObject(OPERATION_RETURN)
Exemplo n.º 3
0
    def __updateTankmen(self, *args):
        tankmen = g_itemsCache.items.getTankmen().values()
        slots = g_itemsCache.items.stats.tankmenBerthsCount
        berths = g_itemsCache.items.stats.tankmenBerthsCount
        berthPrice = g_itemsCache.items.shop.getTankmanBerthPrice(berths)
        defaultBerthPrice = g_itemsCache.items.shop.defaults.getTankmanBerthPrice(berths)
        tankmenList = list()
        tankmenInBarracks = 0
        action = None
        if berthPrice[0] != defaultBerthPrice[0]:
            action = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, 'berthsPrices', True, Money(gold=berthPrice[0]), Money(gold=defaultBerthPrice[0]))
        gold = g_itemsCache.items.stats.money.gold
        enoughGold = True
        if berthPrice[0] > gold:
            enoughGold = False
        tankmenList.append({'buy': True,
         'price': BigWorld.wg_getGoldFormat(berthPrice[0]),
         'enoughGold': enoughGold,
         'actionPriceData': action,
         'count': berthPrice[1]})
        for tankman in sorted(tankmen, TankmenComparator(g_itemsCache.items.getVehicle)):
            if not tankman.isInTank:
                tankmenInBarracks += 1
            slot, vehicleID, vehicleInnationID, vehicle = (None, None, None, None)
            if tankman.isInTank:
                vehicle = g_itemsCache.items.getVehicle(tankman.vehicleInvID)
                vehicleID = vehicle.invID
                vehicleInnationID = vehicle.innationID
                if vehicle is None:
                    LOG_ERROR('Cannot find vehicle for tankman: ', tankman, tankman.descriptor.role, tankman.vehicle.name, tankman.firstname, tankman.lastname)
                    continue
                slot = tankman.vehicleSlotIdx
            if self.filter['nation'] != -1 and tankman.nationID != self.filter['nation'] or self.filter['role'] != 'None' and tankman.descriptor.role != self.filter['role'] or self.filter['tankType'] != 'None' and tankman.vehicleNativeType != self.filter['tankType'] or self.filter['location'] == 'tanks' and tankman.isInTank is not True or self.filter['location'] == 'barracks' and tankman.isInTank is True or self.filter['nationID'] is not None and (self.filter['location'] != str(vehicleInnationID) or self.filter['nationID'] != str(tankman.nationID)):
                continue
            isLocked, msg = self.getTankmanLockMessage(vehicle) if tankman.isInTank else (False, '')
            tankmanVehicle = g_itemsCache.items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr)
            isInCurrentTank = tankmanVehicle.invID == g_currentVehicle.invID if tankman.isInTank and g_currentVehicle.isPresent() else False
            tankmenList.append({'firstname': tankman.firstUserName,
             'lastname': tankman.lastUserName,
             'rank': tankman.rankUserName,
             'specializationLevel': tankman.realRoleLevel[0],
             'role': tankman.roleUserName,
             'vehicleType': tankmanVehicle.shortUserName,
             'iconFile': tankman.icon,
             'rankIconFile': tankman.iconRank,
             'roleIconFile': Tankman.getRoleBigIconPath(tankman.descriptor.role),
             'contourIconFile': tankmanVehicle.iconContour,
             'tankmanID': tankman.invID,
             'nationID': tankman.nationID,
             'typeID': tankmanVehicle.innationID,
             'slot': slot,
             'roleType': tankman.descriptor.role,
             'tankType': tankmanVehicle.type,
             'inTank': tankman.isInTank,
             'inCurrentTank': isInCurrentTank,
             'vehicleID': vehicleID,
             'compact': str(tankman.invID),
             'locked': isLocked,
             'lockMessage': msg,
             'vehicleBroken': vehicle.repairCost > 0 if tankman.isInTank else None,
             'isInSelfVehicleClass': vehicle.type == tankmanVehicle.type if tankman.isInTank else True,
             'isInSelfVehicleType': vehicle.shortUserName == tankmanVehicle.shortUserName if tankman.isInTank else True})

        tankmenInSlots = len(tankmenList) - 1
        if tankmenInBarracks < slots:
            tankmenList.insert(1, {'empty': True,
             'freePlaces': slots - tankmenInBarracks})
        self.as_setTankmenS(len(tankmen), tankmenInSlots, slots, tankmenInBarracks, tankmenList)
        return
 def __getSortedTankmen(self):
     return sorted(self.itemsCache.items.getTankmen().itervalues(),
                   cmp=TankmenComparator(self.itemsCache.items.getVehicle))