コード例 #1
0
 def fnCheckLandBridge(self, pPlot, x, y):
     pTestPlot = CyMap().plot(pPlot.getX()+x, pPlot.getY()+y)
     if not (pPlot.isCity() or pTestPlot.isCity()):
         pTestPlot = CyMap().plot(pPlot.getX()+x, pPlot.getY())
         if (pTestPlot.isCoastalLand()):
             pTestPlot = CyMap().plot(pPlot.getX(), pPlot.getY()+y)
             if (pTestPlot.isCoastalLand()):
                 return True
     return False
コード例 #2
0
 def checkAdjacentRevealed(self, pPlot):
     for dx in xrange(-1, 2):
         for dy in xrange(-1, 2):
             if not (dx == 0 and dy == 0):
                 if CyMap().plot(pPlot.getX()+dx, pPlot.getY()+dy).isRevealed(self.iActivePlayerTeam, False):
                     return True
     return False
コード例 #3
0
 def setPlotColor(self, x, y, iCosts):
     pPlot = CyMap().plot(x, y)
     tPlot = (x, y)
     self.dPlotList[tPlot] = self.COL_NO
     # check impassable
     if iCosts == -1:
         if (pPlot.isWater() and (self.eDomain == DomainTypes.DOMAIN_SEA)) or ((not pPlot.isWater()) and (self.eDomain == DomainTypes.DOMAIN_LAND)):
             self.dPlotList[tPlot] = PleOpt.MH_Color_Impassable_Terrain()
     # check if plot is reachable
     elif iCosts <= self.iMovesLeft:
         # check if the plot is reavealed
         if pPlot.isRevealed(self.iActivePlayerTeam, False):
             # check if a unit at that plot
             if pPlot.isUnit() and pPlot.isVisible(self.iActivePlayerTeam, False):
                 self.dPlotList[tPlot] = self.checkUnit(pPlot)
             # check if the plot is foreign territory
             elif pPlot.isVisible(self.iActivePlayerTeam, False):
                 self.dPlotList[tPlot] = self.checkTerritory(pPlot)
             # nothing special with that plot
             else:
                 self.dPlotList[tPlot] = PleOpt.MH_Color_Passable_Terrain()
         else:
             if self.checkAdjacentRevealed(pPlot):
                 self.dPlotList[tPlot] = PleOpt.MH_Color_Passable_Terrain()
             else:
                 self.dPlotList[tPlot] = self.COL_NO
コード例 #4
0
 def findMinFCost(self):
     fComp = self.maxCost
     for key, val in self.dList.items():
         lData = self.dList[key]
         if lData[self.IDX_FCOSTS] < fComp:
             fComp = lData[self.IDX_FCOSTS]
             retKey = key
     x = retKey[0]
     y = retKey[1]
     return CyMap().plot(x, y)
コード例 #5
0
 def getArea(self):
     lArea = []
     if self.bResultValid:
         for i in xrange(self.pCloseList.len()):
             if i == 0:
                 lAPlot = self.pCloseList.getFirst()
             else:
                 lAPlot = self.pCloseList.getNext()
             iCosts = self.pCloseList.getGCosts(CyMap().plot(lAPlot[0], lAPlot[1]))
             lArea.append((lAPlot, iCosts))
     return lArea
コード例 #6
0
def AddCoordinateSignsToMap():
    """
	adds signs with the coordinates to the map so that potential starting positions can easier be modified

	Returns
	-------
	None.

	"""

    iHumanPlayer = -1
    for iCivs in xrange(gc.getMAX_CIV_PLAYERS()):
        pPlayer = gc.getPlayer(iCivs)
        if pPlayer.isHuman():
            iHumanPlayer = iCivs
            break
    for iX in xrange(CyMap().getGridWidth()):
        for iY in xrange(CyMap().getGridHeight()):
            pPlot = CyMap().plot(iX, iY)
            PrintString = "X = " + str(iX) + " Y = " + str(iY)
            CyEngine().addSign(pPlot, iHumanPlayer, PrintString)
コード例 #7
0
 def getNewPlot(self, pPlot, dx, dy):
     x = pPlot.getX()+dx
     y = pPlot.getY()+dy
     # check x underflow
     if x < 0:
         x += CyMap().getGridWidth()
     # check x overflow
     elif x >= CyMap().getGridWidth():
         x -= CyMap().getGridWidth()
     # check y underflow
     if y < 0:
         y += CyMap().getGridHeight()
     # check y overflow
     elif y >= CyMap().getGridHeight():
         y -= CyMap().getGridHeight()
     return CyMap().plot(x, y)
コード例 #8
0
def FlushVisibleArea():
    """
	makes the old starting positions invisible for the teams

	Returns
	-------
	None.

	"""

    iMaxX = CyMap().getGridWidth()
    iMaxY = CyMap().getGridHeight()
    iMaxTeam = gc.getMAX_CIV_TEAMS()
    for iX in xrange(iMaxX):
        for iY in xrange(iMaxY):
            pPlot = CyMap().plot(iX, iY)
            for iTeams in xrange(iMaxTeam):
                if not pPlot.isVisible(iTeams, False):
                    pPlot.setRevealed(iTeams, False, False, iTeams)
コード例 #9
0
 def getRealYDist(self, y1, y2):
     d1 = abs(y1-y2)
     d2 = abs(min(y1, y2)+CyMap().getGridHeight()-max(y1, y2))
     return min(d1, d2)
コード例 #10
0
 def getParent(self, pPlot):
     pAPlot = self.makeAPlot(pPlot)
     pAPlotData = self.getPlotData(pAPlot)
     x = pAPlotData[self.IDX_PARENT].getX()
     y = pAPlotData[self.IDX_PARENT].getY()
     return CyMap().plot(x, y)
コード例 #11
0
 def getRealXDist(self, x1, x2):
     d1 = abs(x1-x2)
     d2 = abs(min(x1, x2)+CyMap().getGridWidth()-max(x1, x2))
     return min(d1, d2)
