def update(self, fDelta):
     if (CyInterface().isDirty(
             InterfaceDirtyBits.Financial_Screen_DIRTY_BIT) == True):
         CyInterface().setDirty(
             InterfaceDirtyBits.Financial_Screen_DIRTY_BIT, False)
         self.drawContents()
     return
Exemple #2
0
 def onMouseOverPlot(self, argsList=None):
     """
     Called from CvOverlayScreenUtils when mousing over a plot when the screen is active.
     Updates the current plot and its x/y location.
     """
     plot = CyInterface().getMouseOverPlot()
     x = plot.getX()
     y = plot.getY()
     self.currentPoint = (x, y)
     g_DotMap.highlightCity(self.currentPoint, self.currentColor)
     self.resetInterfaceMode()
Exemple #3
0
def getDisplayCity():
    """
    Returns the city to display in the progress bar.
    """
    pHeadSelectedCity = CyInterface().getHeadSelectedCity()
    if pHeadSelectedCity and pHeadSelectedCity.getTeam() == gc.getGame(
    ).getActiveTeam():
        city = pHeadSelectedCity
        iTurns = getCityTurns(city)
    else:
        city, iTurns = findNextCity()
        if not city:
            city, iGPP = findMaxCity()
            iTurns = None
    return (city, iTurns)
