def checkTurn(self, iGameTurn): if data.iRomanPigs == 1: self.doRomanPigs() data.iRomanPigs = 0 # Gujarati horses appear later so Harappa cannot benefit too early if iGameTurn == getTurnForYear(-1000): self.createResource(104, 43, iHorse) self.removeResource(89, 47) # Assyrian copper appears later to prevent Babylonia from building too strong a defensive military if iGameTurn == getTurnForYear(-800): self.createResource(78, 42, iCopper) # Leoreth: to do new map # Tamils, 300 BC elif iGameTurn == getTurnForYear( tBirth[iTamils]) - 1 and data.isPlayerEnabled(iTamils): self.createResource(108, 34, iFish) #Orka: Silk Road elif iGameTurn == getTurnForYear(-200): for i in range(len(lSilkRoute)): gc.getMap().plot(lSilkRoute[i][0], lSilkRoute[i][1]).setRouteType(iRoad) #Orka: Silk Road elif iGameTurn == getTurnForYear(-100): gc.getMap().plot(104, 56).setPlotType(PlotTypes.PLOT_HILLS, True, True) gc.getMap().plot(104, 56).setRouteType(iRoad) self.createResource(103, 55, iSilk) self.createResource(101, 53, iSilk) #Leoreth: Hanseong's pig appears later so China isn't that eager to found Sanshan elif iGameTurn == getTurnForYear(-50): self.createResource(129, 57, iPig) # Leoreth: remove floodplains in Sudan and ivory in Morocco and Tunisia elif iGameTurn == getTurnForYear(550): gc.getMap().plot(79, 37).setFeatureType(-1, 0) gc.getMap().plot(79, 38).setFeatureType(-1, 0) self.removeResource(59, 44) self.removeResource(67, 46) # Leoreth: prepare Tibet, 630 AD elif iGameTurn == getTurnForYear( tBirth[iTibet]) - 1 and data.isPlayerEnabled(iTibet): self.createResource(114, 51, iWheat) self.createResource(113, 49, iHorse) # Leoreth: obstacles for colonization elif iGameTurn == getTurnForYear(700): gc.getMap().plot(38, 64).setFeatureType(iMud, 0) for x, y in lNewfoundlandCapes: gc.getMap().plot(x, y).setFeatureType(iCape, 0) if utils.getHumanID() == iVikings: gc.getMap().plot(45, 72).setFeatureType(-1, 0) # Leoreth: for respawned Egypt elif iGameTurn == getTurnForYear(900): self.createResource(81, 42, iIron) # Leoreth: New Guinea can be settled elif iGameTurn == getTurnForYear(1000): gc.getMap().plot(113, 25).setFeatureType(-1, 0) elif iGameTurn == getTurnForYear(1100): #gc.getMap().plot(71, 30).setBonusType(iSugar) #Egypt self.createResource(84, 28, iSugar) # East Africa self.createResource(81, 19, iSugar) # Zimbabwe self.createResource(77, 13, iSugar) # South Africa self.createResource(72, 25, iBanana) # Central Africa self.createResource(77, 26, iBanana) # Central Africa if data.isPlayerEnabled(iCongo): self.createResource(70, 27, iCotton) # Congo self.createResource(71, 23, iIvory) # Congo self.createResource(69, 28, iIvory) # Cameroon self.createResource(66, 56, iWine) # Savoy self.createResource(66, 54, iClam) # Savoy self.createResource(56, 52, iIron) # Portugal self.removeResource(87, 49) # Orduqent # Leoreth: to do new map self.removeResource(89, 51) # Orduqent # Leoreth: to do new map # Leoreth: route to connect Karakorum to Beijing and help the Mongol attackers elif iGameTurn == getTurnForYear(tBirth[iMongolia]): for tPlot in [(119, 61), (120, 60), (121, 59), (122, 58), (122, 57), (123, 57)]: x, y = tPlot gc.getMap().plot(x, y).setRouteType(iRoad) # silk near Astrakhan self.createResource(91, 60, iSilk) if iGameTurn == getTurnForYear(1250): #gc.getMap().plot(57, 52).setBonusType(iWheat) #Amsterdam self.createResource(113, 41, iFish) # Calcutta, Dhaka, Pagan #elif iGameTurn == getTurnForYear(1350): #gc.getMap().plot(102, 35).setFeatureType(-1, 0) #remove rainforest in Vietnam elif iGameTurn == getTurnForYear(1500): gc.getMap().plot(38, 64).setFeatureType( -1, 0) # remove Marsh in case it had been placed for x, y in lNewfoundlandCapes: gc.getMap().plot(x, y).setFeatureType(-1, 0) # also remove Marsh on Port Moresby gc.getMap().plot(116, 24).setFeatureType(-1, 0) gc.getMap().plot(63, 65).setFeatureType(-1, 0) gc.getMap().plot(64, 65).setFeatureType(-1, 0) gc.getMap().plot(59, 65).setFeatureType(-1, 0) gc.getMap().plot(28, 35).setFeatureType(-1, 0) gc.getMap().plot(69, 65).setFeatureType(-1, 0) gc.getMap().plot(78, 75).setFeatureType(-1, 0) gc.getMap().plot(79, 63).setFeatureType(-1, 0) gc.getMap().plot(79, 64).setFeatureType(-1, 0) gc.getMap().plot(79, 75).setFeatureType(-1, 0) gc.getMap().plot(80, 64).setFeatureType(-1, 0) #self.createResource(56, 54, iFish) # Amsterdam #self.createResource(57, 52, iWheat) # Amsterdam #self.createResource(58, 52, iCow) # Amsterdam elif (iGameTurn == getTurnForYear(1600)): self.createResource(23, 57, iIron) # Indianapolis self.createResource(28, 56, iIron) # Quebec self.createResource(31, 63, iIron) # Quebec self.createResource(22, 62, iCopper) # Kenora self.createResource(24, 60, iCopper) # Williams Lake self.createResource(26, 61, iCopper) # Williams Lake self.createResource(30, 61, iCow) # Montreal self.createResource(15, 62, iCow) # Alberta self.createResource(10, 62, iCow) # British Columbia self.createResource(29, 53, iCow) # Washington area self.createResource(32, 59, iCow) # Boston area #self.createResource(25, 49, iCow) # Lakes self.createResource(21, 49, iCow) # New Orleans area self.createResource(29, 58, iCow) # New York area self.createResource(16, 54, iCow) # Colorado self.createResource(17, 51, iCow) # Texas self.createResource(39, 12, iCow) # Argentina self.createResource(36, 9, iCow) # Pampas self.createResource(46, 29, iCow) # Brazil self.createResource(25, 51, iCotton) # near Florida self.createResource(23, 50, iCotton) # Louisiana self.createResource(21, 52, iCotton) # Louisiana self.createResource(10, 51, iCotton) # California self.createResource(25, 57, iPig) # Lakes self.createResource(24, 52, iPig) # Atlanta area self.createResource(13, 63, iSheep) # Alberta self.createResource(17, 58, iSheep) # Midwest self.createResource(36, 13, iSheep) # Argentina #self.createResource(21, 50, iWheat) # Canadian border self.createResource(17, 54, iWheat) # Midwest self.createResource(20, 63, iWheat) # Manitoba self.createResource(23, 39, iBanana) # Guatemala self.createResource(29, 35, iBanana) # Colombia self.createResource(42, 31, iBanana) # Brazil self.createResource(49, 29, iBanana) # Brazil self.createResource(55, 52, iCorn) # Galicia self.createResource(61, 56, iCorn) # France self.createResource(74, 58, iCorn) # Hungary self.createResource(77, 57, iCorn) # Romania self.createResource(129, 59, iCorn) # Manchuria self.createResource(125, 55, iCorn) # Beijing #self.createResource(77, 52, iCorn) # Caricyn self.createResource(63, 65, iPotato) # Amsterdam self.createResource(65, 64, iPotato) # Amsterdam self.createResource(58, 63, iPotato) # England self.createResource(108, 39, iSpices) # Deccan gc.getMap().plot(108, 39).setFeatureType(iRainforest, 0) # remove floodplains in Transoxania for tuple in [(97, 55), (96, 56)]: x, y = tuple gc.getMap().plot(x, y).setFeatureType(-1, 0) elif iGameTurn == getTurnForYear(1700): self.createResource(15, 63, iHorse) # Alberta self.createResource(28, 54, iHorse) # Washington area self.createResource(17, 59, iHorse) # Midwest self.createResource(20, 56, iHorse) # Midwest self.createResource(17, 52, iHorse) # Texas self.createResource(45, 30, iHorse) # Brazil self.createResource(38, 12, iHorse) # Buenos Aires area self.createResource(35, 10, iHorse) # Pampas self.createResource(28, 42, iSugar) # Caribbean self.createResource(37, 41, iSugar) # Caribbean self.createResource(39, 34, iSugar) # Guayana self.createResource(44, 30, iSugar) # Brazil self.createResource(42, 23, iSugar) # inner Brazil self.createResource(31, 43, iSugar) # Hispaniola self.createResource(43, 19, iCoffee) # Brazil self.createResource(44, 23, iCoffee) # Brazil self.createResource(43, 26, iCoffee) # Brazil self.createResource(29, 31, iCoffee) # Colombia self.createResource(28, 34, iCoffee) # Colombia self.createResource(34, 36, iCoffee) # Colombia self.createResource(119, 28, iCoffee) # Sumatra self.createResource(25, 45, iCoffee) # Cuba self.createResource(32, 43, iCocoa) # Hispaniola self.createResource(124, 25, iCocoa) # Java self.createResource(129, 27, iCocoa) # Clebes self.createResource(46, 29, iCocoa) # Brazil self.createResource(78, 56, iTobacco) # Turkey self.createResource(106, 39, iTea) # West Bengal self.createResource(44, 19, iFish) # Brazil self.createResource(31, 14, iFish) # Chile # self.createResource(70, 59, iDeer) # St Petersburg self.createResource(68, 64, iPotato) # Germany self.createResource(71, 63, iPotato) # Germany self.createResource(93, 62, iPotato) # Caricyn self.createResource(123, 48, iPotato) # China self.createResource(127, 51, iPotato) # China self.createResource(130, 60, iPotato) # Manchuria self.createResource(105, 45, iPotato) # India self.createResource(113, 44, iPotato) # Bangladesh elif iGameTurn == getTurnForYear(1800): if gc.getDefineINT("PLAYER_REBIRTH_MEXICO") != 0: self.createResource(16, 47, iHorse) # Mexico self.createResource(14, 45, iIron) # Mexico self.createResource(16, 44, iCow) # Mexico if gc.getDefineINT("PLAYER_REBIRTH_COLOMBIA") != 0: self.createResource(30, 36, iIron) # Colombia if data.isPlayerEnabled(iArgentina): self.createResource(35, 14, iWine) # Mendoza, Argentina self.createResource(35, 7, iSheep) # Pampas, Argentina self.createResource(35, 15, iIron) # Argentina if data.isPlayerEnabled(iBrazil): self.createResource(43, 19, iCorn) # Sao Paulo self.createResource(47, 23, iCow) # Rio de Janeiro self.createResource(42, 25, iBanana) # Brasilia elif iGameTurn == getTurnForYear(1850): self.createResource(8, 52, iWine) # California self.createResource(35, 10, iWine) # Andes self.createResource(137, 11, iWine) # Barossa Valley, Australia self.createResource(138, 10, iSheep) # Australia self.createResource(140, 14, iSheep) # Australia self.createResource(146, 6, iSheep) # New Zealand # self.createResource(58, 47, iRice) # Vercelli self.createResource(8, 56, iRice) # California self.createResource(9, 50, iFish) # California self.createResource(102, 37, iFish) # Bombay self.createResource(137, 62, iCow) # Hokkaido self.createResource(0, 43, iSugar) # Hawaii self.createResource(2, 42, iBanana) # Hawaii self.createResource(10, 59, iPotato) # Seattle self.createResource(58, 32, iCocoa) # West Africa self.createResource(61, 31, iCocoa) # West Africa self.createResource(67, 31, iCocoa) # West Africa # flood plains in California for tPlot in [(9, 52), (9, 53), (8, 54), (9, 55)]: x, y = tPlot gc.getMap().plot(x, y).setFeatureType(iFloodPlains, 0)
def placeStats(self): screen = CyGInterfaceScreen( "WBPlayerScreen", CvScreenEnums.WB_PLAYER) iLeader = pPlayer.getLeaderType() iCiv = pPlayer.getCivilizationType() screen.addDDSGFC("LeaderPic", gc.getLeaderHeadInfo(iLeader).getButton(), screen.getXResolution() * 3/8 - self.iIconSize/2, 80, self.iIconSize, self.iIconSize, WidgetTypes.WIDGET_PYTHON, 7876, iLeader) screen.addDDSGFC("CivPic", gc.getCivilizationInfo(iCiv).getButton(), screen.getXResolution() * 5/8 - self.iIconSize/2, 80, self.iIconSize, self.iIconSize, WidgetTypes.WIDGET_PYTHON, 7872, iCiv) sText = pPlayer.getName() lTraits = [] for iTrait in xrange(gc.getNumTraitInfos()): if pPlayer.hasTrait(iTrait): lTraits.append(iTrait) if len(lTraits): sText += " [" for iTrait in xrange(len(lTraits)): sText += CyTranslator().getText(gc.getTraitInfo(lTraits[iTrait]).getShortDescription(),()) if iTrait != len(lTraits) -1: sText += "/" sText += "]" sText += " (ID: " + str(pPlayer.getID()) + ")" screen.setLabel("PlayerName", "Background", "<font=4b>" + sText + "</font>", CvUtil.FONT_CENTER_JUSTIFY, screen.getXResolution()/2, 20, -0.1, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) screen.setLabel("CivilizationName", "Background", "<font=4b>" + pPlayer.getCivilizationDescription(0) + "</font>", CvUtil.FONT_CENTER_JUSTIFY, screen.getXResolution()/2, 50, -0.1, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) iY = 110 screen.setButtonGFC("PlayerGoldPlus", "", "", 20, iY, 24, 24, WidgetTypes.WIDGET_PYTHON, 1030, -1, ButtonStyles.BUTTON_STYLE_CITY_PLUS) screen.setButtonGFC("PlayerGoldMinus", "", "", 45, iY, 24, 24, WidgetTypes.WIDGET_PYTHON, 1031, -1, ButtonStyles.BUTTON_STYLE_CITY_MINUS) sText = u"%s %s%c" %(CyTranslator().getText("TXT_KEY_WB_GOLD", ()), CvPlatyBuilderScreen.CvWorldBuilderScreen().addComma(pPlayer.getGold()), gc.getCommerceInfo(CommerceTypes.COMMERCE_GOLD).getChar()) screen.setLabel("PlayerGoldText", "Background", "<font=3>" + sText + "</font>", CvUtil.FONT_LEFT_JUSTIFY, 75, iY + 1, -0.1, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) iY += 30 screen.setButtonGFC("CombatXPPlus", "", "", 20, iY, 24, 24, WidgetTypes.WIDGET_PYTHON, 1030, -1, ButtonStyles.BUTTON_STYLE_CITY_PLUS) screen.setButtonGFC("CombatXPMinus", "", "", 45, iY, 24, 24, WidgetTypes.WIDGET_PYTHON, 1031, -1, ButtonStyles.BUTTON_STYLE_CITY_MINUS) sText = u"%s: %d/%d" %(CyTranslator().getText("TXT_KEY_MISC_COMBAT_EXPERIENCE", ()), pPlayer.getCombatExperience(), pPlayer.greatPeopleThreshold(True)) screen.setLabel("CombatXPText", "Background", "<font=3>" + sText + "</font>", CvUtil.FONT_LEFT_JUSTIFY, 75, iY + 1, -0.1, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) iY += 30 screen.setButtonGFC("GoldenAgePlus", "", "", 20, iY, 24, 24, WidgetTypes.WIDGET_PYTHON, 1030, -1, ButtonStyles.BUTTON_STYLE_CITY_PLUS) screen.setButtonGFC("GoldenAgeMinus", "", "", 45, iY, 24, 24, WidgetTypes.WIDGET_PYTHON, 1031, -1, ButtonStyles.BUTTON_STYLE_CITY_MINUS) sText = u"%s: %d" %(CyTranslator().getText("TXT_KEY_CONCEPT_GOLDEN_AGE", ()), pPlayer.getGoldenAgeTurns()) screen.setLabel("GoldenAgeText", "Background", "<font=3>" + sText + "</font>", CvUtil.FONT_LEFT_JUSTIFY, 75, iY + 1, -0.1, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) iY += 30 screen.setButtonGFC("GPRequiredPlus", "", "", 20, iY, 24, 24, WidgetTypes.WIDGET_PYTHON, 1030, -1, ButtonStyles.BUTTON_STYLE_CITY_PLUS) screen.setButtonGFC("GPRequiredMinus", "", "", 45, iY, 24, 24, WidgetTypes.WIDGET_PYTHON, 1031, -1, ButtonStyles.BUTTON_STYLE_CITY_MINUS) sText = CyTranslator().getText("TXT_KEY_WB_GOLDEN_AGE_UNITS", (pPlayer.unitsRequiredForGoldenAge(),)) screen.setLabel("GPRequiredText", "Background", "<font=3>" + sText + "</font>", CvUtil.FONT_LEFT_JUSTIFY, 75, iY + 1, -0.1, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) iY += 30 screen.setButtonGFC("AnarchyPlus", "", "", 20, iY, 24, 24, WidgetTypes.WIDGET_PYTHON, 1030, -1, ButtonStyles.BUTTON_STYLE_CITY_PLUS) screen.setButtonGFC("AnarchyMinus", "", "", 45, iY, 24, 24, WidgetTypes.WIDGET_PYTHON, 1031, -1, ButtonStyles.BUTTON_STYLE_CITY_MINUS) sText = CyTranslator().getText("TXT_KEY_WB_ANARCHY", (pPlayer.getAnarchyTurns(),)) screen.setLabel("AnarchyText", "Background", "<font=3>" + sText + "</font>", CvUtil.FONT_LEFT_JUSTIFY, 75, iY + 1, -0.1, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) iY += 30 screen.setButtonGFC("CoastalTradePlus", "", "", 20, iY, 24, 24, WidgetTypes.WIDGET_PYTHON, 1030, -1, ButtonStyles.BUTTON_STYLE_CITY_PLUS) screen.setButtonGFC("CoastalTradeMinus", "", "", 45, iY, 24, 24, WidgetTypes.WIDGET_PYTHON, 1031, -1, ButtonStyles.BUTTON_STYLE_CITY_MINUS) sText = CyTranslator().getText("TXT_KEY_WB_COASTAL_TRADE", (pPlayer.getCoastalTradeRoutes(),)) screen.setLabel("CoastalTradeText", "Background", "<font=3>" + sText + "</font>", CvUtil.FONT_LEFT_JUSTIFY, 75, iY + 1, -0.1, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) iY += 30 for i in xrange(CommerceTypes.NUM_COMMERCE_TYPES): iX = 20 screen.hide("CommerceFlexiblePlus" + str(i)) screen.hide("CommerceFlexibleMinus" + str(i)) sColor = CyTranslator().getText("[COLOR_WARNING_TEXT]", ()) if pPlayer.isCommerceFlexible(i): sColor = CyTranslator().getText("[COLOR_POSITIVE_TEXT]", ()) screen.setButtonGFC("CommerceFlexiblePlus" + str(i), "", "", iX, iY, 24, 24, WidgetTypes.WIDGET_PYTHON, 1030, i, ButtonStyles.BUTTON_STYLE_CITY_PLUS) screen.setButtonGFC("CommerceFlexibleMinus" + str(i), "", "", iX + 25, iY, 24, 24, WidgetTypes.WIDGET_PYTHON, 1031, i, ButtonStyles.BUTTON_STYLE_CITY_MINUS) sText = sColor + u"<font=3>%c: %d%% %s</color></font>" %(gc.getCommerceInfo(i).getChar(), pPlayer.getCommercePercent(i), CyTranslator().getText("TXT_KEY_MISC_POS_GOLD_PER_TURN", (pPlayer.getCommerceRate(CommerceTypes(i)),))) screen.setText("AdjustCommerceFlexible" + gc.getCommerceInfo(i).getType(), "Background", "<font=3>" + sText + "</font>", CvUtil.FONT_LEFT_JUSTIFY, iX + 50, iY + 1, -0.1, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_PYTHON, 7881, i) iY += 30 #Merijn: Place Civenabled buttons iY += 30 if iPlayer in lSecondaryCivs: if data.isPlayerEnabled(iPlayer): screen.setButtonGFC("CivEnabledButton", "", gc.getMissionInfo(gc.getInfoTypeForString("MISSION_FOUND")).getButton(), iX, iY, 64, 64, WidgetTypes.WIDGET_PYTHON, 22001, 0, ButtonStyles.BUTTON_STYLE_STANDARD) else: screen.setButtonGFC("CivEnabledButton", "", CyArtFileMgr().getInterfaceArtInfo("INTERFACE_BUTTONS_CANCEL").getPath(), iX, iY, 64, 64, WidgetTypes.WIDGET_PYTHON, 22001, 1, ButtonStyles.BUTTON_STYLE_STANDARD)
def handleInput (self, inputClass): screen = CyGInterfaceScreen( "WBPlayerScreen", CvScreenEnums.WB_PLAYER) global iChange global bRemove if inputClass.getFunctionName() == "ChangeBy": iChange = screen.getPullDownData("ChangeBy", screen.getSelectedPullDownID("ChangeBy")) if bRemove: iChange = -screen.getPullDownData("ChangeBy", screen.getSelectedPullDownID("ChangeBy")) else: iChange = screen.getPullDownData("ChangeBy", screen.getSelectedPullDownID("ChangeBy")) elif inputClass.getFunctionName() == "CurrentPage": iIndex = screen.getPullDownData("CurrentPage", screen.getSelectedPullDownID("CurrentPage")) if iIndex == 1: WBTeamScreen.WBTeamScreen().interfaceScreen(iTeam) elif iIndex == 2: WBProjectScreen.WBProjectScreen().interfaceScreen(iTeam) elif iIndex == 3: WBTechScreen.WBTechScreen().interfaceScreen(iTeam) elif iIndex == 4: WBPlayerUnits.WBPlayerUnits().interfaceScreen(iPlayer) elif iIndex == 8: WBReligionScreen.WBReligionScreen().interfaceScreen(iPlayer) elif iIndex == 9: WBCorporationScreen.WBCorporationScreen().interfaceScreen(iPlayer) elif iIndex == 11: WBInfoScreen.WBInfoScreen().interfaceScreen(iPlayer) elif inputClass.getFunctionName() == "CurrentPlayer": iIndex = screen.getPullDownData("CurrentPlayer", screen.getSelectedPullDownID("CurrentPlayer")) self.interfaceScreen(iIndex) elif inputClass.getFunctionName() == "CurrentEra": pPlayer.setCurrentEra(screen.getPullDownData("CurrentEra", screen.getSelectedPullDownID("CurrentEra"))) dc.checkName(iPlayer) elif inputClass.getFunctionName().find("PlayerGold") > -1: if inputClass.getData1() == 1030: pPlayer.changeGold(iChange) elif inputClass.getData1() == 1031: pPlayer.changeGold(- min(iChange, pPlayer.getGold())) self.placeStats() elif inputClass.getFunctionName().find("CombatXP") > -1: if inputClass.getData1() == 1030: pPlayer.changeCombatExperience(min(iChange, pPlayer.greatPeopleThreshold(True) - pPlayer.getCombatExperience())) elif inputClass.getData1() == 1031: pPlayer.changeCombatExperience(- min(iChange, pPlayer.getCombatExperience())) self.placeStats() elif inputClass.getFunctionName().find("GoldenAge") > -1: if inputClass.getData1() == 1030: pPlayer.changeGoldenAgeTurns(iChange) elif inputClass.getData1() == 1031: pPlayer.changeGoldenAgeTurns(- min(iChange, pPlayer.getGoldenAgeTurns())) self.placeStats() elif inputClass.getFunctionName().find("GPRequired") > -1: if inputClass.getData1() == 1030: pPlayer.changeNumUnitGoldenAges(iChange) elif inputClass.getData1() == 1031: pPlayer.changeNumUnitGoldenAges(- min(iChange, pPlayer.unitsRequiredForGoldenAge() - 1)) self.placeStats() elif inputClass.getFunctionName().find("Anarchy") > -1: if inputClass.getData1() == 1030: pPlayer.changeAnarchyTurns(iChange) elif inputClass.getData1() == 1031: pPlayer.changeAnarchyTurns(- min(iChange, pPlayer.getAnarchyTurns())) self.placeStats() elif inputClass.getFunctionName().find("CoastalTrade") > -1: if inputClass.getData1() == 1030: pPlayer.changeCoastalTradeRoutes(min(iChange, gc.getDefineINT("MAX_TRADE_ROUTES") - pPlayer.getCoastalTradeRoutes())) elif inputClass.getData1() == 1031: pPlayer.changeCoastalTradeRoutes(- min(iChange, pPlayer.getCoastalTradeRoutes())) self.placeStats() elif inputClass.getFunctionName().find("CommerceFlexible") > -1: iCommerce = CommerceTypes(inputClass.getData2()) if inputClass.getData1() == 1030: if pPlayer.isCommerceFlexible(iCommerce): pPlayer.changeCommercePercent(iCommerce, iChange) elif inputClass.getData1() == 1031: if pPlayer.isCommerceFlexible(iCommerce): pPlayer.changeCommercePercent(iCommerce, - min(iChange, pPlayer.getCommercePercent(iCommerce))) elif inputClass.getData1() == 7881: if pPlayer.isCommerceFlexible(iCommerce): pTeam.changeCommerceFlexibleCount(iCommerce, - pTeam.getCommerceFlexibleCount(iCommerce)) else: pTeam.changeCommerceFlexibleCount(iCommerce, 1) self.placeStats() elif inputClass.getFunctionName() == "WBPlayerResearch": iTech = inputClass.getData2() if iTech == -1: pPlayer.clearResearchQueue() else: pPlayer.pushResearch(iTech, True) self.interfaceScreen(iPlayer) elif inputClass.getFunctionName().find("CurrentResearch") > -1: iTech = pPlayer.getCurrentResearch() if iTech > -1: if inputClass.getData1() == 1030: pTeam.changeResearchProgress(pPlayer.getCurrentResearch(), min(iChange, pTeam.getResearchCost(iTech) - pTeam.getResearchProgress(iTech)), iPlayer) elif inputClass.getData1() == 1031: pTeam.changeResearchProgress(pPlayer.getCurrentResearch(), - min(iChange, pTeam.getResearchProgress(iTech)), iPlayer) self.placeResearch() elif inputClass.getFunctionName() == "WBPlayerReligions": iReligion = inputClass.getData1() pPlayer.setLastStateReligion(inputClass.getData1()) # dc.checkName(iPlayer) self.placeReligions() elif inputClass.getFunctionName().find("StateReligionUnit") > -1: if inputClass.getData1() == 1030: pPlayer.changeStateReligionUnitProductionModifier(iChange) elif inputClass.getData1() == 1031: pPlayer.changeStateReligionUnitProductionModifier(- min(iChange, pPlayer.getStateReligionUnitProductionModifier())) self.placeReligions() elif inputClass.getFunctionName().find("StateReligionBuilding") > -1: if inputClass.getData1() == 1030: pPlayer.changeStateReligionBuildingProductionModifier(iChange) elif inputClass.getData1() == 1031: pPlayer.changeStateReligionBuildingProductionModifier(- min(iChange, pPlayer.getStateReligionBuildingProductionModifier())) self.placeReligions() elif inputClass.getFunctionName() == "WBPlayerCivics": iCivic = inputClass.getData2() if pPlayer.canDoCivics(iCivic) or not CvPlatyBuilderScreen.bHideInactive: pPlayer.setCivics(gc.getCivicInfo(iCivic).getCivicOptionType(), iCivic) dc.checkName(iPlayer) self.interfaceScreen(iPlayer) elif inputClass.getFunctionName() == "CivEnabledButton": data.setPlayerEnabled(iPlayer, not data.isPlayerEnabled(iPlayer)) self.interfaceScreen(iPlayer) elif inputClass.getFunctionName() == "PlayerEditScriptData": popup = Popup.PyPopup(1111, EventContextTypes.EVENTCONTEXT_ALL) popup.setHeaderString(CyTranslator().getText("TXT_KEY_WB_SCRIPT", ())) popup.setUserData((pPlayer.getID(),)) popup.createEditBox(pPlayer.getScriptData()) popup.launch() return elif inputClass.getFunctionName().find("ModifierButton") > -1: iModifier = inputClass.getData2() iModifierValue = pPlayer.getModifier(iModifier) if inputClass.getData1() == 1030: pPlayer.setModifier(iModifier, iModifierValue + abs(iChange)) elif inputClass.getData1() == 1031: pPlayer.setModifier(iModifier, iModifierValue - abs(iChange)) self.placeModifiers() elif inputClass.getFunctionName() == "ModifierResetButton": self.placeModifiers(inputClass.getData1() == 1) elif inputClass.getFunctionName().find("ModifierRevertButton") > -1: iModifier = inputClass.getData1() iModifierValue = Modifiers.getAdjustedModifier(iPlayer, iModifier) pPlayer.setModifier(iModifier, iModifierValue) self.placeModifiers(True) elif inputClass.getFunctionName() == "HideInactive": CvPlatyBuilderScreen.bHideInactive = not CvPlatyBuilderScreen.bHideInactive CvPlatyBuilderScreen.CvWorldBuilderScreen().refreshSideMenu() sText = u"<font=3b>" + CyTranslator().getText("TXT_KEY_PEDIA_HIDE_INACTIVE", ()) + "</font>" sColor = CyTranslator().getText("[COLOR_WARNING_TEXT]", ()) if CvPlatyBuilderScreen.bHideInactive: sColor = CyTranslator().getText("[COLOR_POSITIVE_TEXT]", ()) screen.setText("HideInactive", "Background", sColor + sText + "</color>", CvUtil.FONT_LEFT_JUSTIFY, screen.getXResolution()/4 - 25, 20, -0.1, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) self.placeReligions() self.placeCivics() return 1
def handleInput(self, inputClass): screen = CyGInterfaceScreen("WBGameDataScreen", CvScreenEnums.WB_GAMEDATA) global iChange global bHiddenOption global bRepeat global iSelectedCiv global iSelectedLeader global bRemove if inputClass.getFunctionName() == "CurrentPage": iIndex = screen.getPullDownData( "CurrentPage", screen.getSelectedPullDownID("CurrentPage")) if iIndex == 8: WBReligionScreen.WBReligionScreen().interfaceScreen( self.top.m_iCurrentPlayer) elif iIndex == 9: WBCorporationScreen.WBCorporationScreen().interfaceScreen( self.top.m_iCurrentPlayer) elif iIndex == 11: WBInfoScreen.WBInfoScreen().interfaceScreen( self.top.m_iCurrentPlayer) elif iIndex == 12: WBStoredDataScreen.WBStoredDataScreen( self.top).interfaceScreen() elif iIndex == 13: WBPlayerEnabledScreen.WBPlayerEnabledScreen( self.top).interfaceScreen() elif inputClass.getFunctionName() == "ChangeBy": if bRemove: iChange = -screen.getPullDownData( "ChangeBy", screen.getSelectedPullDownID("ChangeBy")) else: iChange = screen.getPullDownData( "ChangeBy", screen.getSelectedPullDownID("ChangeBy")) elif inputClass.getFunctionName() == "ChangeType": bRemove = not bRemove iChange = -iChange elif inputClass.getFunctionName().find("StartYear") > -1: if inputClass.getData1() == 1030: CyGame().setStartYear(CyGame().getStartYear() + abs(iChange)) elif inputClass.getData1() == 1031: CyGame().setStartYear(CyGame().getStartYear() - abs(iChange)) self.placeStats() elif inputClass.getFunctionName().find("MaxCityElimination") > -1: if inputClass.getData1() == 1030: CyGame().setMaxCityElimination( CyGame().getMaxCityElimination() + abs(iChange)) elif inputClass.getData1() == 1031: CyGame().setMaxCityElimination( max(0, CyGame().getMaxCityElimination() - abs(iChange))) self.placeStats() elif inputClass.getFunctionName().find("GameTurn") > -1: if inputClass.getData1() == 1030: iChange = min( abs(iChange), CyGame().getMaxTurns() - CyGame().getElapsedGameTurns()) CyGame().setGameTurn(CyGame().getGameTurn() + iChange) CyGame().changeMaxTurns(-iChange) elif inputClass.getData1() == 1031: iChange = min(CyGame().getGameTurn(), abs(iChange)) CyGame().setGameTurn(CyGame().getGameTurn() - iChange) CyGame().changeMaxTurns(iChange) self.placeStats() elif inputClass.getFunctionName().find("TargetScore") > -1: if inputClass.getData1() == 1030: CyGame().setTargetScore(CyGame().getTargetScore() + abs(iChange)) elif inputClass.getData1() == 1031: CyGame().setTargetScore( max(0, CyGame().getTargetScore() - abs(iChange))) self.placeStats() elif inputClass.getFunctionName().find("EstimateEndTurn") > -1: if inputClass.getData1() == 1030: CyGame().setEstimateEndTurn(CyGame().getEstimateEndTurn() + iChange) elif inputClass.getData1() == 1031: CyGame().setEstimateEndTurn( max(0, CyGame().getEstimateEndTurn() - iChange)) self.placeStats() elif inputClass.getFunctionName().find("NukesExploded") > -1: if inputClass.getData1() == 1030: CyGame().changeNukesExploded(abs(iChange)) elif inputClass.getData1() == 1031: CyGame().changeNukesExploded( -min(CyGame().getNukesExploded(), abs(iChange))) self.placeStats() elif inputClass.getFunctionName().find("MaxTurns") > -1: if inputClass.getData1() == 1030: CyGame().changeMaxTurns(abs(iChange)) elif inputClass.getData1() == 1031: CyGame().changeMaxTurns( -min(CyGame().getMaxTurns(), abs(iChange))) self.placeStats() elif inputClass.getFunctionName().find("TradeRoutes") > -1: if inputClass.getData1() == 1030: CyGame().changeTradeRoutes( min( abs(iChange), gc.getDefineINT("MAX_TRADE_ROUTES") - gc.getDefineINT("INITIAL_TRADE_ROUTES") - CyGame().getTradeRoutes())) elif inputClass.getData1() == 1031: CyGame().changeTradeRoutes( -min(CyGame().getTradeRoutes(), abs(iChange))) self.placeStats() elif inputClass.getFunctionName().find("AIAutoPlay") > -1: if inputClass.getData1() == 1030: CyGame().setAIAutoPlay(CyGame().getAIAutoPlay() + abs(iChange)) elif inputClass.getData1() == 1031: CyGame().setAIAutoPlay( max(0, CyGame().getAIAutoPlay() - abs(iChange))) self.placeStats() elif inputClass.getFunctionName() == "WBGameOptions": iGameOption = inputClass.getData2() if iGameOption < gc.getNumGameOptionInfos(): CyGame().setOption(iGameOption, not CyGame().isOption(iGameOption)) self.checkOptions(iGameOption) else: # Enabling/disabling secondary civs if iGameOption < 2000: iItem = iGameOption - 1000 data.setPlayerEnabled(iItem, not data.isPlayerEnabled(iItem)) # Enabling/disabling RFC options elif iGameOption == 2000: data.bIgnoreAI = not data.bIgnoreAI elif iGameOption == 2001: data.bUnlimitedSwitching = not data.bUnlimitedSwitching elif iGameOption == 2002: data.bNoCongressOption = not data.bNoCongressOption elif iGameOption == 2003: data.bNoPlagues = not data.bNoPlagues # Stored Variables elif iGameOption == 3001: data.bAlreadySwitched = not data.bAlreadySwitched elif iGameOption == 3002 and cong.isCongressEnabled(): data.iCongressTurns = max(1, data.iCongressTurns + iChange) self.placeGameOptions() elif inputClass.getFunctionName() == "HiddenOptions": bHiddenOption = not bHiddenOption self.placeGameOptions() elif inputClass.getFunctionName() == "AllowsRepeat": bRepeat = not bRepeat iSelectedCiv = -1 iSelectedLeader = -1 self.placeNewPlayer() elif inputClass.getFunctionName() == "WBNewCiv": iSelectedCiv = inputClass.getData2() iSelectedLeader = -1 self.interfaceScreen() elif inputClass.getFunctionName() == "WBNewLeader": iSelectedLeader = inputClass.getData2() self.interfaceScreen() elif inputClass.getFunctionName() == "CreatePlayer": for i in xrange(gc.getMAX_CIV_PLAYERS()): if not gc.getPlayer(i).isEverAlive(): CyGame().addPlayer(i, iSelectedLeader, iSelectedCiv) break screen.hideScreen() self.top.m_iCurrentPlayer = i self.top.normalPlayerTabModeCB() elif inputClass.getFunctionName() == "GameEditScriptData": popup = Popup.PyPopup(4444, EventContextTypes.EVENTCONTEXT_ALL) popup.setHeaderString(CyTranslator().getText( "TXT_KEY_WB_SCRIPT", ())) popup.createEditBox(CyGame().getScriptData()) popup.launch() return 1
def placeGameOptions(self): screen = CyGInterfaceScreen("WBGameDataScreen", CvScreenEnums.WB_GAMEDATA) sColor = CyTranslator().getText("[COLOR_WARNING_TEXT]", ()) if bHiddenOption: sColor = CyTranslator().getText("[COLOR_POSITIVE_TEXT]", ()) screen.setText( "HiddenOptions", "Background", "<font=3b>" + sColor + CyTranslator().getText("TXT_KEY_WB_SHOW_HIDDEN", ()) + "</color></font>", CvUtil.FONT_RIGHT_JUSTIFY, screen.getXResolution() - 20, self.iGameOption_Y - 30, -0.1, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) iWidth = screen.getXResolution() - 40 iHeight = (screen.getYResolution() - self.iGameOption_Y - 40) / 24 * 24 + 2 nColumns = 3 iWidth1 = 80 iWidth2 = iWidth / nColumns - iWidth1 screen.addTableControlGFC("WBGameOptions", nColumns * 2, 20, self.iGameOption_Y, iWidth, iHeight, False, False, 24, 24, TableStyles.TABLE_STYLE_STANDARD) for i in xrange(nColumns): screen.setTableColumnHeader("WBGameOptions", i * 2, "", iWidth2) screen.setTableColumnHeader("WBGameOptions", i * 2 + 1, "", iWidth1) lList = [] for item in xrange(gc.getNumGameOptionInfos()): Info = gc.getGameOptionInfo(item) if Info.getVisible() or bHiddenOption: lList.append([Info.getDescription(), item]) lList.sort() # Merijn: Add extra DoC options lList2 = [] lList2.append( [CyTranslator().getText("TXT_KEY_WB_IGNORE_AI_UHV", ()), 2000]) lList2.append([ CyTranslator().getText("TXT_KEY_WB_UNLIMITED_SWITCHING", ()), 2001 ]) lList2.append( [CyTranslator().getText("TXT_KEY_WB_NO_CONGRESS", ()), 2002]) lList2.append( [CyTranslator().getText("TXT_KEY_WB_NO_PLAGUE", ()), 2003]) lList2.sort() # Stored variables lList3 = [] lList3.append( [CyTranslator().getText("TXT_KEY_WB_ALREADY_SWITCHED", ()), 3001]) lList3.append( [CyTranslator().getText("TXT_KEY_WB_CONGRESS_TURNS", ()), 3002]) lList3.sort() iNumRows = (len(lList) + nColumns - 1) / nColumns iNumRows2 = iNumRows + 3 + max(len(lSecondaryCivs), len(lList2), len(lList3)) for i in xrange(iNumRows2): screen.appendTableRow("WBGameOptions") for i in xrange(len(lList)): iColumn = i / iNumRows iRow = i % iNumRows item = lList[i][1] bEnabled = CyGame().isOption(item) bDefault = False if item in [6, 11]: # Aggressive AI, No Tech Brokering bDefault = True sText = self.colorText(lList[i][0], bEnabled) screen.setTableText("WBGameOptions", iColumn * 2, iRow, sText, "", WidgetTypes.WIDGET_PYTHON, 1028, item, CvUtil.FONT_LEFT_JUSTIFY) sText = self.colorText( CyTranslator().getText("TXT_KEY_WB_DEFAULT", ()), bDefault) screen.setTableText("WBGameOptions", iColumn * 2 + 1, iRow, sText, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_CENTER_JUSTIFY) # Merijn: extra rows for secondary civs and RFC options screen.setTableText( "WBGameOptions", 0, iNumRows + 2, CyTranslator().getText("TXT_KEY_WB_SECONDARY_CIVS", ()), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY) screen.setTableText( "WBGameOptions", 2, iNumRows + 2, CyTranslator().getText("TXT_KEY_WB_RFC_OPTIONS", ()), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY) screen.setTableText( "WBGameOptions", 4, iNumRows + 2, CyTranslator().getText("TXT_KEY_WB_RFC_VARIABLES", ()), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY) iRow = iNumRows + 3 for iCiv in lSecondaryCivs: bEnabled = data.isPlayerEnabled(iCiv) bDefault = True if iCiv in [iHarappa, iPolynesia]: bDefault = False sText = self.colorText( gc.getPlayer(iCiv).getCivilizationShortDescription(0), bEnabled) screen.setTableText("WBGameOptions", 0, iRow, sText, "", WidgetTypes.WIDGET_PYTHON, 1028, 1000 + iCiv, CvUtil.FONT_LEFT_JUSTIFY) sText = self.colorText( CyTranslator().getText("TXT_KEY_WB_DEFAULT", ()), bDefault) screen.setTableText("WBGameOptions", 1, iRow, sText, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_CENTER_JUSTIFY) iRow += 1 for i in xrange(len(lList2)): item = lList2[i][1] iRow = iNumRows + 3 + i bEnabled = False bDefault = False if item == 2000: bEnabled = data.bIgnoreAI bDefault = True elif item == 2001: bEnabled = data.bUnlimitedSwitching elif item == 2002: bEnabled = data.bNoCongressOption elif item == 2003: bEnabled = data.bNoPlagues sText = self.colorText(lList2[i][0], bEnabled) screen.setTableText("WBGameOptions", 2, iRow, sText, "", WidgetTypes.WIDGET_PYTHON, 1028, item, CvUtil.FONT_LEFT_JUSTIFY) sText = self.colorText( CyTranslator().getText("TXT_KEY_WB_DEFAULT", ()), bDefault) screen.setTableText("WBGameOptions", 3, iRow, sText, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_CENTER_JUSTIFY) for i in xrange(len(lList3)): item = lList3[i][1] iRow = iNumRows + 3 + i bEnabled = False bWhite = False if item == 3001: bEnabled = data.bAlreadySwitched elif item == 3002: bWhite = True sText = self.colorText(lList3[i][0], bEnabled, bWhite) screen.setTableText("WBGameOptions", 4, iRow, sText, "", WidgetTypes.WIDGET_PYTHON, 1028, item, CvUtil.FONT_LEFT_JUSTIFY) if item == 3002: if not cong.isCongressEnabled(): iTurns = -1 else: iTurns = data.iCongressTurns sText = self.colorText(str(iTurns), True, True) screen.setTableText("WBGameOptions", 5, iRow, sText, "", WidgetTypes.WIDGET_PYTHON, 1028, item, CvUtil.FONT_CENTER_JUSTIFY)
def checkTurn(self, iGameTurn): # Gujarati horses appear later so Harappa cannot benefit too early; also Harappan Stone turns to Marble if iGameTurn == getTurnForYear(-1000): self.removeResource(86, 39) self.createResource(88, 37, iHorse) self.createResource(86, 39, iMarble) # Tamils, 300 BC elif iGameTurn == getTurnForYear(tBirth[iTamils])-1 and data.isPlayerEnabled(iTamils): self.createResource(90, 28, iFish) #Orka: Silk Road elif iGameTurn == getTurnForYear(-200): for i in range( len(lSilkRoute) ): gc.getMap().plot(lSilkRoute[i][0], lSilkRoute[i][1]).setRouteType(iRoad) #Orka: Silk Road elif iGameTurn == getTurnForYear(-100): gc.getMap().plot(88, 47).setPlotType(PlotTypes.PLOT_HILLS, True, True) gc.getMap().plot(88, 47).setRouteType(iRoad) self.createResource(88, 47, iSilk) self.createResource(85, 46, iSilk) #Leoreth: Hanseong's pig appears later so China isn't that eager to found Sanshan elif iGameTurn == getTurnForYear(-50): self.createResource(108, 47, iPig) # Leoreth: remove floodplains in Sudan and ivory in Morocco and Tunisia elif iGameTurn == getTurnForYear(550): gc.getMap().plot(67, 30).setFeatureType(-1, 0) gc.getMap().plot(67, 31).setFeatureType(-1, 0) self.removeResource(51, 36) self.removeResource(58, 37) self.createResource(68, 45, iSilk) #Silk in Constantinople # Leoreth: prepare Tibet, 630 AD elif iGameTurn == getTurnForYear(tBirth[iTibet])-1 and data.isPlayerEnabled(iTibet): self.createResource(95, 43, iWheat) self.createResource(97, 44, iHorse) # Leoreth: obstacles for colonization elif iGameTurn == getTurnForYear(700): gc.getMap().plot(35, 54).setFeatureType(iMud, 0) for x, y in lNewfoundlandCapes: gc.getMap().plot(x, y).setFeatureType(iCape, 0) if utils.getHumanID() == iVikings: gc.getMap().plot(41, 58).setFeatureType(-1, 0) # Leoreth: New Guinea can be settled elif iGameTurn == getTurnForYear(1000): gc.getMap().plot(113, 25).setFeatureType(-1, 0) # Leoreth: for respawned Egypt elif iGameTurn == getTurnForYear(900): self.removeResource(71, 34) self.createResource(71, 34, iIron) # Knoedel: Remove Greek Silver elif iGameTurn == getTurnForYear(-300): self.removeResource(66, 40) # Knoedel: Remove Greek Gold elif iGameTurn == getTurnForYear(-400): self.removeResource(67, 44) elif iGameTurn == getTurnForYear(1100): #gc.getMap().plot(71, 30).setBonusType(iSugar) #Egypt self.createResource(72, 24, iSugar) # East Africa self.createResource(70, 17, iSugar) # Zimbabwe self.createResource(67, 11, iSugar) # South Africa self.createResource(66, 23, iBanana) # Central Africa self.createResource(64, 20, iBanana) # Central Africa if data.isPlayerEnabled(iCongo): self.createResource(61, 22, iCotton) # Congo self.createResource(63, 19, iIvory) # Congo self.createResource(61, 24, iIvory) # Cameroon self.createResource(57, 46, iWine) # Savoy self.createResource(57, 45, iClam) # Savoy self.createResource(50, 44, iIron) # Portugal # Leoreth: route to connect Karakorum to Beijing and help the Mongol attackers elif iGameTurn == getTurnForYear(tBirth[iMongolia]): for tPlot in [(101, 48), (100, 49), (100, 50), (99, 50)]: x, y = tPlot gc.getMap().plot(x, y).setRouteType(iRoad) # silk near Astrakhan self.createResource(78, 51, iSilk) if iGameTurn == getTurnForYear(1250): #gc.getMap().plot(57, 52).setBonusType(iWheat) #Amsterdam self.createResource(96, 36, iFish) # Calcutta, Dhaka, Pagan self.createResource(60, 44, iSilk) # Silk in Rome elif iGameTurn == getTurnForYear(1350): gc.getMap().plot(102, 35).setFeatureType(-1, 0) #remove rainforest in Vietnam elif iGameTurn == getTurnForYear(1500): gc.getMap().plot(35, 54).setFeatureType(-1, 0) # remove Marsh in case it had been placed for x, y in lNewfoundlandCapes: gc.getMap().plot(x, y).setFeatureType(-1, 0) # also remove Marsh on Port Moresby gc.getMap().plot(116, 24).setFeatureType(-1, 0) self.createResource(56, 54, iFish) # Amsterdam self.createResource(57, 52, iWheat) # Amsterdam self.createResource(58, 52, iCow) # Amsterdam elif (iGameTurn == getTurnForYear(1600)): self.createResource(29, 52, iCow) # Montreal self.createResource(18, 53, iCow) # Alberta self.createResource(12, 52, iCow) # British Columbia self.createResource(28, 46, iCow) # Washington area self.createResource(30, 49, iCow) # New York area #self.createResource(25, 49, iCow) # Lakes self.createResource(23, 42, iCow) # Jacksonville area self.createResource(18, 46, iCow) # Colorado self.createResource(20, 45, iCow) # Texas self.createResource(37, 14, iCow) # Argentina self.createResource(33, 11, iCow) # Argentina self.createResource(35, 10, iCow) # Pampas self.createResource(24, 43, iCotton) # near Florida self.createResource(23, 45, iCotton) # Louisiana self.createResource(22, 44, iCotton) # Louisiana self.createResource(13, 45, iCotton) # California self.createResource(26, 49, iPig) # Lakes self.createResource(19, 51, iSheep) # Canadian border #self.createResource(21, 50, iWheat) # Canadian border self.createResource(19, 48, iWheat) # Midwest self.createResource(20, 53, iWheat) # Manitoba self.createResource(22, 33, iBanana) # Guatemala self.createResource(27, 31, iBanana) # Colombia self.createResource(43, 23, iBanana) # Brazil self.createResource(39, 26, iBanana) # Brazil self.createResource(49, 44, iCorn) # Galicia self.createResource(54, 48, iCorn) # France self.createResource(67, 47, iCorn) # Romania self.createResource(106, 50, iCorn) # Manchuria self.createResource(77, 52, iCorn) # Caricyn self.removeResource(49, 57) # remove Irish Horse self.createResource(49, 57, iCorn) # Irish Potatoes self.createResource(62, 59, iCorn) # Scandinavia self.createResource(63, 53, iCorn) # Germany self.createResource(67, 56, iCorn) # Baltic self.createResource(92, 35, iSpices) # Deccan gc.getMap().plot(92, 35).setFeatureType(iRainforest, 0) # remove floodplains in Transoxania for tuple in [(82, 47), (83, 46), (85, 49)]: x, y = tuple gc.getMap().plot(x, y).setFeatureType(-1, 0) elif iGameTurn == getTurnForYear(1700): self.createResource(16, 54, iHorse) # Alberta self.createResource(26, 45, iHorse) # Washington area self.createResource(21, 48, iHorse) # Midwest self.createResource(19, 45, iHorse) # Texas self.createResource(40, 25, iHorse) # Brazil self.createResource(33, 10, iHorse) # Buenos Aires area self.createResource(32, 8, iHorse) # Pampas self.createResource(27, 36, iSugar) # Caribbean self.createResource(39, 25, iSugar) # Brazil self.createResource(37, 20, iSugar) # inner Brazil self.createResource(29, 37, iSugar) # Hispaniola self.createResource(104, 52, iCorn) # Manchuria self.createResource(89, 36, iCorn) # India self.createResource(38, 18, iCoffee) # Brazil self.createResource(39, 20, iCoffee) # Brazil self.createResource(38, 22, iCoffee) # Brazil self.createResource(27, 30, iCoffee) # Colombia self.createResource(29, 30, iCoffee) # Colombia self.createResource(26, 27, iCoffee) # Colombia self.createResource(104, 25, iCoffee) # Java self.createResource(67, 44, iTobacco) # Turkey self.createResource(90, 35, iTea) # West Bengal self.createResource(39, 16, iFish) # Brazil self.createResource(70, 59, iDeer) # St Petersburg elif iGameTurn == getTurnForYear(1800): if gc.getDefineINT("PLAYER_REBIRTH_MEXICO") != 0: self.createResource(17, 41, iHorse) # Mexico self.createResource(16, 42, iIron) # Mexico if gc.getDefineINT("PLAYER_REBIRTH_COLOMBIA") != 0: self.createResource(28, 31, iIron) # Colombia # 2nd UU: Move banana 1W, add horse on old spot self.removeResource(27, 31) self.createResource(27, 31, iHorse) # Colombia self.createResource(26, 31, iBanana) # Colombia gc.getMap().plot(27, 31).setFeatureType(-1, 0) if gc.getMap().plot(27, 31).getImprovementType() != -1: gc.getMap().plot(26, 31).setImprovementType(iPlantation) gc.getMap().plot(27, 31).setImprovementType(-1) if data.isPlayerEnabled(iArgentina): self.createResource(31, 10, iWine) # Mendoza, Argentina self.createResource(31, 6, iSheep) # Pampas, Argentina self.createResource(32, 11, iIron) # Argentina if data.isPlayerEnabled(iBrazil): self.createResource(36, 18, iCorn) # Sao Paulo self.createResource(42, 18, iFish) # Rio de Janeiro elif iGameTurn == getTurnForYear(1850): self.createResource(12, 45, iWine) # California self.createResource(31, 10, iWine) # Andes self.createResource(113, 12, iWine) # Barossa Valley, Australia self.createResource(114, 11, iSheep) # Australia self.createResource(116, 13, iSheep) # Australia self.createResource(121, 6, iSheep) # New Zealand self.createResource(58, 47, iRice) # Vercelli self.createResource(12, 49, iRice) # California self.createResource(11, 45, iFish) # California #self.createResource(10, 45, iFish) # California self.createResource(87, 35, iFish) # Bombay self.createResource(115, 52, iCow) # Hokkaido self.createResource(1, 38, iSugar) # Hawaii self.createResource(5, 36, iBanana) # Hawaii # flood plains in California for tPlot in [(11, 46), (11, 47), (11, 48)]: x, y = tPlot gc.getMap().plot(x,y).setFeatureType(3, 0)
def handleInput(self, inputClass): screen = CyGInterfaceScreen("WBGameDataScreen", CvScreenEnums.WB_GAMEDATA) global iChange global bHiddenOption global bRepeat global iSelectedCiv global iSelectedLeader global bRemove if inputClass.getFunctionName() == "CurrentPage": iIndex = screen.getPullDownData("CurrentPage", screen.getSelectedPullDownID("CurrentPage")) if iIndex == 8: WBReligionScreen.WBReligionScreen().interfaceScreen(self.top.m_iCurrentPlayer) elif iIndex == 9: WBCorporationScreen.WBCorporationScreen().interfaceScreen(self.top.m_iCurrentPlayer) elif iIndex == 11: WBInfoScreen.WBInfoScreen().interfaceScreen(self.top.m_iCurrentPlayer) elif iIndex == 12: WBStoredDataScreen.WBStoredDataScreen(self.top).interfaceScreen() elif inputClass.getFunctionName() == "ChangeBy": if bRemove: iChange = -screen.getPullDownData("ChangeBy", screen.getSelectedPullDownID("ChangeBy")) else: iChange = screen.getPullDownData("ChangeBy", screen.getSelectedPullDownID("ChangeBy")) elif inputClass.getFunctionName() == "ChangeType": bRemove = not bRemove iChange = -iChange elif inputClass.getFunctionName().find("StartYear") > -1: if inputClass.getData1() == 1030: CyGame().setStartYear(CyGame().getStartYear() + abs(iChange)) elif inputClass.getData1() == 1031: CyGame().setStartYear(CyGame().getStartYear() - abs(iChange)) self.placeStats() elif inputClass.getFunctionName().find("MaxCityElimination") > -1: if inputClass.getData1() == 1030: CyGame().setMaxCityElimination(CyGame().getMaxCityElimination() + abs(iChange)) elif inputClass.getData1() == 1031: CyGame().setMaxCityElimination(max(0, CyGame().getMaxCityElimination() - abs(iChange))) self.placeStats() elif inputClass.getFunctionName().find("GameTurn") > -1: if inputClass.getData1() == 1030: iChange = min(abs(iChange), CyGame().getMaxTurns() - CyGame().getElapsedGameTurns()) CyGame().setGameTurn(CyGame().getGameTurn() + iChange) CyGame().changeMaxTurns(- iChange) elif inputClass.getData1() == 1031: iChange = min(CyGame().getGameTurn(), abs(iChange)) CyGame().setGameTurn(CyGame().getGameTurn() - iChange) CyGame().changeMaxTurns(iChange) self.placeStats() elif inputClass.getFunctionName().find("TargetScore") > -1: if inputClass.getData1() == 1030: CyGame().setTargetScore(CyGame().getTargetScore() + abs(iChange)) elif inputClass.getData1() == 1031: CyGame().setTargetScore(max(0, CyGame().getTargetScore() - abs(iChange))) self.placeStats() elif inputClass.getFunctionName().find("EstimateEndTurn") > -1: if inputClass.getData1() == 1030: CyGame().setEstimateEndTurn(CyGame().getEstimateEndTurn() + iChange) elif inputClass.getData1() == 1031: CyGame().setEstimateEndTurn(max(0, CyGame().getEstimateEndTurn() - iChange)) self.placeStats() elif inputClass.getFunctionName().find("NukesExploded") > -1: if inputClass.getData1() == 1030: CyGame().changeNukesExploded(abs(iChange)) elif inputClass.getData1() == 1031: CyGame().changeNukesExploded(- min(CyGame().getNukesExploded(), abs(iChange))) self.placeStats() elif inputClass.getFunctionName().find("MaxTurns") > -1: if inputClass.getData1() == 1030: CyGame().changeMaxTurns(abs(iChange)) elif inputClass.getData1() == 1031: CyGame().changeMaxTurns(- min(CyGame().getMaxTurns(), abs(iChange))) self.placeStats() elif inputClass.getFunctionName().find("TradeRoutes") > -1: if inputClass.getData1() == 1030: CyGame().changeTradeRoutes(min(abs(iChange), gc.getDefineINT("MAX_TRADE_ROUTES") - gc.getDefineINT("INITIAL_TRADE_ROUTES") - CyGame().getTradeRoutes())) elif inputClass.getData1() == 1031: CyGame().changeTradeRoutes(- min(CyGame().getTradeRoutes(), abs(iChange))) self.placeStats() elif inputClass.getFunctionName().find("AIAutoPlay") > -1: if inputClass.getData1() == 1030: CyGame().setAIAutoPlay(CyGame().getAIAutoPlay() + abs(iChange)) elif inputClass.getData1() == 1031: CyGame().setAIAutoPlay(max(0, CyGame().getAIAutoPlay() - abs(iChange))) self.placeStats() elif inputClass.getFunctionName() == "WBGameOptions": iGameOption = inputClass.getData2() if iGameOption < gc.getNumGameOptionInfos(): CyGame().setOption(iGameOption, not CyGame().isOption(iGameOption)) self.checkOptions(iGameOption) else: # Enabling/disabling secondary civs if iGameOption < 2000: iItem = iGameOption - 1000 data.setPlayerEnabled(iItem, not data.isPlayerEnabled(iItem)) # Enabling/disabling RFC options elif iGameOption == 2000: data.bNoAIStability = not data.bNoAIStability elif iGameOption == 2001: data.bNoHumanStability = not data.bNoHumanStability elif iGameOption == 2002: data.bIgnoreAI = not data.bIgnoreAI elif iGameOption == 2003: data.bUnlimitedSwitching = not data.bUnlimitedSwitching elif iGameOption == 2004: data.bNoCongressOption = not data.bNoCongressOption elif iGameOption == 2005: data.bNoPlagues = not data.bNoPlagues # Stored Variables elif iGameOption == 3001: data.bAlreadySwitched = not data.bAlreadySwitched elif iGameOption == 3002 and cong.isCongressEnabled(): data.iCongressTurns = max(1, data.iCongressTurns+iChange) self.placeGameOptions() elif inputClass.getFunctionName() == "HiddenOptions": bHiddenOption = not bHiddenOption self.placeGameOptions() elif inputClass.getFunctionName() == "AllowsRepeat": bRepeat = not bRepeat iSelectedCiv = -1 iSelectedLeader = -1 self.placeNewPlayer() elif inputClass.getFunctionName() == "WBNewCiv": iSelectedCiv = inputClass.getData2() iSelectedLeader = -1 self.interfaceScreen() elif inputClass.getFunctionName() == "WBNewLeader": iSelectedLeader = inputClass.getData2() self.interfaceScreen() elif inputClass.getFunctionName() == "CreatePlayer": for i in xrange(gc.getMAX_CIV_PLAYERS()): if not gc.getPlayer(i).isEverAlive(): CyGame().addPlayer(i, iSelectedLeader, iSelectedCiv) break screen.hideScreen() self.top.m_iCurrentPlayer = i self.top.normalPlayerTabModeCB() elif inputClass.getFunctionName() == "GameEditScriptData": popup = Popup.PyPopup(4444, EventContextTypes.EVENTCONTEXT_ALL) popup.setHeaderString(CyTranslator().getText("TXT_KEY_WB_SCRIPT", ())) popup.createEditBox(CyGame().getScriptData()) popup.launch() return 1
def placeGameOptions(self): screen = CyGInterfaceScreen( "WBGameDataScreen", CvScreenEnums.WB_GAMEDATA) sColor = CyTranslator().getText("[COLOR_WARNING_TEXT]", ()) if bHiddenOption: sColor = CyTranslator().getText("[COLOR_POSITIVE_TEXT]", ()) screen.setText("HiddenOptions", "Background", "<font=3b>" + sColor + CyTranslator().getText("TXT_KEY_WB_SHOW_HIDDEN",()) + "</color></font>", CvUtil.FONT_RIGHT_JUSTIFY, screen.getXResolution() - 20, self.iGameOption_Y - 30, -0.1, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) iWidth = screen.getXResolution() - 40 iHeight = (screen.getYResolution() - self.iGameOption_Y - 40) /24 * 24 + 2 nColumns = 3 iWidth1 = 80 iWidth2 = iWidth / nColumns - iWidth1 screen.addTableControlGFC("WBGameOptions", nColumns * 2, 20, self.iGameOption_Y, iWidth, iHeight, False, False, 24, 24, TableStyles.TABLE_STYLE_STANDARD) for i in xrange(nColumns): screen.setTableColumnHeader("WBGameOptions", i * 2, "", iWidth2) screen.setTableColumnHeader("WBGameOptions", i * 2 + 1, "", iWidth1) lList = [] for item in xrange(gc.getNumGameOptionInfos()): Info = gc.getGameOptionInfo(item) if Info.getVisible() or bHiddenOption: lList.append([Info.getDescription(), item]) lList.sort() # Merijn: Add extra DoC options lList2 = [] lList2.append([CyTranslator().getText("TXT_KEY_WB_NO_STABILITY", ()), 2000]) lList2.append([CyTranslator().getText("TXT_KEY_WB_NO_HUMAN_STABILITY", ()), 2001]) lList2.append([CyTranslator().getText("TXT_KEY_WB_IGNORE_AI_UHV", ()), 2002]) lList2.append([CyTranslator().getText("TXT_KEY_WB_UNLIMITED_SWITCHING", ()), 2003]) lList2.append([CyTranslator().getText("TXT_KEY_WB_NO_CONGRESS", ()), 2004]) lList2.append([CyTranslator().getText("TXT_KEY_WB_NO_PLAGUE", ()), 2005]) lList2.sort() # Stored variables lList3 = [] lList3.append([CyTranslator().getText("TXT_KEY_WB_ALREADY_SWITCHED", ()), 3001]) lList3.append([CyTranslator().getText("TXT_KEY_WB_CONGRESS_TURNS", ()), 3002]) lList3.sort() iNumRows = (len(lList) + nColumns - 1) / nColumns iNumRows2 = iNumRows + 3 + max(len(lSecondaryCivs), len(lList2), len(lList3)) for i in xrange(iNumRows2): screen.appendTableRow("WBGameOptions") for i in xrange(len(lList)): iColumn = i / iNumRows iRow = i % iNumRows item = lList[i][1] bEnabled = CyGame().isOption(item) bDefault = False if item in [6, 11]: # Aggressive AI, No Tech Brokering bDefault = True sText = self.colorText(lList[i][0], bEnabled) screen.setTableText("WBGameOptions", iColumn * 2, iRow, sText, "", WidgetTypes.WIDGET_PYTHON, 1028, item, CvUtil.FONT_LEFT_JUSTIFY) sText = self.colorText(CyTranslator().getText("TXT_KEY_WB_DEFAULT", ()), bDefault) screen.setTableText("WBGameOptions", iColumn * 2 + 1, iRow, sText, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_CENTER_JUSTIFY) # Merijn: extra rows for secondary civs and RFC options screen.setTableText("WBGameOptions", 0, iNumRows + 2, CyTranslator().getText("TXT_KEY_WB_SECONDARY_CIVS", ()), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY) screen.setTableText("WBGameOptions", 2, iNumRows + 2, CyTranslator().getText("TXT_KEY_WB_RFC_OPTIONS", ()), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY) screen.setTableText("WBGameOptions", 4, iNumRows + 2, CyTranslator().getText("TXT_KEY_WB_RFC_VARIABLES", ()), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY) iRow = iNumRows + 3 for iCiv in lSecondaryCivs: bEnabled = data.isPlayerEnabled(iCiv) bDefault = True if iCiv in [iHarappa, iPolynesia]: bDefault = False sText = self.colorText(gc.getPlayer(iCiv).getCivilizationShortDescription(0), bEnabled) screen.setTableText("WBGameOptions", 0, iRow, sText, "", WidgetTypes.WIDGET_PYTHON, 1028, 1000+iCiv, CvUtil.FONT_LEFT_JUSTIFY) sText = self.colorText(CyTranslator().getText("TXT_KEY_WB_DEFAULT", ()), bDefault) screen.setTableText("WBGameOptions", 1, iRow, sText, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_CENTER_JUSTIFY) iRow += 1 for i in xrange(len(lList2)): item = lList2[i][1] iRow = iNumRows + 3 + i bEnabled = False bDefault = False if item == 2000: bEnabled = data.bNoAIStability elif item == 2001: bEnabled = data.bNoHumanStability elif item == 2002: bEnabled = data.bIgnoreAI bDefault = True elif item == 2003: bEnabled = data.bUnlimitedSwitching elif item == 2004: bEnabled = data.bNoCongressOption elif item == 2005: bEnabled = data.bNoPlagues sText = self.colorText(lList2[i][0], bEnabled) screen.setTableText("WBGameOptions", 2, iRow, sText, "", WidgetTypes.WIDGET_PYTHON, 1028, item, CvUtil.FONT_LEFT_JUSTIFY) sText = self.colorText(CyTranslator().getText("TXT_KEY_WB_DEFAULT", ()), bDefault) screen.setTableText("WBGameOptions", 3, iRow, sText, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_CENTER_JUSTIFY) for i in xrange(len(lList3)): item = lList3[i][1] iRow = iNumRows + 3 + i bEnabled = False bWhite = False if item == 3001: bEnabled = data.bAlreadySwitched elif item == 3002: bWhite = True sText = self.colorText(lList3[i][0], bEnabled, bWhite) screen.setTableText("WBGameOptions", 4, iRow, sText, "", WidgetTypes.WIDGET_PYTHON, 1028, item, CvUtil.FONT_LEFT_JUSTIFY) if item == 3002: if not cong.isCongressEnabled(): iTurns = -1 else: iTurns = data.iCongressTurns sText = self.colorText(str(iTurns), True, True) screen.setTableText("WBGameOptions", 5, iRow, sText, "", WidgetTypes.WIDGET_PYTHON, 1028, item, CvUtil.FONT_CENTER_JUSTIFY)