コード例 #12
0
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)
コード例 #13
0
def writeLog():

    if gc.getActivePlayer():
        iID = gc.getActivePlayer().getID()
    else:
        iID = -1
    pFile = open((szFilename % iID), "w")
    # pFile = open(szFilename, "w")

    #
    # Global data
    #
    pFile.write(SEPERATOR)
    pFile.write(SEPERATOR)

    pFile.write("  GLOBALS  \n")

    pFile.write(SEPERATOR)
    pFile.write(SEPERATOR)
    pFile.write("\n\n")

    pFile.write("Next Map Rand Value: %d\n" %
                CyGame().getMapRand().get(10000, "OOS Log"))
    pFile.write("Next Soren Rand Value: %d\n" %
                CyGame().getSorenRand().get(10000, "OOS Log"))

    pFile.write("Total num cities: %d\n" % CyGame().getNumCities())
    pFile.write("Total population: %d\n" % CyGame().getTotalPopulation())
    pFile.write("Total Deals: %d\n" % CyGame().getNumDeals())

    pFile.write("Total owned plots: %d\n" % CyMap().getOwnedPlots())
    pFile.write("Total num areas: %d\n" % CyMap().getNumAreas())

    pFile.write("\n\n")

    #
    # Player data
    #
    iPlayer = 0
    for iPlayer in xrange(gc.getMAX_PLAYERS()):
        pPlayer = gc.getPlayer(iPlayer)
        pTeam = gc.getTeam(pPlayer.getTeam())
        if (pPlayer.isEverAlive()):
            pFile.write(SEPERATOR)
            pFile.write(SEPERATOR)

            pFile.write("  PLAYER %d  \n" % iPlayer)

            pFile.write(SEPERATOR)
            pFile.write(SEPERATOR)
            pFile.write("\n\n")

            pFile.write("Basic data:\n")
            pFile.write("-----------\n")
            pFile.write("Player %d Score: %d\n" %
                        (iPlayer, gc.getGame().getPlayerScore(iPlayer)))
            pFile.write("Player %d Tech Score: %d\n" %
                        (iPlayer, pPlayer.getTechScore()))

            pFile.write("Player %d Population: %d\n" %
                        (iPlayer, pPlayer.getTotalPopulation()))
            pFile.write("Player %d Total Land: %d\n" %
                        (iPlayer, pPlayer.getTotalLand()))
            pFile.write("Player %d Gold: %d\n" % (iPlayer, pPlayer.getGold()))
            pFile.write("Player %d Assets: %d\n" %
                        (iPlayer, pPlayer.getAssets()))
            pFile.write("Player %d Power: %d\n" %
                        (iPlayer, pPlayer.getPower()))
            pFile.write("Player %d Num Cities: %d\n" %
                        (iPlayer, pPlayer.getNumCities()))
            pFile.write("Player %d Num Units: %d\n" %
                        (iPlayer, pPlayer.getNumUnits()))
            pFile.write("Player %d Num Selection Groups: %d\n" %
                        (iPlayer, pPlayer.getNumSelectionGroups()))

            pFile.write("\n\n")

            pFile.write("Yields:\n")
            pFile.write("-------\n")
            for iYield in xrange(int(YieldTypes.NUM_YIELD_TYPES)):
                pFile.write(
                    "Player %d %s Total Yield: %d\n" %
                    (iPlayer,
                     gc.getYieldInfo(iYield).getDescription().encode('utf-8'),
                     pPlayer.calculateTotalYield(iYield)))

            pFile.write("\n\n")

            pFile.write("Commerce:\n")
            pFile.write("---------\n")
            for iCommerce in xrange(int(CommerceTypes.NUM_COMMERCE_TYPES)):
                pFile.write(
                    "Player %d %s Total Commerce: %d\n" %
                    (iPlayer, gc.getCommerceInfo(
                        iCommerce).getDescription().encode('utf-8'),
                     pPlayer.getCommerceRate(CommerceTypes(iCommerce))))

            pFile.write("\n\n")

            pFile.write("Bonus Info:\n")
            pFile.write("-----------\n")
            for iBonus in xrange(gc.getNumBonusInfos()):
                pFile.write(
                    "Player %d, %s, Number Available: %d\n" %
                    (iPlayer,
                     gc.getBonusInfo(iBonus).getDescription().encode('utf-8'),
                     pPlayer.getNumAvailableBonuses(iBonus)))
                pFile.write(
                    "Player %d, %s, Import: %d\n" %
                    (iPlayer,
                     gc.getBonusInfo(iBonus).getDescription().encode('utf-8'),
                     pPlayer.getBonusImport(iBonus)))
                pFile.write(
                    "Player %d, %s, Export: %d\n" %
                    (iPlayer,
                     gc.getBonusInfo(iBonus).getDescription().encode('utf-8'),
                     pPlayer.getBonusExport(iBonus)))
                pFile.write("\n")

            pFile.write("\n\n")

            pFile.write("Improvement Info:\n")
            pFile.write("-----------------\n")
            for iImprovement in xrange(gc.getNumImprovementInfos()):
                pFile.write("Player %d, %s, Improvement count: %d\n" %
                            (iPlayer, gc.getImprovementInfo(
                                iImprovement).getDescription().encode('utf-8'),
                             pPlayer.getImprovementCount(iImprovement)))

            pFile.write("\n\n")

            pFile.write("Building Class Info:\n")
            pFile.write("--------------------\n")
            for iBuildingClass in xrange(gc.getNumBuildingClassInfos()):
                pFile.write(
                    "Player %d, %s, Building class count plus building: %d\n" %
                    (iPlayer, gc.getBuildingClassInfo(
                        iBuildingClass).getDescription().encode('utf-8'),
                     pPlayer.getBuildingClassCountPlusMaking(iBuildingClass)))

            pFile.write("\n\n")

            pFile.write("Unit Class Info:\n")
            pFile.write("--------------------\n")
            for iUnitClass in xrange(gc.getNumUnitClassInfos()):
                pFile.write(
                    "Player %d, %s, Unit class count plus training: %d\n" %
                    (iPlayer, gc.getUnitClassInfo(
                        iUnitClass).getDescription().encode('utf-8'),
                     pPlayer.getUnitClassCountPlusMaking(iUnitClass)))

            pFile.write("\n\n")

            pFile.write("UnitAI Types Info:\n")
            pFile.write("------------------\n")
            for iUnitAIType in xrange(int(UnitAITypes.NUM_UNITAI_TYPES)):
                pFile.write(
                    "Player %d, %s, Unit AI Type count: %d\n" %
                    (iPlayer, gc.getUnitAIInfo(
                        iUnitAIType).getDescription().encode('utf-8'),
                     pPlayer.AI_totalUnitAIs(UnitAITypes(iUnitAIType))))

            pFile.write("\n\n")

            pFile.write("Technologies:\n")
            pFile.write("------------------\n")
            for iTech in xrange(gc.getNumTechInfos()):
                if pTeam.isHasTech(iTech):
                    szTech = "Yes"
                else:
                    szTech = "No"
                pFile.write(
                    "Player %d, %s, Research rate: %d, Possess: %s\n" %
                    (iPlayer,
                     gc.getTechInfo(iTech).getDescription().encode('utf-8'),
                     pPlayer.calculateResearchRate(iTech), szTech))

            pFile.write("\n\n")

            pFile.write("Unit Info:\n")
            pFile.write("----------\n")
            iNumUnits = pPlayer.getNumUnits()

            if (iNumUnits == 0):
                pFile.write("No Units")
            else:
                pLoopUnitTuple = pPlayer.firstUnit(False)
                while (pLoopUnitTuple[0] is not None):
                    pUnit = pLoopUnitTuple[0]
                    pFile.write("Player %d, Unit ID: %d, %s\n" %
                                (iPlayer, pUnit.getID(),
                                 pUnit.getName().encode('utf-8')))
                    pFile.write("X: %d, Y: %d\n" %
                                (pUnit.getX(), pUnit.getY()))
                    pFile.write("Damage: %d\n" % pUnit.getDamage())
                    pFile.write("Experience: %d\n" % pUnit.getExperience())
                    pFile.write("Level: %d\n" % pUnit.getLevel())

                    pLoopUnitTuple = pPlayer.nextUnit(pLoopUnitTuple[1], False)
                    pFile.write("\n")

            # Space at end of player's info
            pFile.write("\n\n")

    # Close file

    pFile.close()
