def getRiverScriptData(pPlot): """ Convert script data into river tile description object.""" riverDesc = RiverDesc() if pPlot is not None: scriptDict = CvUtil.getScriptData(pPlot, ["r"], None) if scriptDict is not None: riverDesc.loadScriptDict(scriptDict) return riverDesc
def doFogOfWar(iPlayer,iGameTurn): pPlayer = gc.getPlayer(iPlayer) iTeam = pPlayer.getTeam() pTeam = gc.getTeam(iTeam) # Human oder KI alle x Runden, aber unterschiedliche Civs pro Runde fuer optimale Rundenzeiten if pPlayer.isHuman() or (iGameTurn % 20 == iPlayer % 20 and pTeam.isMapTrading()): bDontGoBlackAnymore = False bShowCoasts = False bShowPeaksAndRivers = False if pTeam.isHasTech(gc.getInfoTypeForString("TECH_KARTOGRAPHIE2")): # Strassenkarten bDontGoBlackAnymore = True elif pTeam.isHasTech(gc.getInfoTypeForString("TECH_KARTEN")): # Karte zeichnen bShowCoasts = True bShowPeaksAndRivers = True elif pTeam.isHasTech(gc.getInfoTypeForString("TECH_KARTOGRAPHIE")): # Kartographie: Erste Karten bShowCoasts = True if bDontGoBlackAnymore: return iRange = CyMap().numPlots() for iI in xrange(iRange): pPlot = CyMap().plotByIndex(iI) if not pPlot.isVisible(iTeam, 0): bGoBlack = True # fully black or standard fog of war if pPlot.isCity(): pCity = pPlot.getPlotCity() if pCity.isCapital(): bGoBlack = False elif pCity.getNumWorldWonders() > 0: bGoBlack = False # Holy Mountain Quest if bGoBlack: if CvUtil.getScriptData(pPlot, ["H", "t"]) == "X": bGoBlack = False # Improvements (to normal fog of war) # if bGoBlack: # if pPlot.getImprovementType() == improv1 or pPlot.getImprovementType() == improv2: bGoBlack = False # 50% Chance Verdunkelung if bGoBlack and CvUtil.myRandom(2, "bGoBlack") == 0: bGoBlack = False # Black fog if bGoBlack and pPlot.isRevealed(iTeam, 0): # River and coast (land only) #if pPlot.isRevealed (iTeam, 0) and not (pPlot.isRiverSide() or pPlot.isCoastalLand()): pPlot.setRevealed (iTeam,0,0,-1) # River and coast (land and water) #if pPlot.isRevealed (iTeam, 0) and not (pPlot.isRiverSide() or pPlot.isCoastalLand() or (pPlot.isAdjacentToLand() and pPlot.isWater())): pPlot.setRevealed (iTeam,0,0,-1) if bShowCoasts and (pPlot.isCoastalLand() or pPlot.isAdjacentToLand() and pPlot.isWater()): continue if bShowPeaksAndRivers and (pPlot.isRiverSide() or pPlot.isPeak()): continue pPlot.setRevealed(iTeam, 0, 0, -1)
def onCityAcquired(pCity, iNewOwner): iCivRome = 0 # Capital: Rome iCivCarthage = 1 # Capital: Carthage sData = CvUtil.getScriptData(pCity.plot(), ["t"]) if sData == "Rome" and iNewOwner == iCivCarthage or sData == "Carthage" and iNewOwner == iCivRome: # PAE Movie if gc.getPlayer(iNewOwner).isHuman(): if iNewOwner == iCivRome: iMovie = 1 else: iMovie = 2 popupInfo = CyPopupInfo() popupInfo.setButtonPopupType( ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN) popupInfo.setData1(iMovie) # dynamicID in CvWonderMovieScreen popupInfo.setData2(0) # fix pCity.getID() popupInfo.setData3(3) # fix PAE Movie ID for victory movies popupInfo.setText(u"showWonderMovie") popupInfo.addPopup(iNewOwner) gc.getGame().setWinner(gc.getPlayer(iNewOwner).getTeam(), 2)
def drawContents(self): screen = self.getScreen() self.deleteAllWidgets() BUTTON_SIZE = 48 # +++ 1 +++ Units with trade routes lTradeUnitsLand = [ gc.getInfoTypeForString("UNIT_TRADE_MERCHANT"), gc.getInfoTypeForString("UNIT_CARAVAN") ] lTradeUnitsSea = [ gc.getInfoTypeForString("UNIT_TRADE_MERCHANTMAN"), gc.getInfoTypeForString("UNIT_GAULOS"), gc.getInfoTypeForString("UNIT_CARVEL_TRADE") ] list1 = [] list2 = [] pPlayer = gc.getPlayer(CyGame().getActivePlayer()) (unit, pIter) = pPlayer.firstUnit(False) while unit: if unit.getUnitType() in lTradeUnitsLand: if int(CvUtil.getScriptData(unit, ["autA"], 0)): list1.append(unit) elif unit.getUnitType() in lTradeUnitsSea: if int(CvUtil.getScriptData(unit, ["autA"], 0)): list2.append(unit) (unit, pIter) = pPlayer.nextUnit(pIter, False) # Zeige zuerst Landeinheiten, danach Schiffe lHandelseinheiten = list1 + list2 iY = 80 i = 0 iRange = len(lHandelseinheiten) if iRange == 0: szText = localText.getText("TXT_KEY_TRADE_ADVISOR_INFO2", ()) screen.setLabel("Label1_"+str(i), "Background", u"<font=3>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, 100, iY+20, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 ) else: for j in xrange(iRange): pUnit = lHandelseinheiten[j] screen.addPanel( "PanelBG_"+str(i), u"", u"", True, False, 40, iY, 935, 51, PanelStyles.PANEL_STYLE_MAIN_BLACK25 ) iY += 4 # Button unit screen.setImageButton("L1_"+str(i), pUnit.getButton(), 50, iY, BUTTON_SIZE, BUTTON_SIZE, WidgetTypes.WIDGET_GENERAL, 1, pUnit.getID()) # Unit name szText = pUnit.getName() screen.setLabel("L2_"+str(i), "Background", u"<font=3>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, 100, iY+5, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 ) # Unit load szText = localText.getText("TXT_UNIT_INFO_BAR_5", ()) + u" " iValue1 = CvUtil.getScriptData(pUnit, ["b"], -1) if iValue1 != -1: sBonusDesc = gc.getBonusInfo(iValue1).getDescription() iBonusChar = gc.getBonusInfo(iValue1).getChar() szText += localText.getText("TXT_UNIT_INFO_BAR_4", (iBonusChar,sBonusDesc)) else: szText += localText.getText("TXT_KEY_NO_BONUS_STORED", ()) screen.setLabel("L3_"+str(i), "Background", u"<font=3>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, 100, iY+24, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 ) # City 1 iCityX = int(CvUtil.getScriptData(pUnit, ["autX1"], -1)) iCityY = int(CvUtil.getScriptData(pUnit, ["autY1"], -1)) tmpPlot = CyMap().plot(iCityX, iCityY) if tmpPlot and not tmpPlot.isNone() and tmpPlot.isCity(): szText = tmpPlot.getPlotCity().getName() if tmpPlot.getOwner() == CyGame().getActivePlayer(): iTmpX = 470 else: iTmpX = 500 screen.setLabel("L4_"+str(i), "Background", u"<font=3>" + szText + u"</font>", CvUtil.FONT_RIGHT_JUSTIFY, iTmpX, iY+5, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 ) if tmpPlot.getOwner() != -1: iCiv = gc.getPlayer(tmpPlot.getOwner()).getCivilizationType() # Flagge if tmpPlot.getOwner() == CyGame().getActivePlayer(): screen.addFlagWidgetGFC("L5_"+str(i), 480, iY, 24, 54, tmpPlot.getOwner(), WidgetTypes.WIDGET_FLAG, tmpPlot.getOwner(), -1) # Civ-Button else: screen.setImageButton("L5_"+str(i), gc.getCivilizationInfo(iCiv).getButton(), 476, iY+24, 24, 24, WidgetTypes.WIDGET_PEDIA_JUMP_TO_CIV, iCiv, -1) szText = gc.getPlayer(tmpPlot.getOwner()).getCivilizationDescription(0) screen.setLabel("L6_"+str(i), "Background", u"<font=2>" + szText + u"</font>", CvUtil.FONT_RIGHT_JUSTIFY, 470, iY+28, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_PEDIA_JUMP_TO_CIV, iCiv, -1 ) # Button Bonus 1 iBonus = CvUtil.getScriptData(pUnit, ["autB1"], -1) if iBonus != -1: screen.setImageButton("L7_"+str(i), gc.getBonusInfo(iBonus).getButton(), 510, iY, BUTTON_SIZE, BUTTON_SIZE, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BONUS, iBonus, -1) # Buttons Arrow to left screen.setImageButton("L8_"+str(i), "Art/Interface/Buttons/arrow_left.tga", 580, iY+9, 32, 32, WidgetTypes.WIDGET_GENERAL, -1, -1) # Promotion Escort / Begleitschutz iPromo = gc.getInfoTypeForString("PROMOTION_SCHUTZ") if pUnit.isHasPromotion(iPromo): screen.setImageButton("L14_"+str(i), gc.getPromotionInfo(iPromo).getButton(), 615, iY+9, 32, 32, WidgetTypes.WIDGET_PEDIA_JUMP_TO_PROMOTION, iPromo, -1) # Button Arrow to right screen.setImageButton("L9_"+str(i), "Art/Interface/Buttons/arrow_right.tga", 650, iY+9, 32, 32, WidgetTypes.WIDGET_GENERAL, -1, -1) # Button Bonus 2 iBonus = CvUtil.getScriptData(pUnit, ["autB2"], -1) if iBonus != -1: screen.setImageButton("L10_"+str(i), gc.getBonusInfo(iBonus).getButton(), 700, iY, BUTTON_SIZE, BUTTON_SIZE, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BONUS, iBonus, -1) # City 2 iCityX = int(CvUtil.getScriptData(pUnit, ["autX2"], -1)) iCityY = int(CvUtil.getScriptData(pUnit, ["autY2"], -1)) tmpPlot = CyMap().plot(iCityX,iCityY) if tmpPlot and not tmpPlot.isNone() and tmpPlot.isCity(): szText = tmpPlot.getPlotCity().getName() if tmpPlot.getOwner() == CyGame().getActivePlayer(): iTmpX = 790 else: iTmpX = 760 screen.setLabel("L11_"+str(i), "Background", u"<font=3>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, iTmpX, iY+5, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 ) if tmpPlot.getOwner() != -1: iCiv = gc.getPlayer(tmpPlot.getOwner()).getCivilizationType() # Flagge if tmpPlot.getOwner() == CyGame().getActivePlayer(): screen.addFlagWidgetGFC("L12_"+str(i), 756, iY, 24, 54, tmpPlot.getOwner(), WidgetTypes.WIDGET_FLAG, tmpPlot.getOwner(), -1) # Civ-Button else: screen.setImageButton("L12_"+str(i), gc.getCivilizationInfo(iCiv).getButton(), 760, iY+24, 24, 24, WidgetTypes.WIDGET_PEDIA_JUMP_TO_CIV, iCiv, -1) szText = gc.getPlayer(tmpPlot.getOwner()).getCivilizationDescription(0) screen.setLabel("L13_"+str(i), "Background", u"<font=2>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, 790, iY+28, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_PEDIA_JUMP_TO_CIV, iCiv, -1 ) # Cancel Button screen.setImageButton("L15_"+str(i), ArtFileMgr.getInterfaceArtInfo("INTERFACE_TRADE_AUTO_STOP").getPath(), 900, iY, BUTTON_SIZE, BUTTON_SIZE, WidgetTypes.WIDGET_GENERAL, 748, pUnit.getID()) # ---- i += 1 iY += 60
def createCampUnit(iPlayer, iGameTurn): pPlayer = gc.getPlayer(iPlayer) if not pPlayer.isAlive(): return iTeam = pPlayer.getTeam() pTeam = gc.getTeam(iTeam) #eCiv = gc.getCivilizationInfo(pPlayer.getCivilizationType()) if pPlayer.getUnitClassCount( gc.getInfoTypeForString("UNITCLASS_SPECIAL1")) > 0: # Terrain #eTundra = gc.getInfoTypeForString("TERRAIN_TUNDRA") #eGras = gc.getInfoTypeForString("TERRAIN_GRASS") #eEbene = gc.getInfoTypeForString("TERRAIN_PLAINS") eDesert = gc.getInfoTypeForString("TERRAIN_DESERT") # Feature #eDichterWald = gc.getInfoTypeForString("FEATURE_DICHTERWALD") eCamp = gc.getInfoTypeForString("UNIT_CAMP") lCamps = PyPlayer(pPlayer.getID()).getUnitsOfType(eCamp) for pUnit in lCamps: if pUnit is not None and not pUnit.isNone(): #pUnit.NotifyEntity(MissionTypes.MISSION_FOUND) if pUnit.getFortifyTurns() == 0: return bCreateUnit = False iFortified = CvUtil.getScriptData(pUnit, ["f"], -1) if iFortified == -1: CvUtil.addScriptData(pUnit, "f", iGameTurn) elif (iGameTurn - iFortified) % 5 == 0: bCreateUnit = True if bCreateUnit: pPlot = pUnit.plot() lUnits = [] # Not on hills (for HI) if pPlayer.isHuman() and pPlot.isHills(): CyInterface().addMessage( iPlayer, True, 10, CyTranslator().getText("TXT_KEY_HELP_NOCAMPUNIT", ("", )), None, 2, "Art/Interface/Buttons/General/button_alert_new.dds", ColorTypes(11), pPlot.getX(), pPlot.getY(), True, True) return # Desert if pPlot.getTerrainType() == eDesert: if pPlayer.canTrain( gc.getInfoTypeForString( "UNIT_ARABIA_CAMELARCHER"), 0, 0): lUnits.append( gc.getInfoTypeForString( "UNIT_ARABIA_CAMELARCHER")) if pPlayer.canTrain( gc.getInfoTypeForString( "UNIT_CAMEL_CATAPHRACT"), 0, 0): lUnits.append( gc.getInfoTypeForString( "UNIT_CAMEL_CATAPHRACT")) # Open terrain (primary Mounted only) if not lUnits and pPlot.getFeatureType() == -1: if pPlayer.canTrain( gc.getInfoTypeForString("UNIT_MONGOL_KESHIK"), 0, 0): lUnits.append( gc.getInfoTypeForString("UNIT_MONGOL_KESHIK")) if pPlayer.canTrain( gc.getInfoTypeForString("UNIT_CATAPHRACT"), 0, 0): lUnits.append( gc.getInfoTypeForString("UNIT_CATAPHRACT")) if pPlayer.canTrain( gc.getInfoTypeForString("UNIT_HORSE_ARCHER"), 0, 0): lUnits.append( gc.getInfoTypeForString("UNIT_HORSE_ARCHER")) if not lUnits and pPlayer.canTrain( gc.getInfoTypeForString("UNIT_HORSEMAN"), 0, 0): lUnits.append( gc.getInfoTypeForString("UNIT_HORSEMAN")) # On forests or if no mounted units available/constructable if not lUnits: if pPlayer.canTrain( gc.getInfoTypeForString("UNIT_REFLEX_ARCHER"), 0, 0): lUnits.append( gc.getInfoTypeForString("UNIT_REFLEX_ARCHER")) else: lUnits.append( gc.getInfoTypeForString( "UNIT_COMPOSITE_ARCHER")) if pPlayer.canTrain( gc.getInfoTypeForString("UNIT_SKIRMISHER"), 0, 0): lUnits.append( gc.getInfoTypeForString("UNIT_SKIRMISHER")) if pPlayer.canTrain( gc.getInfoTypeForString("UNIT_AXEMAN2"), 0, 0): lUnits.append( gc.getInfoTypeForString("UNIT_AXEMAN2")) if pPlayer.canTrain( gc.getInfoTypeForString("UNIT_SWORDSMAN"), 0, 0): lUnits.append( gc.getInfoTypeForString("UNIT_SWORDSMAN")) elif pPlayer.canTrain( gc.getInfoTypeForString("UNIT_SCHILDTRAEGER"), 0, 0): lUnits.append( gc.getInfoTypeForString("UNIT_SCHILDTRAEGER")) else: lUnits.append( gc.getInfoTypeForString("UNIT_KURZSCHWERT")) # standard unit lUnits.append(gc.getInfoTypeForString("UNIT_SPEARMAN")) iUnit = -1 if lUnits: iUnit = lUnits[CvUtil.myRandom( len(lUnits), "createCampUnit")] # AI: Einheit autom, verkaufen (Soeldnerposten), falls Geldprobleme if not pPlayer.isHuman() and ( pPlayer.AI_isFinancialTrouble() or pTeam.getAtWarCount(True) == 0): pPlayer.changeGold(25) elif iUnit != -1: # Einheit erstellen CvUtil.spawnUnit(iUnit, pPlot, pPlayer)
def doPlotFeatures(): iGameTurn = gc.getGame().getElapsedGameTurns() if iGameTurn < 5: return # Inits iBarbPlayer = gc.getBARBARIAN_PLAYER() pBarbPlayer = gc.getPlayer(iBarbPlayer) # Flotsam terrOzean = gc.getInfoTypeForString("TERRAIN_OCEAN") bFlot = gc.getTeam(pBarbPlayer.getTeam()).isHasTech(gc.getInfoTypeForString("TECH_RUDERER2")) # Barbaren improvements impBarbFort = gc.getInfoTypeForString("IMPROVEMENT_BARBARENFORT") impCave = gc.getInfoTypeForString("IMPROVEMENT_CAVE") impGoody = gc.getInfoTypeForString("IMPROVEMENT_GOODY_HUT") iBarbForts = 0 iCaves = 0 iGoodyHuts = 0 # Animals bonus_lion = gc.getInfoTypeForString("BONUS_LION") bonus_horse = gc.getInfoTypeForString("BONUS_HORSE") bonus_camel = gc.getInfoTypeForString("BONUS_CAMEL") bonus_ivory = gc.getInfoTypeForString("BONUS_IVORY") bonus_dogs = gc.getInfoTypeForString("BONUS_HUNDE") bonus_deer = gc.getInfoTypeForString("BONUS_DEER") bonus_pig = gc.getInfoTypeForString("BONUS_PIG") # features iDarkIce = gc.getInfoTypeForString("FEATURE_DARK_ICE") iFeatBurned = gc.getInfoTypeForString("FEATURE_FOREST_BURNT") iFeatSeuche = gc.getInfoTypeForString("FEATURE_SEUCHE") iTerrDesert = gc.getInfoTypeForString("TERRAIN_DESERT") iTerrPlains = gc.getInfoTypeForString("TERRAIN_PLAINS") iTerrTundra = gc.getInfoTypeForString("TERRAIN_TUNDRA") iFeatForest = gc.getInfoTypeForString("FEATURE_FOREST") iFeatDenseForest = gc.getInfoTypeForString("FEATURE_DICHTERWALD") iFeatJungle = gc.getInfoTypeForString("FEATURE_JUNGLE") # Heuschrecken/Grasshopper iFeatGrasshopper = gc.getInfoTypeForString("FEATURE_GRASSHOPPER") # Desert Storm iFeatDesertstorm = gc.getInfoTypeForString("FEATURE_FALLOUT") lDesertStorm = [] # Plots Ocean = [] Desert = [] Forest = [] DenseForest = [] Tundra = [] Plains = [] Jungle = [] Hills = [] #GoodyPlots = [] # map iMapW = gc.getMap().getGridWidth() iMapH = gc.getMap().getGridHeight() for x in xrange(iMapW): for y in xrange(iMapH): loopPlot = gc.getMap().plot(x, y) if loopPlot and not loopPlot.isNone(): iPlotFeature = loopPlot.getFeatureType() iPlotTerrain = loopPlot.getTerrainType() iPlotImprovement = loopPlot.getImprovementType() if iPlotFeature == iDarkIce: continue if iPlotFeature == iFeatGrasshopper: doMoveGrasshoppers(loopPlot) continue if iPlotFeature == iFeatDesertstorm: lDesertStorm.append(loopPlot) continue if loopPlot.getFeatureType() == iFeatBurned: if CvUtil.myRandom(50, "burntForest2Forest") == 1: loopPlot.setFeatureType(iFeatForest, 0) continue # isWater if loopPlot.isWater(): # Treibgut nur alle 10 Runden erstellen (wenn aktiv) if bFlotsam and gc.getGame().getGameTurn() % 10 == 0: if bFlot and bGoodyHuts: if loopPlot.getOwner() == -1: if iPlotTerrain == terrOzean: if loopPlot.getNumUnits() > 0: Ocean.append(loopPlot) # isLand elif not loopPlot.isPeak(): iPlotOwner = loopPlot.getOwner() # nur ausserhalb von Cities if not loopPlot.isCity(): # Forts oder Handelsposten if iPlotImprovement in L.LImprFortShort: # Init iOwner = -1 iOwner = int(CvUtil.getScriptData(loopPlot, ["p", "t"], loopPlot.getOwner())) # Handelsposten entfernen, wenn der Plot in einem fremden Kulturkreis liegt if iPlotImprovement == gc.getInfoTypeForString("IMPROVEMENT_HANDELSPOSTEN"): if iOwner != iPlotOwner and iPlotOwner != -1: loopPlot.setImprovementType(-1) if gc.getPlayer(iOwner).isHuman(): szText = CyTranslator().getText("TXT_KEY_INFO_CLOSED_TRADEPOST", ("",)) CyInterface().addMessage(iOwner, True, 15, szText, "AS2D_UNIT_BUILD_UNIT", 2, "Art/Interface/Buttons/General/button_alert_new.dds", ColorTypes(7), loopPlot.getX(), loopPlot.getY(), True, True) # Kultur setzen if iPlotOwner == -1: loopPlot.setCulture(iOwner, 1, True) loopPlot.setOwner(iOwner) # Kultur bei Forts #else: # doCheckFortCulture(loopPlot) continue # Check nur alle x Runden (Tier-Spawn) if iGameTurn % 2 == 0: # Lion - 3% Appearance if loopPlot.getBonusType(-1) == bonus_lion and iPlotImprovement == -1: if loopPlot.getNumUnits() == 0: if CvUtil.myRandom(33, "lion") == 1: iUnitType = gc.getInfoTypeForString("UNIT_LION") pBarbPlayer.initUnit(iUnitType, x, y, UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_SOUTH) # ***TEST*** #CyInterface().addMessage(gc.getGame().getActivePlayer(), True, 10, "Barb. Atlasloewe erschaffen", None, 2, None, ColorTypes(10), 0, 0, False, False) continue # Wolf - 3% Appearance elif loopPlot.getBonusType(iPlotOwner) == bonus_dogs and iPlotImprovement == -1: if loopPlot.getNumUnits() == 0: if CvUtil.myRandom(33, "wolf") == 1: iUnitType = gc.getInfoTypeForString("UNIT_WOLF") pBarbPlayer.initUnit(iUnitType, x, y, UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_SOUTH) continue # Deer - 3% Appearance elif loopPlot.getBonusType(-1) == bonus_deer and iPlotImprovement == -1: if loopPlot.getNumUnits() == 0: iRand = CvUtil.myRandom(33, "deer or bear") if iRand == 1: iUnitType = gc.getInfoTypeForString("UNIT_DEER") pBarbPlayer.initUnit(iUnitType, x, y, UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_SOUTH) continue elif iRand == 2: iUnitType = gc.getInfoTypeForString("UNIT_BEAR") pBarbPlayer.initUnit(iUnitType, x, y, UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_SOUTH) continue # Boar/Schwarzwild - 3% Appearance elif loopPlot.getBonusType(iPlotOwner) == bonus_pig and iPlotImprovement == -1: if loopPlot.getNumUnits() == 0: if CvUtil.myRandom(33, "boar") == 1: iUnitType = gc.getInfoTypeForString("UNIT_BOAR") pBarbPlayer.initUnit(iUnitType, x, y, UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_SOUTH) continue # Horse - 2% Appearance elif loopPlot.getBonusType(iPlotOwner) == bonus_horse: iUnitType = gc.getInfoTypeForString("UNIT_HORSE") #iUnitTypeDom = gc.getInfoTypeForString("UNIT_HORSE") iTechDom = gc.getInfoTypeForString("TECH_PFERDEZUCHT") sTextDom = "TXT_KEY_INFO_DOM_HORSE" if loopPlot.getNumUnits() == 0: if CvUtil.myRandom(50, "horse") == 1: # Check Owner iNewUnitOwner = iBarbPlayer if iPlotOwner != -1 and iPlotOwner != iBarbPlayer: if gc.getTeam(gc.getPlayer(iPlotOwner).getTeam()).isHasTech(iTechDom): iNewUnitOwner = iPlotOwner #iUnitType = iUnitTypeDom elif gc.getPlayer(iPlotOwner).isHuman(): CyInterface().addMessage(iPlotOwner, True, 10, CyTranslator().getText(sTextDom, ("",)), None, 2, gc.getBonusInfo(bonus_horse).getButton(), ColorTypes(13), x, y, True, True) # Add Unit gc.getPlayer(iNewUnitOwner).initUnit(iUnitType, x, y, UnitAITypes.UNITAI_EXPLORE, DirectionTypes.DIRECTION_SOUTH) continue # Camel - 2% Appearance elif loopPlot.getBonusType(iPlotOwner) == bonus_camel: iUnitType = gc.getInfoTypeForString("UNIT_CAMEL") #iUnitTypeDom = gc.getInfoTypeForString("UNIT_CAMEL") iTechDom = gc.getInfoTypeForString("TECH_KAMELZUCHT") sTextDom = "TXT_KEY_INFO_DOM_CAMEL" if loopPlot.getNumUnits() == 0: if CvUtil.myRandom(50, "camel") == 1: # Check Owner iNewUnitOwner = iBarbPlayer if iPlotOwner != -1: if gc.getTeam(gc.getPlayer(iPlotOwner).getTeam()).isHasTech(iTechDom): iNewUnitOwner = iPlotOwner #iUnitType = iUnitTypeDom elif gc.getPlayer(iPlotOwner).isHuman(): CyInterface().addMessage(iPlotOwner, True, 10, CyTranslator().getText(sTextDom, ("",)), None, 2, gc.getBonusInfo(bonus_camel).getButton(), ColorTypes(13), x, y, True, True) # Add Unit gc.getPlayer(iNewUnitOwner).initUnit(iUnitType, x, y, UnitAITypes.UNITAI_EXPLORE, DirectionTypes.DIRECTION_SOUTH) continue # Elefant - 2% Appearance (ab Eisenzeit) elif loopPlot.getBonusType(iPlotOwner) == bonus_ivory and pBarbPlayer.getCurrentEra() >= 2: iUnitType = gc.getInfoTypeForString("UNIT_ELEFANT") if loopPlot.getNumUnits() == 0: if CvUtil.myRandom(50, "ele") == 1: # Check Owner iNewUnitOwner = iBarbPlayer if iPlotOwner != -1: if gc.getTeam(gc.getPlayer(iPlotOwner).getTeam()).isHasTech(gc.getInfoTypeForString("TECH_ELEFANTENZUCHT")): iNewUnitOwner = iPlotOwner elif gc.getPlayer(iPlotOwner).isHuman(): CyInterface().addMessage(iPlotOwner, True, 10, CyTranslator().getText("TXT_KEY_INFO_DOM_ELEFANT", ("",)), None, 2, gc.getBonusInfo(bonus_ivory).getButton(), ColorTypes(13), x, y, True, True) # Add Unit gc.getPlayer(iNewUnitOwner).initUnit(iUnitType, x, y, UnitAITypes.UNITAI_EXPLORE, DirectionTypes.DIRECTION_SOUTH) continue # Barbarenforts/festungen (erzeugt barbarische Einheiten alle x Runden) if iPlotImprovement == impBarbFort: iBarbForts += 1 #if iPlotOwner == -1 or iPlotOwner == iBarbPlayer: if loopPlot.getNumUnits() == 0: # Verteidiger setzen PAE_Barbaren.setFortDefence(loopPlot) elif loopPlot.getNumUnits() > 4: iNum = loopPlot.getNumUnits() - 4 for k in xrange(iNum): loopPlot.getUnit(k).kill(True, -1) elif pBarbPlayer.getCurrentEra() > 0: if bRageBarbs: iTurns = 5 else: iTurns = 10 if gc.getGame().getGameTurn() % iTurns == 0: iAnzUnits = PAE_Barbaren.countNearbyUnits(loopPlot, 2, iBarbPlayer) if iAnzUnits < 6: # Einheiten) setzen PAE_Barbaren.createBarbUnit(loopPlot) continue # Baerenhoehle elif iPlotImprovement == impCave: iCaves += 1 #if loopPlot.getNumUnits() <= 1: if CvUtil.myRandom(15, "cave bear") == 1: if not PAE_Barbaren.checkNearbyUnits(loopPlot,3): # (Plot, Radius) setUnitIntoCave(loopPlot) continue # Goody huts elif iPlotImprovement == impGoody: iGoodyHuts += 1 # Keine Seuche in Deserts if iPlotTerrain == iTerrDesert and iPlotFeature == iFeatSeuche: loopPlot.setFeatureType(-1,0) # leere Plots zwischenspeichern if iGameTurn > 150 and iGameTurn % 10 == 0: if iPlotOwner == -1: if loopPlot.getNumUnits() == 0 and not loopPlot.isActiveVisible(0): # Empty Plots for Animals and Barbs if iPlotTerrain == iTerrDesert: Desert.append(loopPlot) elif iPlotTerrain == iTerrTundra: Tundra.append(loopPlot) elif iPlotFeature == iFeatDenseForest: DenseForest.append(loopPlot) elif iPlotFeature == iFeatJungle: Jungle.append(loopPlot) elif iPlotFeature == iFeatForest: Forest.append(loopPlot) elif iPlotTerrain == iTerrPlains: Plains.append(loopPlot) if loopPlot.isHills(): Hills.append(loopPlot) # end if - not isCity # Plots verarbeiten -------------------------------- # Flotsam (if activated) if bFlotsam and bFlot and bGoodyHuts: if Ocean: if CvUtil.myRandom(33, "setFlotsam") == 1: iUnit = gc.getInfoTypeForString("UNIT_TREIBGUT") iNum = gc.getMap().getWorldSize() + 1 for i in xrange(iNum): CvUtil.spawnUnit(iUnit, Ocean[CvUtil.myRandom(len(Ocean), "spawnFlotsam")], pBarbPlayer) # Tiere setzen -------------------- if Desert: if CvUtil.myRandom(33, "setAnimals4Desert") == 1: setAnimals(gc.getInfoTypeForString("UNIT_CAMEL"),Desert) setAnimals(gc.getInfoTypeForString("UNIT_LION"),Desert) setAnimals(gc.getInfoTypeForString("UNIT_HYENA"),Desert) elif DenseForest: if CvUtil.myRandom(33, "setAnimals4DenseForest") == 1: setAnimals(gc.getInfoTypeForString("UNIT_WOLF"),DenseForest) setAnimals(gc.getInfoTypeForString("UNIT_UR"),DenseForest) setAnimals(gc.getInfoTypeForString("UNIT_BEAR"),DenseForest) elif Tundra: if CvUtil.myRandom(33, "setAnimals4Tundra") == 1: setAnimals(gc.getInfoTypeForString("UNIT_WOLF"),Tundra) setAnimals(gc.getInfoTypeForString("UNIT_BEAR"),Tundra) elif Jungle: if CvUtil.myRandom(33, "setAnimals4Jungle") == 1: setAnimals(gc.getInfoTypeForString("UNIT_PANTHER"),Jungle) setAnimals(gc.getInfoTypeForString("UNIT_TIGER"),Jungle) setAnimals(gc.getInfoTypeForString("UNIT_LEOPARD"),Jungle) setAnimals(gc.getInfoTypeForString("UNIT_ELEFANT"),Jungle) elif Forest: if CvUtil.myRandom(33, "setAnimals4Forest") == 1: setAnimals(gc.getInfoTypeForString("UNIT_WOLF"),Forest) setAnimals(gc.getInfoTypeForString("UNIT_BEAR"),Forest) setAnimals(gc.getInfoTypeForString("UNIT_BOAR"),Forest) setAnimals(gc.getInfoTypeForString("UNIT_DEER"),Forest) elif Plains: if CvUtil.myRandom(33, "setAnimals4Plains") == 1: setAnimals(gc.getInfoTypeForString("UNIT_HYENA"),Plains) setAnimals(gc.getInfoTypeForString("UNIT_LEOPARD"),Plains) #setAnimals(gc.getInfoTypeForString("UNIT_HORSE"),Plains) # Goody huts setzen if bGoodyHuts: nPlots = Jungle + Forest + Plains if nPlots: if CvUtil.myRandom(33, "setGoodyHuts") == 1: setGoodies(impGoody,iGoodyHuts,nPlots) # Barbaren Forts setzen if bBarbForts: nPlots = Hills if nPlots: if CvUtil.myRandom(33, "setBarbForts") == 1: setGoodies(impBarbFort,iBarbForts,nPlots) # Caves setzen nPlots = Jungle + Forest + DenseForest + Desert + Tundra if nPlots: if CvUtil.myRandom(33, "setCaves") == 1: setGoodies(impCave,iCaves,nPlots) # move Desertstorm / Sandsturm bewegen if lDesertStorm: doMoveDesertStorm(lDesertStorm) # Olympiade / Olympic Games / Panhellenic Games doOlympicGames()
def drawContents(self): screen = self.getScreen() self.deleteAllWidgets() # addPanel: Vertical, scrollable, x ,y, width, height # +++ 1 +++ PANEL Requests: Trade Requests screen.addPanel( "PanelRequests", u"", u"", True, False, 35, 75, 945, 200, PanelStyles.PANEL_STYLE_DAWNTOP ) BUTTON_SIZE = 48 iY = 30 # Cities with Special bonus order bMessageNoCities = True i = 0 for iPlayer in xrange(gc.getMAX_PLAYERS()): loopPlayer = gc.getPlayer(iPlayer) if loopPlayer.isAlive() and not loopPlayer.isHuman() and not loopPlayer.isBarbarian(): (pCity, pIter) = loopPlayer.firstCity(False) while pCity: if not pCity.isNone() and pCity.getOwner() == loopPlayer.getID(): #only valid cities iTurn = int(CvUtil.getScriptData(pCity, ["tst"], -1)) - gc.getGame().getGameTurn() if iTurn != -1: i += 1 pTeam = gc.getTeam(loopPlayer.getTeam()) if pTeam.isHasMet(gc.getPlayer(gc.getGame().getActivePlayer()).getTeam()): iBonus = int(CvUtil.getScriptData(pCity, ["tsb"],-1)) if iBonus != -1: iCiv = loopPlayer.getCivilizationType() iLeader = loopPlayer.getLeaderType() iPop = pCity.getPopulation() bMessageNoCities = False iX = 50 iY += 60 # Button Bonus screen.setImageButton("Label_1_"+str(i), gc.getBonusInfo(iBonus).getButton(), iX, iY, BUTTON_SIZE, BUTTON_SIZE, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BONUS, iBonus, -1) iX += 60 # Text City name szText = pCity.getName() screen.setLabel("Label_2_"+str(i), "Background", u"<font=4>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, iX, iY + 2, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 ) # Text CIV Name szText = loopPlayer.getCivilizationDescription(0) screen.setLabel("Label_CivName_"+str(i), "Background", u"<font=3>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, iX, iY + 25, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 ) iX += 325 # Text City Population szText = localText.getText("POP:", ()) + u" %d" %(iPop) screen.setLabel("Label_3_"+str(i), "Background", u"<font=4>" + szText + u"</font>", CvUtil.FONT_RIGHT_JUSTIFY, iX, iY + 10, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 ) iX += 10 # Button Civ screen.setImageButton("Label_4_"+str(i), gc.getCivilizationInfo(iCiv).getButton(), iX, iY, BUTTON_SIZE, BUTTON_SIZE, WidgetTypes.WIDGET_PEDIA_JUMP_TO_CIV, iCiv, -1) iX += 60 # Button Leader screen.setImageButton("Label_5_"+str(i), gc.getLeaderHeadInfo(iLeader).getButton(), iX, iY, BUTTON_SIZE, BUTTON_SIZE, WidgetTypes.WIDGET_PEDIA_JUMP_TO_LEADER, iLeader, iCiv) iX += 60 # Text Open Borders szText = localText.getText("TXT_KEY_MISC_OPEN_BORDERS", ()) + u": " if pTeam.isOpenBorders(CyGame().getActiveTeam()): szText += localText.getText("TXT_KEY_COLOR_POSITIVE", ()) + localText.getText("TXT_KEY_POPUP_YES", ( )) + localText.getText("TXT_KEY_COLOR_REVERT", ()) else: szText += localText.getText("TXT_KEY_COLOR_NEGATIVE", ()) + localText.getText("TXT_KEY_POPUP_NO", ( )) + localText.getText("TXT_KEY_COLOR_REVERT", ()) screen.setLabel("Label_6_"+str(i), "Background", u"<font=3>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, iX, iY+4, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 ) # AI Attitudes - KI Haltung iAtt = loopPlayer.AI_getAttitude(gc.getGame().getActivePlayer()) lAttText = ["TXT_KEY_ATTITUDE_FURIOUS","TXT_KEY_ATTITUDE_ANNOYED","TXT_KEY_ATTITUDE_CAUTIOUS","TXT_KEY_ATTITUDE_PLEASED","TXT_KEY_ATTITUDE_FRIENDLY"] # Text Attitude szText = localText.getText("TXT_KEY_ATTITUDE", ()) + u": %c" %(CyGame().getSymbolID(FontSymbols.POWER_CHAR) + 4 + iAtt) + localText.getText(lAttText[iAtt], ()) screen.setLabel("Label_7_"+str(i), "Background", u"<font=3>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, iX, iY+24, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 ) iX += 200 # Text Required Bonus szText = localText.getText("TXT_KEY_TRADE_ADVISOR_1",()) + u": " + gc.getBonusInfo(iBonus).getDescription() screen.setLabel("Label_8_"+str(i), "Background", u"<font=3>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, iX, iY+4, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 ) # Text Remaining Turns szText = localText.getText("TXT_KEY_TRADE_ADVISOR_2",()) + u": %d" %(iTurn) screen.setLabel("Label_9_"+str(i), "Background", u"<font=3>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, iX, iY+24, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 ) (pCity, pIter) = loopPlayer.nextCity(pIter, False) if bMessageNoCities: szText = localText.getText("TXT_KEY_TRADE_ADVISOR_INFO", ()) screen.setLabel("Label1_0", "Background", u"<font=3>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, 100, iY+80, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 ) # +++ 2 +++ PANEL 1-4: Goods (Bonus resources) screen.addPanel( "Panel1", u"", u"", True, False, 35, 280, 225, 50, PanelStyles.PANEL_STYLE_DAWNTOP ) screen.addPanel( "Panel2", u"", u"", True, False, 275, 280, 225, 50, PanelStyles.PANEL_STYLE_DAWNTOP ) screen.addPanel( "Panel3", u"", u"", True, False, 515, 280, 225, 50, PanelStyles.PANEL_STYLE_DAWNTOP ) screen.addPanel( "Panel4", u"", u"", True, False, 755, 280, 225, 50, PanelStyles.PANEL_STYLE_DAWNTOP ) szText = u"<font=3>" + localText.getText("TXT_KEY_TRADE_ADVISOR_TITLE_PANEL1",()).upper() + u"</font>" screen.setLabel("TitelPanel1", "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, 45, 286, -2.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 ) szText = u"<font=3>" + localText.getText("TXT_KEY_TRADE_ADVISOR_TITLE_PANEL2",()).upper() + u"</font>" screen.setLabel("TitelPanel2", "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, 285, 286, -2.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 ) szText = u"<font=3>" + localText.getText("TXT_KEY_TRADE_ADVISOR_TITLE_PANEL3",()).upper() + u"</font>" screen.setLabel("TitelPanel3", "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, 525, 286, -2.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 ) szText = u"<font=3>" + localText.getText("TXT_KEY_TRADE_ADVISOR_TITLE_PANEL4",()).upper() + u"</font>" screen.setLabel("TitelPanel4", "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, 765, 286, -2.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 ) szText = u"<font=3>" + localText.getText("TXT_KEY_TRADE_ADVISOR_WERT_PANEL1",()) + u"</font>" screen.setLabel("WertPanel1", "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, 45, 304, -2.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 ) szText = u"<font=3>" + localText.getText("TXT_KEY_TRADE_ADVISOR_WERT_PANEL2",()) + u"</font>" screen.setLabel("WertPanel2", "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, 285, 304, -2.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 ) szText = u"<font=3>" + localText.getText("TXT_KEY_TRADE_ADVISOR_WERT_PANEL3",()) + u"</font>" screen.setLabel("WertPanel3", "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, 525, 304, -2.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 ) szText = u"<font=3>" + localText.getText("TXT_KEY_TRADE_ADVISOR_WERT_PANEL4",()) + u"</font>" screen.setLabel("WertPanel4", "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, 765, 304, -2.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 ) # Tabellen screen.addTableControlGFC("Table1", 1, 40, 340, 215, 310, False, True, 24,24, TableStyles.TABLE_STYLE_STANDARD) screen.addTableControlGFC("Table2", 1, 280, 340, 215, 310, False, True, 24,24, TableStyles.TABLE_STYLE_STANDARD) screen.addTableControlGFC("Table3", 1, 520, 340, 215, 310, False, True, 24,24, TableStyles.TABLE_STYLE_STANDARD) screen.addTableControlGFC("Table4", 1, 760, 340, 215, 310, False, True, 24,24, TableStyles.TABLE_STYLE_STANDARD) # Add bonus to tables # pPlayer = gc.getPlayer(self.iActivePlayer) iCol1 = 0 iCol2 = 0 iCol3 = 0 iCol4 = 0 iNumBonus = gc.getNumBonusInfos() for iLoop in xrange(iNumBonus): szName = gc.getBonusInfo(iLoop).getDescription() szButton = gc.getBonusInfo(iLoop).getButton() iBonusClassType = gc.getBonusInfo(iLoop).getBonusClassType() # iBonusTechReveal = gc.getBonusInfo(iLoop).getTechReveal() #bShow = False #if gc.getTeam(pPlayer.getTeam()).isHasTech(iBonusTechReveal): bShow = True # BonusclassTypes PAE: # 0: BONUSCLASS_GENERAL # 1: BONUSCLASS_GRAIN # 2: BONUSCLASS_LIVESTOCK # 3: BONUSCLASS_MERCENARY # 4: BONUSCLASS_LUXURY # 5: BONUSCLASS_WONDER # 6: BONUSCLASS_MISC # 7: BONUSCLASS_RARITY # 8: BONUSCLASS_PLANTATION if bShow: if iBonusClassType == 7: screen.appendTableRow("Table1") screen.setTableText("Table1", 0, iCol1, szName, szButton, WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY) iCol1 += 1 elif iBonusClassType == 4: screen.appendTableRow("Table2") screen.setTableText("Table2", 0, iCol2, szName, szButton, WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY) iCol2 += 1 elif iBonusClassType == 0 or iBonusClassType == 5: screen.appendTableRow("Table3") screen.setTableText("Table3", 0, iCol3, szName, szButton, WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY) iCol3 += 1 elif iBonusClassType == 1 or iBonusClassType == 2 or iBonusClassType == 8: screen.appendTableRow("Table4") screen.setTableText("Table4", 0, iCol4, szName, szButton, WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY) iCol4 += 1 # +++ 3 +++ PANEL Bottom: Formeln screen.addPanel( "PanelBottom", u"", u"", True, False, 40, self.H_SCREEN-110, 935, 50, PanelStyles.PANEL_STYLE_MAIN_BLACK25 ) szText = u"<font=3>" + localText.getText("TXT_KEY_TRADE_ADVISOR_BOTTOM1",()) + u"</font>" screen.setLabel("TextBottom1", "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, 50, self.H_SCREEN-103, -2.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 ) szText = u"<font=3>" + localText.getText("TXT_KEY_TRADE_ADVISOR_BOTTOM2",()) + u"</font>" screen.setLabel("TextBottom2", "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, 50, self.H_SCREEN-83, -2.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )