Exemple #1
0
    def getCrewBySkillLevels(self, *skillLevels):
        """
        Generate sorted list of tankmans with provided skills levels
        :param skillLevels: desired skills levels (list of integers)
        :return: list of tuples [(role, gui_items.Tankman), (role, gui_items.Tankman), ...] sorted by tankmans roles
        """
        crewItems = list()
        crewRoles = self.descriptor.type.crewRoles
        nationID, vehicleTypeID = self.descriptor.type.id
        passport = tankmen.generatePassport(nationID)
        skillLvlsCount = len(skillLevels)
        for idx, tankmanID in enumerate(crewRoles):
            role = self.descriptor.type.crewRoles[idx][0]
            roleLevel = skillLevels[
                idx] if idx < skillLvlsCount else skillLevels[skillLvlsCount -
                                                              1]
            if roleLevel is not None:
                tankman = Tankman(tankmen.generateCompactDescr(
                    passport, vehicleTypeID, role, roleLevel),
                                  vehicle=self)
            else:
                tankman = None
            crewItems.append((idx, tankman))

        return _sortCrew(crewItems, crewRoles)
Exemple #2
0
 def createTankman(self,
                   strCompactDescr,
                   inventoryID=-1,
                   vehicle=None,
                   dismissedAt=None,
                   proxy=None):
     return Tankman(strCompactDescr, inventoryID, vehicle, dismissedAt,
                    proxy)
Exemple #3
0
    def _showAward(self, ctx):
        _, message = ctx
        completedQuestIDs = message.data.get('completedQuestIDs', set())
        for tmanCompDescr in message.data.get('tankmen') or []:
            self._awardCtrl._proxy.refSystem.showTankmanAwardWindow(Tankman(tmanCompDescr), completedQuestIDs)

        for vehTypeCompDescr in message.data.get('vehicles') or {}:
            self._awardCtrl._proxy.refSystem.showVehicleAwardWindow(Vehicle(typeCompDescr=abs(vehTypeCompDescr)), completedQuestIDs)

        self._awardCtrl._proxy.refSystem.showCreditsAwardWindow(message.data.get('credits', 0), completedQuestIDs)
Exemple #4
0
    def _buildCrew(self, crew, proxy):
        crewItems = list()
        crewRoles = self.descriptor.type.crewRoles
        for idx, tankmanID in enumerate(crew):
            tankman = None
            if tankmanID is not None:
                tmanInvData = proxy.inventory.getItems(GUI_ITEM_TYPE.TANKMAN, tankmanID)
                tankman = Tankman(strCompactDescr=tmanInvData['compDescr'], inventoryID=tankmanID, vehicle=self, proxy=proxy)
            crewItems.append((idx, tankman))

        return _sortCrew(crewItems, crewRoles)
Exemple #5
0
    def _buildCrew(self, crew, proxy):
        crewItems = list()
        crewRoles = self.descriptor.type.crewRoles
        for idx, tankmanID in enumerate(crew):
            tankman = None
            if tankmanID is not None:
                tmanInvData = proxy.inventory.getItems(vehicles._TANKMAN, tankmanID)
                tankman = Tankman(strCompactDescr=tmanInvData['compDescr'], inventoryID=tankmanID, vehicle=self, proxy=proxy)
            crewItems.append((idx, tankman))

        RO = Tankman.TANKMEN_ROLES_ORDER
        return sorted(crewItems, cmp=lambda a, b: RO[crewRoles[a[0]][0]] - RO[crewRoles[b[0]][0]])
Exemple #6
0
 def createTankman(self, strCompactDescr, inventoryID = -1, vehicle = None, dismissedAt = None, proxy = None):
     """
     Creates Tankman item by the given arguments.
     
     :param strCompactDescr: vehicle string compact descriptor
     :param inventoryID:  tankman's inventory id
     :param vehicle: tankman's vehicle where it has been seat
     :param dismissedAt:
     :param proxy:  instance of ItemsRequester
     :return: an instance of Tankman class.
     """
     return Tankman(strCompactDescr, inventoryID, vehicle, dismissedAt, proxy)
Exemple #7
0
    def getPerfectCrew(self):
        crewItems = list()
        crewRoles = self.descriptor.type.crewRoles
        nationID, vehicleTypeID = self.descriptor.type.id
        passport = tankmen.generatePassport(nationID)
        for idx, tankmanID in enumerate(crewRoles):
            role = self.descriptor.type.crewRoles[idx][0]
            tankman = Tankman(tankmen.generateCompactDescr(
                passport, vehicleTypeID, role, 100),
                              vehicle=self)
            crewItems.append((idx, tankman))

        return _sortCrew(crewItems, crewRoles)
 def calcDropSkillsParams(self, tmanCompDescrPickle, xpReuseFraction):
     """
     Recalculates tankman skills by given skills reuse fraction
     
     @param tmanCompDescr: tankman string compact descriptor
     @param xpReuseFraction: tankman experience reuse fraction
     @return: (new skills count, last new skill level)
     """
     tmanCompDescr = pickle.loads(tmanCompDescrPickle)
     tmanDescr = tankmen.TankmanDescr(tmanCompDescr)
     tmanDescr.dropSkills(xpReuseFraction)
     tankman = Tankman(tmanDescr.makeCompactDescr())
     return (tankman.roleLevel, ) + tankman.newSkillCount