コード例 #14
0
    def interfaceScreen(self):

        # Create a new screen
        screen = self.getScreen()
        if screen.isActive():
            return
        screen.setRenderInterfaceOnly(True)
        screen.showScreen(PopupStates.POPUPSTATE_IMMEDIATE, False)

        self.EXIT_TEXT = u"<font=4>" + localText.getText(
            "TXT_KEY_PEDIA_SCREEN_EXIT", ()).upper() + "</font>"
        self.TITLE = u"<font=4b>" + localText.getText(
            "TXT_KEY_MILITARY_ADVISOR_TITLE", ()).upper() + "</font>"

        self.nWidgetCount = 0

        # Set the background and exit button, and show the screen
        screen.setDimensions(screen.centerX(0), screen.centerY(0),
                             self.W_SCREEN, self.H_SCREEN)
        screen.addDDSGFC(
            self.BACKGROUND_ID,
            ArtFileMgr.getInterfaceArtInfo(
                "MAINMENU_SLIDESHOW_LOAD").getPath(), 0, 0, self.W_SCREEN,
            self.H_SCREEN, WidgetTypes.WIDGET_GENERAL, -1, -1)
        screen.addPanel("TechTopPanel", u"", u"", True, False, 0, 0,
                        self.W_SCREEN, 55, PanelStyles.PANEL_STYLE_TOPBAR)
        screen.addPanel("TechBottomPanel", u"", u"", True, False, 0, 713,
                        self.W_SCREEN, 55, PanelStyles.PANEL_STYLE_BOTTOMBAR)
        screen.showWindowBackground(False)
        screen.setText(self.EXIT_ID, "Background", self.EXIT_TEXT,
                       CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXIT, self.Y_EXIT,
                       self.Z_CONTROLS, FontTypes.TITLE_FONT,
                       WidgetTypes.WIDGET_CLOSE_SCREEN, -1, -1)

        # Header...
        self.szHeader = self.getNextWidgetName()
        screen.setText(self.szHeader, "Background", self.TITLE,
                       CvUtil.FONT_CENTER_JUSTIFY, self.X_SCREEN, self.Y_TITLE,
                       self.Z_CONTROLS, FontTypes.TITLE_FONT,
                       WidgetTypes.WIDGET_GENERAL, -1, -1)

        # Minimap initialization
        self.H_MAP = (self.W_MAP *
                      CyMap().getGridHeight()) / CyMap().getGridWidth()
        if self.H_MAP > self.H_MAP_MAX:
            self.W_MAP = (self.H_MAP_MAX *
                          CyMap().getGridWidth()) / CyMap().getGridHeight()
            self.H_MAP = self.H_MAP_MAX
        screen.addPanel("", u"", "", False, False, self.X_MAP, self.Y_MAP,
                        self.W_MAP, self.H_MAP, PanelStyles.PANEL_STYLE_MAIN)
        screen.initMinimap(self.X_MAP + self.MAP_MARGIN,
                           self.X_MAP + self.W_MAP - self.MAP_MARGIN,
                           self.Y_MAP + self.MAP_MARGIN,
                           self.Y_MAP + self.H_MAP - self.MAP_MARGIN,
                           self.Z_CONTROLS)
        screen.updateMinimapSection(False, False)

        screen.updateMinimapColorFromMap(
            MinimapModeTypes.MINIMAPMODE_TERRITORY, 0.3)

        screen.setMinimapMode(MinimapModeTypes.MINIMAPMODE_MILITARY)

        iOldMode = CyInterface().getShowInterface()
        CyInterface().setShowInterface(
            InterfaceVisibility.INTERFACE_MINIMAP_ONLY)
        screen.updateMinimapVisibility()
        CyInterface().setShowInterface(iOldMode)

        self.iActivePlayer = gc.getGame().getActivePlayer()

        self.unitsList = [(0, 0, [], 0)] * gc.getNumUnitInfos()
        self.selectedUnitList = []
        self.selectedPlayerList.append(self.iActivePlayer)

        self.drawCombatExperience()

        self.refresh(True)
