def __init__(self, xp, vehiclesCD, freeConversion=False): rate = self.itemsCache.items.shop.freeXPConversion self.xp = xp self.__freeConversion = bool(freeConversion) self.gold = round(rate[1] * xp / rate[0]) if not freeConversion else 0 self.vehiclesCD = vehiclesCD super(FreeXPExchanger, self).__init__(plugins=(self.__makeConfirmator(), plugins.MoneyValidator(Money(gold=self.gold)), plugins.EliteVehiclesValidator(self.vehiclesCD)))
def _setupPlugins(self): self.addPlugins( (proc_plugs.VehicleValidator(self._vehicle), proc_plugs.MoneyValidator(getVehicleConsumablesLayoutPrice( self._vehicle).price, byCurrencyError=False), proc_plugs.ConsumablesInstallValidator(self._vehicle)))
def _setupPlugins(self): self.addPlugins( (proc_plugs.VehicleValidator(self.__vehicle), proc_plugs.MoneyValidator(getVehicleBattleBoostersLayoutPrice( self.__vehicle).price, byCurrencyError=False), proc_plugs.BattleBoostersInstallValidator(self.__vehicle)))
def _setupPlugins(self): price = self.__getPrice() self.addPlugins( (proc_plugs.VehicleValidator(self.__vehicle), proc_plugs.MoneyValidator(price), proc_plugs.ShellsInstallValidator(self.__vehicle), proc_plugs.ConsumablesInstallValidator(self.__vehicle)))
def _getPluginsList(self): """ Gets plugins collection :return: <tuple(ProcessorPlugin, ...)> """ return (plugins.MoneyValidator(self.price), plugins.VehicleFreeLimitConfirmator(self.item, self.crewType))
def _getPluginsList(self): return (proc_plugs.MoneyValidator(self.price), proc_plugs.VehicleSlotsConfirmator(self.showNotEnoughSlotMsg and not self.buySlot), proc_plugs.VehicleFreeLimitConfirmator(self.item, self.crewType), proc_plugs.CollectibleVehiclesValidator(self.item.intCD))
def __init__(self, vehicle, dismantlingGoldCost, shells = [], eqs = [], optDevs = [], inventory = [], isCrewDismiss = False): self.gainMoney, self.spendMoney = self.__getGainSpendMoney(vehicle, shells, eqs, optDevs, inventory, dismantlingGoldCost) barracksBerthsNeeded = len(filter(lambda (idx, item): item is not None, vehicle.crew)) bufferOverflowCtx = {} isBufferOverflowed = False if isCrewDismiss: tankmenGoingToBuffer, deletedTankmen = getRestoreController().getTankmenDeletedBySelling(vehicle) countOfDeleted = len(deletedTankmen) if countOfDeleted > 0: isBufferOverflowed = True bufferOverflowCtx['deleted'] = deletedTankmen[-1] bufferOverflowCtx['dismissed'] = tankmenGoingToBuffer[-1] if countOfDeleted > 1: bufferOverflowCtx['multiple'] = True bufferOverflowCtx['extraCount'] = countOfDeleted - 1 super(VehicleSeller, self).__init__(vehicle, (plugins.VehicleValidator(vehicle, False, prop={'isBroken': True, 'isLocked': True}), plugins.VehicleSellValidator(vehicle), plugins.MoneyValidator(self.spendMoney), plugins.VehicleSellsLeftValidator(vehicle, not (vehicle.isRented and vehicle.rentalIsOver)), plugins.BarracksSlotsValidator(barracksBerthsNeeded, isEnabled=not isCrewDismiss), plugins.BufferOverflowConfirmator(bufferOverflowCtx, isEnabled=isBufferOverflowed), _getUniqueVehicleSellConfirmator(vehicle))) self.vehicle = vehicle self.shells = shells self.eqs = eqs self.optDevs = optDevs self.inventory = inventory self.isCrewDismiss = isCrewDismiss self.isDismantlingForGold = self.__dismantlingForGoldDevicesCount(vehicle, optDevs) > 0 self.isRemovedAfterRent = vehicle.isRented
def __init__(self, period, price, arenaUniqueID=0, withoutBenefits=False): self.wasPremium = g_itemsCache.items.stats.isPremium super(PremiumAccountBuyer, self).__init__( (self.__getConfirmator(withoutBenefits, period, price), plugins.MoneyValidator(Money(gold=price)))) self.premiumPrice = price self.period = period self.arenaUniqueID = arenaUniqueID
def __init__(self, gold, withConfirm=True): self.gold = gold self.credits = int(gold) * self.itemsCache.items.shop.exchangeRate super(GoldToCreditsExchanger, self).__init__() if withConfirm: self.addPlugin(plugins.HtmlMessageConfirmator('exchangeGoldConfirmation', 'html_templates:lobby/dialogs', 'confirmExchange', {'primaryCurrencyAmount': backport.getGoldFormat(self.gold), 'resultCurrencyAmount': backport.getIntegralFormat(self.credits)})) self.addPlugin(plugins.MoneyValidator(Money(gold=self.gold)))
def __init__(self, tankman): self.__tankman = tankman restorePrice, _ = getTankmenRestoreInfo(tankman) super(TankmanRestore, self).__init__(tankman, (plugins.TankmanLockedValidator(tankman), plugins.TankmanOperationConfirmator('restoreTankman', tankman), plugins.BarracksSlotsValidator(berthsNeeded=1), plugins.MoneyValidator(restorePrice), plugins.IsLongDisconnectedFromCenter()))
def __init__(self, nationID, vehTypeID, role, tmanCostTypeIdx): super(TankmanRecruit, self).__init__([plugins.MoneyValidator(self.__getRecruitPrice(tmanCostTypeIdx)), plugins.FreeTankmanValidator(isEnabled=tmanCostTypeIdx == 0), plugins.BarracksSlotsValidator(), plugins.IsLongDisconnectedFromCenter()]) self.nationID = nationID self.vehTypeID = vehTypeID self.role = role self.tmanCostTypeIdx = tmanCostTypeIdx
def __init__(self, tankman, role, vehTypeCompDescr): self.__roleIdx = SKILL_INDICES[role] self.__vehTypeCompDescr = vehTypeCompDescr self.__changeRoleCost = g_itemsCache.items.shop.changeRoleCost vehicle = g_itemsCache.items.getItemByCD(self.__vehTypeCompDescr) super(TankmanChangeRole, self).__init__(tankman, [plugins.MessageConfirmator('tankmanChageRole/unknownVehicle', ctx={'tankname': vehicle.userName}, isEnabled=not vehicle.isInInventory), plugins.VehicleValidator(vehicle, False), plugins.VehicleRoleValidator(vehicle, role), plugins.MoneyValidator(Money(gold=self.__changeRoleCost))])
def __init__(self, berthsPrice, berthsCount): super(TankmanBerthsBuyer, self).__init__( (plugins.MessageInformator( 'barracksExpandNotEnoughMoney', activeHandler=lambda: not plugins.MoneyValidator( berthsPrice).validate().success), plugins.MessageConfirmator( 'barracksExpand', ctx={ 'price': text_styles.concatStylesWithSpace( text_styles.gold(str(berthsPrice.gold)), icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2)), 'count': text_styles.stats(berthsCount) }), plugins.MoneyValidator(berthsPrice))) self.berthsPrice = berthsPrice
def _setupPlugins(self, skipConfirm): itemPrice = self.battleBooster.buyPrices.getSum().price self.addPlugins((proc_plugs.MoneyValidator(itemPrice * self.count), proc_plugs.BattleBoosterConfirmator( 'confirmBattleBoosterBuyAndInstall', 'confirmBattleBoosterInstallNotSuitable', self.vehicle, self.battleBooster, isEnabled=not skipConfirm)))
def _getPluginsList(self): barracksBerthsNeeded = len( [item for item in self.itemToTradeOff.crew if item[1] is not None]) return (proc_plugs.VehicleValidator(self.itemToTradeOff, setAll=True), proc_plugs.VehicleTradeInValidator(self.item, self.itemToTradeOff), proc_plugs.VehicleSellValidator(self.itemToTradeOff), proc_plugs.MoneyValidator(self.price), proc_plugs.BarracksSlotsValidator(barracksBerthsNeeded))
def __init__(self, tankman): raise tankman is not None or AssertionError('tankman must be given') self.__tankman = tankman restorePrice, _ = getTankmenRestoreInfo(tankman) super(TankmanRestore, self).__init__(tankman, [plugins.TankmanOperationConfirmator('restoreTankman', tankman), plugins.BarracksSlotsValidator(berthsNeeded=1), plugins.MoneyValidator(restorePrice), plugins.IsLongDisconnectedFromCenter()]) return
def __init__(self, period, price, arenaUniqueID=0, withoutBenefits=False, requireConfirm=True): self.wasPremium = self.itemsCache.items.stats.isPremium plugList = [plugins.MoneyValidator(Money(gold=price))] if requireConfirm: plugList.insert(0, self.__getConfirmator(withoutBenefits, period, price)) super(PremiumAccountBuyer, self).__init__(plugList) self.premiumPrice = price self.period = period self.arenaUniqueID = arenaUniqueID
def __init__(self, booster, count, currency): """ Ctr. :param booster: booster <Booster>. :param count: count of boosters <int>. :param currency: desired currency for buying <string>, see Currency enum. """ super(BoosterBuyer, self).__init__(booster, count, 'buy') self.buyCurrency = currency self.addPlugins((plugins.MoneyValidator(self._getOpPrice().price), ))
def __init__(self, nationID, vehTypeID, role, tmanCostTypeIdx): super(TankmanRecruit, self).__init__([plugins.VehicleCrewLockedValidator(self.itemsCache.items.getItemByCD(makeIntCompactDescrByID('vehicle', nationID, vehTypeID))), plugins.MoneyValidator(self.__getRecruitPrice(tmanCostTypeIdx)), plugins.FreeTankmanValidator(isEnabled=tmanCostTypeIdx == 0), plugins.BarracksSlotsValidator(), plugins.IsLongDisconnectedFromCenter()]) self.nationID = nationID self.vehTypeID = vehTypeID self.role = role self.tmanCostTypeIdx = tmanCostTypeIdx
def _getPluginsList(self): nationGroupVehs = self.itemToTradeOff.getAllNationGroupVehs( self.itemsCache.items) barracksBerthsNeeded = getCrewCount(nationGroupVehs) return (proc_plugs.VehicleValidator(self.itemToTradeOff, setAll=True), proc_plugs.VehicleTradeInValidator(self.item, self.itemToTradeOff), proc_plugs.VehicleSellValidator(self.itemToTradeOff), proc_plugs.MoneyValidator(self.price), proc_plugs.BarracksSlotsValidator(barracksBerthsNeeded))
def __init__(self, item, count, buyForCredits): """ Ctor. @param item: module to install @param count: buying count @param buyForCredits: buy gold item for credits """ super(ModuleBuyer, self).__init__(item, count, 'buy') self.buyForCredits = buyForCredits self.addPlugins((plugins.MoneyValidator(self._getOpPrice()), ))
def __init__(self, vehicle, buySlot, buyShell = False, crewType = -1): self.price = self.__sumBuyPrice(vehicle, buyShell, crewType) super(VehicleBuyer, self).__init__(vehicle, (plugins.VehicleValidator(vehicle, False, prop={'isBroken': True, 'isLocked': True}), plugins.MoneyValidator(self.price), plugins.VehicleSlotsConfirmator(not buySlot), plugins.VehicleFreeLimitConfirmator(vehicle, crewType))) self.buyShell = buyShell self.buyCrew = crewType != -1 self.crewType = crewType self.vehicle = vehicle
def __init__(self, vehicle, slot, tmanCostTypeIdx): super(TankmanRecruitAndEquip, self).__init__() self.vehicle = vehicle self.slot = slot self.tmanCostTypeIdx = tmanCostTypeIdx self.isReplace = dict(vehicle.crew).get(slot) is not None self.addPlugins([plugins.VehicleValidator(vehicle, False, prop={'isLocked': True}), plugins.MoneyValidator(self.__getRecruitPrice(tmanCostTypeIdx)), plugins.FreeTankmanValidator(isEnabled=tmanCostTypeIdx == 0), plugins.BarracksSlotsValidator(isEnabled=self.isReplace)]) return
def __init__(self, item, vehicle, slotIdx, plugs=tuple()): super(ModuleUpgradeProcessor, self).__init__(item, 'upgrade', plugs) addPlugins = [] self.__upgradePrice = item.getUpgradePrice(self.itemsCache.items) addPlugins += (plugins.MoneyValidator(self.__upgradePrice.price),) if vehicle is not None: addPlugins += (plugins.VehicleValidator(vehicle, True, prop={'isBroken': True, 'isLocked': True}),) self.vehicle = vehicle self.slotIdx = slotIdx self.addPlugins(addPlugins) return
def __init__(self, vehicle, shells=None, eqs=None, optDevs=None, inventory=None, isCrewDismiss=False): shells = shells or [] eqs = eqs or [] optDevs = optDevs or [] inventory = inventory or [] self.gainMoney, self.spendMoney = self.__getGainSpendMoney( vehicle, shells, eqs, optDevs, inventory) barracksBerthsNeeded = len( [item for item in vehicle.crew if item[1] is not None]) bufferOverflowCtx = {} isBufferOverflowed = False if isCrewDismiss: tankmenGoingToBuffer, deletedTankmen = self.restore.getTankmenDeletedBySelling( vehicle) countOfDeleted = len(deletedTankmen) if countOfDeleted > 0: isBufferOverflowed = True bufferOverflowCtx['deleted'] = deletedTankmen[-1] bufferOverflowCtx['dismissed'] = tankmenGoingToBuffer[-1] if countOfDeleted > 1: bufferOverflowCtx['multiple'] = True bufferOverflowCtx['extraCount'] = countOfDeleted - 1 super(VehicleSeller, self).__init__( vehicle, (proc_plugs.VehicleValidator( vehicle, False, prop={ 'isBroken': True, 'isLocked': True }), proc_plugs.VehicleSellValidator(vehicle), proc_plugs.MoneyValidator(self.spendMoney - self.gainMoney), proc_plugs.VehicleSellsLeftValidator( vehicle, not (vehicle.isRented and vehicle.rentalIsOver)), proc_plugs.BarracksSlotsValidator(barracksBerthsNeeded, isEnabled=not isCrewDismiss), proc_plugs.BufferOverflowConfirmator( bufferOverflowCtx, isEnabled=isBufferOverflowed), _getUniqueVehicleSellConfirmator(vehicle))) self.vehicle = vehicle self.shells = shells self.eqs = eqs self.optDevs = optDevs self.inventory = inventory self.isCrewDismiss = isCrewDismiss self.isDismantlingForMoney = len( getDismantlingToInventoryDevices(vehicle, optDevs)) > 0 self.isRemovedAfterRent = vehicle.isRented return
def __init__(self, gold): self.gold = gold self.credits = int(gold) * g_itemsCache.items.shop.exchangeRate super(GoldToCreditsExchanger, self).__init__(plugins=(plugins.HtmlMessageConfirmator( 'exchangeGoldConfirmation', 'html_templates:lobby/dialogs', 'confirmExchange', { 'primaryCurrencyAmount': BigWorld.wg_getGoldFormat(self.gold), 'resultCurrencyAmount': BigWorld.wg_getIntegralFormat(self.credits) }), plugins.MoneyValidator(Money(gold=self.gold))))
def __init__(self, showConfirm=True, showWarning=True): self.__hasDiscounts = bool( g_itemsCache.items.shop.personalSlotDiscounts) self.__frozenSlotPrice = None slotCost = self.__getSlotPrice() if self.__hasDiscounts and not slotCost: confirmationType = 'freeSlotConfirmation' ctx = {} else: confirmationType = 'buySlotConfirmation' ctx = {'gold': slotCost.gold} super(VehicleSlotBuyer, self).__init__( (plugins.MessageInformator( 'buySlotNotEnoughCredits', activeHandler=lambda: not plugins.MoneyValidator( slotCost).validate().success, isEnabled=showWarning), plugins.MessageConfirmator(confirmationType, isEnabled=showConfirm, ctx=ctx), plugins.MoneyValidator(slotCost))) return
def __init__(self, item, count, currency): """ Ctor. @param item: module to install @param count: buying count @param currency: currency to be used for buying """ super(ModuleBuyer, self).__init__(item, count, 'buy') self._currency, self._itemPrice = self._getItemCurrencyAndPrice( currency) self.addPlugins((plugins.MoneyValidator(self._getOpPrice().price), plugins.ModuleConfigValidator(item)))
def _getPluginsList(self): """ Gets plugins collection :return: <tuple(ProcessorPlugin, ...)> """ barracksBerthsNeeded = len( filter(lambda (idx, item): item is not None, self.itemToTradeOff.crew)) return (plugins.VehicleValidator(self.itemToTradeOff, setAll=True), plugins.VehicleTradeInValidator(self.item, self.itemToTradeOff), plugins.VehicleSellValidator(self.itemToTradeOff), plugins.MoneyValidator(self.price), plugins.BarracksSlotsValidator(barracksBerthsNeeded))
def __init__(self, period, price, arenaUniqueID=0): self.wasPremium = g_itemsCache.items.stats.isPremium localKey = 'premiumContinueConfirmation' if self.wasPremium else 'premiumBuyConfirmation' super(PremiumAccountBuyer, self).__init__( (plugins.MessageConfirmator(localKey, ctx={ 'days': int(period), 'gold': BigWorld.wg_getGoldFormat(price) }), plugins.MoneyValidator( (0, price)))) self.premiumPrice = price self.period = period self.arenaUniqueID = arenaUniqueID