def _update(self, onlyMoneyUpdate=False): if g_currentVehicle.isPresent(): hangarMessage = g_currentVehicle.getHangarMessage() if onlyMoneyUpdate and self.__hangarMessage == hangarMessage: return vehicle = g_currentVehicle.item self.__hangarMessage = hangarMessage statusId, msg, msgLvl = hangarMessage rentAvailable = False if statusId in (Vehicle.VEHICLE_STATE.RENTAL_IS_OVER, Vehicle.VEHICLE_STATE.RENTABLE_AGAIN): canBuyOrRent, _ = vehicle.mayObtainForMoney(self.itemsCache.items.stats.money) rentAvailable = vehicle.isRentable and canBuyOrRent if msgLvl == Vehicle.VEHICLE_STATE_LEVEL.RENTABLE: msgLvl = Vehicle.VEHICLE_STATE_LEVEL.INFO msg, msgLvl = self.__applyGamemodeOverrides(statusId, i18n.makeString(msg), msgLvl) msgString = '' if statusId != Vehicle.VEHICLE_STATE.UNDAMAGED or msgLvl == Vehicle.VEHICLE_STATE_LEVEL.ACTIONS_GROUP: msgString = makeHtmlString('html_templates:vehicleStatus', msgLvl, {'message': msg}) roleID = ROLE_TYPE.NOT_DEFINED if msgLvl == Vehicle.VEHICLE_STATE_LEVEL.ACTIONS_GROUP: roleID = vehicle.role self.__applyCustomizationNewCounter(vehicle) self.__updateDevices(vehicle) self.as_updateVehicleStatusS({'message': msgString, 'rentAvailable': rentAvailable, 'isElite': vehicle.isElite, 'tankType': '{}_elite'.format(vehicle.type) if vehicle.isElite else vehicle.type, 'vehicleLevel': '{}'.format(int2roman(vehicle.level)), 'vehicleName': '{}'.format(vehicle.shortUserName), 'actionGroupId': roleID})
def __updateState(self): isVehicleDisabled = False if self.prbDispatcher is not None: permission = self.prbDispatcher.getGUIPermissions() if permission is not None: isVehicleDisabled = not permission.canChangeVehicle() isInHangar = g_currentVehicle.isInHangar() and not g_currentVehicle.item.isInUnit msg, msgLvl = g_currentVehicle.getHangarMessage() isPresent = g_currentVehicle.isPresent() self.as_readyToFightS(g_currentVehicle.isReadyToFight(), msg, msgLvl, isPresent, isVehicleDisabled, g_currentVehicle.isCrewFull(), isInHangar, g_currentVehicle.isBroken() if isPresent else False, g_currentVehicle.isDisabledInRoaming()) return
def _update(self, onlyMoneyUpdate=False): if g_currentVehicle.isPresent(): hangarMessage = g_currentVehicle.getHangarMessage() if onlyMoneyUpdate and self.__hangarMessage == hangarMessage: return vehicle = g_currentVehicle.item self.__hangarMessage = hangarMessage statusId, msg, msgLvl = hangarMessage rentAvailable = False if statusId in (Vehicle.VEHICLE_STATE.RENTAL_IS_OVER, Vehicle.VEHICLE_STATE.RENTABLE_AGAIN): canBuyOrRent, _ = vehicle.mayObtainForMoney( self.__itemsCache.items.stats.money) rentAvailable = vehicle.isRentable and canBuyOrRent if msgLvl == Vehicle.VEHICLE_STATE_LEVEL.RENTABLE: msgLvl = Vehicle.VEHICLE_STATE_LEVEL.INFO statusOverrideRes = R.strings.ranked_battles.currentVehicleStatus.dyn( statusId) if statusOverrideRes: msg = backport.text(statusOverrideRes()) msgString = '' if statusId != Vehicle.VEHICLE_STATE.UNDAMAGED: msgString = makeHtmlString('html_templates:vehicleStatus', msgLvl, {'message': msg}) self.__applyCustomizationNewCounter(vehicle) self.__updateDevices(vehicle) self.as_updateVehicleStatusS({ 'message': msgString, 'rentAvailable': rentAvailable, 'isElite': vehicle.isElite, 'tankType': '{}_elite'.format(vehicle.type) if vehicle.isElite else vehicle.type, 'vehicleLevel': '{}'.format(int2roman(vehicle.level)), 'vehicleName': '{}'.format(vehicle.shortUserName), 'roleId': vehicle.role, 'roleMessage': self.__getRoleMessage(), 'vehicleCD': vehicle.intCD })
def _update(self): if g_currentVehicle.isPresent(): vehicle = g_currentVehicle.item statusId, msg, msgLvl = g_currentVehicle.getHangarMessage() rentAvailable = False if statusId == Vehicle.VEHICLE_STATE.RENTAL_IS_ORVER: canBuyOrRent, _ = vehicle.mayObtainForMoney( g_itemsCache.items.stats.money) rentAvailable = vehicle.isRentable and canBuyOrRent isBackground = statusId == Vehicle.VEHICLE_STATE.NOT_PRESENT msgString = makeHtmlString('html_templates:vehicleStatus', msgLvl, {'message': i18n.makeString(msg)}) self.__updateDevices(vehicle) self.as_updateVehicleStatusS({ 'message': msgString, 'rentAvailable': rentAvailable, 'isBackground': isBackground })
def __updateState(self): isVehicleDisabled = False if self.prbDispatcher is not None: permission = self.prbDispatcher.getGUIPermissions() if permission is not None: isVehicleDisabled = not permission.canChangeVehicle() isInHangar = g_currentVehicle.isInHangar() and not g_currentVehicle.item.isInUnit msg, msgLvl = g_currentVehicle.getHangarMessage() isPresent = g_currentVehicle.isPresent() self.as_readyToFightS( g_currentVehicle.isReadyToFight(), msg, msgLvl, isPresent, isVehicleDisabled, g_currentVehicle.isCrewFull(), isInHangar, g_currentVehicle.isBroken() if isPresent else False, g_currentVehicle.isDisabledInRoaming(), ) return
def onVehicleChange(self): self.uiHolder.call('logitech.setMonoText', [ g_currentVehicle.item.userName + '\r\n' + i18n.makeString(g_currentVehicle.getHangarMessage()[1]) ])
def _update(self, modulesData = None, shellsData = None): if g_currentVehicle.isPresent(): self.as_setModulesEnabledS(True) self.__updateAmmo(shellsData) money = g_itemsCache.items.stats.money exchangeRate = g_itemsCache.items.shop.exchangeRate vehicle = g_currentVehicle.item self.as_setVehicleHasTurretS(vehicle.hasTurrets) devices = [] for slotType in AmmunitionPanel.__FITTING_SLOTS: data = g_itemsCache.items.getItems(GUI_ITEM_TYPE_INDICES[slotType], REQ_CRITERIA.VEHICLE.SUITABLE([vehicle], [GUI_ITEM_TYPE_INDICES[slotType]])).values() data.sort(reverse=True) if slotType in AmmunitionPanel.__ARTEFACTS_SLOTS: dataProvider = [[], [], []] else: dataProvider = [] for module in data: price = module.buyPrice defaultPrice = module.defaultPrice thisTypeHBItem = None target = module.TARGETS.OTHER if modulesData is not None: thisTypeHBItem = modulesData.get(module.itemTypeID) if thisTypeHBItem and thisTypeHBItem.intCD == module.intCD: target = module.TARGETS.CURRENT action = None if price != defaultPrice: action = getItemActionTooltipData(module) moduleData = {'id': module.intCD, 'type': slotType, 'name': module.userName, 'desc': module.getShortInfo(), 'target': target if thisTypeHBItem is not None else module.getTarget(vehicle), 'price': price, 'currency': 'credits' if price[1] == 0 else 'gold', 'actionPriceData': action, 'moduleLabel': module.getGUIEmblemID()} if slotType == ITEM_TYPE_NAMES[4]: if module.isClipGun(vehicle.descriptor): moduleData[EXTRA_MODULE_INFO] = CLIP_ICON_PATH isFit, reason = True, '' if not module.isInInventory: isFit, reason = module.mayPurchase(money) if not isFit and reason == 'credit_error': isFit = module.mayPurchaseWithExchange(money, exchangeRate) if slotType in AmmunitionPanel.__ARTEFACTS_SLOTS: moduleData['removable'] = module.isRemovable for i in xrange(3): md = moduleData.copy() if isFit: reason = self._getInstallReason(module, vehicle, reason, i) isCurrent = module.isInstalled(vehicle, i) if md.get('target') == 1: md['status'] = MENU.MODULEFITS_WRONG_SLOT if not isCurrent else self.__getStatus(reason) md['isSelected'] = isCurrent md['disabled'] = not isFit or not isCurrent or reason == 'unlock_error' else: md['status'] = self.__getStatus(reason) md['isSelected'] = False md['disabled'] = not isFit or reason == 'unlock_error' md['slotIndex'] = i dataProvider[i].append(md) else: if isFit: reason = self._getInstallReason(module, vehicle, reason) moduleData['icon'] = module.level moduleData['removable'] = True moduleData['isSelected'] = moduleData.get('target') == 1 moduleData['status'] = self.__getStatus(reason) moduleData['disabled'] = not isFit or reason == 'unlock_error' dataProvider.append(moduleData) if slotType in AmmunitionPanel.__ARTEFACTS_SLOTS: for i in xrange(3): self.__addDevice(devices, dataProvider[i], slotType, i) else: self.__addDevice(devices, dataProvider, slotType) self.as_setDataS(devices) statusId, msg, msgLvl = g_currentVehicle.getHangarMessage() rentAvailable = False if statusId == Vehicle.VEHICLE_STATE.RENTAL_IS_ORVER: canBuyOrRent, _ = vehicle.mayRentOrBuy(g_itemsCache.items.stats.money) rentAvailable = vehicle.isRentable and canBuyOrRent isBackground = False if statusId == Vehicle.VEHICLE_STATE.NOT_PRESENT: isBackground = True isSuitableVeh = not (self.__falloutCtrl.isSelected() and not g_currentVehicle.item.isFalloutAvailable) and g_currentVehicle.item.getCustomState() != Vehicle.VEHICLE_STATE.UNSUITABLE_TO_QUEUE if not isSuitableVeh: msg = i18n.makeString('#menu:tankCarousel/vehicleStates/%s' % Vehicle.VEHICLE_STATE.NOT_SUITABLE) msgLvl = Vehicle.VEHICLE_STATE_LEVEL.WARNING msgString = makeHtmlString('html_templates:vehicleStatus', msgLvl, {'message': i18n.makeString(msg)}) self.as_updateVehicleStatusS({'message': msgString, 'rentAvailable': rentAvailable, 'isBackground': isBackground}) return
def _update(self, modulesData = None, shellsData = None, historicalBattleID = -1): if g_currentVehicle.isPresent(): self.as_setHistoricalBattleS(historicalBattleID) self.as_setModulesEnabledS(historicalBattleID == -1) self.__updateAmmo(shellsData, historicalBattleID) vehicle = g_currentVehicle.item self.as_setVehicleHasTurretS(vehicle.hasTurrets) for type in AmmunitionPanel.__FITTING_SLOTS: data = g_itemsCache.items.getItems(GUI_ITEM_TYPE_INDICES[type], REQ_CRITERIA.VEHICLE.SUITABLE([vehicle], [GUI_ITEM_TYPE_INDICES[type]])).values() data.sort(reverse=True) if type in AmmunitionPanel.__ARTEFACTS_SLOTS: dataProvider = [[], [], []] else: dataProvider = [] for module in data: price = module.buyPrice defaultPrice = module.defaultPrice thisTypeHBItem = None target = module.TARGETS.OTHER if modulesData is not None: thisTypeHBItem = modulesData.get(module.itemTypeID) if thisTypeHBItem and thisTypeHBItem.intCD == module.intCD: target = module.TARGETS.CURRENT action = None if price != defaultPrice: action = getItemActionTooltipData(module) moduleData = {'id': str(module.intCD), 'type': type, 'name': module.userName, 'desc': module.getShortInfo(), 'target': target if thisTypeHBItem is not None else module.getTarget(vehicle), 'price': price, 'currency': 'credits' if price[1] == 0 else 'gold', 'icon': module.icon if type in AmmunitionPanel.__ARTEFACTS_SLOTS else module.level, 'actionPriceData': action} if type == ITEM_TYPE_NAMES[4]: if module.isClipGun(vehicle.descriptor): moduleData[EXTRA_MODULE_INFO] = CLIP_ICON_PATH isFit, reason = True, '' if not module.isInInventory: isFit, reason = module.mayPurchase(g_itemsCache.items.stats.money) if type in AmmunitionPanel.__ARTEFACTS_SLOTS: moduleData['removable'] = module.isRemovable for i in xrange(3): md = moduleData.copy() if isFit: _, reason = module.mayInstall(vehicle, i) isCurrent = module.isInstalled(vehicle, i) if md.get('target') == 1: md['status'] = MENU.MODULEFITS_WRONG_SLOT if not isCurrent else self.__getStatus(reason) md['isSelected'] = isCurrent else: md['status'] = self.__getStatus(reason) md['isSelected'] = False md['slotIndex'] = i dataProvider[i].append(md) else: if isFit: isFit, reason = module.mayInstall(vehicle) moduleData['removable'] = True moduleData['isSelected'] = moduleData.get('target') == 1 moduleData['status'] = self.__getStatus(reason) dataProvider.append(moduleData) self.as_setDataS(dataProvider, type) statusId, msg, msgLvl = g_currentVehicle.getHangarMessage() rentAvailable = False if statusId == Vehicle.VEHICLE_STATE.RENTAL_IS_ORVER: canBuyOrRent, _ = vehicle.mayRentOrBuy(g_itemsCache.items.stats.money) rentAvailable = vehicle.isRentable and canBuyOrRent self.as_updateVehicleStatusS(statusId, msg, msgLvl, rentAvailable)
def onVehicleChange(self): self.uiHolder.call('logitech.setMonoText', [g_currentVehicle.item.userName + '\r\n' + i18n.makeString(g_currentVehicle.getHangarMessage()[1])])
def _update(self, modulesData=None, shellsData=None, historicalBattleID=-1): if g_currentVehicle.isPresent(): self.as_setHistoricalBattleS(historicalBattleID) self.as_setModulesEnabledS(historicalBattleID == -1) self.__updateAmmo(shellsData, historicalBattleID) money = g_itemsCache.items.stats.money exchangeRate = g_itemsCache.items.shop.exchangeRate vehicle = g_currentVehicle.item self.as_setVehicleHasTurretS(vehicle.hasTurrets) devices = [] for type in AmmunitionPanel.__FITTING_SLOTS: data = g_itemsCache.items.getItems( GUI_ITEM_TYPE_INDICES[type], REQ_CRITERIA.VEHICLE.SUITABLE( [vehicle], [GUI_ITEM_TYPE_INDICES[type]])).values() data.sort(reverse=True) if type in AmmunitionPanel.__ARTEFACTS_SLOTS: dataProvider = [[], [], []] else: dataProvider = [] for module in data: price = module.buyPrice defaultPrice = module.defaultPrice thisTypeHBItem = None target = module.TARGETS.OTHER if modulesData is not None: thisTypeHBItem = modulesData.get(module.itemTypeID) if thisTypeHBItem and thisTypeHBItem.intCD == module.intCD: target = module.TARGETS.CURRENT action = None if price != defaultPrice: action = getItemActionTooltipData(module) moduleData = { 'id': module.intCD, 'type': type, 'name': module.userName, 'desc': module.getShortInfo(), 'target': target if thisTypeHBItem is not None else module.getTarget(vehicle), 'price': price, 'currency': 'credits' if price[1] == 0 else 'gold', 'actionPriceData': action, 'moduleLabel': module.getGUIEmblemID() } if type == ITEM_TYPE_NAMES[4]: if module.isClipGun(vehicle.descriptor): moduleData[EXTRA_MODULE_INFO] = CLIP_ICON_PATH isFit, reason = True, '' if not module.isInInventory: isFit, reason = module.mayPurchase(money) if not isFit and reason == 'credit_error': isFit = module.mayPurchaseWithExchange( money, exchangeRate) if type in AmmunitionPanel.__ARTEFACTS_SLOTS: moduleData['removable'] = module.isRemovable for i in xrange(3): md = moduleData.copy() if isFit: reason = self._getInstallReason( module, vehicle, reason, i) isCurrent = module.isInstalled(vehicle, i) if md.get('target') == 1: md['status'] = MENU.MODULEFITS_WRONG_SLOT if not isCurrent else self.__getStatus( reason) md['isSelected'] = isCurrent md['disabled'] = not isFit or not isCurrent or reason == 'unlock_error' else: md['status'] = self.__getStatus(reason) md['isSelected'] = False md['disabled'] = not isFit or reason == 'unlock_error' md['slotIndex'] = i dataProvider[i].append(md) else: if isFit: reason = self._getInstallReason( module, vehicle, reason) moduleData['icon'] = module.level moduleData['removable'] = True moduleData['isSelected'] = moduleData.get( 'target') == 1 moduleData['status'] = self.__getStatus(reason) moduleData[ 'disabled'] = not isFit or reason == 'unlock_error' dataProvider.append(moduleData) if type in AmmunitionPanel.__ARTEFACTS_SLOTS: for i in xrange(3): self.__addDevice(devices, dataProvider[i], type, i) else: self.__addDevice(devices, dataProvider, type) self.as_setDataS(devices) statusId, msg, msgLvl = g_currentVehicle.getHangarMessage() rentAvailable = False if statusId == Vehicle.VEHICLE_STATE.RENTAL_IS_ORVER: canBuyOrRent, _ = vehicle.mayRentOrBuy( g_itemsCache.items.stats.money) rentAvailable = vehicle.isRentable and canBuyOrRent self.as_updateVehicleStatusS(i18n.makeString(msg), msgLvl, rentAvailable)
def __updateText(self): self.as_setText(g_currentVehicle.item.userName + '\r\n' + i18n.makeString(g_currentVehicle.getHangarMessage()[1]))
def __updateAmmo(self): Waiting.show('updateAmmo') credits = g_itemsCache.items.stats.credits shopRqs = yield ShopRequester().request() ammo = {'gunName': '', 'maxAmmo': 0, 'reserved1': False, 'reserved2': False, 'defaultAmmoCount': 0, 'reserved3': 0, 'vehicleLocked': True, 'stateMsg': '', 'stateLevel': 'info', 'shells': [], 'stateWarning': 0} if g_currentVehicle.isPresent(): vehicle = g_currentVehicle.item default_ammo_count = 0 default_ammo = dict(((s.intCD, s.defaultCount) for s in vehicle.shells)) stateWarning = vehicle.isBroken or not vehicle.isCrewFull or not vehicle.isAmmoFull or not g_currentVehicle.isAutoLoadFull() or not g_currentVehicle.isAutoEquipFull() for compactDescr, count in default_ammo.iteritems(): default_ammo_count += count msg, msgLvl = g_currentVehicle.getHangarMessage() ammo.update({'gunName': vehicle.gun.longUserName, 'maxAmmo': vehicle.ammoMaxSize, 'reserved1': not g_currentVehicle.isLocked(), 'reserved2': not g_currentVehicle.isBroken(), 'defaultAmmoCount': default_ammo_count, 'reserved3': 0, 'vehicleLocked': g_currentVehicle.isLocked(), 'stateMsg': msg, 'stateLevel': msgLvl, 'stateWarning': int(stateWarning)}) iAmmo = yield Requester('shell').getFromInventory() sAmmo = yield Requester('shell').getFromShop() iVehicles = yield Requester('vehicle').getFromInventory() oldStyleVehicle = None for v in iVehicles: if v.inventoryId == vehicle.invID: oldStyleVehicle = v break shells = ammo.get('shells') for shell in oldStyleVehicle.shells: shopShell = sAmmo[sAmmo.index(shell)] if shell in sAmmo else None goldAmmoForCredits = shopRqs.isEnabledBuyingGoldShellsForCredits if shopShell: iCount = iAmmo[iAmmo.index(shell)].count if shell in iAmmo else 0 sPrice = (yield shopShell.getPrice()) if shell is not shopShell else (0, 0) if goldAmmoForCredits: shopShell.priceOrder = (sPrice[0] + sPrice[1] * shopRqs.exchangeRateForShellsAndEqs, sPrice[1]) shells.append({'id': gui_items.compactItem(shopShell), 'type': shell.type, 'label': ITEM_TYPES.shell_kindsabbreviation(shell.type), 'icon': '../maps/icons/ammopanel/ammo/%s' % shell.descriptor['icon'][0], 'count': shell.count, 'defaultCount': shell.default, 'inventoryCount': iCount, 'price': sPrice[0 if not sPrice[1] else 1], 'currentcy': 'credits' if not sPrice[1] else 'gold', 'ammoName': shell.longName, 'tableName': shell.tableName}) self.as_setAmmoS(ammo) Waiting.hide('updateAmmo') return