Exemple #4
0
 def handleInput (self, inputClass):
     if inputClass.getNotifyCode() == NotifyCode.NOTIFY_CLICKED:
       if inputClass.getButtonType() == WidgetTypes.WIDGET_GENERAL and inputClass.getData2() != -1:
         pPlayer = gc.getPlayer(CyGame().getActivePlayer())
         pUnit = pPlayer.getUnit(inputClass.getData2())
         if inputClass.getData1() == 1:
           CyCamera().JustLookAtPlot(pUnit.plot())
           CyInterface().selectUnit(pUnit, True, True, True)
           self.hideScreen()
         elif inputClass.getData1() == 748:
           CyMessageControl().sendModNetMessage(748, -1, -1, CyGame().getActivePlayer(), inputClass.getData2())
           CyCamera().JustLookAtPlot(pUnit.plot())
           CyInterface().selectUnit(pUnit, True, True, True)
           self.hideScreen()
     return 0
    def handleInput(self, inputClass):
        ' Calls function mapped in DomesticAdvisorInputMap'
        # only get from the map if it has the key

        if (inputClass.getNotifyCode() ==
                NotifyCode.NOTIFY_LISTBOX_ITEM_SELECTED):
            if (inputClass.getMouseX() == 0):
                screen = CyGInterfaceScreen("DomesticAdvisor",
                                            CvScreenEnums.DOMESTIC_ADVISOR)
                screen.hideScreen()

                CyInterface().selectCity(
                    gc.getPlayer(inputClass.getData1()).getCity(
                        inputClass.getData2()), True)

                popupInfo = CyPopupInfo()
                popupInfo.setButtonPopupType(
                    ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
                popupInfo.setText(u"showDomesticAdvisor")
                popupInfo.addPopup(inputClass.getData1())
            else:
                self.updateAppropriateCitySelection()
                self.updateSpecialists()
        elif (inputClass.getNotifyCode() == NotifyCode.NOTIFY_CLICKED):
            if (inputClass.getFunctionName() == "DomesticSplit"):
                screen = CyGInterfaceScreen("DomesticAdvisor",
                                            CvScreenEnums.DOMESTIC_ADVISOR)
                screen.hideScreen()

        return 0
def convertCity(pCity):
	iReligion = gc.getInfoTypeForString("RELIGION_CHRISTIANITY")
	iPlayer = pCity.getOwner()
	pPlayer = gc.getPlayer(iPlayer)

	# nicht bei Judentum, Hindu, Buddh und Jain
	if (not pCity.isHasReligion(gc.getInfoTypeForString("RELIGION_JUDAISM"))
			and not pCity.isHasReligion(gc.getInfoTypeForString("RELIGION_HINDUISM"))
			and not pCity.isHasReligion(gc.getInfoTypeForString("RELIGION_BUDDHISM"))
			and not pCity.isHasReligion(gc.getInfoTypeForString("RELIGION_JAINISMUS"))):

		if pCity.isCapital():
			iChance = 40 # 2.5%
		elif pCity.isHasBuilding(gc.getInfoTypeForString("BUILDING_STADT")):
			if pCity.isHasBuilding(gc.getInfoTypeForString("BUILDING_SKLAVENMARKT")):
				iChance = 30 # 3%
			else:
				iChance = 50 # 2%
		elif pCity.isHasBuilding(gc.getInfoTypeForString("BUILDING_SKLAVENMARKT")):
			iChance = 40 # 2.5%
		else:
			iChance = 75 # 1.5%

		# bei folgenden Civics Chance verringern
		if pPlayer.isCivic(gc.getInfoTypeForString("CIVIC_THEOCRACY")):
			iChance += 25
		if pPlayer.isCivic(gc.getInfoTypeForString("CIVIC_AMPHIKTIONIE")):
			iChance += 25

		if CvUtil.myRandom(iChance, "convertCity") == 1:
			pCity.setHasReligion(iReligion, 1, 1, 0)
			if pPlayer.isHuman():
				iRand = 1 + CvUtil.myRandom(3, "TXT_KEY_MESSAGE_HERESY_2CHRIST_")
				CyInterface().addMessage(iPlayer, True, 10, CyTranslator().getText("TXT_KEY_MESSAGE_HERESY_2CHRIST_"+str(iRand),(pCity.getName(),0)), None, 2,"Art/Interface/Buttons/Actions/button_kreuz.dds", ColorTypes(11), pCity.getX(), pCity.getY(), True, True)
def doGameUpdate():
    global bWroteLog
    bOOS = CyInterface().isOOSVisible()

    if (bOOS and not bWroteLog):
        writeLog()
        bWroteLog = True
Exemple #8
0
def doOnUnitMove(pUnit, pPlot, pOldPlot):
    # Seevoelkereinheit wird entladen, leere Seevoelkerschiffe werden gekillt
    if pUnit.getUnitType() == gc.getInfoTypeForString("UNIT_SEEVOLK"):
        if not pUnit.hasCargo():
            # COMMAND_DELETE can cause CtD if used in onUnitMove()
            # pUnit.doCommand(CommandTypes.COMMAND_DELETE, 1, 1)
            pUnit.kill(True, -1)
            return True
        else:
            if pOldPlot.getOwner() == -1 and pPlot.getOwner() != -1:
                if gc.getPlayer(pPlot.getOwner()).isHuman():
                    CyInterface().addMessage(
                        pPlot.getOwner(), True, 15,
                        CyTranslator().getText("TXT_KEY_MESSAGE_SEEVOLK_ALERT",
                                               ()), None, 2, pUnit.getButton(),
                        ColorTypes(7), pPlot.getX(), pPlot.getY(), True, True)
                if pPlot.getOwner() == gc.getGame().getActivePlayer():
                    CyAudioGame().Play2DSound("AS2D_THEIRDECLAREWAR")

    # Barbarische Tiere sollen keine Stadt betreten / Barbarian animals will be disbanded when moving into a city
    elif pUnit.getUnitAIType() == UnitAITypes.UNITAI_ANIMAL:
        if pPlot.isCity():
            pUnit.kill(True, -1)
            return True
    # Barbarische Emigranten stehen nur rum und benoetigen unnoetig Rechenzeit
    elif pUnit.getUnitType() == gc.getInfoTypeForString("UNIT_EMIGRANT"):
        pUnit.kill(True, -1)
        return True
    # Barbarische befreite Sklaven stehen nur rum und benoetigen unnoetig Rechenzeit
    elif pUnit.getUnitType() == gc.getInfoTypeForString("UNIT_FREED_SLAVE"):
        pUnit.kill(True, -1)
        return True

    return False
Exemple #9
0
 def update(self, fDelta):
     """
     Called each update cycle, checks for mouse button clicks when screen is up.
     """
     if CyInterface().isLeftMouseDown():
         if not self.bLeftMouseDown:
             self.onLeftMouseDown()
         self.bLeftMouseDown = True
     else:
         self.bLeftMouseDown = False
     if CyInterface().isRightMouseDown():
         if not self.bRightMouseDown:
             self.onRightMouseDown()
         self.bRightMouseDown = True
     else:
         self.bRightMouseDown = False
    def handleInput (self, inputClass):

        screen = self.getScreen()
        szWidgetName = inputClass.getFunctionName()
        # szFullWidgetName = szWidgetName + str(inputClass.getID())
        # code = inputClass.getNotifyCode()

        if inputClass.getNotifyCode() == NotifyCode.NOTIFY_LISTBOX_ITEM_SELECTED and szWidgetName != self.TABLE_ID:

            iIndex = screen.getSelectedPullDownID(self.DEBUG_DROPDOWN_ID)
            self.iActivePlayer = screen.getPullDownData(self.DEBUG_DROPDOWN_ID, iIndex)
            self.drawReligionInfo()
            self.drawCityInfo(self.iReligionSelected)
            return 1
        # Mod BUG Zoom to City
        elif szWidgetName == self.TABLE_ID:
            if inputClass.getMouseX() == 0:
                screen.hideScreen()
                pPlayer = gc.getPlayer(inputClass.getData1())
                pCity = pPlayer.getCity(inputClass.getData2())
#               CyCamera().JustLookAtPlot(pCity.plot())

                CyInterface().selectCity(pCity, True);

        elif self.ReligionScreenInputMap.has_key(inputClass.getFunctionName()):
            'Calls function mapped in ReligionScreenInputMap'
            # only get from the map if it has the key

            # get bound function from map and call it
            self.ReligionScreenInputMap.get(inputClass.getFunctionName())(inputClass)
            return 1
        return 0
Exemple #11
0
 def hideScreen(self):
     """
     Hides the screen.
     """
     g_DotMap.unhighlightCity()
     CyInterface().setInterfaceMode(
         InterfaceModeTypes.INTERFACEMODE_SELECTION)
     screen = self.getScreen()
     screen.hideScreen()
def debug(argsList):
    printToScr = True
    printToLog = True
    message = "%s" % (argsList)
    if (printToScr):
        CyInterface().addImmediateMessage(message, "")
    if (printToLog):
        CvUtil.pyPrint(message)
    return 0
    def update(self, fDelta):
        if (CyInterface().isDirty(
                InterfaceDirtyBits.Domestic_Advisor_DIRTY_BIT) == True):
            CyInterface().setDirty(
                InterfaceDirtyBits.Domestic_Advisor_DIRTY_BIT, False)

            # screen = CyGInterfaceScreen( "DomesticAdvisor", CvScreenEnums.DOMESTIC_ADVISOR )
            player = gc.getPlayer(CyGame().getActivePlayer())

            i = 0
            (loopCity, iter) = player.firstCity(False)
            while loopCity:
                #if not loopCity.isNone() and loopCity.getOwner() == player.getID(): #only valid cities
                self.updateTable(loopCity, i)
                i += 1
                (loopCity, iter) = player.nextCity(iter, False)

            self.updateSpecialists()

        return
def doStrandgut():
	iBarbPlayer = gc.getBARBARIAN_PLAYER()
	pBarbPlayer = gc.getPlayer(iBarbPlayer)
	iTreibgut = gc.getInfoTypeForString("UNIT_TREIBGUT")
	iStrandgut = gc.getInfoTypeForString("UNIT_STRANDGUT")
	iGoldkarren = gc.getInfoTypeForString("UNIT_GOLDKARREN")
	iDarkIce = gc.getInfoTypeForString("FEATURE_DARK_ICE")
	eCoast = gc.getInfoTypeForString("TERRAIN_COAST")

	lUnits = PyPlayer(iBarbPlayer).getUnitsOfType(iTreibgut)
	# CyInterface().addMessage(gc.getGame().getActivePlayer(), True, 15, CyTranslator().getText("TXT_KEY_MESSAGE_TEST", ("Test",len(lUnits))), None, 2, None, ColorTypes(11), 0, 0, False, False)
	for loopUnit in lUnits:
		pPlot = loopUnit.plot()
		if pPlot.getTerrainType() == eCoast:
			lPlots = []
			iX = pPlot.getX()
			iY = pPlot.getY()
			# iRange = 1
			for iI in xrange(DirectionTypes.NUM_DIRECTION_TYPES):
				loopPlot = plotDirection(iX, iY, DirectionTypes(iI))
				if loopPlot and not loopPlot.isNone():
					if not loopPlot.isWater():
						if not loopPlot.isPeak() and not loopPlot.isUnit() and loopPlot.getFeatureType() != iDarkIce:
							lPlots.append(loopPlot)
			if lPlots:
				pPlot = lPlots[CvUtil.myRandom(len(lPlots), "strandgut")]
				# Create Strandgut
				CvUtil.spawnUnit(iStrandgut, pPlot, pBarbPlayer)
				iPlotOwner = pPlot.getOwner()
				if iPlotOwner != -1 and gc.getPlayer(iPlotOwner).isHuman():
					CyInterface().addMessage(iPlotOwner, True, 15, CyTranslator().getText("TXT_KEY_TREIB2STRANDGUT", ()), None, 2, "Art/Interface/Buttons/Units/button_unit_strandgut.dds", ColorTypes(11), pPlot.getX(), pPlot.getY(), True, True)
				# Disband Treibgut
				# loopUnit.doCommand(CommandTypes.COMMAND_DELETE, -1, -1)
				loopUnit.kill(True, -1)  # RAMK_CTD
		elif pPlot.isCity():
			# Create Goldkarren
			CvUtil.spawnUnit(iGoldkarren, pPlot, pBarbPlayer)
			# Disband Treibgut
			# CyInterface().addMessage(gc.getGame().getActivePlayer(), True, 15, CyTranslator().getText("disbandTreibgutCity", ()), None, 2, None, ColorTypes(11), pPlot.getX(), pPlot.getY(), False, False)
			# loopUnit.doCommand(CommandTypes.COMMAND_DELETE, -1, -1)
			loopUnit.kill(True, -1)  # RAMK_CTD
def doMoveDesertStorm(lDesertStorm):
	iFeatDesertstorm = gc.getInfoTypeForString("FEATURE_FALLOUT")
	iTerrainDesert = gc.getInfoTypeForString("TERRAIN_DESERT")
	#iDarkIce = gc.getInfoTypeForString("FEATURE_DARK_ICE")

	lImprovements = [
		gc.getInfoTypeForString("IMPROVEMENT_FORT"),
		gc.getInfoTypeForString("IMPROVEMENT_FORT2"),
		gc.getInfoTypeForString("IMPROVEMENT_TURM2"),
		gc.getInfoTypeForString("IMPROVEMENT_MINE")
	]

	# Wegen Wind von West nach Ost, die Reihenfolge der Plot-Liste umkehren
	lDesertStorm.reverse()

	for p in lDesertStorm:
		loopPlot = plotXY(p.getX(), p.getY(), 2, 0) # 2-Plot-Schritte nach Osten
		if loopPlot and not loopPlot.isNone():
			if loopPlot.getTerrainType() == iTerrainDesert:
				if loopPlot.getFeatureType() == -1:
					if not loopPlot.isPeak():
						bMeldung = False
						# Entferne Modernisierung 1:3
						if loopPlot.getImprovementType() not in lImprovements:
							if CvUtil.myRandom(3, "doDestroyImprovementDueToDesertStorm") == 1:
								loopPlot.setImprovementType(-1)
								bMeldung = True
						# Entferne Strasse 1:3
						if loopPlot.getRouteType() == 0 and not loopPlot.isCity():
							if CvUtil.myRandom(3, "doDestroyRouteDueToDesertStorm") == 1:
								loopPlot.setRouteType(-1)
								bMeldung = True
						# Sandsturm setzen
						loopPlot.setFeatureType(iFeatDesertstorm, 0)
						# Meldung an den Spieler
						if bMeldung and loopPlot.getOwner() != -1:
							if gc.getPlayer(loopPlot.getOwner()).isHuman():
								CyInterface().addMessage(gc.getPlayer(loopPlot.getOwner()).getID(), True, 12, CyTranslator().getText("TXT_KEY_DISASTER_DESERTSTORM", ("", )), None, 2, gc.getFeatureInfo(iFeatDesertstorm).getButton(), ColorTypes(7), loopPlot.getX(), loopPlot.getY(), True, True)
		# Sandsturm entfernen (vorheriger Plot)
		p.setFeatureType(-1, 0)
    def drawContents(self):

        # Get the screen and the player
        screen = CyGInterfaceScreen("DomesticAdvisor",
                                    CvScreenEnums.DOMESTIC_ADVISOR)
        player = gc.getPlayer(CyGame().getActivePlayer())

        screen.moveToFront("Background")

        # Build the table
        screen.addTableControlGFC("CityListBackground", 21, 18, 21,
                                  self.nTableWidth, self.nTableHeight, True,
                                  False, 24, 24,
                                  TableStyles.TABLE_STYLE_STANDARD)
        screen.enableSelect("CityListBackground", True)
        screen.enableSort("CityListBackground")
        screen.setStyle("CityListBackground", "Table_StandardCiv_Style")

        # Loop through the cities
        i = 0
        (loopCity, iter) = player.firstCity(False)
        while loopCity:
            screen.appendTableRow("CityListBackground")
            if (loopCity.getName() in self.listSelectedCities):
                screen.selectRow("CityListBackground", i, True)
            self.updateTable(loopCity, i)
            i += 1
            (loopCity, iter) = player.nextCity(iter, False)

        self.drawHeaders()

        self.drawSpecialists()

        screen.moveToBack("DomesticAdvisorBG")

        self.updateAppropriateCitySelection()

        CyInterface().setDirty(InterfaceDirtyBits.Domestic_Advisor_DIRTY_BIT,
                               True)
def doHistory():
	"""++++++++++++++++++ Historische Texte ++++++++++++++++++++++++++++++++++++++++++++++"""
	iGameYear = gc.getGame().getGameTurnYear()
	# txts = 0
	if iGameYear in lNumHistoryTexts:
		txts = lNumHistoryTexts[iGameYear]
	# if txts > 0:
		iRand = CvUtil.myRandom(txts, "doHistory")

		# iRand 0 bedeutet keinen Text anzeigen. Bei mehr als 2 Texte immer einen einblenden
		if txts > 2:
			iRand += 1

		if iRand > 0:
			text = "TXT_KEY_HISTORY_"
			if iGameYear < 0:
				text = text + str(iGameYear * (-1)) + "BC_" + str(iRand)
			else:
				text = text + str(iGameYear) + "AD_" + str(iRand)

			text = CyTranslator().getText("TXT_KEY_HISTORY", ("",)) + " " + CyTranslator().getText(text, ("",))
			CyInterface().addMessage(gc.getGame().getActivePlayer(), True, 15, text, None, 2, None, ColorTypes(14), 0, 0, False, False)
def launch(argsList=None):
    """
    Opens the mod's help file or web page externally if it can be found or displays an error alert.

    On Windows this opens the compiled HTML help file (CHM).
    On Mac this opens a browser window to the online help file.
    """
    if BugPath.isMac():
        sLang = ["ENG", "ENG", "DEU", "ITA", "ENG"]
        url = "http://civ4bug.sourceforge.net/BUGModHelp/%s/index.htm" % sLang[
            CyGame().getCurrentLanguage()]
        try:
            import webbrowser
            showLaunchMessage()
            webbrowser.open(url, new=1, autoraise=1)
            return True
        except:
            showErrorAlert(
                BugUtil.getPlainText(
                    "TXT_KEY_BUG_HELP_CANNOT_OPEN_BROWSER_TITLE"),
                BugUtil.getText("TXT_KEY_BUG_HELP_CANNOT_OPEN_BROWSER_BODY",
                                (url, )))
    else:
        sLang = ["ENG", "FRA", "DEU", "ITA", "ESP"]
        name = "BUG Mod Help-%s.chm" % (sLang[CyGame().getCurrentLanguage()])
        file = BugPath.findInfoFile(name)
        if file:
            import os
            message = BugUtil.getPlainText("TXT_KEY_BUG_HELP_OPENING")
            CyInterface().addImmediateMessage(message, "")
            os.startfile(file)
            return True
        else:
            showErrorAlert(
                BugUtil.getPlainText("TXT_KEY_BUG_HELP_MISSING_TITLE"),
                BugUtil.getText("TXT_KEY_BUG_HELP_MISSING_BODY", (name, )))
    return False
def _riverErrorMsg(msg, argTuple=()):
	CyInterface().addMessage(gc.getGame().getActivePlayer(), True, 5,
							 CyTranslator().getText(msg, argTuple),
							 None, 2, None, ColorTypes(14), 0, 0,
							 False, False)
Exemple #20
0
 def _addMessage(self, ePlayer, szString, szIcon, iFlashX, iFlashY):
     """Displays an on-screen message."""
     eventMessageTimeLong = self.gc.getDefineINT("EVENT_MESSAGE_TIME_LONG")
     CyInterface().addMessage(ePlayer, True, eventMessageTimeLong, szString,
                              None, 0, szIcon, ColorTypes(-1), iFlashX,
                              iFlashY, True, True)
Exemple #21
0
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)
Exemple #22
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)
def doOlympicGames():
	# wurde das Projekt erstellt?
	if gc.getGame().getProjectCreatedCount(gc.getInfoTypeForString("PROJECT_OLYMPIC_GAMES")) == 0:
		return

	# alle 4 Runden
	if gc.getGame().getCalendar() == gc.getInfoTypeForString("CALENDAR_MONTHS"):
		iTurns = 48
	elif gc.getGame().getCalendar() == gc.getInfoTypeForString("CALENDAR_SEASONS"):
		iTurns = 16
	else:
		iTurns = 4

	if gc.getGame().getElapsedGameTurns() % iTurns == 1:

		# Inits
		lCities4Olympiade = []
		lHumans = []
		lPlayers = []

		iTechSchaukampf = gc.getInfoTypeForString("TECH_GLADIATOR")
		iTechImperialismus = gc.getInfoTypeForString("TECH_NATIONALISM")
		iTechPapsttum = gc.getInfoTypeForString("TECH_PAPSTTUM")
		iReligionGreek = gc.getInfoTypeForString("RELIGION_GREEK")
		iReligionRome = gc.getInfoTypeForString("RELIGION_ROME")

		iBuildingStadion = gc.getInfoTypeForString("BUILDING_STADION")
		iBuildingClassStadion = gc.getInfoTypeForString("BUILDINGCLASS_STADION")
		iBuildingOlympionike = gc.getInfoTypeForString("BUILDING_OLYMPIONIKE")
		iBuildingClassGymnasion = gc.getInfoTypeForString("BUILDINGCLASS_SPECIAL3")

		# Los gehts
		iNumPlayers = gc.getMAX_PLAYERS()
		for iPlayer in xrange (iNumPlayers):
			pPlayer = gc.getPlayer(iPlayer)
			if pPlayer and not pPlayer.isNone() and pPlayer.isAlive(): # and not pPlayer.isBarbarian():

				# Hat der Spieler noch nicht Schaukampf erforscht, isser nicht dabei
				if not gc.getTeam(pPlayer.getTeam()).isHasTech(iTechSchaukampf):
					continue

				# Hat der Spieler bereits das Papsttum erforscht, is der Spass vorbei
				if gc.getTeam(pPlayer.getTeam()).isHasTech(iTechPapsttum):
					continue

				# Hat der Spieler Imperialismus erforscht?
				bAllowRomanGods = False
				if gc.getTeam(pPlayer.getTeam()).isHasTech(iTechImperialismus):
					bAllowRomanGods = True

				# Init des Spezialgebäudes Gymnasion, Gymnasium
				iBuildingGymnasion = gc.getCivilizationInfo(pPlayer.getCivilizationType()).getCivilizationBuildings(iBuildingClassGymnasion)

				# Cities
				iNumCities = pPlayer.getNumCities()
				for iCity in xrange (iNumCities):
					pCity = pPlayer.getCity(iCity)
					if pCity and not pCity.isNone():

						# Aktuellen Olympioniken rausschmeissen
						pCity.setNumRealBuilding(iBuildingOlympionike,0)

						# Hat die Stadt die richtige Religion?
						if pCity.isHasReligion(iReligionGreek) or bAllowRomanGods and pCity.isHasReligion(iReligionRome):

							# Liste für Spielermeldungen
							if pPlayer.isHuman() and iPlayer not in lHumans:
								lHumans.append(iPlayer)

							# Liste verschiedener CIVs
							if iPlayer not in lPlayers:
								lPlayers.append(iPlayer)

							# Stadt an den Spielen zulassen
							lCities4Olympiade.append(pCity)
							# Verbesserte Chancen:
							if pCity.isHasBuilding(iBuildingStadion):
								lCities4Olympiade.append(pCity)
							if pCity.isHasBuilding(iBuildingGymnasion):
								lCities4Olympiade.append(pCity)

		# Choose new Olympic Winner City
		# erst ab 2 CIVs
		if len(lPlayers) <= 1:
			return

		iRand = CvUtil.myRandom(len(lCities4Olympiade), "CityOfOlympiadWinner")
		pCity = lCities4Olympiade[iRand]

		# Olympionike in die Stadt stellen
		pCity.setNumRealBuilding(iBuildingOlympionike,1)

		# Stadion verbessern +1 Kultur
		if pCity.isHasBuilding(iBuildingStadion):
			iCulture = pCity.getBuildingCommerceChange(iBuildingClassStadion, CommerceTypes.COMMERCE_CULTURE) + 1
			pCity.setBuildingCommerceChange(iBuildingClassStadion, CommerceTypes.COMMERCE_CULTURE, iCulture)

		# Goldkarren erzeugen
		CvUtil.spawnUnit(gc.getInfoTypeForString("UNIT_GOLDKARREN"), pCity.plot(), gc.getPlayer(pCity.getOwner()))
		CvUtil.spawnUnit(gc.getInfoTypeForString("UNIT_GOLDKARREN"), pCity.plot(), gc.getPlayer(pCity.getOwner()))
		# einen weiteren bei Seasons
		if iTurns >= 16:
			CvUtil.spawnUnit(gc.getInfoTypeForString("UNIT_GOLDKARREN"), pCity.plot(), gc.getPlayer(pCity.getOwner()))
			# zwei weitere bei Months (insg. 5)
			if iTurns > 16:
				CvUtil.spawnUnit(gc.getInfoTypeForString("UNIT_GOLDKARREN"), pCity.plot(), gc.getPlayer(pCity.getOwner()))
				CvUtil.spawnUnit(gc.getInfoTypeForString("UNIT_GOLDKARREN"), pCity.plot(), gc.getPlayer(pCity.getOwner()))

		# Chance eines beladenen Fuhrwerks
		if CvUtil.myRandom(4, "Olympia_ChanceOfBonus") == 1:
			pNewUnit = CvUtil.spawnUnit(gc.getInfoTypeForString("UNIT_SUPPLY_FOOD"), pCity.plot(), gc.getPlayer(pCity.getOwner()))
			lBonuses = [
				gc.getInfoTypeForString("BONUS_OLIVES"),
				gc.getInfoTypeForString("BONUS_OLIVES"),
				gc.getInfoTypeForString("BONUS_OLIVES"),
				gc.getInfoTypeForString("BONUS_OLIVES"),
				gc.getInfoTypeForString("BONUS_OLIVES"),
				gc.getInfoTypeForString("BONUS_GRAPES"),
				gc.getInfoTypeForString("BONUS_GRAPES"),
				gc.getInfoTypeForString("BONUS_GRAPES"),
				gc.getInfoTypeForString("BONUS_ROGGEN"),
				gc.getInfoTypeForString("BONUS_HAFER"),
				gc.getInfoTypeForString("BONUS_GERSTE"),
				gc.getInfoTypeForString("BONUS_WHEAT"),
				gc.getInfoTypeForString("BONUS_HIRSE"),
				gc.getInfoTypeForString("BONUS_HORSE")
			]
			eBonus = CvUtil.myRandom(len(lBonuses), "Olympia_BonusType")
			eBonus = lBonuses[eBonus]
			CvUtil.addScriptData(pNewUnit, "b", eBonus)


		# Meldung an alle beteiligten Spieler
		for iPlayer in lHumans:
			xSound = None
			iColor = 14 # graublau
			bShow = False
			# Extra PopUp wenn HI der Gewinner ist
			if iPlayer == pCity.getOwner():
				xSound = "AS2D_WELOVEKING"
				iColor = 10 # cyan
				bShow = True
				popupInfo = CyPopupInfo()
				popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_TEXT)
				sText = CyTranslator().getText("TXT_KEY_INFO_OLYMPIC_GAMES_WINNER", (pCity.getName(),gc.getPlayer(pCity.getOwner()).getCivilizationShortDescription(0)))
				popupInfo.setText(sText)
				popupInfo.addPopup(iPlayer)
			# Ingame Text
			CyInterface().addMessage(iPlayer, True, 15, CyTranslator().getText("TXT_KEY_INFO_OLYMPIC_GAMES_WINNER", (pCity.getName(),gc.getPlayer(pCity.getOwner()).getCivilizationShortDescription(0))), xSound, 2, "Art/Interface/Buttons/Buildings/button_building_olympionike.dds", ColorTypes(iColor), pCity.plot().getX(), pCity.plot().getY(), bShow, bShow)
