示例#1
0
 def _request(self, callback):
     vehDescr = self.vehicle.descriptor
     vehDescr.installTurret(self.item.intCD, self.gunCD)
     self.vehicle.turret = VehicleTurret(vehDescr.turret.compactDescr, descriptor=vehDescr.turret)
     if self.gunCD:
         self.vehicle.descriptor.installComponent(self.gunCD)
         self.vehicle.gun = VehicleGun(self.gunCD, descriptor=self.vehicle.descriptor.gun)
     callback(makeSuccess())
示例#2
0
 def createVehicleTurret(self, intCompactDescr, proxy = None, descriptor = None):
     """
     Creates VehicleTurret item by the given arguments.
     
     :param intCompactDescr: item int compact descriptor
     :param proxy:  instance of ItemsRequester
     :param descriptor: vehicle module descriptor
     :return: an instance of VehicleTurret class.
     """
     return VehicleTurret(intCompactDescr, proxy, descriptor)
示例#3
0
    def __init__(self, strCompactDescr = None, inventoryID = -1, typeCompDescr = None, proxy = None):
        if strCompactDescr is not None:
            vehDescr = vehicles.VehicleDescr(compactDescr=strCompactDescr)
        else:
            raise typeCompDescr is not None or AssertionError
            _, nID, innID = vehicles.parseIntCompactDescr(typeCompDescr)
            vehDescr = vehicles.VehicleDescr(typeID=(nID, innID))
        self.__descriptor = vehDescr
        HasStrCD.__init__(self, strCompactDescr)
        FittingItem.__init__(self, vehDescr.type.compactDescr, proxy)
        self.inventoryID = inventoryID
        self.xp = 0
        self.dailyXPFactor = -1
        self.isElite = False
        self.clanLock = 0
        self.isUnique = self.isHidden
        invData = dict()
        if proxy is not None:
            invDataTmp = proxy.inventory.getItems(vehicles._VEHICLE, inventoryID)
            if invDataTmp is not None:
                invData = invDataTmp
            self.xp = proxy.stats.vehiclesXPs.get(self.intCD, self.xp)
            self.dailyXPFactor = proxy.shop.dailyXPFactor if self.intCD not in proxy.stats.multipliedVehicles else self.dailyXPFactor
            self.isElite = len(vehDescr.type.unlocksDescrs) == 0 or self.intCD in proxy.stats.eliteVehicles
            clanDamageLock = proxy.stats.vehicleTypeLocks.get(self.intCD, {}).get(CLAN_LOCK, 0)
            clanNewbieLock = proxy.stats.globalVehicleLocks.get(CLAN_LOCK, 0)
            self.clanLock = clanDamageLock or clanNewbieLock
        self.inventoryCount = 1 if len(invData.keys()) else 0
        self.settings = invData.get('settings', 0)
        self.lock = invData.get('lock', 0)
        self.repairCost, self.health = invData.get('repair', (0, 0))
        self.gun = VehicleGun(vehDescr.gun['compactDescr'], proxy, vehDescr.gun)
        self.turret = VehicleTurret(vehDescr.turret['compactDescr'], proxy, vehDescr.turret)
        self.engine = VehicleEngine(vehDescr.engine['compactDescr'], proxy, vehDescr.engine)
        self.chassis = VehicleChassis(vehDescr.chassis['compactDescr'], proxy, vehDescr.chassis)
        self.radio = VehicleRadio(vehDescr.radio['compactDescr'], proxy, vehDescr.radio)
        self.fuelTank = VehicleFuelTank(vehDescr.fuelTank['compactDescr'], proxy, vehDescr.fuelTank)
        self.sellPrice = self._calcSellPrice(proxy)
        self.optDevices = self._parserOptDevs(vehDescr.optionalDevices, proxy)
        gunAmmoLayout = []
        for shell in self.gun.defaultAmmo:
            gunAmmoLayout += (shell.intCD, shell.defaultCount)

        self.shells = self._parseShells(invData.get('shells', list()), invData.get('shellsLayout', dict()).get(self.shellsLayoutIdx, gunAmmoLayout), proxy)
        self.eqs = self._parseEqs(invData.get('eqs') or [0, 0, 0], proxy)
        self.eqsLayout = self._parseEqs(invData.get('eqsLayout') or [0, 0, 0], proxy)
        defaultCrew = [None] * len(vehDescr.type.crewRoles)
        crewList = invData.get('crew', defaultCrew)
        self.bonuses = self._calcCrewBonuses(crewList, proxy)
        self.crewIndices = dict([ (invID, idx) for idx, invID in enumerate(crewList) ])
        self.crew = self._buildCrew(crewList, proxy)
        return