コード例 #15
0
def onEndPlayerTurn(iPlayer, iGameTurn):

    # Kelten erheben sich in der Po-Ebene
    if iGameTurn == 13:
        if iPlayer == iRome and gc.getPlayer(iPlayer).isHuman():

            # 1. barb. Einheiten bei Placentia
            # Plot für die Landungseinheiten
            lPlots = [
                CyMap().plot(47, 66),
                CyMap().plot(48, 66),
                CyMap().plot(49, 66)
            ]
            Landungsplot = getRandomPlot(lPlots)

            # Einheiten erstellen
            LNewUnits = [
                gc.getInfoTypeForString("UNIT_CELTIC_GALLIC_WARRIOR"),
                gc.getInfoTypeForString("UNIT_SCHILDTRAEGER"),
                gc.getInfoTypeForString("UNIT_SKIRMISHER"),
                gc.getInfoTypeForString("UNIT_HORSEMAN_CELTIC")
            ]
            for i in LNewUnits:
                pUnit = gc.getPlayer(gc.getBARBARIAN_PLAYER()).initUnit(
                    i, Landungsplot.getX(), Landungsplot.getY(),
                    UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_SOUTH)
                pUnit.setExperience(2, -1)

            # Ping
            CyInterface().doPing(Landungsplot.getX(), Landungsplot.getY(),
                                 iPlayer)

            # 2. barb. Einheiten bei Ravenna
            # Plot für die Landungseinheiten
            lPlots = [
                CyMap().plot(53, 67),
                CyMap().plot(53, 57),
                CyMap().plot(53, 65)
            ]
            Landungsplot = getRandomPlot(lPlots)

            # Einheiten erstellen
            LNewUnits = [
                gc.getInfoTypeForString("UNIT_CELTIC_GALLIC_WARRIOR"),
                gc.getInfoTypeForString("UNIT_SCHILDTRAEGER"),
                gc.getInfoTypeForString("UNIT_SKIRMISHER"),
                gc.getInfoTypeForString("UNIT_HORSEMAN_CELTIC")
            ]
            for i in LNewUnits:
                pUnit = gc.getPlayer(gc.getBARBARIAN_PLAYER()).initUnit(
                    i, Landungsplot.getX(), Landungsplot.getY(),
                    UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_SOUTH)
                pUnit.setExperience(2, -1)

            # Ping
            CyInterface().doPing(Landungsplot.getX(), Landungsplot.getY(),
                                 iPlayer)

            # Meldung an den Spieler
            popupInfo = CyPopupInfo()
            popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
            popupInfo.setText(CyTranslator().getText(
                "TXT_KEY_MESSAGE_2NDPUNICWAR_2", ("", )))
            popupInfo.addPopup(iPlayer)

    # 2. Schlacht von Lilybaeum, Angriff Karthago auf Sizilien
    if iGameTurn == 19:
        if iPlayer == iRome and gc.getPlayer(iPlayer).isHuman():

            # Plot für die Schiffe
            lPlots = [
                CyMap().plot(51, 45),
                CyMap().plot(51, 46),
                CyMap().plot(51, 47)
            ]
            Schiffsplot = getRandomPlot(lPlots)

            # Schiffe erstellen
            LNewUnits = [gc.getInfoTypeForString("UNIT_QUADRIREME")]
            for i in LNewUnits:
                for _ in range(4):
                    pUnit = gc.getPlayer(iCarthago).initUnit(
                        i, Schiffsplot.getX(), Schiffsplot.getY(),
                        UnitAITypes.UNITAI_ASSAULT_SEA,
                        DirectionTypes.DIRECTION_SOUTH)
                    pUnit.setExperience(2, -1)
                    pUnit.setHasPromotion(
                        gc.getInfoTypeForString("PROMOTION_COMBAT1"), True)
                    pUnit.setHasPromotion(
                        gc.getInfoTypeForString("PROMOTION_COMBAT2"), True)

            # Meldung an den Spieler
            popupInfo = CyPopupInfo()
            popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
            popupInfo.setText(CyTranslator().getText(
                "TXT_KEY_MESSAGE_2NDPUNICWAR_3", ("", )))
            popupInfo.addPopup(iPlayer)
            CyCamera().JustLookAtPlot(Schiffsplot)

    # Schlacht von Cissa, Römer landen in Iberien
    if iGameTurn == 23:
        if iPlayer == iCarthago and gc.getPlayer(iPlayer).isHuman():

            # Plot für die Landungseinheiten
            lPlots = [
                CyMap().plot(19, 52),
                CyMap().plot(19, 53),
                CyMap().plot(20, 53)
            ]
            Landungsplot = getRandomPlot(lPlots)
            # Plot für die Schiffe
            lPlots = [
                CyMap().plot(20, 52),
                CyMap().plot(21, 52),
                CyMap().plot(21, 53)
            ]
            Schiffsplot = getRandomPlot(lPlots)

            # Schiffe erstellen
            LNewUnits = [
                gc.getInfoTypeForString("UNIT_QUADRIREME"),
                gc.getInfoTypeForString("UNIT_TRIREME")
            ]
            for i in LNewUnits:
                for _ in range(2):
                    pUnit = gc.getPlayer(iRome).initUnit(
                        i, Schiffsplot.getX(), Schiffsplot.getY(),
                        UnitAITypes.UNITAI_ASSAULT_SEA,
                        DirectionTypes.DIRECTION_SOUTH)
                    pUnit.setExperience(2, -1)
                    pUnit.setHasPromotion(
                        gc.getInfoTypeForString("PROMOTION_COMBAT1"), True)
                    pUnit.setHasPromotion(
                        gc.getInfoTypeForString("PROMOTION_CORVUS1"), True)

            # Einheiten erstellen
            LNewUnits = [
                gc.getInfoTypeForString("UNIT_TRIARII"),
                gc.getInfoTypeForString("UNIT_PRINCIPES"),
                gc.getInfoTypeForString("UNIT_PRINCIPES"),
                gc.getInfoTypeForString("UNIT_HASTATI"),
                gc.getInfoTypeForString("UNIT_HASTATI"),
                gc.getInfoTypeForString("UNIT_SKIRMISHER_ROME"),
                gc.getInfoTypeForString("UNIT_SKIRMISHER_ROME")
            ]
            for i in LNewUnits:
                pUnit = gc.getPlayer(iRome).initUnit(
                    i, Landungsplot.getX(), Landungsplot.getY(),
                    UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_SOUTH)
                pUnit.setExperience(2, -1)

            # Meldung an den Spieler
            popupInfo = CyPopupInfo()
            popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
            popupInfo.setText(CyTranslator().getText(
                "TXT_KEY_MESSAGE_2NDPUNICWAR_4", ("", )))
            popupInfo.addPopup(iPlayer)
            CyCamera().JustLookAtPlot(Landungsplot)

    # Rom erobert Sagunt (Plot: 20,50)
    if iGameTurn == 30:
        if iPlayer == iCarthago and gc.getPlayer(iPlayer).isHuman() and CyMap(
        ).plot(20, 50).getOwner() == iCarthago:

            # Plot für die Landungseinheiten
            lPlots = [CyMap().plot(19, 51), CyMap().plot(20, 49)]
            Landungsplot = getRandomPlot(lPlots)
            # Plot für die Schiffe
            lPlots = [
                CyMap().plot(20, 49),
                CyMap().plot(20, 50),
                CyMap().plot(20, 51)
            ]
            Schiffsplot = getRandomPlot(lPlots)

            # Schiffe erstellen
            LNewUnits = [
                gc.getInfoTypeForString("UNIT_QUADRIREME"),
                gc.getInfoTypeForString("UNIT_TRIREME")
            ]
            for i in LNewUnits:
                for _ in range(2):
                    pUnit = gc.getPlayer(iRome).initUnit(
                        i, Schiffsplot.getX(), Schiffsplot.getY(),
                        UnitAITypes.UNITAI_ASSAULT_SEA,
                        DirectionTypes.DIRECTION_SOUTH)
                    pUnit.setExperience(2, -1)
                    pUnit.setHasPromotion(
                        gc.getInfoTypeForString("PROMOTION_COMBAT1"), True)
                    pUnit.setHasPromotion(
                        gc.getInfoTypeForString("PROMOTION_CORVUS1"), True)

            # Einheiten erstellen
            LNewUnits = [
                gc.getInfoTypeForString("UNIT_TRIARII"),
                gc.getInfoTypeForString("UNIT_PRINCIPES"),
                gc.getInfoTypeForString("UNIT_PRINCIPES"),
                gc.getInfoTypeForString("UNIT_HASTATI"),
                gc.getInfoTypeForString("UNIT_HASTATI"),
                gc.getInfoTypeForString("UNIT_SKIRMISHER_ROME"),
                gc.getInfoTypeForString("UNIT_SKIRMISHER_ROME")
            ]
            for i in LNewUnits:
                pUnit = gc.getPlayer(iRome).initUnit(
                    i, Landungsplot.getX(), Landungsplot.getY(),
                    UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_SOUTH)
                pUnit.setExperience(2, -1)

            # Meldung an den Spieler
            popupInfo = CyPopupInfo()
            popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
            popupInfo.setText(CyTranslator().getText(
                "TXT_KEY_MESSAGE_2NDPUNICWAR_5", ("", )))
            popupInfo.addPopup(iPlayer)
            CyCamera().JustLookAtPlot(Landungsplot)

    # iberische Städte rebellieren gegen Karthago
    # barb. Einheiten in Iberien
    if iGameTurn == 38:
        if iPlayer == iCarthago and gc.getPlayer(iPlayer).isHuman():

            LNewUnits = [
                gc.getInfoTypeForString("UNIT_SCHILDTRAEGER_IBERIA"),
                gc.getInfoTypeForString("UNIT_SPEARMAN"),
                gc.getInfoTypeForString("UNIT_SKIRMISHER_ROME"),
                gc.getInfoTypeForString("UNIT_CELTIBERIAN_CAVALRY")
            ]

            # Plot für die Landungseinheiten
            lPlots = [
                CyMap().plot(14, 50),
                CyMap().plot(14, 51),
                CyMap().plot(14, 52)
            ]
            Landungsplot = getRandomPlot(lPlots)
            for i in LNewUnits:
                pUnit = gc.getPlayer(gc.getBARBARIAN_PLAYER()).initUnit(
                    i, Landungsplot.getX(), Landungsplot.getY(),
                    UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_SOUTH)
                pUnit.setExperience(2, -1)

            # Plot für die Landungseinheiten
            lPlots = [
                CyMap().plot(8, 43),
                CyMap().plot(9, 42),
                CyMap().plot(9, 43)
            ]
            Landungsplot = getRandomPlot(lPlots)
            for i in LNewUnits:
                pUnit = gc.getPlayer(gc.getBARBARIAN_PLAYER()).initUnit(
                    i, Landungsplot.getX(), Landungsplot.getY(),
                    UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_SOUTH)
                pUnit.setExperience(2, -1)

            # Meldung an den Spieler
            popupInfo = CyPopupInfo()
            popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
            popupInfo.setText(CyTranslator().getText(
                "TXT_KEY_MESSAGE_2NDPUNICWAR_6", ("", )))
            popupInfo.addPopup(iPlayer)
            CyCamera().JustLookAtPlot(Landungsplot)

    # Capua verbündet sich mit Hannibal
    # Capua wird barbarisch (Plot: 58, 58)
    # Bedinung: Capua = römisch + Rom u. Karthago im Krieg
    if iGameTurn == 50:
        if iPlayer == iRome and gc.getPlayer(iPlayer).isHuman():
            pPlot = CyMap().plot(58, 58)
            if pPlot.getOwner() == iRome and gc.getTeam(
                    gc.getPlayer(iCarthago)).isAtWar(gc.getPlayer(iRome)):

                # Stadt wird barbarisch + Einheiten
                PAE_City.doRenegadeCity(pPlot.getPlotCity(),
                                        gc.getBARBARIAN_PLAYER(), None)

                LNewUnits = [
                    gc.getInfoTypeForString("UNIT_REBELL"),
                    gc.getInfoTypeForString("UNIT_REFLEX_ARCHER"),
                    gc.getInfoTypeForString("UNIT_SAMNIT")
                ]
                for i in LNewUnits:
                    pUnit = gc.getPlayer(gc.getBARBARIAN_PLAYER()).initUnit(
                        i, pPlot.getX(), pPlot.getY(),
                        UnitAITypes.UNITAI_CITY_DEFENSE,
                        DirectionTypes.DIRECTION_SOUTH)
                    pUnit.setExperience(2, -1)
                    pUnit.setHasPromotion(
                        gc.getInfoTypeForString("PROMOTION_CITY_GARRISON1"),
                        True)

                # Meldung an den Spieler
                popupInfo = CyPopupInfo()
                popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
                popupInfo.setText(CyTranslator().getText(
                    "TXT_KEY_MESSAGE_2NDPUNICWAR_9", ("", )))
                popupInfo.addPopup(iPlayer)
                CyCamera().JustLookAtPlot(pPlot)

    # Schlacht von Cornus, Punier landen auf Sardinien
    if iGameTurn == 56:
        if iPlayer == iRome and gc.getPlayer(iPlayer).isHuman():

            # Plot für die Landungseinheiten
            lPlots = [
                CyMap().plot(44, 52),
                CyMap().plot(45, 51),
                CyMap().plot(45, 52)
            ]
            Landungsplot = getRandomPlot(lPlots)
            # Plot für die Schiffe
            lPlots = [
                CyMap().plot(43, 51),
                CyMap().plot(43, 52),
                CyMap().plot(43, 53)
            ]
            Schiffsplot = getRandomPlot(lPlots)

            # Schiffe erstellen
            LNewUnits = [
                gc.getInfoTypeForString("UNIT_QUADRIREME"),
                gc.getInfoTypeForString("UNIT_TRIREME")
            ]
            for i in LNewUnits:
                for _ in range(2):
                    pUnit = gc.getPlayer(iRome).initUnit(
                        i, Schiffsplot.getX(), Schiffsplot.getY(),
                        UnitAITypes.UNITAI_ASSAULT_SEA,
                        DirectionTypes.DIRECTION_SOUTH)
                    pUnit.setExperience(2, -1)
                    pUnit.setHasPromotion(
                        gc.getInfoTypeForString("PROMOTION_COMBAT1"), True)
                    pUnit.setHasPromotion(
                        gc.getInfoTypeForString("PROMOTION_COMBAT2"), True)

            # Einheiten erstellen
            LNewUnits = [
                gc.getInfoTypeForString("UNIT_CARTH_SACRED_BAND_OFFICER"),
                gc.getInfoTypeForString("UNIT_SPEARMAN_CARTHAGE"),
                gc.getInfoTypeForString("UNIT_SPEARMAN_CARTHAGE"),
                gc.getInfoTypeForString("UNIT_REBELL"),
                gc.getInfoTypeForString("UNIT_REBELL"),
                gc.getInfoTypeForString("UNIT_SKIRMISHER"),
                gc.getInfoTypeForString("UNIT_SKIRMISHER")
            ]
            for i in LNewUnits:
                pUnit = gc.getPlayer(iRome).initUnit(
                    i, Landungsplot.getX(), Landungsplot.getY(),
                    UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_SOUTH)
                pUnit.setExperience(2, -1)

            # Meldung an den Spieler
            popupInfo = CyPopupInfo()
            popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
            popupInfo.setText(CyTranslator().getText(
                "TXT_KEY_MESSAGE_2NDPUNICWAR_10", ("", )))
            popupInfo.addPopup(iPlayer)
            CyCamera().JustLookAtPlot(Landungsplot)

    # Massinissa schickt Truppen nach Iberien
    # ost-num. Truppen in Karthago-Nova
    # Bedingung: Ost-Numider Vasall von Karthago + Rom und Karthago im Krieg
    if iGameTurn == 85:
        if iPlayer == iCarthago or iPlayer == iRome:
            iMessana = 3
            iTeamCarthago = gc.getPlayer(iCarthago).getTeam()
            iTeamMessana = gc.getPlayer(iMessana).getTeam()
            pTeamMessana = gc.getTeam(iTeamMessana)
            if pTeamMessana.isVassal(iTeamCarthago) and gc.getTeam(
                    gc.getPlayer(iCarthago)).isAtWar(gc.getPlayer(iRome)):

                # Plot für die Einheiten
                Landungsplot = CyMap().plot(19, 46)

                if iPlayer == iCarthago:
                    # Einheiten erstellen
                    LNewUnits = [
                        gc.getInfoTypeForString("UNIT_HORSEMAN_NUMIDIA")
                    ]

                    for i in LNewUnits:
                        for _ in range(4):
                            pUnit = gc.getPlayer(iMessana).initUnit(
                                i, Landungsplot.getX(), Landungsplot.getY(),
                                UnitAITypes.UNITAI_ATTACK,
                                DirectionTypes.DIRECTION_SOUTH)
                            pUnit.setExperience(2, -1)

                # Meldung an den Spieler
                popupInfo = CyPopupInfo()
                popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
                popupInfo.setText(CyTranslator().getText(
                    "TXT_KEY_MESSAGE_2NDPUNICWAR_12", ("", )))
                popupInfo.addPopup(iPlayer)
                CyCamera().JustLookAtPlot(Landungsplot)

    # Hannibal erobert Tarent
    # Tarent wird barbarisch
    # Bedinung: Tarent = römisch + Rom u. Karthago im Krieg
    if iGameTurn == 90:
        if iPlayer == iRome:
            pPlot = CyMap().plot(62, 53)
            if pPlot.getOwner() == iRome and gc.getTeam(
                    gc.getPlayer(iRome)).isAtWar(gc.getPlayer(iCarthago)):

                # Stadt wird barbarisch + Einheiten
                PAE_City.doRenegadeCity(pPlot.getPlotCity(),
                                        gc.getBARBARIAN_PLAYER(), None)

                LNewUnits = [
                    gc.getInfoTypeForString("UNIT_REBELL"),
                    gc.getInfoTypeForString("UNIT_REFLEX_ARCHER"),
                    gc.getInfoTypeForString("UNIT_HOPLIT")
                ]
                for i in LNewUnits:
                    pUnit = gc.getPlayer(gc.getBARBARIAN_PLAYER()).initUnit(
                        i, pPlot.getX(), pPlot.getY(),
                        UnitAITypes.UNITAI_CITY_DEFENSE,
                        DirectionTypes.DIRECTION_SOUTH)
                    pUnit.setExperience(2, -1)
                    pUnit.setHasPromotion(
                        gc.getInfoTypeForString("PROMOTION_CITY_GARRISON1"),
                        True)

                # Meldung an den Spieler
                popupInfo = CyPopupInfo()
                popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
                popupInfo.setText(CyTranslator().getText(
                    "TXT_KEY_MESSAGE_2NDPUNICWAR_13", ("", )))
                popupInfo.addPopup(iPlayer)
                CyCamera().JustLookAtPlot(pPlot)

    # Unruhen in Rom
    if iGameTurn == 110:
        if iPlayer == iRome:
            pCity = gc.getPlayer(iPlayer).getCapitalCity()

            PAE_City.doCityRevolt(pCity, 4)

            # Meldung an den Spieler
            popupInfo = CyPopupInfo()
            popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
            popupInfo.setText(CyTranslator().getText(
                "TXT_KEY_MESSAGE_2NDPUNICWAR_14", ("", )))
            popupInfo.addPopup(iPlayer)
            CyCamera().JustLookAtPlot(pCity.plot())

    # Schlacht von Neu-Karthago, Römer greifen Stadt an
    # röm. Schiffe + Einheiten bei Neu-Karthago (Plot: 19,46)
    # Bedingung: Neu-Karthago = karth. + Rom und Karthago im Krieg
    if iGameTurn == 125:
        if iPlayer == iCarthago:
            pPlot = CyMap().plot(19, 46)  # TXT_KEY_CITY_NAME_CARTHAGO_NOVO
            if pPlot.getOwner() == iCarthago and gc.getTeam(
                    gc.getPlayer(iCarthago)).isAtWar(gc.getPlayer(iRome)):

                # Plot für die Landungseinheiten
                lPlots = [
                    CyMap().plot(18, 45),
                    CyMap().plot(19, 45),
                    CyMap().plot(19, 47)
                ]
                Landungsplot = getRandomPlot(lPlots)
                # Plot für die Schiffe
                lPlots = [
                    CyMap().plot(20, 45),
                    CyMap().plot(20, 46),
                    CyMap().plot(20, 47)
                ]
                Schiffsplot = getRandomPlot(lPlots)

                # Schiffe erstellen
                LNewUnits = [
                    gc.getInfoTypeForString("UNIT_QUADRIREME"),
                    gc.getInfoTypeForString("UNIT_TRIREME")
                ]
                for i in LNewUnits:
                    for _ in range(2):
                        pUnit = gc.getPlayer(iRome).initUnit(
                            i, Schiffsplot.getX(), Schiffsplot.getY(),
                            UnitAITypes.UNITAI_ASSAULT_SEA,
                            DirectionTypes.DIRECTION_SOUTH)
                        pUnit.setExperience(2, -1)
                        pUnit.setHasPromotion(
                            gc.getInfoTypeForString("PROMOTION_COMBAT1"), True)
                        pUnit.setHasPromotion(
                            gc.getInfoTypeForString("PROMOTION_CORVUS1"), True)

                # Einheiten erstellen
                LNewUnits = [
                    gc.getInfoTypeForString("UNIT_TRIARII"),
                    gc.getInfoTypeForString("UNIT_PRINCIPES"),
                    gc.getInfoTypeForString("UNIT_PRINCIPES"),
                    gc.getInfoTypeForString("UNIT_HASTATI"),
                    gc.getInfoTypeForString("UNIT_HASTATI"),
                    gc.getInfoTypeForString("UNIT_SKIRMISHER_ROME"),
                    gc.getInfoTypeForString("UNIT_SKIRMISHER_ROME")
                ]
                for i in LNewUnits:
                    pUnit = gc.getPlayer(iRome).initUnit(
                        i, Landungsplot.getX(), Landungsplot.getY(),
                        UnitAITypes.UNITAI_ATTACK,
                        DirectionTypes.DIRECTION_SOUTH)
                    pUnit.setExperience(2, -1)

                pUnit = gc.getPlayer(iRome).initUnit(
                    gc.getInfoTypeForString("UNIT_LEGION_TRIBUN"),
                    Landungsplot.getX(), Landungsplot.getY(),
                    UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_SOUTH)
                pUnit.setExperience(2, -1)
                pUnit.setHasPromotion(
                    gc.getInfoTypeForString("PROMOTION_COMBAT1"), True)
                pUnit.setName("Publius Cornelius Scipio")

                # Meldung an den Spieler
                popupInfo = CyPopupInfo()
                popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
                popupInfo.setText(CyTranslator().getText(
                    "TXT_KEY_MESSAGE_2NDPUNICWAR_15", ("", )))
                popupInfo.addPopup(iPlayer)
                CyCamera().JustLookAtPlot(Landungsplot)

    # Schlacht am Metaurus (Ost-Italien) Hasdrubal Barca
    # karthag. Einheiten in Italien
    # Stadt (Ariminum) = römisch + Rom und Karthago im Krieg
    if iGameTurn == 150:
        if iPlayer == iRome:
            pPlot = CyMap().plot(54, 62)  # Florentia
            if pPlot.getOwner() == iRome and gc.getTeam(
                    gc.getPlayer(iRome)).isAtWar(gc.getPlayer(iCarthago)):

                # Plot für die Landungseinheiten
                lPlots = [
                    CyMap().plot(55, 64),
                    CyMap().plot(54, 64),
                    CyMap().plot(55, 63)
                ]
                Landungsplot = getRandomPlot(lPlots)

                # Einheiten erstellen
                LNewUnits = [
                    gc.getInfoTypeForString("UNIT_CARTH_SACRED_BAND_OFFICER"),
                    gc.getInfoTypeForString("UNIT_SPEARMAN_CARTHAGE"),
                    gc.getInfoTypeForString("UNIT_SPEARMAN_CARTHAGE"),
                    gc.getInfoTypeForString("UNIT_SCHILDTRAEGER_IBERIA"),
                    gc.getInfoTypeForString("UNIT_SCHILDTRAEGER_IBERIA"),
                    gc.getInfoTypeForString("UNIT_CELTIC_GALLIC_WARRIOR"),
                    gc.getInfoTypeForString("UNIT_CELTIC_GALLIC_WARRIOR")
                ]

                for i in LNewUnits:
                    pUnit = gc.getPlayer(iCarthago).initUnit(
                        i, Landungsplot.getX(), Landungsplot.getY(),
                        UnitAITypes.UNITAI_ATTACK,
                        DirectionTypes.DIRECTION_SOUTH)
                    pUnit.setExperience(2, -1)
                    pUnit.setHasPromotion(
                        gc.getInfoTypeForString("PROMOTION_COMBAT1"), True)
                    pUnit.setHasPromotion(
                        gc.getInfoTypeForString("PROMOTION_COMBAT2"), True)

                pUnit = gc.getPlayer(iCarthago).initUnit(
                    gc.getInfoTypeForString(
                        "UNIT_MOUNTED_SACRED_BAND_CARTHAGE"),
                    Landungsplot.getX(), Landungsplot.getY(),
                    UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_SOUTH)
                pUnit.setExperience(2, -1)
                pUnit.setHasPromotion(
                    gc.getInfoTypeForString("PROMOTION_COMBAT1"), True)
                pUnit.setHasPromotion(
                    gc.getInfoTypeForString("PROMOTION_COMBAT2"), True)
                pUnit.setHasPromotion(
                    gc.getInfoTypeForString("PROMOTION_LEADER"), True)
                pUnit.setHasPromotion(
                    gc.getInfoTypeForString("PROMOTION_LEADERSHIP"), True)
                pUnit.setHasPromotion(
                    gc.getInfoTypeForString("PROMOTION_FLANKING1"), True)
                pUnit.setHasPromotion(
                    gc.getInfoTypeForString("PROMOTION_FORM_FLANKENSCHUTZ"),
                    True)
                pUnit.setName("Hasdrubal Barca")

                # Meldung an den Spieler
                popupInfo = CyPopupInfo()
                popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
                popupInfo.setText(CyTranslator().getText(
                    "TXT_KEY_MESSAGE_2NDPUNICWAR_17", ("", )))
                popupInfo.addPopup(iPlayer)
                CyCamera().JustLookAtPlot(Landungsplot)

    # Rom landet in Afrika bei Utica
    if iGameTurn == 183:
        if iPlayer == iCarthago and not gc.getPlayer(iRome).isHuman():
            if gc.getTeam(gc.getPlayer(iCarthago)).isAtWar(
                    gc.getPlayer(iRome)):

                # Plot für die Landungseinheiten
                lPlots = [
                    CyMap().plot(40, 40),
                    CyMap().plot(41, 40),
                    CyMap().plot(41, 41)
                ]
                Landungsplot = getRandomPlot(lPlots)
                # Plot für die Schiffe
                lPlots = [
                    CyMap().plot(40, 42),
                    CyMap().plot(41, 42),
                    CyMap().plot(42, 42)
                ]
                Schiffsplot = getRandomPlot(lPlots)

                # Schiffe erstellen
                LNewUnits = [
                    gc.getInfoTypeForString("UNIT_QUADRIREME"),
                    gc.getInfoTypeForString("UNIT_TRIREME")
                ]
                for i in LNewUnits:
                    for _ in range(2):
                        pUnit = gc.getPlayer(iRome).initUnit(
                            i, Schiffsplot.getX(), Schiffsplot.getY(),
                            UnitAITypes.UNITAI_ASSAULT_SEA,
                            DirectionTypes.DIRECTION_SOUTH)
                        pUnit.setExperience(2, -1)
                        pUnit.setHasPromotion(
                            gc.getInfoTypeForString("PROMOTION_COMBAT1"), True)
                        pUnit.setHasPromotion(
                            gc.getInfoTypeForString("PROMOTION_CORVUS1"), True)

                # Einheiten erstellen
                LNewUnits = [
                    gc.getInfoTypeForString("UNIT_TRIARII"),
                    gc.getInfoTypeForString("UNIT_PRINCIPES"),
                    gc.getInfoTypeForString("UNIT_PRINCIPES"),
                    gc.getInfoTypeForString("UNIT_HASTATI"),
                    gc.getInfoTypeForString("UNIT_HASTATI"),
                    gc.getInfoTypeForString("UNIT_SKIRMISHER_ROME"),
                    gc.getInfoTypeForString("UNIT_SKIRMISHER_ROME")
                ]
                for i in LNewUnits:
                    pUnit = gc.getPlayer(iRome).initUnit(
                        i, Landungsplot.getX(), Landungsplot.getY(),
                        UnitAITypes.UNITAI_ATTACK,
                        DirectionTypes.DIRECTION_SOUTH)
                    pUnit.setExperience(2, -1)
                    pUnit.setHasPromotion(
                        gc.getInfoTypeForString("PROMOTION_COMBAT1"), True)

                # Meldung an den Spieler
                popupInfo = CyPopupInfo()
                popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
                popupInfo.setText(CyTranslator().getText(
                    "TXT_KEY_MESSAGE_2NDPUNICWAR_20", ("", )))
                popupInfo.addPopup(iPlayer)
                CyCamera().JustLookAtPlot(Landungsplot)