def removePagans(pCity):
	iReligion = gc.getInfoTypeForString("RELIGION_CHRISTIANITY")
	iPlayer = pCity.getOwner()
	pPlayer = gc.getPlayer(iPlayer)

	# Kult
	lCorp = []
	iRange = gc.getNumCorporationInfos()
	for i in xrange(iRange):
		if pCity.isHasCorporation(i):
			lCorp.append(i)

	# Religion
	lReli = []
	iRange = gc.getNumReligionInfos()
	for i in xrange(iRange):
		if pCity.isHasReligion(i) and i != iReligion:
			lReli.append(i)

	# Kult oder Religion entfernen
	text = ""
	bUndoCorp = False
	if lCorp and lReli:
		if CvUtil.myRandom(2, "undoCorp") == 1:
			bUndoCorp = True

	# Kult
	if lCorp or bUndoCorp:
		iRand = CvUtil.myRandom(len(lCorp), "removePaganCult")
		iRange = gc.getNumBuildingInfos()
		for iBuildingLoop in xrange(iRange):
			if pCity.getNumBuilding(iBuildingLoop) > 0:
				pBuilding = gc.getBuildingInfo(iBuildingLoop)
				if pBuilding.getPrereqCorporation() == lCorp[iRand]:
					# Akademien (Corp7)
					if pBuilding.getType() not in [
						gc.getInfoTypeForString("BUILDING_ACADEMY_2"),
						gc.getInfoTypeForString("BUILDING_ACADEMY_3"),
						gc.getInfoTypeForString("BUILDING_ACADEMY_4")
					]:
						# Wunder sollen nicht betroffen werden
						iBuildingClass = pBuilding.getBuildingClassType()
						if not isWorldWonderClass(iBuildingClass) and not isTeamWonderClass(iBuildingClass) and not isNationalWonderClass(iBuildingClass):
							pCity.setNumRealBuilding(iBuildingLoop,0)
		pCity.setHasCorporation(lCorp[iRand], 0, 0, 0)
		text = gc.getCorporationInfo( lCorp[iRand] ).getText()

	# Religion
	elif lReli:
		iRand = CvUtil.myRandom(len(lReli), "removePaganReli")
		iRange = gc.getNumBuildingInfos()
		for iBuildingLoop in xrange(iRange):
			if pCity.isHasBuilding(iBuildingLoop):
				pBuilding = gc.getBuildingInfo(iBuildingLoop)
				if pBuilding.getPrereqReligion() == lReli[iRand]:
					# Holy City
					if pBuilding.getHolyCity() == -1:
						# Wunder sollen nicht betroffen werden
						iBuildingClass = pBuilding.getBuildingClassType()
						if not isWorldWonderClass(iBuildingClass) and not isTeamWonderClass(iBuildingClass) and not isNationalWonderClass(iBuildingClass):
							pCity.setNumRealBuilding(iBuildingLoop,0)

		pCity.setHasReligion(lReli[iRand], 0, 0, 0)
		text = gc.getReligionInfo( lReli[iRand] ).getText()

	# Meldung
	if pPlayer.isHuman() and text != "":
		iRand = 1 + CvUtil.myRandom(3, "TXT_KEY_MESSAGE_HERESY_CULTS_")
		CyInterface().addMessage(iPlayer, True, 10, CyTranslator().getText("TXT_KEY_MESSAGE_HERESY_CULTS_"+str(iRand),(text,pCity.getName())), None, 2,"Art/Interface/Buttons/Actions/button_kreuz.dds", ColorTypes(11), pCity.getX(), pCity.getY(), True, True)