Exemple #9
0
def createTankman(nationID, vehicleTypeID, role, roleLevel, skills):
    """
    Generates tankmen with provided parameters
    :param nationID: *.nations.INDICES
    :param vehicleTypeID: int
    :param role: *.Tankman.ROLES
    :param roleLevel: *.CREW_TYPES
    :param skills: the set of skills
    :return: gui.shared.gui_items.Tankman
    """
    descr = tankmen.generateCompactDescr(tankmen.generatePassport(nationID),
                                         vehicleTypeID, role, roleLevel,
                                         skills)
    return Tankman(descr)
Exemple #10
0
def createTankman(nationID, vehicleTypeID, role, roleLevel, skills, vehicle,
                  vehicleSlotIDx):
    descr = tankmen.generateCompactDescr(tankmen.generatePassport(nationID),
                                         vehicleTypeID, role, roleLevel,
                                         skills)
    newTankmen = Tankman(descr, vehicle=vehicle, vehicleSlotIdx=vehicleSlotIDx)
    if BROTHERHOOD_SKILL_NAME in skills:
        newTankmen.setBrotherhoodActivity(True)
        newTankmen.rebuildSkills()
    return newTankmen
Exemple #11
0
 def setCrewLvl(self, crewLvl, crewData):
     """
     Updates crew information
     :param crewLvl: int, one of gui.game_control.veh_comparison_basket.CREW_TYPES
     :param crewData: list, [(crewIndex, tankmanStrCD), ...]
     :return: bool, True if new incoming data is not similar as existed, otherwise - False
     """
     if self.__crewLvl != crewLvl or self.__crewData != crewData:
         self.__crewLvl = crewLvl
         self.__crewData = crewData
         self.__vehicle.crew = map(
             lambda strCD: (strCD[0], Tankman(strCD[1])
                            if strCD[1] else None), crewData)
         self.__isCrewInvalid = True
         self.__isCurrVehParamsInvalid = True
     return self.__isCrewInvalid
    def _showAward(self, ctx):
        _, message = ctx
        completedQuestIDs = message.data.get('completedQuestIDs', set())
        allQuests = self.eventsCache.getAllQuests(includePotapovQuests=True)
        if completedQuestIDs in allQuests:
            q = allQuests[completedQuestIDs]
            if not self.isShowCongrats(q):
                return
        for tmanCompDescr in message.data.get('tankmen') or []:
            self._awardCtrl.refSystem.showTankmanAwardWindow(
                Tankman(tmanCompDescr), completedQuestIDs)

        for vehTypeCompDescr in message.data.get('vehicles') or {}:
            self._awardCtrl.refSystem.showVehicleAwardWindow(
                Vehicle(typeCompDescr=abs(vehTypeCompDescr)),
                completedQuestIDs)

        self._awardCtrl.refSystem.showCreditsAwardWindow(
            message.data.get('credits', 0), completedQuestIDs)
Exemple #13
0
def _recruit(recruitInfo):
    iterNationGroups = ((nationID,
                         set(
                             _iterNationGroups(config,
                                               recruitInfo.getIsPremium(),
                                               recruitInfo.getGroupName())))
                        for nationID, config in _iterNationsConfigs())
    currentNationGroup = first(((nationID, first(nationGroups))
                                for nationID, nationGroups in iterNationGroups
                                if nationGroups))
    return Tankman(
        TankmanDescr(
            generateCompactDescr(
                passport=_makePassport(recruitInfo, currentNationGroup),
                vehicleTypeID=VEHICLE_TYPES_ORDER_INDICES[
                    VEHICLE_CLASS_NAME.MEDIUM_TANK],
                role=Tankman.ROLES.COMMANDER,
                roleLevel=recruitInfo.getRoleLevel(),
                skills=[
                    s for s in recruitInfo.getLearntSkills() if s != _NEW_SKILL
                ],
                lastSkillLevel=recruitInfo.getLastSkillLevel())).
        makeCompactDescr())
Exemple #14
0
def createTankmans(crewData):
    return map(
        lambda strCD: (strCD[0], Tankman(strCD[1])
                       if strCD[1] else None), crewData)
Exemple #15
0
 def calcDropSkillsParams(self, tmanCompDescrPickle, xpReuseFraction):
     tmanCompDescr = pickle.loads(tmanCompDescrPickle)
     tmanDescr = tankmen.TankmanDescr(tmanCompDescr)
     tmanDescr.dropSkills(xpReuseFraction)
     tankman = Tankman(tmanDescr.makeCompactDescr())
     return (tankman.roleLevel, ) + tankman.newSkillCount
Exemple #16
0
def createTankmans(crewData):
    return [ (strCD[0], Tankman(strCD[1]) if strCD[1] else None) for strCD in crewData ]
Exemple #17
0
def createTankman(nationID, vehicleTypeID, role, roleLevel, skills):
    descr = tankmen.generateCompactDescr(tankmen.generatePassport(nationID), vehicleTypeID, role, roleLevel, skills)
    return Tankman(descr)