Esempio n. 1
0
 def __init__(self, intCompactDescr, count = 0, defaultCount = 0, proxy = None, isBoughtForCredits = False):
     """
     Ctor.
     
     @param intCompactDescr: item int compact descriptor
     @param count: count of shells in ammo bay
     @param defaultCount: count default shells in ammo bay
     @param proxy: instance of ItemsRequester
     """
     FittingItem.__init__(self, intCompactDescr, proxy, isBoughtForCredits)
     self.count = count
     self.defaultCount = defaultCount
Esempio n. 2
0
 def __init__(self, intCompactDescr, count = 0, defaultCount = 0, proxy = None, isBoughtForCredits = False):
     """
     Ctor.
     
     @param intCompactDescr: item int compact descriptor
     @param count: count of shells in ammo bay
     @param defaultCount: count default shells in ammo bay
     @param proxy: instance of ItemsRequester
     """
     FittingItem.__init__(self, intCompactDescr, proxy, isBoughtForCredits)
     self.count = count
     self.defaultCount = defaultCount
Esempio n. 3
0
    def _calcSellPrice(self, proxy):
        price = list(self.sellPrice)
        defaultDevices, installedDevices, _ = self.descriptor.getDevices()
        for defCompDescr, instCompDescr in izip(defaultDevices, installedDevices):
            if defCompDescr == instCompDescr:
                continue
            modulePrice = FittingItem(defCompDescr, proxy).sellPrice
            price = (price[0] - modulePrice[0], price[1] - modulePrice[1])
            modulePrice = FittingItem(instCompDescr, proxy).sellPrice
            price = (price[0] + modulePrice[0], price[1] + modulePrice[1])

        return price
Esempio n. 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.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
Esempio n. 5
0
    def _calcDefaultSellPrice(self, proxy):
        if self.isRented:
            return ZERO_MONEY
        price = self.defaultSellPrice
        defaultDevices, installedDevices, _ = self.descriptor.getDevices()
        for defCompDescr, instCompDescr in izip(defaultDevices, installedDevices):
            if defCompDescr == instCompDescr:
                continue
            modulePrice = FittingItem(defCompDescr, proxy).defaultSellPrice
            price = price - modulePrice
            modulePrice = FittingItem(instCompDescr, proxy).defaultSellPrice
            price = price + modulePrice

        return price
Esempio n. 6
0
 def toDict(self):
     result = FittingItem.toDict(self)
     result.update({'inventoryID': self.inventoryID,
      'xp': self.xp,
      'dailyXPFactor': self.dailyXPFactor,
      'clanLock': self.clanLock,
      'isUnique': self.isUnique,
      'crew': [ (g_itemSerializer.pack(tankman) if tankman else None) for role, tankman in self.crew ],
      'settings': self.settings,
      'lock': self.lock,
      'repairCost': self.repairCost,
      'health': self.health,
      'gun': g_itemSerializer.pack(self.gun),
      'turret': g_itemSerializer.pack(self.turret),
      'engine': g_itemSerializer.pack(self.engine),
      'chassis': g_itemSerializer.pack(self.chassis),
      'radio': g_itemSerializer.pack(self.radio),
      'fuelTank': g_itemSerializer.pack(self.fuelTank),
      'optDevices': [ (g_itemSerializer.pack(dev) if dev else None) for dev in self.optDevices ],
      'shells': [ (g_itemSerializer.pack(shell) if shell else None) for shell in self.shells ],
      'eqs': [ (g_itemSerializer.pack(eq) if eq else None) for eq in self.eqs ],
      'eqsLayout': [ (g_itemSerializer.pack(eq) if eq else None) for eq in self.eqsLayout ],
      'type': self.type,
      'isPremium': self.isPremium,
      'isElite': self.isElite,
      'icon': self.icon,
      'isLocked': self.isLocked,
      'isBroken': self.isBroken,
      'isAlive': self.isAlive})
     return result
Esempio n. 7
0
 def fromDict(self, d):
     FittingItem.fromDict(self, d)
     self.inventoryID = d.get('inventoryID', -1)
     self.xp = d.get('xp', 0)
     self.isUnique = d.get('isUnique', 0)
     self.dailyXPFactor = d.get('dailyXPFactor', -1)
     self.isElite = d.get('isElite', False)
     self.clanLock = d.get('clanLock', 0)
     self.crew = [ (g_itemSerializer.unpack(t) if t else None) for t in d.get('crew', list()) ]
     self.settings = d.get('settings', 0)
     self.lock = d.get('lock', 0)
     self.repairCost = d.get('repairCost', 0)
     self.health = d.get('health', 0)
     self.gun = g_itemSerializer.unpack(d.get('gun'))
     self.turret = g_itemSerializer.unpack(d.get('turret'))
     self.engine = g_itemSerializer.unpack(d.get('engine'))
     self.chassis = g_itemSerializer.unpack(d.get('chassis'))
     self.radio = g_itemSerializer.unpack(d.get('radio'))
     self.fuelTank = g_itemSerializer.unpack(d.get('fuelTank'))
     self.shells = [ (g_itemSerializer.unpack(shell) if shell else None) for shell in d.get('shells', list()) ]
     self.optDevices = [ (g_itemSerializer.unpack(dev) if dev else None) for dev in d.get('optDevices', list()) ]
     self.eqs = [ (g_itemSerializer.unpack(eq) if eq else None) for eq in d.get('eqs', list()) ]
     self.eqsLayout = [ (g_itemSerializer.unpack(eq) if eq else None) for eq in d.get('eqsLayout', list()) ]
     return
Esempio n. 8
0
 def mayInstall(self, vehicle, slotIdx=None):
     installPossible, reason = FittingItem.mayInstall(
         self, vehicle, slotIdx)
     if not installPossible and reason == 'too heavy':
         return (False, 'too heavy chassis')
     return (installPossible, reason)
Esempio n. 9
0
 def mayInstall(self, vehicle, slotIdx=None):
     installPossible, reason = FittingItem.mayInstall(self, vehicle)
     if not installPossible and reason == 'not for current vehicle':
         return (False, 'need turret')
     return (installPossible, reason)
Esempio n. 10
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
Esempio n. 11
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
        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:
                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.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
Esempio n. 12
0
 def mayInstall(self, vehicle, slotIdx = None):
     installPossible, reason = FittingItem.mayInstall(self, vehicle)
     if not installPossible and reason == 'not for current vehicle':
         return (False, 'need turret')
     return (installPossible, reason)
Esempio n. 13
0
 def mayInstall(self, vehicle, slotIdx = None):
     installPossible, reason = FittingItem.mayInstall(self, vehicle, slotIdx)
     if not installPossible and reason == 'too heavy':
         return (False, 'too heavy chassis')
     return (installPossible, reason)
Esempio n. 14
0
 def toDict(self):
     d = FittingItem.toDict(self)
     d.update({'count': self.count,
      'defaulCount': self.defaultCount,
      'kind': self.type})
     return d