示例#4
0
    def __init__(self,
                 strCompactDescr=None,
                 inventoryID=-1,
                 typeCompDescr=None,
                 proxy=None):
        if strCompactDescr is not None:
            vehDescr = vehicles.VehicleDescr(compactDescr=strCompactDescr)
        else:
            raise typeCompDescr is not None or AssertionError
            _, nID, innID = vehicles.parseIntCompactDescr(typeCompDescr)
            vehDescr = vehicles.VehicleDescr(typeID=(nID, innID))
        self.__descriptor = vehDescr
        HasStrCD.__init__(self, strCompactDescr)
        FittingItem.__init__(self, vehDescr.type.compactDescr, proxy)
        self.inventoryID = inventoryID
        self.xp = 0
        self.dailyXPFactor = -1
        self.isElite = False
        self.isFullyElite = False
        self.clanLock = 0
        self.isUnique = self.isHidden
        self.rentPackages = []
        self.hasRentPackages = False
        self.isDisabledForBuy = False
        self.isSelected = False
        self.igrCustomizationsLayout = {}
        invData = dict()
        if proxy is not None and proxy.inventory.isSynced(
        ) and proxy.stats.isSynced() and proxy.shop.isSynced():
            invDataTmp = proxy.inventory.getItems(GUI_ITEM_TYPE.VEHICLE,
                                                  inventoryID)
            if invDataTmp is not None:
                invData = invDataTmp
            self.xp = proxy.stats.vehiclesXPs.get(self.intCD, self.xp)
            if proxy.shop.winXPFactorMode == WIN_XP_FACTOR_MODE.ALWAYS or self.intCD not in proxy.stats.multipliedVehicles and not self.isOnlyForEventBattles:
                self.dailyXPFactor = proxy.shop.dailyXPFactor
            self.isElite = len(
                vehDescr.type.unlocksDescrs
            ) == 0 or self.intCD in proxy.stats.eliteVehicles
            self.isFullyElite = self.isElite and len([
                data for data in vehDescr.type.unlocksDescrs
                if data[1] not in proxy.stats.unlocks
            ]) == 0
            clanDamageLock = proxy.stats.vehicleTypeLocks.get(self.intCD,
                                                              {}).get(
                                                                  CLAN_LOCK, 0)
            clanNewbieLock = proxy.stats.globalVehicleLocks.get(CLAN_LOCK, 0)
            self.clanLock = clanDamageLock or clanNewbieLock
            self.isDisabledForBuy = self.intCD in proxy.shop.getNotToBuyVehicles(
            )
            self.hasRentPackages = bool(proxy.shop.getVehicleRentPrices().get(
                self.intCD, {}))
            self.isSelected = bool(self.invID in proxy.stats.oldVehInvIDs)
            self.igrCustomizationsLayout = proxy.inventory.getIgrCustomizationsLayout(
            ).get(self.inventoryID, {})
        self.inventoryCount = 1 if len(invData.keys()) else 0
        data = invData.get('rent')
        if data is not None:
            self.rentInfo = RentalInfoProvider(isRented=True, *data)
        self.settings = invData.get('settings', 0)
        self.lock = invData.get('lock', (0, 0))
        self.repairCost, self.health = invData.get('repair', (0, 0))
        self.gun = VehicleGun(vehDescr.gun['compactDescr'], proxy,
                              vehDescr.gun)
        self.turret = VehicleTurret(vehDescr.turret['compactDescr'], proxy,
                                    vehDescr.turret)
        self.engine = VehicleEngine(vehDescr.engine['compactDescr'], proxy,
                                    vehDescr.engine)
        self.chassis = VehicleChassis(vehDescr.chassis['compactDescr'], proxy,
                                      vehDescr.chassis)
        self.radio = VehicleRadio(vehDescr.radio['compactDescr'], proxy,
                                  vehDescr.radio)
        self.fuelTank = VehicleFuelTank(vehDescr.fuelTank['compactDescr'],
                                        proxy, vehDescr.fuelTank)
        self.sellPrice = self._calcSellPrice(proxy)
        self.defaultSellPrice = self._calcDefaultSellPrice(proxy)
        self.optDevices = self._parserOptDevs(vehDescr.optionalDevices, proxy)
        gunAmmoLayout = []
        for shell in self.gun.defaultAmmo:
            gunAmmoLayout += (shell.intCD, shell.defaultCount)

        self.shells = self._parseShells(
            invData.get('shells', list()),
            invData.get('shellsLayout', dict()).get(self.shellsLayoutIdx,
                                                    gunAmmoLayout), proxy)
        self.eqs = self._parseEqs(invData.get('eqs') or [0, 0, 0], proxy)
        self.eqsLayout = self._parseEqs(
            invData.get('eqsLayout') or [0, 0, 0], proxy)
        defaultCrew = [None] * len(vehDescr.type.crewRoles)
        crewList = invData.get('crew', defaultCrew)
        self.bonuses = self._calcCrewBonuses(crewList, proxy)
        self.crewIndices = dict([(invID, idx)
                                 for idx, invID in enumerate(crewList)])
        self.crew = self._buildCrew(crewList, proxy)
        self.lastCrew = invData.get('lastCrew')
        self.rentPackages = calcRentPackages(self, proxy)
        self.__customState = ''
        return
示例#5
0
 def createVehicleTurret(self,
                         intCompactDescr,
                         proxy=None,
                         descriptor=None):
     return VehicleTurret(intCompactDescr, proxy, descriptor)