Exemple #25
0
 def update(self, fDelta):
     if (CyInterface().isDirty(InterfaceDirtyBits.Espionage_Advisor_DIRTY_BIT) == True):
         CyInterface().setDirty(InterfaceDirtyBits.Espionage_Advisor_DIRTY_BIT, False)
         self.refreshScreen()
     return
Exemple #26
0
    def handleInput (self, inputClass):
        'Calls function mapped in EspionageAdvisorInputMap'

        screen = self.getScreen()
        pActivePlayer = gc.getPlayer(self.iActivePlayer)

        ##### Debug Dropdown #####
        if CyGame().isDebugMode():
            if inputClass.getFunctionName() == self.DEBUG_DROPDOWN_ID:
                iIndex = screen.getSelectedPullDownID(self.DEBUG_DROPDOWN_ID)
                self.iActivePlayer = screen.getPullDownData(self.DEBUG_DROPDOWN_ID, iIndex)
                self.drawContents()
                CyInterface().setDirty(InterfaceDirtyBits.Espionage_Advisor_DIRTY_BIT, True)

        if self.iTargetPlayer != -1:

            ##### Player Images #####
            if (inputClass.getData1() == self.iLeaderImagesID):

                self.iTargetPlayer = inputClass.getData2()

                # Loop through all images
                for iPlayerID in self.aiKnownPlayers:
                    szName = "LeaderImage%d" %(iPlayerID)
                    if (self.iTargetPlayer == iPlayerID):
                        screen.setState(szName, True)
                    else:
                        screen.setState(szName, False)

                    self.iActiveCityID = -1

                CyInterface().setDirty(InterfaceDirtyBits.Espionage_Advisor_DIRTY_BIT, True)


            ##### City Listbox #####
            if "%s%d" %(inputClass.getFunctionName(), inputClass.getID()) == self.szCityListBox:
                iCityID = inputClass.getData1()
                self.iActiveCityID = iCityID#gc.getPlayer(self.iTargetPlayer).getCity(iCityID)
                CyInterface().setDirty(InterfaceDirtyBits.Espionage_Advisor_DIRTY_BIT, True)

            # Is there any other players which have been met?
            if self.iTargetPlayer != -1:

                ##### Increase Button #####
                if inputClass.getData1() == self.iIncreaseButtonID:

                    iPlayerID = inputClass.getData2()
                    iTargetTeam = gc.getPlayer(iPlayerID).getTeam()

                    #CyMessageControl().sendEspionageSpendingWeightChange(iTargetTeam, 1)
                    # K-Mod. Right click -> min/max
                    if inputClass.getFlags() & MouseFlags.MOUSE_RBUTTONUP:
                        CyMessageControl().sendEspionageSpendingWeightChange(iTargetTeam, 99)
                    else:
                        CyMessageControl().sendEspionageSpendingWeightChange(iTargetTeam, 1)
                    # K-Mod end

                    if (pActivePlayer.getEspionageSpending(iTargetTeam) > 0):
                        szText = u"<font=2><color=0,255,0,0>%s</color></font>" %(localText.getText("TXT_KEY_ESPIONAGE_NUM_EPS_PER_TURN", (pActivePlayer.getEspionageSpending(iTargetTeam),)))
                    else:
                        szText = u"<font=2><color=192,0,0,0>%s</color></font>" %(localText.getText("TXT_KEY_ESPIONAGE_NUM_EPS_PER_TURN", (pActivePlayer.getEspionageSpending(iTargetTeam),)))

                    screen.setLabelAt("AmountText%d" %(iPlayerID), "LeaderContainer%d" % (iPlayerID), szText, 0, 247, 15 - 1, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

                    if (pActivePlayer.getEspionageSpendingWeightAgainstTeam(iTargetTeam) > 0):
                        szText = u"<font=2>%c</font>" %(gc.getCommerceInfo(CommerceTypes.COMMERCE_ESPIONAGE).getChar())
                    else:
                        szText = u""
                    attach = "LeaderContainer%d" % (iPlayerID)
                    iY = 15
                    screen.setLabelAt("SpendingIcon%d" %(iPlayerID), attach, szText, 0, 25, iY - 1, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

                    CyInterface().setDirty(InterfaceDirtyBits.Espionage_Advisor_DIRTY_BIT, True)

                ##### Decrease Button #####
                elif inputClass.getData1() == self.iDecreaseButtonID:

                    iPlayerID = inputClass.getData2()
                    iTargetTeam = gc.getPlayer(iPlayerID).getTeam()

                    if pActivePlayer.getEspionageSpendingWeightAgainstTeam(iTargetTeam) > 0:  # Can't reduce weight below 0
                        #CyMessageControl().sendEspionageSpendingWeightChange(iTargetTeam, -1)
                        # K-Mod. Right click -> min/max
                        if inputClass.getFlags() & MouseFlags.MOUSE_RBUTTONUP:
                            CyMessageControl().sendEspionageSpendingWeightChange(iTargetTeam, -99)
                        else:
                            CyMessageControl().sendEspionageSpendingWeightChange(iTargetTeam, -1)
                        # K-Mod end

                        if pActivePlayer.getEspionageSpending(iTargetTeam) > 0:
                            szText = u"<font=2><color=0,255,0,0>%s</color></font>" %(localText.getText("TXT_KEY_ESPIONAGE_NUM_EPS_PER_TURN", (pActivePlayer.getEspionageSpending(iTargetTeam),)))
                        else:
                            szText = u"<font=2><color=192,0,0,0>%s</color></font>" %(localText.getText("TXT_KEY_ESPIONAGE_NUM_EPS_PER_TURN", (pActivePlayer.getEspionageSpending(iTargetTeam),)))

                        screen.setLabelAt("AmountText%d" %(iPlayerID), "LeaderContainer%d" % (iPlayerID), szText, 0, 247, 15 - 1, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

                        if pActivePlayer.getEspionageSpendingWeightAgainstTeam(iTargetTeam) > 0:
                            szText = u"<font=2>%c</font>" %(gc.getCommerceInfo(CommerceTypes.COMMERCE_ESPIONAGE).getChar())
                        else:
                            szText = u""
                        attach = "LeaderContainer%d" % (iPlayerID)
                        iY = 15
                        screen.setLabelAt("SpendingIcon%d" %(iPlayerID), attach, szText, 0, 25, iY - 1, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

                        CyInterface().setDirty(InterfaceDirtyBits.Espionage_Advisor_DIRTY_BIT, True)

        return 0
Exemple #27
0
                                CyInterface, NotifyCode, GameOptionTypes)
import ColorUtil
import CvEventInterface
import sys
import time
import traceback
import types

# TODO remove
# DEBUG code for Python 3 linter
# unicode = str
# xrange = range

gc = CyGlobalContext()
localText = CyTranslator()
interface = CyInterface()

## Display Year


def getDisplayYear(vYear):
    if (vYear < 0):
        return str(-vYear) + getPlainText("TXT_KEY_AUTOLOG_BC")
    else:
        return str(vYear) + getPlainText("TXT_KEY_AUTOLOG_AD")


## Text Formatting and Processing


def getPlainText(key, default=None, replaceFontTags=True):
def _debugMsg(m):
	CyInterface().addMessage(gc.getGame().getActivePlayer(), True, 5,
							 m, None, 2, None, ColorTypes(14), 0, 0,
							 False, False)
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 interfaceScreen(self, iEra):

        # K-Mod note: I've taken out all reference to X_SCREEN and Y_SCREEN, and instead set it up to be automatically centered. (I haven't left the old code in. I've just deleted it.)
        self.W_SCREEN = 775
        self.H_SCREEN = 660
        self.Y_TITLE = 20

        self.X_EXIT = self.W_SCREEN / 2 - 50
        self.Y_EXIT = self.H_SCREEN - 50
        self.W_EXIT = 120
        self.H_EXIT = 30

        if (CyInterface().noTechSplash()):
            return 0

        # player = PyPlayer(CyGame().getActivePlayer())

        screen = CyGInterfaceScreen("EraMovieScreen" + str(iEra),
                                    CvScreenEnums.ERA_MOVIE_SCREEN)
        #screen.setDimensions(screen.centerX(0), screen.centerY(0), self.W_SCREEN, self.H_SCREEN) # This doesn't work. Those 'center' functions assume a particular window size. (not original code)
        screen.setDimensions(screen.getXResolution() / 2 - self.W_SCREEN / 2,
                             screen.getYResolution() / 2 - self.H_SCREEN / 2 -
                             70, self.W_SCREEN, self.H_SCREEN)  # K-Mod
        screen.addPanel("EraMoviePanel", "", "", True, True, 0, 0,
                        self.W_SCREEN, self.H_SCREEN,
                        PanelStyles.PANEL_STYLE_MAIN)

        screen.showWindowBackground(True)
        screen.setRenderInterfaceOnly(False)
        screen.setSound("AS2D_NEW_ERA")
        screen.showScreen(PopupStates.POPUPSTATE_MINIMIZED, False)

        # Header...
        szHeader = localText.getText("TXT_KEY_ERA_SPLASH_SCREEN",
                                     (gc.getEraInfo(iEra).getTextKey(), ))
        szHeaderId = "EraTitleHeader" + str(iEra)
        screen.setText(szHeaderId, "Background", szHeader,
                       CvUtil.FONT_CENTER_JUSTIFY, self.W_SCREEN / 2,
                       self.Y_TITLE, 0, FontTypes.TITLE_FONT,
                       WidgetTypes.WIDGET_GENERAL, -1, -1)

        screen.setButtonGFC("EraExit" + str(iEra),
                            localText.getText("TXT_KEY_MAIN_MENU_OK", ()), "",
                            self.X_EXIT, self.Y_EXIT, self.W_EXIT, self.H_EXIT,
                            WidgetTypes.WIDGET_CLOSE_SCREEN, -1, -1,
                            ButtonStyles.BUTTON_STYLE_STANDARD)

        # Play the movie
        if iEra == 1:
            szMovie = "Art/Movies/Era/Era01-Classical.dds"
        elif iEra == 2:
            szMovie = "Art/Movies/Era/Era02-Medeival.dds"
        elif iEra == 3:
            szMovie = "Art/Movies/Era/Era03-Renaissance.dds"
        elif iEra == 4:
            szMovie = "Art/Movies/Era/Era04-Industrial.dds"
        else:
            szMovie = "Art/Movies/Era/Era05-Modern.dds"

        screen.addDDSGFC("EraMovieMovie" + str(iEra), szMovie, 27, 50, 720,
                         540, WidgetTypes.WIDGET_GENERAL, -1, -1)

        return 0