def drawContents(self): self.deleteAllWidgets() # Create a new screen, called FinanceAdvisor, using the file FinanceAdvisor.py for input screen = self.getScreen() player = gc.getPlayer(self.iActiveLeader) numCities = player.getNumCities() totalUnitCost = player.calculateUnitCost() totalUnitSupply = player.calculateUnitSupply() totalMaintenance = player.getTotalMaintenance() totalCivicUpkeep = player.getCivicUpkeep([], False) totalPreInflatedCosts = player.calculatePreInflatedCosts() totalInflatedCosts = player.calculateInflatedCosts() goldCommerce = player.getCommerceRate(CommerceTypes.COMMERCE_GOLD) if not player.isCommerceFlexible(CommerceTypes.COMMERCE_RESEARCH): goldCommerce += player.calculateBaseNetResearch() gold = player.getGold() goldFromCivs = player.getGoldPerTurn() goldPerTurn = player.calculateGoldRate() szTreasuryPanel = self.getNextWidgetName() screen.addPanel( szTreasuryPanel, u"", "", True, True, self.X_SLIDERS, self.Y_TREASURY, self.X_EXPENSES + self.PANE_WIDTH - self.X_SLIDERS, self.H_TREASURY, PanelStyles.PANEL_STYLE_MAIN, ) szText = localText.getText("TXT_KEY_FINANCIAL_ADVISOR_TREASURY", (gold,)).upper() if gold < 0: if goldPerTurn != 0: if gold + goldPerTurn >= 0: szText += BugUtil.getText("TXT_KEY_MISC_POS_GOLD_PER_TURN", goldPerTurn) elif goldPerTurn >= 0: szText += BugUtil.getText("TXT_KEY_MISC_POS_WARNING_GOLD_PER_TURN", goldPerTurn) else: szText += BugUtil.getText("TXT_KEY_MISC_NEG_GOLD_PER_TURN", goldPerTurn) else: if goldPerTurn != 0: if goldPerTurn >= 0: szText += BugUtil.getText("TXT_KEY_MISC_POS_GOLD_PER_TURN", goldPerTurn) elif gold + goldPerTurn >= 0: szText += BugUtil.getText("TXT_KEY_MISC_NEG_WARNING_GOLD_PER_TURN", goldPerTurn) else: szText += BugUtil.getText("TXT_KEY_MISC_NEG_GOLD_PER_TURN", goldPerTurn) screen.setLabel( self.getNextWidgetName(), szTreasuryPanel, u"<font=4>" + szText + u"</font>", CvUtil.FONT_CENTER_JUSTIFY, (self.X_SLIDERS + self.PANE_WIDTH + self.X_EXPENSES) / 2, self.Y_TREASURY + self.H_TREASURY / 2 - self.Y_SPACING / 2, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_HELP_FINANCE_GOLD_RESERVE, -1, -1, ) szCommercePanel = self.getNextWidgetName() screen.addPanel( szCommercePanel, u"", "", True, True, self.X_SLIDERS, self.Y_LOCATION, self.PANE_WIDTH, self.PANE_HEIGHT, PanelStyles.PANEL_STYLE_MAIN, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_COMMERCE", ()).upper() + u"</font>", CvUtil.FONT_CENTER_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH / 2, self.Y_LOCATION + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) szIncomePanel = self.getNextWidgetName() screen.addPanel( szIncomePanel, u"", "", True, True, self.X_INCOME, self.Y_LOCATION, self.PANE_WIDTH, self.PANE_HEIGHT, PanelStyles.PANEL_STYLE_MAIN, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_INCOME_HEADER", ()).upper() + u"</font>", CvUtil.FONT_CENTER_JUSTIFY, self.X_INCOME + self.PANE_WIDTH / 2, self.Y_LOCATION + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) szExpensePanel = self.getNextWidgetName() screen.addPanel( szExpensePanel, u"", "", True, True, self.X_EXPENSES, self.Y_LOCATION, self.PANE_WIDTH, self.PANE_HEIGHT, PanelStyles.PANEL_STYLE_MAIN, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_EXPENSES_HEADER", ()).upper() + u"</font>", CvUtil.FONT_CENTER_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH / 2, self.Y_LOCATION + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) # Commerce yLocation = self.Y_LOCATION iCommerce = 0 # sum all worked tiles' commerce yields for player # move to MapUtil? iWorkedTileCount = 0 iWorkedTiles = 0 for city in PlayerUtil.playerCities(player): if not city.isDisorder(): for i in range(gc.getNUM_CITY_PLOTS()): plot = city.getCityIndexPlot(i) if plot and not plot.isNone() and plot.hasYield(): if city.isWorkingPlot(plot): iWorkedTileCount += 1 iWorkedTiles += plot.getYield(YieldTypes.YIELD_COMMERCE) yLocation += 1.5 * self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_WORKED_TILES", (iWorkedTileCount,)) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iWorkedTiles) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) iCommerce += iWorkedTiles # trade iDomesticTrade, _, iForeignTrade, _ = TradeUtil.calculateTradeRoutes(player) if iDomesticTrade > 0: if TradeUtil.isFractionalTrade(): iDomesticTrade //= 100 yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_DOMESTIC_TRADE", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, *BugDll.widget("WIDGET_HELP_FINANCE_DOMESTIC_TRADE", self.iActiveLeader, 1) ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iDomesticTrade) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, *BugDll.widget("WIDGET_HELP_FINANCE_DOMESTIC_TRADE", self.iActiveLeader, 1) ) iCommerce += iDomesticTrade if iForeignTrade > 0: if TradeUtil.isFractionalTrade(): iForeignTrade //= 100 yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_FOREIGN_TRADE", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, *BugDll.widget("WIDGET_HELP_FINANCE_FOREIGN_TRADE", self.iActiveLeader, 1) ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iForeignTrade) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, *BugDll.widget("WIDGET_HELP_FINANCE_FOREIGN_TRADE", self.iActiveLeader, 1) ) iCommerce += iForeignTrade # corporations iCorporations = 0 for city in PlayerUtil.playerCities(player): if not city.isDisorder(): iCorporations += city.getCorporationYield(YieldTypes.YIELD_COMMERCE) if iCorporations > 0: yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_CORPORATIONS", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iCorporations) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) iCommerce += iCorporations # specialists iSpecialists = 0 for city in PlayerUtil.playerCities(player): if not city.isDisorder(): for eSpec in range(gc.getNumSpecialistInfos()): iSpecialists += player.specialistYield(eSpec, YieldTypes.YIELD_COMMERCE) * ( city.getSpecialistCount(eSpec) + city.getFreeSpecialistCount(eSpec) ) if iSpecialists > 0: yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_SPECIALISTS", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iSpecialists) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) iCommerce += iSpecialists # buildings iTotalCommerce = player.calculateTotalYield(YieldTypes.YIELD_COMMERCE) # buildings includes 50% capital bonus for Bureaucracy civic iBuildings = iTotalCommerce - iCommerce if iBuildings > 0: yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_BUILDINGS", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iBuildings) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) iCommerce += iBuildings yLocation += 1.5 * self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_BUG_FINANCIAL_ADVISOR_COMMERCE", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iCommerce) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) # Slider percentages yLocation += 0.5 * self.Y_SPACING for iI in range(CommerceTypes.NUM_COMMERCE_TYPES): eCommerce = (iI + 1) % CommerceTypes.NUM_COMMERCE_TYPES if player.isCommerceFlexible(eCommerce): yLocation += self.Y_SPACING screen.setButtonGFC( self.getNextWidgetName(), u"", "", self.X_SLIDERS + self.TEXT_MARGIN, int(yLocation) + self.TEXT_MARGIN, 20, 20, WidgetTypes.WIDGET_CHANGE_PERCENT, eCommerce, gc.getDefineINT("COMMERCE_PERCENT_CHANGE_INCREMENTS"), ButtonStyles.BUTTON_STYLE_CITY_PLUS, ) screen.setButtonGFC( self.getNextWidgetName(), u"", "", self.X_SLIDERS + self.TEXT_MARGIN + 24, int(yLocation) + self.TEXT_MARGIN, 20, 20, WidgetTypes.WIDGET_CHANGE_PERCENT, eCommerce, -gc.getDefineINT("COMMERCE_PERCENT_CHANGE_INCREMENTS"), ButtonStyles.BUTTON_STYLE_CITY_MINUS, ) szText = ( u"<font=3>" + gc.getCommerceInfo(eCommerce).getDescription() + u" (" + unicode(player.getCommercePercent(eCommerce)) + u"%)</font>" ) screen.setLabel( self.getNextWidgetName(), "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN + 50, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) szRate = u"<font=3>" + unicode(player.getCommerceRate(CommerceTypes(eCommerce))) + u"</font>" screen.setLabel( self.getNextWidgetName(), "Background", szRate, CvUtil.FONT_RIGHT_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) yLocation += self.Y_SPACING szText = ( u"<font=3>" + gc.getCommerceInfo(CommerceTypes.COMMERCE_GOLD).getDescription() + u" (" + unicode(player.getCommercePercent(CommerceTypes.COMMERCE_GOLD)) + u"%)</font>" ) screen.setLabel( self.getNextWidgetName(), "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN + 50, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) szCommerce = u"<font=3>" + unicode(goldCommerce) + u"</font>" screen.setLabel( self.getNextWidgetName(), "Background", szCommerce, CvUtil.FONT_RIGHT_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) # Income yLocation = self.Y_LOCATION iTaxRate = player.getCommercePercent(CommerceTypes.COMMERCE_GOLD) multipliers = [] for eBldg in range(gc.getNumBuildingInfos()): info = gc.getBuildingInfo(eBldg) iMultiplier = info.getCommerceModifier(CommerceTypes.COMMERCE_GOLD) if iMultiplier > 0: multipliers.append([eBldg, iMultiplier, 0, 0.0]) iBuildingCount = 0 iHeadquartersCount = 0 iShrinesCount = 0 fTaxes = 0.0 fBuildings = 0.0 fHeadquarters = 0.0 fShrines = 0.0 fCorporations = 0.0 fSpecialists = 0.0 iWealthCount = 0 fWealth = 0.0 eWealth = gc.getInfoTypeForString("PROCESS_WEALTH") # ignores # CyCity.getReligionCommerce() -- excludes shrines # CyPlayer.getFreeCityCommerce() # CyPlayer.getSpecialistExtraCommerce() * (CyCity.getSpecialistPopulation() + CyCity.getNumGreatPeople()) for city in PlayerUtil.playerCities(player): if not city.isDisorder(): fCityTaxes = city.getYieldRate(YieldTypes.YIELD_COMMERCE) * iTaxRate / 100.0 fTaxes += fCityTaxes fCityBuildings = 0.0 fCityHeadquarters = 0.0 fCityShrines = 0.0 for eBldg in range(gc.getNumBuildingInfos()): iCount = city.getNumRealBuilding(eBldg) if iCount > 0: iBuildingGold = city.getBuildingCommerceByBuilding(CommerceTypes.COMMERCE_GOLD, eBldg) if iBuildingGold > 0: info = gc.getBuildingInfo(eBldg) if info.getFoundsCorporation() != -1: fCityHeadquarters += iBuildingGold iHeadquartersCount += 1 elif info.getGlobalReligionCommerce() != -1: fCityShrines += iBuildingGold iShrinesCount += 1 else: fCityBuildings += iBuildingGold iBuildingCount += iCount fBuildings += fCityBuildings fHeadquarters += fCityHeadquarters fShrines += fCityShrines fCityCorporations = city.getCorporationCommerce(CommerceTypes.COMMERCE_GOLD) fCorporations += fCityCorporations fCitySpecialists = city.getSpecialistCommerce(CommerceTypes.COMMERCE_GOLD) fSpecialists += fCitySpecialists fCityWealth = 0.0 if city.isProductionProcess() and city.getProductionProcess() == eWealth: fCityWealth = ( city.getProductionToCommerceModifier(CommerceTypes.COMMERCE_GOLD) * city.getYieldRate(YieldTypes.YIELD_PRODUCTION) / 100.0 ) fWealth += fCityWealth iWealthCount += 1 # buildings don't multiply wealth fCityTotel = fCityTaxes + fCityBuildings + fCityHeadquarters + fCityCorporations + fCitySpecialists for entry in multipliers: eBldg, iMultiplier, _, _ = entry iCount = city.getNumRealBuilding(eBldg) if iCount > 0: entry[2] += iCount entry[3] += iCount * fCityTotel * iMultiplier / 100.0 iTotalMinusTaxes = int(fBuildings) + int(fCorporations) + int(fSpecialists) + int(fWealth) for _, _, _, fGold in multipliers: iTotalMinusTaxes += int(fGold) yLocation += 1.5 * self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_TAXES", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(goldCommerce - iTotalMinusTaxes) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) if fBuildings > 0.0: yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_BUILDINGS", ()) + " (%d)</font>" % iBuildingCount, CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(int(fBuildings)) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) if fHeadquarters > 0.0: yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CORPORATION_HEADQUARTERS", ()) + " (%d)</font>" % iHeadquartersCount, CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(int(fHeadquarters)) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) if fCorporations > 0.0: yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_CORPORATIONS", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(int(fCorporations)) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) if fShrines > 0.0: yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_RELIGIOUS_SHRINES", ()) + " (%d)</font>" % iShrinesCount, CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(int(fShrines)) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) if fSpecialists > 0.0: yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_SPECIALISTS", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, *BugDll.widget("WIDGET_HELP_FINANCE_SPECIALISTS", self.iActiveLeader, 1) ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(int(fSpecialists)) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, *BugDll.widget("WIDGET_HELP_FINANCE_SPECIALISTS", self.iActiveLeader, 1) ) for eBldg, iMultiplier, iCount, fGold in multipliers: if iCount > 0 and fGold > 0.0: fAverage = fGold / iCount szDescription = ( gc.getBuildingInfo(eBldg).getDescription() + u" " + localText.getText( "TXT_KEY_BUG_FINANCIAL_ADVISOR_BUILDING_COUNT_AVERAGE", (iCount, BugUtil.formatFloat(fAverage, 2)), ) ) yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + szDescription + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(int(fGold)) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) if fWealth > 0.0 and iWealthCount > 0: yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_PROCESS_WEALTH", ()) + " (%d)</font>" % iWealthCount, CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(int(fWealth)) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) iIncome = goldCommerce if goldFromCivs > 0: yLocation += self.Y_SPACING szText = unicode(goldFromCivs) + " : " + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_PER_TURN", ()) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_PER_TURN", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_FOREIGN_INCOME, self.iActiveLeader, 1, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(goldFromCivs) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_FOREIGN_INCOME, self.iActiveLeader, 1, ) iIncome += goldFromCivs yLocation += 1.5 * self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_INCOME", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iIncome) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) # Expenses yLocation = self.Y_LOCATION iExpenses = 0 yLocation += 1.5 * self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_UNITCOST", ()) + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_UNIT_COST, self.iActiveLeader, 1, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(totalUnitCost) + u"</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_UNIT_COST, self.iActiveLeader, 1, ) iExpenses += totalUnitCost yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_UNITSUPPLY", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_AWAY_SUPPLY, self.iActiveLeader, 1, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(totalUnitSupply) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_AWAY_SUPPLY, self.iActiveLeader, 1, ) iExpenses += totalUnitSupply yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_MAINTENANCE", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_CITY_MAINT, self.iActiveLeader, 1, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(totalMaintenance) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_CITY_MAINT, self.iActiveLeader, 1, ) iExpenses += totalMaintenance yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_CIVICS", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_CIVIC_UPKEEP, self.iActiveLeader, 1, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(totalCivicUpkeep) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_CIVIC_UPKEEP, self.iActiveLeader, 1, ) iExpenses += totalCivicUpkeep if goldFromCivs < 0: yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_COST_PER_TURN", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_FOREIGN_INCOME, self.iActiveLeader, 1, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(-goldFromCivs) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_FOREIGN_INCOME, self.iActiveLeader, 1, ) iExpenses -= goldFromCivs yLocation += self.Y_SPACING iInflation = totalInflatedCosts - totalPreInflatedCosts screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_INFLATION", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_INFLATED_COSTS, self.iActiveLeader, 1, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iInflation) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_INFLATED_COSTS, self.iActiveLeader, 1, ) iExpenses += iInflation yLocation += 1.5 * self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_EXPENSES", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iExpenses) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1, ) return 0
def __init__(self): Grouping.__init__(self, "level", "TXT_KEY_UNIT_GROUPER_LEVEL_GROUPING") self.MAX_LEVEL = 50 for i in range(self.MAX_LEVEL): self._addGroup(Group(self, i, BugUtil.getText("TXT_KEY_UNIT_GROUPER_LEVEL_GROUP", (str(i),)))) self._addGroup(Group(self, self.MAX_LEVEL, BugUtil.getText("TXT_KEY_UNIT_GROUPER_LEVEL_GROUP", ("%d+" % self.MAX_LEVEL,))))
def launch(argsList=None): """ Opens the mod's help file or web page externally if it can be found or displays an error alert. On Windows this opens the compiled HTML help file (CHM). On Mac this opens a browser window to the online help file. """ if BugPath.isMac(): sLang = ["ENG", "ENG", "DEU", "ITA", "ENG"] url = "http://civ4bug.sourceforge.net/BUGModHelp/%s/index.htm" % sLang[CyGame().getCurrentLanguage()] try: import webbrowser showLaunchMessage() webbrowser.open(url, new=1, autoraise=1) return True except: showErrorAlert(BugUtil.getPlainText("TXT_KEY_BUG_HELP_CANNOT_OPEN_BROWSER_TITLE"), BugUtil.getText("TXT_KEY_BUG_HELP_CANNOT_OPEN_BROWSER_BODY", (url,))) else: sLang = ["ENG", "FRA", "DEU", "ITA", "ESP"] name = "BUG Mod Help-%s.chm" % (sLang[CyGame().getCurrentLanguage()]) file = BugPath.findInfoFile(name) if file: import os message = BugUtil.getPlainText("TXT_KEY_BUG_HELP_OPENING") CyInterface().addImmediateMessage(message, "") os.startfile(file) return True else: showErrorAlert(BugUtil.getPlainText("TXT_KEY_BUG_HELP_MISSING_TITLE"), BugUtil.getText("TXT_KEY_BUG_HELP_MISSING_BODY", (name,))) return False
def getHoverText(eWidgetType, iData1, iData2, bOption): city, iTurns = getDisplayCity() if not city: # no rate or progress in any city and no city selected return BugUtil.getText( "TXT_KEY_MISC_GREAT_PERSON", (0, PlayerUtil.getActivePlayer().greatPeopleThreshold(False))) iThreshold = gc.getPlayer(city.getOwner()).greatPeopleThreshold(False) iProgress = city.getGreatPeopleProgress() iRate = city.getGreatPeopleRate() szText = BugUtil.colorText(city.getName(), "COLOR_HIGHLIGHT_TEXT") szText += u"\n" szText += BugUtil.getText("TXT_KEY_MISC_GREAT_PERSON", (iProgress, iThreshold)) if iRate > 0: szText += u"\n%d%s%s " % (iRate, g_gpIcon, BugUtil.getPlainText("TXT_KEY_PER_TURN")) szText += BugUtil.getText("INTERFACE_CITY_TURNS", (iTurns, )) percents = calcPercentages(city) if percents: percents.sort() percents.reverse() szText += u"\n" for iPercent, iUnit in percents: # iUnit = getUnitType(gpType) szText += u"\n%s%s - %d%%" % (getUnitIcon( iUnit), gc.getUnitInfo(iUnit).getDescription(), iPercent) return szText
def getHoverText(eWidgetType, iData1, iData2, bOption): city, iTurns = getDisplayCity() if (not city): # no rate or progress in any city and no city selected return BugUtil.getText( "TXT_KEY_MISC_GREAT_PERSON", (0, PlayerUtil.getActivePlayer().greatPeopleThreshold(False))) iThreshold = gc.getPlayer(city.getOwner()).greatPeopleThreshold(False) iProgress = city.getGreatPeopleProgress() iRate = city.getGreatPeopleRate() #szText = BugUtil.colorText(city.getName(), "COLOR_HIGHLIGHT_TEXT") # advc.004: Don't color the city (I don't think this matches the overall color scheme of the game) szText = city.getName() szText += u"\n" szText += BugUtil.getText("TXT_KEY_MISC_GREAT_PERSON", (iProgress, iThreshold)) if (iRate > 0): szText += u"\n%d%s%s " % (iRate, g_gpIcon, BugUtil.getPlainText("TXT_KEY_PER_TURN")) szText += BugUtil.getText("INTERFACE_CITY_TURNS", (iTurns, )) percents = calcPercentages(city) if (len(percents) > 0): percents.sort() percents.reverse() #szText += u"\n" advc.004: No empty line between total rate and percentages for iPercent, iUnit in percents: # iUnit = getUnitType(gpType) szText += u"\n%s%s - %d%%" % (getUnitIcon( iUnit), gc.getUnitInfo(iUnit).getDescription(), iPercent) return szText
def launch(argsList=None): """ Opens the mod's help file or web page externally if it can be found or displays an error alert. On Windows this opens the compiled HTML help file (CHM). On Mac this opens a browser window to the online help file. """ if BugPath.isMac(): sLang = ["ENG", "ENG", "DEU", "ITA", "ENG"] url = "http://civ4bug.sourceforge.net/BUGModHelp/%s/index.htm" % sLang[CyGame().getCurrentLanguage()] try: import webbrowser showLaunchMessage() webbrowser.open(url, new=1, autoraise=1) return True except: showErrorAlert(BugUtil.getPlainText("TXT_KEY_BUG_HELP_CANNOT_OPEN_BROWSER_TITLE"), BugUtil.getText("TXT_KEY_BUG_HELP_CANNOT_OPEN_BROWSER_BODY", (url,))) else: sLang = ["ENG", "FRA", "DEU", "ITA", "ESP"] name = "BUG Mod Help-%s.chm" % (sLang[CyGame().getCurrentLanguage()]) file = BugPath.findInfoFile(name) if file: import os message = BugUtil.getPlainText("TXT_KEY_BUG_HELP_OPENING") CyInterface().addImmediateMessage(message, "") os.startfile(file) return True else: showErrorAlert(BugUtil.getPlainText("TXT_KEY_BUG_HELP_MISSING_TITLE"), BugUtil.getText("TXT_KEY_BUG_HELP_MISSING_BODY", (name,))) return False
def __init__(self): Grouping.__init__(self, "level", "TXT_KEY_UNIT_GROUPER_LEVEL_GROUPING") self.MAX_LEVEL = 50 for i in range(self.MAX_LEVEL): self._addGroup(Group(self, i, BugUtil.getText("TXT_KEY_UNIT_GROUPER_LEVEL_GROUP", (str(i),)))) self._addGroup(Group(self, self.MAX_LEVEL, BugUtil.getText("TXT_KEY_UNIT_GROUPER_LEVEL_GROUP", ("%d+" % self.MAX_LEVEL,))))
def onCombatResult(self, argsList): 'Combat Result' pWinner,pLoser = argsList playerX = PyPlayer(pWinner.getOwner()) unitX = PyInfo.UnitInfo(pWinner.getUnitType()) playerY = PyPlayer(pLoser.getOwner()) unitY = PyInfo.UnitInfo(pLoser.getUnitType()) pPlayer = gc.getPlayer(pWinner.getOwner()) pPlayerLoser = gc.getPlayer(pLoser.getOwner()) if (ANewDawnOpt.isWarPrizes()): if not (gc.getPlayer(pWinner.getOwner()).isBarbarian()): if (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_WOODEN_SHIPS")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_STEAM_SHIPS")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_DIESEL_SHIPS")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NUCLEAR_SHIPS")): if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_WOODEN_SHIPS")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_STEAM_SHIPS")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_DIESEL_SHIPS")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NUCLEAR_SHIPS")): if not (unitX.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")): if not (unitY.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")): if CyGame().getSorenRandNum(100, "Bob") <= 15: iUnit = pLoser.getUnitType() newUnit = pPlayer.initUnit(pLoser.getUnitType(), pWinner.getX(), pWinner.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION) newUnit.finishMoves() newUnit.setDamage(50, pWinner.getOwner()) CyInterface().addMessage(pWinner.getOwner(),false,20,BugUtil.getText("TXT_KEY_MISC_WARPRIZES_SUCCESS", gc.getUnitInfo(iUnit).getDescription()),'',0,gc.getUnitInfo(iUnit).getButton(),ColorTypes(gc.getInfoTypeForString("COLOR_GREEN")), pWinner.getX(), pWinner.getY(), True,True) CyInterface().addMessage(pLoser.getOwner(),false,20,BugUtil.getText("TXT_KEY_MISC_WARPRIZES_FAILURE",gc.getUnitInfo(iUnit).getDescription()),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_RED")), pLoser.getX(), pLoser.getY(), True,True) if ((pLoser.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_GALLEY")) or (pLoser.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_FLUYT")) or (pLoser.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_GALLEON")) or (pLoser.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_TRANSPORT"))): Loot = CyGame().getSorenRandNum(100, "Loot") pPlayer.changeGold(Loot) if (pPlayerLoser.getGold() >= Loot): pPlayerLoser.changeGold(-Loot) CyInterface().addMessage(pLoser.getOwner(),false,20,BugUtil.getText("TXT_KEY_MISC_WARPRIZES_FAILURE_GOLD_LOST",gc.getUnitInfo(iUnit).getDescription()),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_RED")), pLoser.getX(), pLoser.getY(), True,True) CyInterface().addMessage(pWinner.getOwner(),false,20,BugUtil.getText("TXT_KEY_MISC_WARPRIZES_SUCCESS_GOLD_GAINED",gc.getUnitInfo(iUnit).getDescription() ),'',0,'Art/Interface/Buttons/process/processwealth.dds',ColorTypes(gc.getInfoTypeForString("COLOR_GREEN")), pWinner.getX(), pWinner.getY(), True,True) ## War Prize Modcomp END##
def StatusDump_Basic(self): BugUtil.debug("StatusDump - basic") # dump basic stuff # - leader name / civ # - current game turn and year # - current tech being researched # - techs available to research # - opponents # - scoreboard # - number of cities # - bank balance # player stuff ePlayer = gc.getGame().getActivePlayer() pPlayer = gc.getPlayer(ePlayer) # human / game name sMsg = BugUtil.getText("TXT_KEY_STATUS_DUMP_PLAYER_NAME", (pPlayer.getCivilizationShortDescription(0))) self._writeMsg(sMsg, vColor="Black", vBold=False, vUnderline=False, vOpenSpoiler="", vCloseSpoiler=False) # leader / civ name sMsg = BugUtil.getText("TXT_KEY_STATUS_DUMP_LEADER_CIV", (gc.getLeaderHeadInfo(pPlayer.getLeaderType()).getDescription(), pPlayer.getCivilizationShortDescription(0))) self._writeMsg(sMsg, vColor="Black", vBold=False, vUnderline=False, vOpenSpoiler="", vCloseSpoiler=False)
def fillTable(self, screen, table, eYield, eTileType): """Fills the given GFC table control with the chosen yield values.""" self.iRow = 0 # Tiles iTotal = self.getYield(eYield, eTileType) self.appendTable(screen, table, False, BugUtil.getText( LABEL_KEYS[eTileType], (self.tileCounts[eTileType],)), eYield, iTotal) # Trade for eType in (DOMESTIC_TRADE, FOREIGN_TRADE): iValue = self.getYield(eYield, eType) if iValue != 0: self.appendTable(screen, table, False, BugUtil.getPlainText( LABEL_KEYS[eType]), eYield, iValue, TradeUtil.isFractionalTrade()) iValue = self.getYield(eYield, DOMESTIC_TRADE) + self.getYield(eYield, FOREIGN_TRADE) if TradeUtil.isFractionalTrade(): iValue //= 100 iTotal += iValue # Buildings, Corporations, Specialists for eType in (BUILDINGS, CORPORATIONS, SPECIALISTS): iValue = self.getYield(eYield, eType) if iValue != 0: iTotal += iValue self.appendTable(screen, table, False, BugUtil.getPlainText(LABEL_KEYS[eType]), eYield, iValue) # Subtotal and Base Modifiers iModifier = self.getYield(eYield, BASE_MODIFIER) if iModifier != 0: # Subtotal self.appendTableTotal(screen, table, eYield, iTotal) #self.appendTable(screen, table, True, BugUtil.getPlainText("TXT_KEY_CONCEPT_SUBTOTAL"), eYield, iTotal) # Modifier iValue = (iTotal * (iModifier + 100) // 100) - iTotal iSubtotal = iTotal + iValue self.appendTable(screen, table, False, BugUtil.getText( "TXT_KEY_CONCEPT_BASE_MODIFIER", (iModifier,)), eYield, iValue) else: iSubtotal = iTotal # Subtotal and Production Modifiers if eYield == YieldTypes.YIELD_PRODUCTION and self.iProductionModifier != 0: # Subtotal self.appendTableTotal(screen, table, eYield, iSubtotal) #self.appendTable(screen, table, True, BugUtil.getPlainText("TXT_KEY_CONCEPT_SUBTOTAL"), eYield, iSubtotal) # Total iTotal = iTotal * (iModifier + self.iProductionModifier + 100) // 100 # Modifier iValue = iTotal - iSubtotal self.appendTable(screen, table, False, BugUtil.getText("TXT_KEY_CONCEPT_PRODUCTION_MODIFIER", (self.sModifierDetail, self.iProductionModifier)), eYield, iValue) else: iTotal = iSubtotal # Total self.appendTableTotal(screen, table, eYield, iTotal)
def getWarningMessage(): """ Returns either a HOF-only or HOF-and-GOTM warning message based on CyGame.getWarningStatus(). """ if not Buffy.isActive(): return BugUtil.getText("TXT_KEY_BUFFY_INVALID_HOF") if CyGame().getWarningStatus() == 1: return BugUtil.getText("TXT_KEY_BUFFY_INVALID_HOF_GOTM") else: return BugUtil.getText("TXT_KEY_BUFFY_INVALID_HOF")
def getWarningMessage(): """ Returns either a HOF-only or HOF-and-GOTM warning message based on CyGame.getWarningStatus(). """ if not Buffy.isActive(): return BugUtil.getText("TXT_KEY_BUFFY_INVALID_HOF") if CyGame().getWarningStatus() == 1: return BugUtil.getText("TXT_KEY_BUFFY_INVALID_HOF_GOTM") else: return BugUtil.getText("TXT_KEY_BUFFY_INVALID_HOF")
def fillTable(self, screen, table, eYield, eTileType): """Fills the given GFC table control with the chosen yield values.""" self.iRow = 0 # Tiles iTotal = self.getYield(eYield, eTileType) self.appendTable(screen, table, False, BugUtil.getText(LABEL_KEYS[eTileType], (self.tileCounts[eTileType],)), eYield, iTotal) # Trade for eType in (DOMESTIC_TRADE, FOREIGN_TRADE): iValue = self.getYield(eYield, eType) if iValue != 0: self.appendTable(screen, table, False, BugUtil.getPlainText(LABEL_KEYS[eType]), eYield, iValue, TradeUtil.isFractionalTrade()) iValue = self.getYield(eYield, DOMESTIC_TRADE) + self.getYield(eYield, FOREIGN_TRADE) if TradeUtil.isFractionalTrade(): iValue //= 100 iTotal += iValue # Buildings, Corporations, Specialists for eType in (BUILDINGS, CORPORATIONS, SPECIALISTS): iValue = self.getYield(eYield, eType) if iValue != 0: iTotal += iValue self.appendTable(screen, table, False, BugUtil.getPlainText(LABEL_KEYS[eType]), eYield, iValue) # Subtotal and Base Modifiers iModifier = self.getYield(eYield, BASE_MODIFIER) if iModifier != 0: # Subtotal self.appendTableTotal(screen, table, eYield, iTotal) #self.appendTable(screen, table, True, BugUtil.getPlainText("TXT_KEY_CONCEPT_SUBTOTAL"), eYield, iTotal) # Modifier iValue = (iTotal * (iModifier + 100) // 100) - iTotal iSubtotal = iTotal + iValue self.appendTable(screen, table, False, BugUtil.getText("TXT_KEY_CONCEPT_BASE_MODIFIER", (iModifier,)), eYield, iValue) else: iSubtotal = iTotal # Subtotal and Production Modifiers if eYield == YieldTypes.YIELD_PRODUCTION and self.iProductionModifier != 0: # Subtotal self.appendTableTotal(screen, table, eYield, iSubtotal) #self.appendTable(screen, table, True, BugUtil.getPlainText("TXT_KEY_CONCEPT_SUBTOTAL"), eYield, iSubtotal) # Total iTotal = iTotal * (iModifier + self.iProductionModifier + 100) // 100 # Modifier iValue = iTotal - iSubtotal self.appendTable(screen, table, False, BugUtil.getText("TXT_KEY_CONCEPT_PRODUCTION_MODIFIER", (self.sModifierDetail, self.iProductionModifier)), eYield, iValue) else: iTotal = iSubtotal # Total self.appendTableTotal(screen, table, eYield, iTotal)
def display(self, eActivePlayer, key, players): for ePlayer in players: player = gc.getPlayer(ePlayer) if player.isAlive(): message = BugUtil.getText( key, player.getCivilizationShortDescription(0)) addMessageNoIcon(eActivePlayer, message)
def display(self, eActivePlayer, key, players): if GAME.getElapsedGameTurns() > 0: for ePlayer in players: player = GC.getPlayer(ePlayer) if player.isAlive(): message = BugUtil.getText(key, player.getName()) addMessage(eActivePlayer, message)
def DumpStatus(self): BugUtil.debug("StatusDump") # open the status dump file self.StatusDump_OpenFile() # Year zyear = self._getGameYear() zsTurn = self._getGameTurn() zCurrDateTime = time.strftime("%d-%b-%Y %H:%M:%S") sMsg = BugUtil.getText("TXT_KEY_STATUS_DUMP_TURN", (zsTurn, zyear, zCurrDateTime)) self._writeMsg(sMsg, vColor="Black", vBold=False, vUnderline=True, vOpenSpoiler=sMsg, vCloseSpoiler=False) # basic leader information self.StatusDump_Basic() # tech, culture, espionage, gold per turn info self.StatusDump_Spinners() # loop over each city self.StatusDump_Player_Cities() # loop over each unit self.StatusDump_Player_Units() # tech, culture, espionage, gold per turn info self.StatusDump_AIs() self._writeMsg(" ", vColor="Black", vBold=False, vUnderline=False, vOpenSpoiler="", vCloseSpoiler=True) self.StatusDump_CloseFile()
def setNewNameByCivics(self, iPlayer): [newCivDesc, newCivShort, newCivAdj] = self.newNameByCivics(iPlayer) if gc.getPlayer( iPlayer).isHuman() or game.getActivePlayer() == iPlayer: if self.bLeaveHumanName: CvUtil.pyPrint(" Name - Leaving name for human player") return newDesc = CvUtil.convertToStr(newCivDesc) newShort = CvUtil.convertToStr(newCivShort) newAdj = CvUtil.convertToStr(newCivAdj) newDesc = CvUtil.remove_diacriticals(newDesc) newShort = CvUtil.remove_diacriticals(newShort) newAdj = CvUtil.remove_diacriticals(newAdj) if not newDesc == gc.getPlayer(iPlayer).getCivilizationDescription(0): szMessage = BugUtil.getText("TXT_KEY_MOD_DCN_NEWCIV_NAME_DESC", newDesc) CyInterface().addMessage( iPlayer, False, gc.getEVENT_MESSAGE_TIME(), szMessage, None, InterfaceMessageTypes.MESSAGE_TYPE_INFO, None, gc.getInfoTypeForString("COLOR_HIGHLIGHT_TEXT"), -1, -1, False, False) gc.getPlayer(iPlayer).setCivName(newDesc, newShort, newAdj) return
def setNewNameByCivics( self, iPlayer ) : [newCivDesc, newCivShort, newCivAdj] = self.newNameByCivics( iPlayer ) if( gc.getPlayer(iPlayer).isHuman() or game.getActivePlayer() == iPlayer ) : if( self.bLeaveHumanName ) : CvUtil.pyPrint(" Name - Leaving name for human player") return else : #CvUtil.pyPrint(" Name - Changing name for human player!") pass newDesc = CvUtil.convertToStr(newCivDesc) newShort = CvUtil.convertToStr(newCivShort) newAdj = CvUtil.convertToStr(newCivAdj) newDesc = remove_diacriticals(newDesc) newShort = remove_diacriticals(newShort) newAdj = remove_diacriticals(newAdj) if( not newDesc == gc.getPlayer(iPlayer).getCivilizationDescription(0) ) : szMessage = BugUtil.getText("TXT_KEY_MOD_DCN_NEWCIV_NAME_DESC", newDesc) CyInterface().addMessage(iPlayer, false, gc.getDefineINT("EVENT_MESSAGE_TIME"), szMessage, None, InterfaceMessageTypes.MESSAGE_TYPE_INFO, None, gc.getInfoTypeForString("COLOR_HIGHLIGHT_TEXT"), -1, -1, False, False) if( self.LOG_DEBUG ) : CvUtil.pyPrint(" Name - Setting civ name due to civics to %s"%(newDesc)) gc.getPlayer(iPlayer).setCivName( newDesc, newShort, newAdj ) return
def display(self, eActivePlayer, key, players): for ePlayer in players: player = gc.getPlayer(ePlayer) #RevolutionDCM start - start as minors fix if player.isAlive() and gc.getGame().getElapsedGameTurns() > 0: #RevolutionDCM end - start as minors fix message = BugUtil.getText(key, player.getName()) addMessageNoIcon(eActivePlayer, message)
def display(self, eActivePlayer, key, players): for ePlayer in players: player = gc.getPlayer(ePlayer) #RevolutionDCM start - start as minors fix if player.isAlive() and gc.getGame().getElapsedGameTurns() > 0: #RevolutionDCM end - start as minors fix message = BugUtil.getText(key, player.getName()) addMessageNoIcon(eActivePlayer, message)
def check(self, silent=False): if (not Civ4lertsOpt.isShowWorstEnemyAlert()): return eActivePlayer = PlayerUtil.getActivePlayerID() eActiveTeam, activeTeam = PlayerUtil.getActiveTeamAndID() try: # advc.009b enemies = self.enemies[eActivePlayer] # <advc.009b> except AttributeError: return # </advc.009b> newEnemies = AttitudeUtil.getWorstEnemyTeams() delayedMessages = {} for eTeam, eNewEnemy in newEnemies.iteritems(): if activeTeam.isHasMet(eTeam): eOldEnemy = enemies[eTeam] if eOldEnemy != -1 and not gc.getTeam(eOldEnemy).isAlive(): eOldEnemy = -1 enemies[eTeam] = -1 #if eActiveTeam != eNewEnemy and not activeTeam.isHasMet(eNewEnemy): if eNewEnemy != -1 and not activeTeam.isHasMet(eNewEnemy): # K-Mod. (isHasMet(-1) could cause a seg-fault.) eNewEnemy = -1 if eOldEnemy != eNewEnemy: enemies[eTeam] = eNewEnemy if eNewEnemy == -1: if eOldEnemy == eActiveTeam: message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_YOU_NO_WORST_ENEMY", gc.getTeam(eTeam).getName()) else: message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_NO_WORST_ENEMY", (gc.getTeam(eTeam).getName(), gc.getTeam(eOldEnemy).getName())) elif eOldEnemy == -1: message = None # handled below if eNewEnemy not in delayedMessages: delayedMessages[eNewEnemy] = gc.getTeam(eTeam).getName() else: delayedMessages[eNewEnemy] += u", " + gc.getTeam(eTeam).getName() else: if eOldEnemy == eActiveTeam: message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_SWITCH_WORST_ENEMY_FROM_YOU", (gc.getTeam(eTeam).getName(), gc.getTeam(eNewEnemy).getName())) elif eNewEnemy == eActiveTeam: message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_SWITCH_WORST_ENEMY_TO_YOU", (gc.getTeam(eTeam).getName(), gc.getTeam(eOldEnemy).getName())) else: message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_SWITCH_WORST_ENEMY", (gc.getTeam(eTeam).getName(), gc.getTeam(eNewEnemy).getName(), gc.getTeam(eOldEnemy).getName())) if message and not silent: # advc.106c addMessageNoIcon(eActivePlayer, message) for eEnemy, haters in delayedMessages.iteritems(): if eActiveTeam == eEnemy: message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_YOU_WORST_ENEMY", haters) else: message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_WORST_ENEMY", (haters, gc.getTeam(eEnemy).getName())) if not silent: # advc.106c addMessageNoIcon(eActivePlayer, message)
def check(self): #DLP if CyGame().isPitbossHost(): return if (not Civ4lertsOpt.isShowWorstEnemyAlert()): return eActivePlayer = PlayerUtil.getActivePlayerID() eActiveTeam, activeTeam = PlayerUtil.getActiveTeamAndID() enemies = self.enemies[eActivePlayer] newEnemies = AttitudeUtil.getWorstEnemyTeams() delayedMessages = {} for eTeam, eNewEnemy in newEnemies.iteritems(): if activeTeam.isHasMet(eTeam): eOldEnemy = enemies[eTeam] if eOldEnemy != -1 and not gc.getTeam(eOldEnemy).isAlive(): eOldEnemy = -1 enemies[eTeam] = -1 if eActiveTeam != eNewEnemy and not activeTeam.isHasMet(eNewEnemy): eNewEnemy = -1 if eOldEnemy != eNewEnemy: enemies[eTeam] = eNewEnemy if eNewEnemy == -1: if eOldEnemy == eActiveTeam: message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_YOU_NO_WORST_ENEMY", gc.getTeam(eTeam).getName()) else: message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_NO_WORST_ENEMY", (gc.getTeam(eTeam).getName(), gc.getTeam(eOldEnemy).getName())) elif eOldEnemy == -1: message = None # handled below if eNewEnemy not in delayedMessages: delayedMessages[eNewEnemy] = gc.getTeam(eTeam).getName() else: delayedMessages[eNewEnemy] += u", " + gc.getTeam(eTeam).getName() else: if eOldEnemy == eActiveTeam: message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_SWITCH_WORST_ENEMY_FROM_YOU", (gc.getTeam(eTeam).getName(), gc.getTeam(eNewEnemy).getName())) elif eNewEnemy == eActiveTeam: message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_SWITCH_WORST_ENEMY_TO_YOU", (gc.getTeam(eTeam).getName(), gc.getTeam(eOldEnemy).getName())) else: message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_SWITCH_WORST_ENEMY", (gc.getTeam(eTeam).getName(), gc.getTeam(eNewEnemy).getName(), gc.getTeam(eOldEnemy).getName())) if message: addMessageNoIcon(eActivePlayer, message) for eEnemy, haters in delayedMessages.iteritems(): if eActiveTeam == eEnemy: message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_YOU_WORST_ENEMY", haters) else: message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_WORST_ENEMY", (haters, gc.getTeam(eEnemy).getName())) addMessageNoIcon(eActivePlayer, message)
def getHoverText(eWidgetType, iData1, iData2, bOption): city, iTurns = getDisplayCity() if (not city): # no rate or progress in any city and no city selected return BugUtil.getText("TXT_KEY_MISC_GREAT_PERSON", (0, PlayerUtil.getActivePlayer().greatPeopleThreshold(False))) iThreshold = gc.getPlayer(city.getOwner()).greatPeopleThreshold(False) iProgress = city.getGreatPeopleProgress() iRate = city.getGreatPeopleRate() szText = BugUtil.colorText(city.getName(), "COLOR_HIGHLIGHT_TEXT") szText += u"\n" szText += BugUtil.getText("TXT_KEY_MISC_GREAT_PERSON", (iProgress, iThreshold)) if (iRate > 0): szText += u"\n%d%s%s " % (iRate, g_gpIcon, BugUtil.getPlainText("TXT_KEY_PER_TURN")) szText += BugUtil.getText("INTERFACE_CITY_TURNS", (iTurns,)) percents = calcPercentages(city) if (len(percents) > 0): percents.sort() percents.reverse() szText += u"\n" for iPercent, iUnit in percents: # iUnit = getUnitType(gpType) szText += u"\n%s%s - %d%%" % (getUnitIcon(iUnit), gc.getUnitInfo(iUnit).getDescription(), iPercent) return szText
def check(self): if (not Civ4lertsOpt.isShowWorstEnemyAlert()): return eActivePlayer = GAME.getActivePlayer() iActiveTeam = GC.getGame().getActiveTeam() activeTeam = GC.getTeam(iActiveTeam) enemies = self.enemies[eActivePlayer] newEnemies = AttitudeUtil.getWorstEnemyTeams() delayedMessages = {} for eTeam, eNewEnemy in newEnemies.iteritems(): #RevolutionDCM fix if eTeam != -1 and activeTeam.isHasMet(eTeam): eOldEnemy = enemies[eTeam] if eOldEnemy != -1 and not GC.getTeam(eOldEnemy).isAlive(): eOldEnemy = -1 enemies[eTeam] = -1 #RevolutionDCM fix if eNewEnemy != -1 and iActiveTeam != eNewEnemy and not activeTeam.isHasMet(eNewEnemy): eNewEnemy = -1 if eOldEnemy != eNewEnemy: enemies[eTeam] = eNewEnemy if eNewEnemy == -1: if eOldEnemy == iActiveTeam: message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_YOU_NO_WORST_ENEMY", GC.getTeam(eTeam).getName()) else: message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_NO_WORST_ENEMY", (GC.getTeam(eTeam).getName(), GC.getTeam(eOldEnemy).getName())) elif eOldEnemy == -1: message = None # handled below if eNewEnemy not in delayedMessages: delayedMessages[eNewEnemy] = GC.getTeam(eTeam).getName() else: delayedMessages[eNewEnemy] += u", " + GC.getTeam(eTeam).getName() else: if eOldEnemy == iActiveTeam: message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_SWITCH_WORST_ENEMY_FROM_YOU", (GC.getTeam(eTeam).getName(), GC.getTeam(eNewEnemy).getName())) elif eNewEnemy == iActiveTeam: message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_SWITCH_WORST_ENEMY_TO_YOU", (GC.getTeam(eTeam).getName(), GC.getTeam(eOldEnemy).getName())) else: message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_SWITCH_WORST_ENEMY", (GC.getTeam(eTeam).getName(), GC.getTeam(eNewEnemy).getName(), GC.getTeam(eOldEnemy).getName())) if message: addMessage(eActivePlayer, message) for eEnemy, haters in delayedMessages.iteritems(): if iActiveTeam == eEnemy: message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_YOU_WORST_ENEMY", haters) else: message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_WORST_ENEMY", (haters, GC.getTeam(eEnemy).getName())) addMessage(eActivePlayer, message)
def getUniquePowerText(iUniquePowerLevel, iUniquePowerRate, iUniquePowerRateAfterDecimalPoint, iTurnsUniquePower): if (iUniquePowerLevel == 0): g_cUniquePower = "[I]" if(iUniquePowerLevel == 1): g_cUniquePower = "[II]" if(iUniquePowerLevel == 2): g_cUniquePower = "[III]" if(iUniquePowerLevel == 3): g_cUniquePower = "[IV]" if(iUniquePowerLevel == 4): g_cUniquePower = "[V]" if(iUniquePowerLevel == 5): g_cUniquePower = "[-]" return BugUtil.getText("INTERFACE_NEXT_UNIQUE_POWER_LEVEL", (g_cUniquePower, iUniquePowerRate, iUniquePowerRateAfterDecimalPoint, iTurnsUniquePower))
def launch(): "Opens the mod's help file externally if it can be found or displays an error alert" sLang = ["ENG", "FRA", "DEU", "ITA", "ESP"] name = "BUG Mod Help-%s.chm" % (sLang[CyGame().getCurrentLanguage()]) file = findIniFile(name) if file: message = BugUtil.getPlainText("TXT_KEY_BUG_HELP_OPENING") CyInterface().addImmediateMessage(message, "") os.startfile(file) return True else: title = BugUtil.getPlainText("TXT_KEY_BUG_HELP_MISSING_TITLE") body = BugUtil.getText("TXT_KEY_BUG_HELP_MISSING_BODY", (name,)) popup = PyPopup.PyPopup() popup.setHeaderString(title) popup.setBodyString(body) popup.launch() return False
def start(self): self.writeMsg("") self.writeMsg("Logging by " + CvModName.getDisplayNameAndVersion() + " (" + CvModName.getCivNameAndVersion() + ")") self.writeMsg("------------------------------------------------") zcurrturn = gc.getGame().getElapsedGameTurns() + AutologOpt.get4000BCTurn() zmaxturn = gc.getGame().getMaxTurns() zyear = gc.getGame().getGameTurnYear() if (zyear < 0): zyear = str(-zyear) + BugUtil.getPlainText("TXT_KEY_AUTOLOG_BC") else: zyear = str(zyear) + BugUtil.getPlainText("TXT_KEY_AUTOLOG_AD") zCurrDateTime = time.strftime("%d-%b-%Y %H:%M:%S") if (zmaxturn == 0): zsTurn = "%i" % (zcurrturn) else: zsTurn = "%i/%i" % (zcurrturn, zmaxturn) message = BugUtil.getText("TXT_KEY_AUTOLOG_TURN", (zsTurn, zyear, zCurrDateTime)) self.writeMsg(message, vBold=True, vUnderline=True) self.bStarted = True
def start(self): self.writeMsg("") self.writeMsg("Logging by " + CvModName.getDisplayNameAndVersion() + " (" + CvModName.getCivNameAndVersion() + ")") self.writeMsg("------------------------------------------------") zcurrturn = gc.getGame().getElapsedGameTurns( ) + AutologOpt.get4000BCTurn() zmaxturn = gc.getGame().getMaxTurns() zyear = gc.getGame().getGameTurnYear() if (zyear < 0): zyear = str(-zyear) + BugUtil.getPlainText("TXT_KEY_AUTOLOG_BC") else: zyear = str(zyear) + BugUtil.getPlainText("TXT_KEY_AUTOLOG_AD") zCurrDateTime = time.strftime("%d-%b-%Y %H:%M:%S") if (zmaxturn == 0): zsTurn = "%i" % (zcurrturn) else: zsTurn = "%i/%i" % (zcurrturn, zmaxturn) message = BugUtil.getText("TXT_KEY_AUTOLOG_TURN", (zsTurn, zyear, zCurrDateTime)) self.writeMsg(message, vBold=True, vUnderline=True) self.bStarted = True
def drawContents(self): self.deleteAllWidgets() # Create a new screen, called FinanceAdvisor, using the file FinanceAdvisor.py for input screen = self.getScreen() player = gc.getPlayer(self.iActiveLeader) numCities = player.getNumCities() totalUnitCost = player.calculateUnitCost() totalUnitSupply = player.calculateUnitSupply() totalMaintenance = player.getTotalMaintenance() totalCivicUpkeep = player.getCivicUpkeep([], False) totalPreInflatedCosts = player.calculatePreInflatedCosts() totalInflatedCosts = player.calculateInflatedCosts() goldCommerce = player.getCommerceRate(CommerceTypes.COMMERCE_GOLD) if (not player.isCommerceFlexible(CommerceTypes.COMMERCE_RESEARCH)): goldCommerce += player.calculateBaseNetResearch() gold = player.getGold() goldFromCivs = player.getGoldPerTurn() goldPerTurn = player.calculateGoldRate() szTreasuryPanel = self.getNextWidgetName() screen.addPanel(szTreasuryPanel, u"", "", True, True, self.X_SLIDERS, self.Y_TREASURY, self.X_EXPENSES + self.PANE_WIDTH - self.X_SLIDERS, self.H_TREASURY, PanelStyles.PANEL_STYLE_MAIN) szText = localText.getText("TXT_KEY_FINANCIAL_ADVISOR_TREASURY", (gold, )).upper() if gold < 0: if goldPerTurn != 0: if gold + goldPerTurn >= 0: szText += BugUtil.getText("TXT_KEY_MISC_POS_GOLD_PER_TURN", goldPerTurn) elif goldPerTurn >= 0: szText += BugUtil.getText( "TXT_KEY_MISC_POS_WARNING_GOLD_PER_TURN", goldPerTurn) else: szText += BugUtil.getText("TXT_KEY_MISC_NEG_GOLD_PER_TURN", goldPerTurn) else: if goldPerTurn != 0: if goldPerTurn >= 0: szText += BugUtil.getText("TXT_KEY_MISC_POS_GOLD_PER_TURN", goldPerTurn) elif gold + goldPerTurn >= 0: szText += BugUtil.getText( "TXT_KEY_MISC_NEG_WARNING_GOLD_PER_TURN", goldPerTurn) else: szText += BugUtil.getText("TXT_KEY_MISC_NEG_GOLD_PER_TURN", goldPerTurn) screen.setLabel( self.getNextWidgetName(), szTreasuryPanel, u"<font=4>" + szText + u"</font>", CvUtil.FONT_CENTER_JUSTIFY, (self.X_SLIDERS + self.PANE_WIDTH + self.X_EXPENSES) / 2, self.Y_TREASURY + self.H_TREASURY / 2 - self.Y_SPACING / 2, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_HELP_FINANCE_GOLD_RESERVE, -1, -1) szCommercePanel = self.getNextWidgetName() screen.addPanel(szCommercePanel, u"", "", True, True, self.X_SLIDERS, self.Y_LOCATION, self.PANE_WIDTH, self.PANE_HEIGHT, PanelStyles.PANEL_STYLE_MAIN) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_COMMERCE", ()).upper() + u"</font>", CvUtil.FONT_CENTER_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH / 2, self.Y_LOCATION + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) szIncomePanel = self.getNextWidgetName() screen.addPanel(szIncomePanel, u"", "", True, True, self.X_INCOME, self.Y_LOCATION, self.PANE_WIDTH, self.PANE_HEIGHT, PanelStyles.PANEL_STYLE_MAIN) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_INCOME_HEADER", ()).upper() + u"</font>", CvUtil.FONT_CENTER_JUSTIFY, self.X_INCOME + self.PANE_WIDTH / 2, self.Y_LOCATION + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) szExpensePanel = self.getNextWidgetName() screen.addPanel(szExpensePanel, u"", "", True, True, self.X_EXPENSES, self.Y_LOCATION, self.PANE_WIDTH, self.PANE_HEIGHT, PanelStyles.PANEL_STYLE_MAIN) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_EXPENSES_HEADER", ()).upper() + u"</font>", CvUtil.FONT_CENTER_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH / 2, self.Y_LOCATION + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) # Commerce yLocation = self.Y_LOCATION iCommerce = 0 # sum all worked tiles' commerce yields for player # move to MapUtil? iWorkedTileCount = 0 iWorkedTiles = 0 for city in PlayerUtil.playerCities(player): if not city.isDisorder(): for i in range(gc.getNUM_CITY_PLOTS()): plot = city.getCityIndexPlot(i) if plot and not plot.isNone() and plot.hasYield(): if city.isWorkingPlot(plot): iWorkedTileCount += 1 iWorkedTiles += plot.getYield( YieldTypes.YIELD_COMMERCE) yLocation += 1.5 * self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_WORKED_TILES", (iWorkedTileCount, )) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iWorkedTiles) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) iCommerce += iWorkedTiles # trade iDomesticTrade, _, iForeignTrade, _ = TradeUtil.calculateTradeRoutes( player) if iDomesticTrade > 0: if TradeUtil.isFractionalTrade(): iDomesticTrade //= 100 yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_DOMESTIC_TRADE", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, *BugDll.widget("WIDGET_HELP_FINANCE_DOMESTIC_TRADE", self.iActiveLeader, 1)) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iDomesticTrade) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, *BugDll.widget("WIDGET_HELP_FINANCE_DOMESTIC_TRADE", self.iActiveLeader, 1)) iCommerce += iDomesticTrade if iForeignTrade > 0: if TradeUtil.isFractionalTrade(): iForeignTrade //= 100 yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_FOREIGN_TRADE", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, *BugDll.widget("WIDGET_HELP_FINANCE_FOREIGN_TRADE", self.iActiveLeader, 1)) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iForeignTrade) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, *BugDll.widget("WIDGET_HELP_FINANCE_FOREIGN_TRADE", self.iActiveLeader, 1)) iCommerce += iForeignTrade # corporations iCorporations = 0 for city in PlayerUtil.playerCities(player): if not city.isDisorder(): iCorporations += city.getCorporationYield( YieldTypes.YIELD_COMMERCE) if iCorporations > 0: yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_CORPORATIONS", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iCorporations) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) iCommerce += iCorporations # specialists iSpecialists = 0 for city in PlayerUtil.playerCities(player): if not city.isDisorder(): for eSpec in range(gc.getNumSpecialistInfos()): iSpecialists += player.specialistYield( eSpec, YieldTypes.YIELD_COMMERCE) * ( city.getSpecialistCount(eSpec) + city.getFreeSpecialistCount(eSpec)) if iSpecialists > 0: yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_SPECIALISTS", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iSpecialists) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) iCommerce += iSpecialists # buildings iTotalCommerce = player.calculateTotalYield(YieldTypes.YIELD_COMMERCE) # buildings includes 50% capital bonus for Bureaucracy civic iBuildings = iTotalCommerce - iCommerce if iBuildings > 0: yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_BUILDINGS", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iBuildings) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) iCommerce += iBuildings yLocation += 1.5 * self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_BUG_FINANCIAL_ADVISOR_COMMERCE", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iCommerce) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) # Slider percentages yLocation += 0.5 * self.Y_SPACING for iI in range(CommerceTypes.NUM_COMMERCE_TYPES): eCommerce = (iI + 1) % CommerceTypes.NUM_COMMERCE_TYPES if (player.isCommerceFlexible(eCommerce)): yLocation += self.Y_SPACING screen.setButtonGFC( self.getNextWidgetName(), u"", "", self.X_SLIDERS + self.TEXT_MARGIN, int(yLocation) + self.TEXT_MARGIN, 20, 20, WidgetTypes.WIDGET_CHANGE_PERCENT, eCommerce, gc.getDefineINT("COMMERCE_PERCENT_CHANGE_INCREMENTS"), ButtonStyles.BUTTON_STYLE_CITY_PLUS) screen.setButtonGFC( self.getNextWidgetName(), u"", "", self.X_SLIDERS + self.TEXT_MARGIN + 24, int(yLocation) + self.TEXT_MARGIN, 20, 20, WidgetTypes.WIDGET_CHANGE_PERCENT, eCommerce, -gc.getDefineINT("COMMERCE_PERCENT_CHANGE_INCREMENTS"), ButtonStyles.BUTTON_STYLE_CITY_MINUS) szText = u"<font=3>" + gc.getCommerceInfo( eCommerce).getDescription() + u" (" + unicode( player.getCommercePercent(eCommerce)) + u"%)</font>" screen.setLabel(self.getNextWidgetName(), "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN + 50, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) szRate = u"<font=3>" + unicode( player.getCommerceRate( CommerceTypes(eCommerce))) + u"</font>" screen.setLabel( self.getNextWidgetName(), "Background", szRate, CvUtil.FONT_RIGHT_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) yLocation += self.Y_SPACING szText = u"<font=3>" + gc.getCommerceInfo( CommerceTypes.COMMERCE_GOLD).getDescription() + u" (" + unicode( player.getCommercePercent( CommerceTypes.COMMERCE_GOLD)) + u"%)</font>" screen.setLabel(self.getNextWidgetName(), "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN + 50, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) szCommerce = u"<font=3>" + unicode(goldCommerce) + u"</font>" screen.setLabel(self.getNextWidgetName(), "Background", szCommerce, CvUtil.FONT_RIGHT_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) # Income yLocation = self.Y_LOCATION iTaxRate = player.getCommercePercent(CommerceTypes.COMMERCE_GOLD) multipliers = [] for eBldg in range(gc.getNumBuildingInfos()): info = gc.getBuildingInfo(eBldg) iMultiplier = info.getCommerceModifier(CommerceTypes.COMMERCE_GOLD) if iMultiplier > 0: multipliers.append([eBldg, iMultiplier, 0, 0.0]) iBuildingCount = 0 iHeadquartersCount = 0 iShrinesCount = 0 fTaxes = 0.0 fBuildings = 0.0 fHeadquarters = 0.0 fShrines = 0.0 fCorporations = 0.0 fSpecialists = 0.0 iWealthCount = 0 fWealth = 0.0 eWealth = gc.getInfoTypeForString("PROCESS_WEALTH") # ignores # CyCity.getReligionCommerce() -- excludes shrines # CyPlayer.getFreeCityCommerce() # CyPlayer.getSpecialistExtraCommerce() * (CyCity.getSpecialistPopulation() + CyCity.getNumGreatPeople()) for city in PlayerUtil.playerCities(player): if not city.isDisorder(): fCityTaxes = city.getYieldRate( YieldTypes.YIELD_COMMERCE) * iTaxRate / 100.0 fTaxes += fCityTaxes fCityBuildings = 0.0 fCityHeadquarters = 0.0 fCityShrines = 0.0 for eBldg in range(gc.getNumBuildingInfos()): iCount = city.getNumRealBuilding(eBldg) if iCount > 0: iBuildingGold = city.getBuildingCommerceByBuilding( CommerceTypes.COMMERCE_GOLD, eBldg) if iBuildingGold > 0: info = gc.getBuildingInfo(eBldg) if info.getFoundsCorporation() != -1: fCityHeadquarters += iBuildingGold iHeadquartersCount += 1 elif info.getGlobalReligionCommerce() != -1: fCityShrines += iBuildingGold iShrinesCount += 1 else: fCityBuildings += iBuildingGold iBuildingCount += iCount fBuildings += fCityBuildings fHeadquarters += fCityHeadquarters fShrines += fCityShrines fCityCorporations = city.getCorporationCommerce( CommerceTypes.COMMERCE_GOLD) fCorporations += fCityCorporations fCitySpecialists = city.getSpecialistCommerce( CommerceTypes.COMMERCE_GOLD) fSpecialists += fCitySpecialists fCityWealth = 0.0 if city.isProductionProcess() and city.getProductionProcess( ) == eWealth: fCityWealth = city.getProductionToCommerceModifier( CommerceTypes.COMMERCE_GOLD) * city.getYieldRate( YieldTypes.YIELD_PRODUCTION) / 100.0 fWealth += fCityWealth iWealthCount += 1 # buildings don't multiply wealth fCityTotel = fCityTaxes + fCityBuildings + fCityHeadquarters + fCityCorporations + fCitySpecialists for entry in multipliers: eBldg, iMultiplier, _, _ = entry iCount = city.getNumRealBuilding(eBldg) if iCount > 0: entry[2] += iCount entry[3] += iCount * fCityTotel * iMultiplier / 100.0 iTotalMinusTaxes = int(fBuildings) + int(fCorporations) + int( fSpecialists) + int(fWealth) for _, _, _, fGold in multipliers: iTotalMinusTaxes += int(fGold) yLocation += 1.5 * self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_TAXES", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(goldCommerce - iTotalMinusTaxes) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) if fBuildings > 0.0: yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_BUILDINGS", ()) + " (%d)</font>" % iBuildingCount, CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(int(fBuildings)) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) if fHeadquarters > 0.0: yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CORPORATION_HEADQUARTERS", ()) + " (%d)</font>" % iHeadquartersCount, CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(int(fHeadquarters)) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) if fCorporations > 0.0: yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_CORPORATIONS", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(int(fCorporations)) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) if fShrines > 0.0: yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_RELIGIOUS_SHRINES", ()) + " (%d)</font>" % iShrinesCount, CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(int(fShrines)) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) if fSpecialists > 0.0: yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_SPECIALISTS", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, *BugDll.widget("WIDGET_HELP_FINANCE_SPECIALISTS", self.iActiveLeader, 1)) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(int(fSpecialists)) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, *BugDll.widget("WIDGET_HELP_FINANCE_SPECIALISTS", self.iActiveLeader, 1)) for eBldg, iMultiplier, iCount, fGold in multipliers: if iCount > 0 and fGold > 0.0: fAverage = fGold / iCount szDescription = gc.getBuildingInfo( eBldg).getDescription() + u" " + localText.getText( "TXT_KEY_BUG_FINANCIAL_ADVISOR_BUILDING_COUNT_AVERAGE", (iCount, BugUtil.formatFloat(fAverage, 2))) yLocation += self.Y_SPACING screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + szDescription + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(int(fGold)) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) if fWealth > 0.0 and iWealthCount > 0: yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_PROCESS_WEALTH", ()) + " (%d)</font>" % iWealthCount, CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(int(fWealth)) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) iIncome = goldCommerce if (goldFromCivs > 0): yLocation += self.Y_SPACING szText = unicode(goldFromCivs) + " : " + localText.getText( "TXT_KEY_FINANCIAL_ADVISOR_PER_TURN", ()) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_PER_TURN", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_FOREIGN_INCOME, self.iActiveLeader, 1) screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(goldFromCivs) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_FOREIGN_INCOME, self.iActiveLeader, 1) iIncome += goldFromCivs yLocation += 1.5 * self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_INCOME", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iIncome) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) # Expenses yLocation = self.Y_LOCATION iExpenses = 0 yLocation += 1.5 * self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_UNITCOST", ()) + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_UNIT_COST, self.iActiveLeader, 1) screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(totalUnitCost) + u"</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_UNIT_COST, self.iActiveLeader, 1) iExpenses += totalUnitCost yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_UNITSUPPLY", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_AWAY_SUPPLY, self.iActiveLeader, 1) screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(totalUnitSupply) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_AWAY_SUPPLY, self.iActiveLeader, 1) iExpenses += totalUnitSupply yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_MAINTENANCE", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_CITY_MAINT, self.iActiveLeader, 1) screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(totalMaintenance) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_CITY_MAINT, self.iActiveLeader, 1) iExpenses += totalMaintenance yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_CIVICS", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_CIVIC_UPKEEP, self.iActiveLeader, 1) screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(totalCivicUpkeep) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_CIVIC_UPKEEP, self.iActiveLeader, 1) iExpenses += totalCivicUpkeep if (goldFromCivs < 0): yLocation += self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_COST_PER_TURN", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_FOREIGN_INCOME, self.iActiveLeader, 1) screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + unicode(-goldFromCivs) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_FOREIGN_INCOME, self.iActiveLeader, 1) iExpenses -= goldFromCivs yLocation += self.Y_SPACING iInflation = totalInflatedCosts - totalPreInflatedCosts screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_INFLATION", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_INFLATED_COSTS, self.iActiveLeader, 1) screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iInflation) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_INFLATED_COSTS, self.iActiveLeader, 1) iExpenses += iInflation yLocation += 1.5 * self.Y_SPACING screen.setLabel( self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_EXPENSES", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iExpenses) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) return 0
def display(self): BugUtil.error(BugUtil.getText(self.key, self.args))
def display(self, eActivePlayer, key, players): for ePlayer in players: player = gc.getPlayer(ePlayer) if player.isAlive(): message = BugUtil.getText(key, player.getCivilizationShortDescription(0)) addMessageNoIcon(eActivePlayer, message)
def getGreatPeopleText(city, iGPTurns, iGPBarWidth, bGPBarTypesNone, bGPBarTypesOne, bIncludeCityName): sGreatPeopleChar = u"%c" % CyGame().getSymbolID(FontSymbols.GREAT_PEOPLE_CHAR) if (not city): szText = BugUtil.getText("INTERFACE_GREAT_PERSON_NONE", (sGreatPeopleChar, )) elif (bGPBarTypesNone): if (iGPTurns): if (bIncludeCityName): szText = BugUtil.getText("INTERFACE_GREAT_PERSON_CITY_TURNS", (sGreatPeopleChar, city.getName(), iGPTurns)) else: szText = BugUtil.getText("INTERFACE_GREAT_PERSON_TURNS", (sGreatPeopleChar, iGPTurns)) else: if (bIncludeCityName): szText = BugUtil.getText("INTERFACE_GREAT_PERSON_CITY", (sGreatPeopleChar, city.getName())) else: szText = sGreatPeopleChar else: lPercents = calcPercentages(city) if (len(lPercents) == 0): if (iGPTurns): if (bIncludeCityName): szText = BugUtil.getText("INTERFACE_GREAT_PERSON_CITY_TURNS", (sGreatPeopleChar, city.getName(), iGPTurns)) else: szText = BugUtil.getText("INTERFACE_GREAT_PERSON_TURNS", (sGreatPeopleChar, iGPTurns)) else: if (bIncludeCityName): szText = BugUtil.getText("INTERFACE_GREAT_PERSON_CITY", (sGreatPeopleChar, city.getName())) else: szText = sGreatPeopleChar else: lPercents.sort() lPercents.reverse() if (bGPBarTypesOne or len(lPercents) == 1): iPercent, iUnit = lPercents[0] pInfo = gc.getUnitInfo(iUnit) if (iGPTurns): if (bIncludeCityName): szText = BugUtil.getText("INTERFACE_GREAT_PERSON_CITY_TURNS", (pInfo.getDescription(), city.getName(), iGPTurns)) else: szText = BugUtil.getText("INTERFACE_GREAT_PERSON_TURNS", (pInfo.getDescription(), iGPTurns)) else: if (bIncludeCityName): szText = BugUtil.getText("INTERFACE_GREAT_PERSON_CITY", (pInfo.getDescription(), city.getName())) else: szText = unicode(pInfo.getDescription()) else: if (iGPTurns): if (bIncludeCityName): szText = BugUtil.getText("INTERFACE_GREAT_PERSON_CITY_TURNS", (sGreatPeopleChar, city.getName(), iGPTurns)) else: szText = BugUtil.getText("INTERFACE_GREAT_PERSON_TURNS", (sGreatPeopleChar, iGPTurns)) else: if (bIncludeCityName): szText = BugUtil.getText("INTERFACE_GREAT_PERSON_CITY", (sGreatPeopleChar, city.getName())) else: szText = sGreatPeopleChar + u":" szTypes = "" for iPercent, iUnit in lPercents: szNewTypes = szTypes + u" %c%d%%" % (getUnitIcon(iUnit), iPercent) szNewText = szText + u"<font=2> -%s</font>" % szTypes if (CyInterface().determineWidth(szNewText) > iGPBarWidth - 10): # Keep under width break szTypes = szNewTypes if (len(szTypes) > 0): szText += u"<font=2> -%s</font>" % szTypes return szText
def getGreatPeopleText(city, iGPTurns, iGPBarWidth, bGPBarTypesNone, bGPBarTypesOne, bIncludeCityName): sGreatPeopleChar = u"%c" % CyGame().getSymbolID( FontSymbols.GREAT_PEOPLE_CHAR) if (not city): szText = BugUtil.getText("INTERFACE_GREAT_PERSON_NONE", (sGreatPeopleChar, )) elif (bGPBarTypesNone): if (iGPTurns): if (bIncludeCityName): szText = BugUtil.getText( "INTERFACE_GREAT_PERSON_CITY_TURNS", (sGreatPeopleChar, city.getName(), iGPTurns)) else: szText = BugUtil.getText("INTERFACE_GREAT_PERSON_TURNS", (sGreatPeopleChar, iGPTurns)) else: if (bIncludeCityName): szText = BugUtil.getText("INTERFACE_GREAT_PERSON_CITY", (sGreatPeopleChar, city.getName())) else: szText = sGreatPeopleChar else: lPercents = calcPercentages(city) if (len(lPercents) == 0): if (iGPTurns): if (bIncludeCityName): szText = BugUtil.getText( "INTERFACE_GREAT_PERSON_CITY_TURNS", (sGreatPeopleChar, city.getName(), iGPTurns)) else: szText = BugUtil.getText("INTERFACE_GREAT_PERSON_TURNS", (sGreatPeopleChar, iGPTurns)) else: if (bIncludeCityName): szText = BugUtil.getText( "INTERFACE_GREAT_PERSON_CITY", (sGreatPeopleChar, city.getName())) else: szText = sGreatPeopleChar else: lPercents.sort() lPercents.reverse() if (bGPBarTypesOne or len(lPercents) == 1): iPercent, iUnit = lPercents[0] pInfo = gc.getUnitInfo(iUnit) if (iGPTurns): if (bIncludeCityName): szText = BugUtil.getText( "INTERFACE_GREAT_PERSON_CITY_TURNS", (pInfo.getDescription(), city.getName(), iGPTurns)) else: szText = BugUtil.getText( "INTERFACE_GREAT_PERSON_TURNS", (pInfo.getDescription(), iGPTurns)) else: if (bIncludeCityName): szText = BugUtil.getText( "INTERFACE_GREAT_PERSON_CITY", (pInfo.getDescription(), city.getName())) else: szText = unicode(pInfo.getDescription()) else: if (iGPTurns): if (bIncludeCityName): szText = BugUtil.getText( "INTERFACE_GREAT_PERSON_CITY_TURNS", (sGreatPeopleChar, city.getName(), iGPTurns)) else: szText = BugUtil.getText( "INTERFACE_GREAT_PERSON_TURNS", (sGreatPeopleChar, iGPTurns)) else: if (bIncludeCityName): szText = BugUtil.getText( "INTERFACE_GREAT_PERSON_CITY", (sGreatPeopleChar, city.getName())) else: szText = sGreatPeopleChar + u":" szTypes = "" for iPercent, iUnit in lPercents: szNewTypes = szTypes + u" %c%d%%" % (getUnitIcon(iUnit), iPercent) szNewText = szText + u"<font=2> -%s</font>" % szTypes if (CyInterface().determineWidth(szNewText) > iGPBarWidth - 10): # Keep under width break szTypes = szNewTypes if (len(szTypes) > 0): szText += u"<font=2> -%s</font>" % szTypes return szText
def format(self, player, trade): return BugUtil.getText(self.key, (self.getParameters(player, trade), ))
def getTradePeaceDeal(player, trade): BugUtil.debug("TradeUtil - peace treaty has iData %d", trade.iData) return BugUtil.getText("TXT_KEY_TRADE_PEACE_TREATY_STRING", (gc.getDefineINT("PEACE_TREATY_LENGTH"), ))
def onCityRazed(argsList): CyCity, iPlayer = argsList if not CyCity: return CyPlayer = GC.getPlayer(iPlayer) bHuman = CyPlayer.isHuman() sCityName = CyCity.getName() X = CyCity.getX() Y = CyCity.getY() ''' # Convert Great Specialists into captives or other iCount = CyCity.getSpecialistCount(GC.getInfoTypeForString('SPECIALIST_GREAT_PROPHET')) if iCount > 0: iCountKilled = iCount iCountCaptured = 0 sMessage = BugUtil.getText("TXT_KEY_MSG_CITY_HAD_PRIESTS",(iCount,iCountCaptured)) CyInterface().addMessage(iPlayer,False,15, sMessage ,'',0,'Art/Interface/Buttons/Civics/Serfdom.dds',ColorTypes(44), X, Y, True,True) iCount = CyCity.getSpecialistCount(GC.getInfoTypeForString('SPECIALIST_GREAT_ARTIST')) if iCount > 0: iCountKilled = iCount iCountCaptured = 0 sMessage = BugUtil.getText("TXT_KEY_MSG_CITY_HAD_ARTISTS",(iCount,iCountCaptured)) CyInterface().addMessage(iPlayer,False,15, sMessage,'',0,'Art/Interface/Buttons/Civics/Serfdom.dds',ColorTypes(44), X, Y, True,True) iCount = CyCity.getSpecialistCount(GC.getInfoTypeForString('SPECIALIST_GREAT_SCIENTIST')) if iCount > 0: iCountKilled = iCount iCountCaptured = 0 sMessage = BugUtil.getText("TXT_KEY_MSG_CITY_HAD_SCIENTISTS",(iCount,iCountCaptured)) CyInterface().addMessage(iPlayer,False,15, sMessage,'',0,'Art/Interface/Buttons/Civics/Serfdom.dds',ColorTypes(44), X, Y, True,True) iCount = CyCity.getSpecialistCount(GC.getInfoTypeForString('SPECIALIST_GREAT_MERCHANT')) if iCount > 0: iCountKilled = iCount iCountCaptured = 0 sMessage = BugUtil.getText("TXT_KEY_MSG_CITY_HAD_MERCHANTS",(iCount,iCountCaptured)) CyInterface().addMessage(iPlayer,False,15, sMessage,'',0,'Art/Interface/Buttons/Civics/Serfdom.dds',ColorTypes(44), X, Y, True,True) iCount = CyCity.getSpecialistCount(GC.getInfoTypeForString('SPECIALIST_GREAT_ENGINEER')) if iCount > 0: iCountKilled = iCount iCountCaptured = 0 sMessage = BugUtil.getText("TXT_KEY_MSG_CITY_HAD_ENGINEERS",(iCount,iCountCaptured)) CyInterface().addMessage(iPlayer,False,15, sMessage,'',0,'Art/Interface/Buttons/Civics/Serfdom.dds',ColorTypes(44), X, Y, True,True) iCount = CyCity.getSpecialistCount(GC.getInfoTypeForString('SPECIALIST_GREAT_DOCTOR')) if iCount > 0: iCountKilled = iCount iCountCaptured = 0 sMessage = BugUtil.getText("TXT_KEY_MSG_CITY_HAD_DOCTORS",(iCount,iCountCaptured)) CyInterface().addMessage(iPlayer,False,15, sMessage,'',0,'Art/Interface/Buttons/Civics/Serfdom.dds',ColorTypes(44), X, Y, True,True) iCount = CyCity.getSpecialistCount(GC.getInfoTypeForString('SPECIALIST_GREAT_SPY')) if iCount > 0: iCountKilled = iCount Inhiding = 0 iCountCaptured = 0 sMessage = BugUtil.getText("TXT_KEY_MSG_CITY_HAD_SPIES",(iCount,iCountCaptured)) CyInterface().addMessage(iPlayer,False,15, sMessage,'',0,'Art/Interface/Buttons/Civics/Serfdom.dds',ColorTypes(44), X, Y, True,True) iCount = CyCity.getSpecialistCount(GC.getInfoTypeForString('SPECIALIST_GREAT_MILITARY_INSTRUCTOR')) + CyCity.getSpecialistCount(GC.getInfoTypeForString('SPECIALIST_MILITARY_INSTRUCTOR')) if iCount > 0: iCountKilled = iCount iCountRebelled = 0 iCountCaptured = 0 sMessage = BugUtil.getText("TXT_KEY_MSG_CITY_HAD_GENERALS",(iCount,iCountKilled,iCountRebelled,iCountCaptured)) CyInterface().addMessage(iPlayer,False,15, sMessage,'',0,'Art/Interface/Buttons/Civics/Serfdom.dds',ColorTypes(44), X, Y, True,True) ''' ## Slaves iSlaveSettled = GC.getInfoTypeForString("SPECIALIST_SETTLED_SLAVE") iSlaveFood = GC.getInfoTypeForString("SPECIALIST_SETTLED_SLAVE_FOOD") iSlaveProd = GC.getInfoTypeForString("SPECIALIST_SETTLED_SLAVE_PRODUCTION") iSlaveCom = GC.getInfoTypeForString("SPECIALIST_SETTLED_SLAVE_COMMERCE") iSlaveHealth = GC.getInfoTypeForString("SPECIALIST_SETTLED_SLAVE_HEALTH") iSlaveEntertain = GC.getInfoTypeForString( "SPECIALIST_SETTLED_SLAVE_ENTERTAINMENT") iSlaveTutor = GC.getInfoTypeForString("SPECIALIST_SETTLED_SLAVE_TUTOR") iSlaveMilitary = GC.getInfoTypeForString( "SPECIALIST_SETTLED_SLAVE_MILITARY") iUnitCaptiveSlave = GC.getInfoTypeForString("UNIT_FREED_SLAVE") iUnitImmigrant = GC.getInfoTypeForString("UNIT_CAPTIVE_IMMIGRANT") iUnitEntertain = GC.getInfoTypeForString("UNIT_STORY_TELLER") iUnitMerCaravan = GC.getInfoTypeForString("UNIT_EARLY_MERCHANT_C2C") iUnitHealth = GC.getInfoTypeForString("UNIT_HEALER") iCountSettled = CyCity.getFreeSpecialistCount(iSlaveSettled) iCountFood = CyCity.getFreeSpecialistCount(iSlaveFood) iCountProd = CyCity.getFreeSpecialistCount(iSlaveProd) iCountCom = CyCity.getFreeSpecialistCount(iSlaveCom) iCountHealth = CyCity.getFreeSpecialistCount(iSlaveHealth) iCountEntertain = CyCity.getFreeSpecialistCount(iSlaveEntertain) iCountTutor = CyCity.getFreeSpecialistCount(iSlaveTutor) iCountMilitary = CyCity.getFreeSpecialistCount(iSlaveMilitary) ## Process those that can become population or immagrants ## where 3 slaves = 1 pop or immigrant ## and can only increase the city pop to 7 iCount = iCountSettled + iCountFood + iCountCom + iCountTutor + iCountMilitary iCountNewPop = int(iCount / 3) iCount = iCount - 3 * iCountNewPop if iCount > 0: for i in xrange(iCount): newunit = CyPlayer.initUnit(iUnitCaptiveSlave, X, Y, UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION) if bHuman: sMessage = BugUtil.getText( "TXT_KEY_MSG_FREED_SLAVES_AS", (sCityName, GC.getUnitInfo(iUnitCaptiveSlave).getDescription(), iCount)) CyInterface().addMessage( iPlayer, False, 15, sMessage, '', 0, 'Art/Interface/Buttons/Civics/Serfdom.dds', ColorTypes(44), X, Y, True, True) if iCountNewPop > 0: iCountImmigrants = iCountNewPop if iCountImmigrants > 0: for i in range(iCountImmigrants): newunit = CyPlayer.initUnit(iUnitImmigrant, X, Y, UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION) if bHuman: sMessage = BugUtil.getText( "TXT_KEY_MSG_FREED_SLAVES_AS_IMMIGRANTS", (iCountImmigrants * 3, sCityName, iCountImmigrants)) CyInterface().addMessage( iPlayer, False, 15, sMessage, '', 0, 'Art/Interface/Buttons/Civics/Serfdom.dds', ColorTypes(44), X, Y, True, True) ## Now remove those slaves if iCountSettled > 0: CyCity.changeFreeSpecialistCount(iSlaveSettled, -iCountSettled) if iCountFood > 0: CyCity.changeFreeSpecialistCount(iSlaveFood, -iCountFood) if iCountCom > 0: CyCity.changeFreeSpecialistCount(iSlaveCom, -iCountCom) if iCountTutor > 0: CyCity.changeFreeSpecialistCount(iSlaveTutor, -iCountTutor) if iCountMilitary > 0: CyCity.changeFreeSpecialistCount(iSlaveMilitary, -iCountMilitary) ## Now convert the other slaves if iCountProd > 0: for i in range(iCountProd): CyPlayer.initUnit(iUnitMerCaravan, X, Y, UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION) CyCity.changeFreeSpecialistCount(iSlaveProd, -1) if bHuman: sMessage = BugUtil.getText( "TXT_KEY_MSG_FREED_SLAVES_AS", (sCityName, GC.getUnitInfo(iUnitMerCaravan).getDescription(), iCountProd)) CyInterface().addMessage( iPlayer, False, 15, sMessage, '', 0, 'Art/Interface/Buttons/Civics/Serfdom.dds', ColorTypes(44), X, Y, True, True) if iCountHealth > 0: for i in range(iCountProd): CyPlayer.initUnit(iUnitHealth, X, Y, UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION) CyCity.changeFreeSpecialistCount(iSlaveHealth, -1) if bHuman: sMessage = BugUtil.getText( "TXT_KEY_MSG_FREED_SLAVES_AS", (sCityName, GC.getUnitInfo(iUnitHealth).getDescription(), iCountHealth)) CyInterface().addMessage( iPlayer, False, 15, sMessage, '', 0, 'Art/Interface/Buttons/Civics/Serfdom.dds', ColorTypes(44), X, Y, True, True) if iCountEntertain > 0: for i in range(iCountEntertain): CyPlayer.initUnit(iUnitEntertain, X, Y, UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION) CyCity.changeFreeSpecialistCount(iSlaveEntertain, -1) if bHuman: sMessage = BugUtil.getText( "TXT_KEY_MSG_FREED_SLAVES_AS", (sCityName, GC.getUnitInfo(iUnitEntertain).getDescription(), iCountEntertain)) CyInterface().addMessage( iPlayer, False, 15, sMessage, '', 0, 'Art/Interface/Buttons/Civics/Serfdom.dds', ColorTypes(44), X, Y, True, True) ## Convert population to captives iUnit = GC.getInfoTypeForString('UNIT_CAPTIVE_CIVILIAN') iCount = 0 iPop = CyCity.getPopulation() if iPop == 1: if GAME.getSorenRandNum(100, "Slave") < 66: CyPlayer.initUnit(iUnit, X, Y, UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION) iCount = 1 else: iCivilianCitizenUnits = (iPop + 1) / 2 for loop in xrange(iCivilianCitizenUnits): CyPlayer.initUnit(iUnit, X, Y, UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION) iCount += 1 if bHuman and iCount: sMessage = BugUtil.getText("TXT_KEY_MSG_CIVILIAN_CAPTIVE", iCount) CyInterface().addMessage(iPlayer, False, 15, sMessage, '', 0, 'Art/Interface/Buttons/Civics/Serfdom.dds', ColorTypes(44), X, Y, True, True)
def getGreatGeneralText(iNeededExp): return BugUtil.getText("INTERFACE_NEXT_GREAT_GENERAL_XP", (g_cGreatGeneral, iNeededExp))
def format(self, player, trade): return BugUtil.getText(self.key, (self.getParameters(player, trade),))
def getTradePeaceDeal(player, trade): BugUtil.debug("TradeUtil - peace treaty has iData %d", trade.iData) return BugUtil.getText("TXT_KEY_TRADE_PEACE_TREATY_STRING", (gc.getDefineINT("PEACE_TREATY_LENGTH"),))
def display(self, eActivePlayer, key, players): for ePlayer in players: player = gc.getPlayer(ePlayer) if player.isAlive(): message = BugUtil.getText(key, player.getName()) addMessageNoIcon(eActivePlayer, message)
def display(self): BugUtil.error(BugUtil.getText(self.key, self.args))
def display(self, eActivePlayer, key, players): for ePlayer in players: player = gc.getPlayer(ePlayer) if player.isAlive(): message = BugUtil.getText(key, player.getName()) addMessageNoIcon(eActivePlayer, message)
def create(self, screen): tab = self.createTab(screen) panel = self.createMainPanel(screen) #Standard Settings self.addLabel(screen, panel, "AutomatedSettings__AutomatedSettings") column = self.addOneColumnLayout(screen, panel, panel) left, right = self.addTwoColumnLayout(screen, column, "Options", False) screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Pillage Options self.addLabel(screen, left, "AutomatedSettings__PillageSettings") col1, col2, col3 = self.addMultiColumnLayout(screen, right, 3, "Automate_Pillage") self.addCheckbox(screen, col1, "AutomatedSettings__AvoidEnemyUnits") self.addCheckbox(screen, col2, "AutomatedSettings__AvoidBarbarianCities") self.addCheckbox(screen, col3, "AutomatedSettings__HideAutomatePillage") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Hunt Options self.addLabel(screen, left, "AutomatedSettings__HuntSettings") col1, col2 = self.addMultiColumnLayout(screen, right, 2, "Automate_Hunt") self.addCheckbox(screen, col1, "AutomatedSettings__NoCapturingCities") self.addCheckbox(screen, col2, "AutomatedSettings__AllowUnitSuiciding") self.addCheckbox(screen, col1, "AutomatedSettings__HideAutomateHunt") self.addIntDropdown(screen, col2, col2, "AutomatedSettings__AutoHuntMinimumAttackOdds", True, "RIGHT") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Patrol Options: self.addLabel(screen, left, "AutomatedSettings__PatrolSettings") col1, col2, col3 = self.addMultiColumnLayout(screen, right, 3, "Automate_Patrol") self.addCheckbox(screen, col1, "AutomatedSettings__CanLeaveBorders") self.addCheckbox(screen, col2, "AutomatedSettings__AllowPatrolUnitSuiciding") self.addCheckbox(screen, col1, "AutomatedSettings__HideAutomatePatrol") self.addIntDropdown(screen, col2, col2, "AutomatedSettings__AutoPatrolMinimumAttackOdds", True, "RIGHT") self.addCheckbox(screen, col3, "AutomatedSettings__NoPatrolCapturingCities") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Defense Options: self.addLabel(screen, left, "AutomatedSettings__DefenseSettings") col1, col2, col3 = self.addMultiColumnLayout(screen, right, 3, "Automate_Defense") self.addCheckbox(screen, col1, "AutomatedSettings__CanLeaveCity") self.addCheckbox(screen, col2, "AutomatedSettings__HideAutomateDefense") self.addIntDropdown(screen, col3, col3, "AutomatedSettings__AutoDefenseMinimumAttackOdds", True, "RIGHT") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Air Options: self.addLabel(screen, left, "AutomatedSettings__AirSettings") col1, col2, col3 = self.addMultiColumnLayout(screen, right, 3, "Automate_Air") self.addCheckbox(screen, col1, "AutomatedSettings__AirUnitCanDefend") self.addCheckbox(screen, col2, "AutomatedSettings__AirUnitCanRebase") self.addCheckbox(screen, col3, "AutomatedSettings__HideAirAutomations") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Explore Options: self.addLabel(screen, left, "AutomatedSettings__ExploreSettings") col1, col2, col3 = self.addMultiColumnLayout(screen, right, 3, "Automate_Explore") self.addCheckbox(screen, col1, "AutomatedSettings__HideAutoExplore") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Spread Options: self.addLabel(screen, left, "AutomatedSettings__SpreadSettings") col1, col2, col3 = self.addMultiColumnLayout(screen, right, 3, "Automate_Spread") self.addCheckbox(screen, col1, "AutomatedSettings__HideAutoSpread") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Caravan Options: self.addLabel(screen, left, "AutomatedSettings__CaravanSettings") col1, col2, col3 = self.addMultiColumnLayout(screen, right, 3, "Automate_Caravan") self.addCheckbox(screen, col1, "AutomatedSettings__HideAutoCaravan") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Protect Options: self.addLabel(screen, left, "AutomatedSettings__ProtectSettings") col1, col2, col3 = self.addMultiColumnLayout(screen, right, 3, "Automate_Protect") self.addCheckbox(screen, col1, "AutomatedSettings__HideAutoProtect") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Pirate Options: self.addLabel(screen, left, "AutomatedSettings__PirateSettings") col1, col2, col3 = self.addMultiColumnLayout(screen, right, 3, "Automate_Pirate") self.addCheckbox(screen, col1, "AutomatedSettings__HideAutoPirate") self.addIntDropdown(screen, col2, col2, "AutomatedSettings__AutoPirateMinimumAttackOdds", True, "RIGHT") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Upgrading Options: self.addLabel(screen, left, "AutomatedSettings__UpgradingSettings") col1, col2 = self.addMultiColumnLayout(screen, right, 2, "Automate_Upgrading") self.addCheckbox(screen, col1, "AutomatedSettings__HideAutoUpgrade") self.addIntDropdown(screen, col2, col2, "AutomatedSettings__MinimumUpgradeGold", True, "RIGHT") self.addCheckbox(screen, col1, "AutomatedSettings__MostExpensive") self.addCheckbox(screen, col2, "AutomatedSettings__MostExpierenced") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Promote Options: self.addLabel(screen, left, "AutomatedSettings__PromoteSettings") col1, col2 = self.addMultiColumnLayout(screen, right, 2, "Automate_Promote") self.addCheckbox(screen, col1, "AutomatedSettings__HideAutoPromote") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Worker Options: self.addLabel(screen, left, "AutomatedSettings__WorkerSettings") self.addCheckbox(screen, left, "AutomatedSettings__ShowCityAutomations") bFirst = True global g_BuildNames if g_BuildNames == None: self.normalizeBuildNames() player = gc.getPlayer(gc.getGame().getActivePlayer()) team = gc.getTeam(gc.getGame().getActiveTeam()) (loopCity, iter) = player.firstCity(False) if ANewDawnOpt.isShowCityAutomations(): while (loopCity): BugUtil.debug("Timer") if not bFirst: self.addSpacer(screen, left, "City Spacer") bFirst = False szCityName = remove_diacriticals(loopCity.getName()) self.addLabel( screen, left, str( BugUtil.getText( "TXT_KEY_AUTOMATED_WORKERS_CAN_BUILD_CITY", szCityName)), str( BugUtil.getText( "TXT_KEY_AUTOMATED_WORKERS_CAN_BUILD_CITY", szCityName)), None, False, True) col1, col2, col3, col4, col5 = self.addMultiColumnLayout( screen, left, 5, "Automate_Workers") iCount = 0 for iI in range(gc.getNumBuildInfos()): if (team.isHasTech(gc.getBuildInfo(iI).getTechPrereq())): columnKey = self.determineColumnPlacement( 5, iCount, (col1, col2, col3, col4, col5)) control = str(szCityName + gc.getBuildInfo(iI).getDescription() + "Check") bEnabled = loopCity.isAutomatedCanBuild(iI) szNewDescription = g_BuildNames[iI] screen.attachCheckBox( columnKey, control, szNewDescription, "CvOptionsScreenCallbackInterface", "handleAutomatedBuildCheckboxClicked", control, bEnabled) screen.setToolTip( control, BugUtil.getText( "TXT_KEY_AUTOMATED_WORKERS_CAN_BUILD", (szCityName, szNewDescription))) iCount += 1 (loopCity, iter) = player.nextCity(iter, False) self.addSpacer(screen, left, "City Spacer") self.addLabel(screen, left, "AutomatedSettings__NationalWorkerSettings") self.addLabel(screen, left, "AutomatedSettings__NationalWorkerSettingsHover") col1, col2, col3, col4, col5 = self.addMultiColumnLayout( screen, left, 5, "Automate_Workers") iCount = 0 for iI in range(gc.getNumBuildInfos()): if (team.isHasTech(gc.getBuildInfo(iI).getTechPrereq())): columnKey = self.determineColumnPlacement( 5, iCount, (col1, col2, col3, col4, col5)) control = str( remove_diacriticals(player.getNameKey() + gc.getBuildInfo(iI).getDescription() + "Check")) bEnabled = player.isAutomatedCanBuild(iI) szNewDescription = g_BuildNames[iI] screen.attachCheckBox( columnKey, control, szNewDescription, "CvOptionsScreenCallbackInterface", "handleNationalAutomatedBuildCheckboxClicked", control, bEnabled) screen.setToolTip( control, BugUtil.getText( "TXT_KEY_NATIONAL_AUTOMATED_WORKERS_CAN_BUILD", szNewDescription)) iCount += 1