Ejemplo n.º 1
0
def _generateTankman(vehicleDescr, roles, level):
    nationID, vehicleTypeID = vehicleDescr.type.id
    passport = (nationID, False, False, 0, 0, 0)
    skills = ()
    return tankmen.stripNonBattle(
        tankmen.generateCompactDescr(passport, vehicleTypeID, roles[0], level,
                                     skills, level))
Ejemplo n.º 2
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)
 def __makeFakeDescriptor(self):
     vehType = vehicles.VehicleDescr(typeID=(0, 0)).type
     skills = self._getSkillsForDescr()
     freeSkills = self._getFreeSkillsForDescr()
     tmanDescr = tankmen.TankmanDescr(tankmen.generateCompactDescr(tankmen.generatePassport(vehType.id[0], False), vehType.id[1], vehType.crewRoles[0][0], self._roleLevel, skills=skills, freeSkills=freeSkills, lastSkillLevel=self._lastSkillLevel))
     tmanDescr.addXP(self._freeXP)
     return tmanDescr
Ejemplo n.º 4
0
def __makeFakeTankmanDescr(startRoleLevel, freeXpValue, typeID):
    vehType = vehicles.VehicleDescr(typeID=typeID).type
    tmanDescr = tankmen.TankmanDescr(
        tankmen.generateCompactDescr(
            tankmen.generatePassport(vehType.id[0], False), vehType.id[1],
            vehType.crewRoles[0][0], startRoleLevel))
    tmanDescr.addXP(freeXpValue)
    return tmanDescr
Ejemplo n.º 5
0
def __makeFakeTankmanDescr(startRoleLevel, freeXpValue, typeID):
    vehType = vehicles.VehicleDescr(typeID=typeID).type
    tmanDescr = tankmen.TankmanDescr(
        tankmen.generateCompactDescr(
            tankmen.generatePassport(vehType.id[0], False), vehType.id[1], vehType.crewRoles[0][0], startRoleLevel
        )
    )
    tmanDescr.addXP(freeXpValue)
    return tmanDescr
Ejemplo n.º 6
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
Ejemplo n.º 7
0
def _generateTankman(vehicleDescr, roles, level):
    nationID, vehicleTypeID = vehicleDescr.type.id
    passport = (nationID,
     False,
     False,
     0,
     0,
     0)
    skills = ()
    return tankmen.stripNonBattle(tankmen.generateCompactDescr(passport, vehicleTypeID, roles[0], level, skills, level))
Ejemplo n.º 8
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)
Ejemplo n.º 9
0
def generateDefaultCrew(vehicleType, level):
    nationID, vehicleTypeID = vehicleType.id
    skills = ()
    passport = (nationID, False, False, 0, 0, 0)
    res = []
    for roles in vehicleType.crewRoles:
        cd = tankmen.generateCompactDescr(passport, vehicleTypeID, roles[0],
                                          level, skills, level)
        res.append(tankmen.stripNonBattle(cd))

    return tuple(res)
Ejemplo n.º 10
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)
Ejemplo n.º 11
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)
Ejemplo n.º 12
0
def generateDefaultCrew(vehicleType, level):
    raise 0 <= level <= tankmen.MAX_SKILL_LEVEL or AssertionError
    nationID, vehicleTypeID = vehicleType.id
    skills = ()
    passport = (nationID,
     False,
     False,
     0,
     0,
     0)
    res = []
    for roles in vehicleType.crewRoles:
        cd = tankmen.generateCompactDescr(passport, vehicleTypeID, roles[0], level, skills, level)
        res.append(tankmen.stripNonBattle(cd))

    return tuple(res)
def __makeFakeTankmanDescr(startRoleLevel,
                           freeXpValue,
                           typeID,
                           skills=(),
                           freeSkills=(),
                           lastSkillLevel=tankmen.MAX_SKILL_LEVEL):
    vehType = vehicles.VehicleDescr(typeID=typeID).type
    tmanDescr = tankmen.TankmanDescr(
        tankmen.generateCompactDescr(tankmen.generatePassport(
            vehType.id[0], False),
                                     vehType.id[1],
                                     vehType.crewRoles[0][0],
                                     startRoleLevel,
                                     skills=skills,
                                     freeSkills=freeSkills,
                                     lastSkillLevel=lastSkillLevel))
    tmanDescr.addXP(freeXpValue)
    return tmanDescr
Ejemplo n.º 14
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)
Ejemplo n.º 15
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())
Ejemplo n.º 16
0
def createTankman(nationID, vehicleTypeID, role, roleLevel, skills):
    descr = tankmen.generateCompactDescr(tankmen.generatePassport(nationID), vehicleTypeID, role, roleLevel, skills)
    return Tankman(descr)
Ejemplo n.º 17
0
def getTankmanRoleLevel(startRoleLevel, freeXpValue = 0, vehTypeName = 'ussr:T-34'):
    vehType = vehicles.VehicleDescr(typeName=vehTypeName).type
    tmanDescr = tankmen.TankmanDescr(tankmen.generateCompactDescr(tankmen.generatePassport(vehType.id[0], False), vehType.id[1], vehType.crewRoles[0][0], startRoleLevel))
    tmanDescr.addXP(freeXpValue)
    return tmanDescr.roleLevel
Ejemplo n.º 18
0
def createFakeTankmanDescr(role, vehicleType, roleLevel=100):
    nationID, vehicleTypeID = vehicleType.id
    passport = tankmen.generatePassport(nationID)
    return tankmen.generateCompactDescr(passport, vehicleTypeID, role,
                                        roleLevel)
Ejemplo n.º 19
0
def createFakeTankmanDescr(role, vehicleType, roleLevel = 100):
    nationID, vehicleTypeID = vehicleType.id
    passport = tankmen.generatePassport(nationID)
    return tankmen.generateCompactDescr(passport, vehicleTypeID, role, roleLevel)