コード例 #16
0
    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
コード例 #17
0
def getPlotHealFactor(pUnit):

    # heal rates for certain areas. They are usually stored in the GlobalDefines.XML but can't be read out with a standard API function.
    # So I placed them here as constants.
    ENEMY_HEAL_RATE = 5
    NEUTRAL_HEAL_RATE = 10
    FRIENDLY_HEAL_RATE = 15
    CITY_HEAL_RATE = 20

    # set/reset some variables
    pPlot = pUnit.plot()
    iSameTileHealFactor = 0
    iAdjacentTileHealFactor = 0
    iBuildingHealFactor = 0
    iSelfHealFactor = 0
    iPromotionHealFactor = 0
    iTileHealFactor = 0
    iActivePlayer = CyGame().getActivePlayer()
    pActivePlayer = gc.getPlayer(iActivePlayer)
    iActivePlayerTeam = pActivePlayer.getTeam()
    eDomain = gc.getUnitInfo(pUnit.getUnitType()).getDomainType()

    # a sea or air unit in a city, behaves like a land unit
    if pPlot.isCity():
        eDomain = DomainTypes.DOMAIN_LAND

    # calculate the adjacent-tile heal-factor caused by other units (only the unit with the highest factor counts)
    for dx in xrange(-1, 2):
        for dy in xrange(-1, 2):
            # ignore same tile. Adjacent-tile healing does not work on the same tile.
            if not (dx == 0 and dy == 0):
                pLoopPlot = CyMap().plot(pPlot.getX() + dx, pPlot.getY() + dy)
                # loop through all units on the plot
                for i in xrange(pLoopPlot.getNumUnits()):
                    pLoopUnit = pLoopPlot.getUnit(i)
                    eLoopUnitDomain = gc.getUnitInfo(
                        pLoopUnit.getUnitType()).getDomainType()
                    # a sea or air unit in a city, behaves like a land unit
                    if pLoopPlot.isCity():
                        eLoopUnitDomain = DomainTypes.DOMAIN_LAND
                    # adjacent-tile heal does only work if the units have the same domain type
                    if (eDomain == eLoopUnitDomain):
                        if (pLoopUnit.getTeam() == iActivePlayerTeam):
                            if (pLoopUnit.getAdjacentTileHeal() >
                                    iAdjacentTileHealFactor):
                                iAdjacentTileHealFactor = pLoopUnit.getAdjacentTileHeal(
                                )

    # calculate the same-tile heal-factor caused by other or same unit (only the unit with the highest factor counts)
    # the same-tile healing is also a kind of self-healing. Means : the promotion Medic I has also effect on the owner unit
    for i in xrange(pPlot.getNumUnits()):
        pLoopUnit = pPlot.getUnit(i)
        eLoopUnitDomain = gc.getUnitInfo(
            pLoopUnit.getUnitType()).getDomainType()
        # a sea or air unit in a city, behaves like a land unit
        if pLoopPlot.isCity():
            eLoopUnitDomain = DomainTypes.DOMAIN_LAND
        # same tile heal does only work if the units are of the same domain type
        if (eDomain == eLoopUnitDomain):
            if (pLoopUnit.getTeam() == iActivePlayerTeam):
                if (pLoopUnit.getSameTileHeal() > iSameTileHealFactor):
                    iSameTileHealFactor = pLoopUnit.getSameTileHeal()

    # only the highest value counts
    iTileHealFactor = max(iAdjacentTileHealFactor, iSameTileHealFactor)

    # calculate the self heal factor by the location and promotion
    iTeam = pPlot.getTeam()
    pTeam = gc.getTeam(iTeam)
    iSelfHealFactor = NEUTRAL_HEAL_RATE
    iPromotionHealFactor = pUnit.getExtraNeutralHeal()
    if pPlot.isCity():
        iSelfHealFactor = CITY_HEAL_RATE
        iPromotionHealFactor = pUnit.getExtraFriendlyHeal()
    elif (iTeam == iActivePlayerTeam):
        iSelfHealFactor = FRIENDLY_HEAL_RATE
        iPromotionHealFactor = pUnit.getExtraFriendlyHeal()
    elif (iTeam != TeamTypes.NO_TEAM):
        if (pTeam.isAtWar(iActivePlayerTeam)):
            iSelfHealFactor = ENEMY_HEAL_RATE
            iPromotionHealFactor = pUnit.getExtraEnemyHeal()

    # calculate the heal factor by city buildings
    if pPlot.isCity():
        if (pPlot.getTeam() == iActivePlayerTeam):
            # EF: should probably allow friendly healing too, but this doesn't
            pCity = pPlot.getPlotCity()
            # loop for all buldings
            for iBuilding in xrange(gc.getNumBuildingInfos()):
                # check if city has that building
                if pCity.getNumActiveBuilding(iBuilding) > 0:
                    # sum up all heal rates
                    iBuildingHealFactor += gc.getBuildingInfo(iBuilding).getHealRateChange() * \
                        pCity.getNumActiveBuilding(iBuilding)

    # return the sum of all heal factors
    return iTileHealFactor + iBuildingHealFactor + iSelfHealFactor + iPromotionHealFactor