def __getAvailabilityStr(self): battle = g_eventsCache.getCompanyBattles() if not battle.isValid(): return startTimeLeft = battle.getCreationTimeLeft() finishTimeLeft = battle.getDestroyingTimeLeft() if startTimeLeft is not None and startTimeLeft > 0: if startTimeLeft < time_utils.ONE_DAY: return text_styles.alert( i18n.makeString( MENU.HEADERBUTTONS_BATTLE_AVAILABLESINCESOON, time=text_styles.stats( time_formatters.getTimeDurationStr( startTimeLeft, True)))) else: return text_styles.stats( i18n.makeString(MENU.HEADERBUTTONS_BATTLE_AVAILABLESINCE, datetime=self._getDateTimeString( battle.startTime))) elif finishTimeLeft is not None and finishTimeLeft > 0: if finishTimeLeft < time_utils.ONE_DAY: return text_styles.success( i18n.makeString( MENU.HEADERBUTTONS_BATTLE_AVAILABLEUNTILSOON, time=text_styles.stats( time_formatters.getTimeDurationStr( finishTimeLeft, True)))) else: return text_styles.success( i18n.makeString(MENU.HEADERBUTTONS_BATTLE_AVAILABLEUNTIL, datetime=self._getDateTimeString( battle.finishTime)))
def getCommonBuildTooltipData(self, buildingDescr): hpVal = 0 maxHpValue = 0 defResVal = 0 maxDefResValue = 0 orderTooltipData = None if buildingDescr is not None: hpVal = buildingDescr.hp maxHpValue = buildingDescr.levelRef.hp defResVal = buildingDescr.storage maxDefResValue = buildingDescr.levelRef.storage if buildingDescr.orderInProduction: if self._isProductionInPause(buildingDescr): orderTooltipData = '\n' + i18n.makeString( TOOLTIPS.FORTIFICATION_ORDERPROCESS_INPAUSE) else: order = self.fortCtrl.getFort().getOrder( self.fortCtrl.getFort().getBuildingOrder( buildingDescr.typeID)) orderTime = time_formatters.getTimeDurationStr( order.getProductionLeftTime()) orderTooltipData = i18n.makeString( FORTIFICATIONS.BUILDINGS_BUILDINGTOOLTIP_ORDER, order.productionCount, orderTime) toolTipData = self.getBuildingTooltipBody(hpVal, maxHpValue, defResVal, maxDefResValue) if orderTooltipData is not None: toolTipData += orderTooltipData return toolTipData
def __getTransportingBuildTooltipData(self, building): state = None headerArgs = {} bodyArgs = {} if building is not None: buildingName = building.userName if building.isInCooldown(): state = 'cooldown' timeStr = time_formatters.getTimeDurationStr(building.getEstimatedCooldown()) headerArgs = {'buildingName': buildingName} bodyArgs = {'time': timeStr} elif not building.hasStorageToExport(): state = 'emptyStorage' headerArgs = {'buildingName': buildingName} elif not building.hasSpaceToImport() and self.isOnNextTransportingStep(): state = 'notEmptySpace' headerArgs = {'buildingName': buildingName} elif not building.isReady(): state = 'foundation' else: state = 'foundation' if state == 'foundation': headerArgs = {'buildingName': i18n.makeString(FORTIFICATIONS.BUILDINGS_TROWELLABEL)} if state is not None: header = TOOLTIPS.fortification_transporting(state + '/header') body = TOOLTIPS.fortification_transporting(state + '/body') return [i18n.makeString(header, **headerArgs), i18n.makeString(body, **bodyArgs)] else: return return
def _getEffectTimeStr(self, order): if order.isPermanent: return i18n.makeString(FORTIFICATIONS.ORDERS_ORDERPOPOVER_INDEFENSIVE) elif order.isConsumable: return i18n.makeString('#fortifications:Orders/orderPopover/battleConsumable') else: return time_formatters.getTimeDurationStr(order.effectTime)
def _prepareAndSetData(self): orderID = self.getOrderIDbyUID(self._orderID) order = self.fortCtrl.getFort().getOrder(orderID) building = self.fortCtrl.getFort().getBuilding(order.buildingID) canActivateOrder, _ = self.fortCtrl.getLimits().canActivateOrder(orderID) isBtnDisabled = not canActivateOrder or self._isProductionInPause(building) showAlertIcon, alertIconTooltip = self._showOrderAlertIcon(order) data = { "title": self._getTitle(), "levelStr": self._getLevelStr(order.level), "description": self._getOrderDescription(order), "effectTimeStr": self._getEffectTimeStr(order), "leftTimeStr": "" if order.isConsumable else self._getFormattedLeftTime(order), "productionTime": time_formatters.getTimeDurationStr(order.productionTotalTime), "buildingStr": self._getBuildingStr(order), "productionCost": fort_formatters.getDefRes(order.productionCost, True), "producedAmount": self._getCountStr(order), "icon": order.bigIcon, "canUseOrder": False if order.isConsumable else self._canGiveOrder(), "canCreateOrder": self._canCreateOrder(order), "inCooldown": False if order.isConsumable else order.inCooldown, "effectTime": order.effectTime, "leftTime": order.getUsageLeftTime(), "useBtnTooltip": self._getUseBtnTooltip(order, building, isBtnDisabled), "hasBuilding": order.hasBuilding, "isPermanent": order.isPermanent, "questID": self._getQuestID(order), "showLinkBtn": self._showLinkBtn(order), "showAlertIcon": showAlertIcon, "alertIconTooltip": alertIconTooltip, "showDetailsBtn": order.isConsumable, } self.as_setInitDataS(data) self.as_disableOrderS(isBtnDisabled)
def _prepareAndSetData(self): orderID = self.getOrderIDbyUID(self._orderID) order = self.fortCtrl.getFort().getOrder(orderID) building = self.fortCtrl.getFort().getBuilding(order.buildingID) canActivateOrder, _ = self.fortCtrl.getLimits().canActivateOrder(orderID) isBtnDisabled = not canActivateOrder or self._isProductionInPause(building) showAlertIcon, alertIconTooltip = self._showOrderAlertIcon(order) data = {'title': self._getTitle(), 'levelStr': self._getLevelStr(order.level), 'description': self._getOrderDescription(order), 'effectTimeStr': self._getEffectTimeStr(order), 'leftTimeStr': '' if order.isConsumable else self._getFormattedLeftTime(order), 'productionTime': time_formatters.getTimeDurationStr(order.productionTotalTime), 'buildingStr': self._getBuildingStr(order), 'productionCost': fort_formatters.getDefRes(order.productionCost, True), 'producedAmount': self._getCountStr(order), 'icon': order.bigIcon, 'canUseOrder': False if order.isConsumable else self._canGiveOrder(), 'canCreateOrder': self._canCreateOrder(order), 'inCooldown': False if order.isConsumable else order.inCooldown, 'effectTime': order.effectTime, 'leftTime': order.getUsageLeftTime(), 'useBtnTooltip': self._getUseBtnTooltip(order, building, isBtnDisabled), 'hasBuilding': order.hasBuilding, 'isPermanent': order.isPermanent, 'questID': self._getQuestID(order), 'showLinkBtn': self._showLinkBtn(order), 'showAlertIcon': showAlertIcon, 'alertIconTooltip': alertIconTooltip, 'showDetailsBtn': order.isConsumable} self.as_setInitDataS(data) self.as_disableOrderS(isBtnDisabled)
def _getCooldownInfo(self, order): if not order.isPermanent: leftTime = order.getUsageLeftTime() leftTimeStr = time_formatters.getTimeDurationStr(leftTime) return i18n.makeString(TOOLTIPS.FORTIFICATION_ORDERPOPOVER_PROGRESSBAR_TIMELEFT, timeLeft=leftTimeStr) else: return i18n.makeString(TOOLTIPS.FORTIFICATION_ORDERPOPOVER_INDEFENSIVE)
def _getFormattedLeftTime(self, order): if order.inCooldown: if not order.isPermanent: secondsLeft = order.getUsageLeftTime() return time_formatters.getTimeDurationStr(secondsLeft) else: nextBattle = i18n.makeString(FORTIFICATIONS.ORDERS_ORDERPOPOVER_NEXTBATTLE) return text_styles.success(nextBattle) return ''
def getLeftTimeTooltip(self): order = self.fortCtrl.getFort().getOrder(self.getOrderIDbyUID(self._orderID)) if order.inCooldown: if order.isPermanent: return i18n.makeString(TOOLTIPS.FORTIFICATION_ORDERPOPOVER_PERMANENTORDER_INFO) else: leftTimeStr = time_formatters.getTimeDurationStr(order.getUsageLeftTime()) return i18n.makeString(TOOLTIPS.FORTIFICATION_ORDERPOPOVER_PROGRESSBAR_TIMELEFT, timeLeft=leftTimeStr) return ''
def _getProgressInfo(self, description, order): createdTime = order.getProductionLeftTime() createdTimeStr = time_formatters.getTimeDurationStr(createdTime) productionCountStr = '' if order.productionCount > 1: productionCountStr = ' (x%d)' % order.productionCount text = i18n.makeString(TOOLTIPS.FORTIFICATION_ORDERPOPOVER_INPROGRESS_TEXT, count=productionCountStr) text += '\n' + i18n.makeString(TOOLTIPS.FORTIFICATION_ORDERPOPOVER_INPROGRESS_TIMELEFT, timeLeft=createdTimeStr) if len(description) > 0: description += '\n' + text else: description = text return description
def __getAvailabilityStr(self): battle = g_eventsCache.getCompanyBattles() if not battle.isValid(): return else: startTimeLeft = battle.getCreationTimeLeft() finishTimeLeft = battle.getDestroyingTimeLeft() if startTimeLeft is not None and startTimeLeft > 0: if startTimeLeft < time_utils.ONE_DAY: return text_styles.alert( i18n.makeString( MENU.HEADERBUTTONS_BATTLE_AVAILABLESINCESOON, time=text_styles.stats(time_formatters.getTimeDurationStr(startTimeLeft, True)), ) ) else: return text_styles.stats( i18n.makeString( MENU.HEADERBUTTONS_BATTLE_AVAILABLESINCE, datetime=self._getDateTimeString(battle.startTime) ) ) elif finishTimeLeft is not None and finishTimeLeft > 0: if finishTimeLeft < time_utils.ONE_DAY: return text_styles.success( i18n.makeString( MENU.HEADERBUTTONS_BATTLE_AVAILABLEUNTILSOON, time=text_styles.stats(time_formatters.getTimeDurationStr(finishTimeLeft, True)), ) ) else: return text_styles.success( i18n.makeString( MENU.HEADERBUTTONS_BATTLE_AVAILABLEUNTIL, datetime=self._getDateTimeString(battle.finishTime), ) ) return
def _update(self): prefix = i18n.makeString(FORTIFICATIONS.FORTTRANSPORTCONFIRMATIONWINDOW_MAXTRANSPORTINGSIZELABEL) stdText = text_styles.standard(prefix) defResText = fort_formatters.getDefRes(self.getTransportingSize(), True) self.as_setMaxTransportingSizeS(stdText + defResText) clockIcon = icons.clock() time = time_formatters.getTimeDurationStr(self.fortCtrl.getFort().getTransportationLevel().cooldownTime) ctx = {'estimatedTime': time} estimatedTextString = i18n.makeString(FORTIFICATIONS.FORTTRANSPORTCONFIRMATIONWINDOW_TRANSPORTINGFOOTERTEXT, **ctx) estimatedText = text_styles.standard(estimatedTextString) self.as_setFooterTextS(clockIcon + estimatedText) data = self.__buildData() self.as_setDataS(data) isFirstTransporting = self._isTutorial() self.as_enableForFirstTransportingS(isFirstTransporting)
def __prepareData(self): self.__isTutorial = not self.fortCtrl.getFort().isStartingScriptDone() self._buildingID = self.getBuildingIDbyUID(self._buildingUID) self.__congratMessage = False limits = self.fortCtrl.getLimits() canUpgrade, _ = limits.canUpgrade(self._buildingID) self.__canUpgrade = canUpgrade and self._isAvailableBlinking() if self._buildingID not in self.fortCtrl.getUpgradeVisitedBuildings( ) and self.__canUpgrade and self._isAvailableBlinking(): self.__congratMessage = True self._isBaseBuilding = self._buildingUID == ALIAS.FORT_BASE_BUILDING self.__isViceCommander = g_clanCache.clanRole == CLAN_MEMBER_FLAGS.VICE_LEADER self.__isCommander = self.fortCtrl.getPermissions().canUpgradeBuilding( ) self.__buildingDescr = self.fortCtrl.getFort().getBuilding( self._buildingID) self.__buildingLevel = self.__buildingDescr.level self.__hpVal = self.__buildingDescr.hp self.__hpTotalVal = self.__buildingDescr.levelRef.hp self.__defResVal = self.__buildingDescr.storage self.__maxDefResVal = self.__buildingDescr.levelRef.storage self.__progress = ALIAS.STATE_BUILDING if self.__buildingDescr.level else ALIAS.STATE_FOUNDATION_DEF self.__orderID = self.fortCtrl.getFort().getBuildingOrder( self._buildingID) self.__orderTime = None self.__orderCount = 0 self.__buildingCurrentCapacity = 0 self.__orderLevel = 0 self.__buildingTotalCapacity = 0 if self.__orderID is not None: order = self.fortCtrl.getFort().getOrder(self.__orderID) self.__buildingTotalCapacity = self.__buildingDescr.levelRef.maxOrdersCount self.__buildingCurrentCapacity = order.count self.__orderLevel = order.level if order.inProgress: self.__orderTime = time_formatters.getTimeDurationStr( order.getProductionLeftTime()) self.__orderCount = order.productionCount self.__directionOpened = len( self.fortCtrl.getFort().getOpenedDirections()) self.__assignedPlayerCount = len(self.__buildingDescr.attachedPlayers) self.__maxPlayerCount = self.__buildingDescr.typeRef.attachedPlayersLimit baseBuildingDescr = self.fortCtrl.getFort().getBuilding( FORT_BUILDING_TYPE.MILITARY_BASE) self.__baseLevel = baseBuildingDescr.level return
def _update(self): prefix = i18n.makeString( FORTIFICATIONS. FORTTRANSPORTCONFIRMATIONWINDOW_MAXTRANSPORTINGSIZELABEL) stdText = text_styles.standard(prefix) defResText = fort_formatters.getDefRes(self.getTransportingSize(), True) self.as_setMaxTransportingSizeS(stdText + defResText) clockIcon = icons.clock() time = time_formatters.getTimeDurationStr( self.fortCtrl.getFort().getTransportationLevel().cooldownTime) ctx = {'estimatedTime': time} estimatedTextString = i18n.makeString( FORTIFICATIONS. FORTTRANSPORTCONFIRMATIONWINDOW_TRANSPORTINGFOOTERTEXT, **ctx) estimatedText = text_styles.standard(estimatedTextString) self.as_setFooterTextS(clockIcon + estimatedText) data = self.__buildData() self.as_setDataS(data) isFirstTransporting = self._isTutorial() self.as_enableForFirstTransportingS(isFirstTransporting)
def getCommonBuildTooltipData(self, buildingDescr): hpVal = 0 maxHpValue = 0 defResVal = 0 maxDefResValue = 0 orderTooltipData = None if buildingDescr is not None: hpVal = buildingDescr.hp maxHpValue = buildingDescr.levelRef.hp defResVal = buildingDescr.storage maxDefResValue = buildingDescr.levelRef.storage if buildingDescr.orderInProduction: if self._isProductionInPause(buildingDescr): orderTooltipData = '\n' + i18n.makeString(TOOLTIPS.FORTIFICATION_ORDERPROCESS_INPAUSE) else: order = self.fortCtrl.getFort().getOrder(self.fortCtrl.getFort().getBuildingOrder(buildingDescr.typeID)) orderTime = time_formatters.getTimeDurationStr(order.getProductionLeftTime()) orderTooltipData = i18n.makeString(FORTIFICATIONS.BUILDINGS_BUILDINGTOOLTIP_ORDER, order.productionCount, orderTime) toolTipData = self.getBuildingTooltipBody(hpVal, maxHpValue, defResVal, maxDefResValue) if orderTooltipData is not None: toolTipData += orderTooltipData return toolTipData
def __prepareData(self): self.__isTutorial = not self.fortCtrl.getFort().isStartingScriptDone() self._buildingID = self.getBuildingIDbyUID(self._buildingUID) self.__congratMessage = False limits = self.fortCtrl.getLimits() canUpgrade, _ = limits.canUpgrade(self._buildingID) self.__canUpgrade = canUpgrade and self._isAvailableBlinking() if self._buildingID not in self.fortCtrl.getUpgradeVisitedBuildings() and self.__canUpgrade and self._isAvailableBlinking(): self.__congratMessage = True self._isBaseBuilding = self._buildingUID == ALIAS.FORT_BASE_BUILDING self.__isViceCommander = g_clanCache.clanRole == CLAN_MEMBER_FLAGS.VICE_LEADER self.__isCommander = self.fortCtrl.getPermissions().canUpgradeBuilding() self.__buildingDescr = self.fortCtrl.getFort().getBuilding(self._buildingID) self.__buildingLevel = self.__buildingDescr.level self.__hpVal = self.__buildingDescr.hp self.__hpTotalVal = self.__buildingDescr.levelRef.hp self.__defResVal = self.__buildingDescr.storage self.__maxDefResVal = self.__buildingDescr.levelRef.storage self.__progress = ALIAS.STATE_BUILDING if self.__buildingDescr.level else ALIAS.STATE_FOUNDATION_DEF self.__orderID = self.fortCtrl.getFort().getBuildingOrder(self._buildingID) self.__orderTime = None self.__orderCount = 0 self.__buildingCurrentCapacity = 0 self.__orderLevel = 0 self.__buildingTotalCapacity = 0 if self.__orderID is not None: order = self.fortCtrl.getFort().getOrder(self.__orderID) self.__buildingTotalCapacity = self.__buildingDescr.levelRef.maxOrdersCount self.__buildingCurrentCapacity = order.count self.__orderLevel = order.level if order.inProgress: self.__orderTime = time_formatters.getTimeDurationStr(order.getProductionLeftTime()) self.__orderCount = order.productionCount self.__directionOpened = len(self.fortCtrl.getFort().getOpenedDirections()) self.__assignedPlayerCount = len(self.__buildingDescr.attachedPlayers) self.__maxPlayerCount = self.__buildingDescr.typeRef.attachedPlayersLimit baseBuildingDescr = self.fortCtrl.getFort().getBuilding(FORT_BUILDING_TYPE.MILITARY_BASE) self.__baseLevel = baseBuildingDescr.level return
def getProductionLeftTimeStr(self): return time_formatters.getTimeDurationStr(self.getProductionLeftTime())
def getEstimatedCooldownStr(self): return time_formatters.getTimeDurationStr(self.getEstimatedCooldown())