示例#1
0
def give(GC, TRNSLTR, GAME, CyUnit, iPlayer, bLand):

    aStarSignList = ("PROMOTION_AQUARIUS", "PROMOTION_ARIES",
                     "PROMOTION_CANCER", "PROMOTION_GEMINI", "PROMOTION_LEO",
                     "PROMOTION_LIBRA", "PROMOTION_PISCES",
                     "PROMOTION_SAGITTARIUS", "PROMOTION_SCORPIO",
                     "PROMOTION_TAURUS", "PROMOTION_CAPRICORN",
                     "PROMOTION_VIRGO")
    if bLand:
        iChance = GAME.getSorenRandNum(12, "Star Signs")  # integer 0-11
    else:
        iChance = GAME.getSorenRandNum(10, "Star Signs")  # integer 0-9

    iPromotion = GC.getInfoTypeForString(aStarSignList[iChance])
    CyUnit.setHasPromotion(iPromotion, True)

    if iPlayer == GAME.getActivePlayer() and GAME.isFinalInitialized():
        CyCity = CyUnit.plot().getPlotCity()
        if CyCity and not CyCity.isNone():
            szTxt = TRNSLTR.getText("TXT_KEY_MSG_STARSIGN_BUILD",
                                    (CyCity.getName(), ))
        else:
            szTxt = TRNSLTR.getText("TXT_KEY_MSG_STARSIGN_CREATE", ())

        szIcon = GC.getPromotionInfo(iPromotion).getButton()
        CvUtil.sendMessage(szTxt, iPlayer, 16, szIcon, ColorTypes(44),
                           CyUnit.getX(), CyUnit.getY(), True, True)
示例#2
0
	def doCityCaptureGold(self, argsList):
		CyCity, iOwnerNew, = argsList

		ownerOld = GC.getPlayer(CyCity.getOwner())
		obsoleteTech = self.iHimejiCastleObsoleteTech
		if obsoleteTech == -1 or not GC.getTeam(ownerOld.getTeam()).isHasTech(obsoleteTech) and ownerOld.countNumBuildings(self.iHimejiCastle):
			return 0

		gold = self.BASE_CAPTURE_GOLD

		gold += CyCity.getPopulation() * self.CAPTURE_GOLD_PER_POP
		gold += GAME.getSorenRandNum(self.CAPTURE_GOLD_RAND1, "One")
		gold += GAME.getSorenRandNum(self.CAPTURE_GOLD_RAND2, "Two")

		iMaxTurns = self.CAPTURE_GOLD_MAX_TURNS
		if iMaxTurns > 0:
			iTurns = GAME.getGameTurn() - CyCity.getGameTurnAcquired()
			if iTurns > 0 and iTurns < iMaxTurns:
				gold *= 1.0 * iTurns / iMaxTurns

		if CyCity.getNumActiveBuilding(self.iNationalMint):
			gold *= 10

		if (iOwnerNew == GAME.getActivePlayer()):
			CvUtil.sendMessage(CyTranslator().getText("TXT_KEY_MISC_PILLAGED_CITY_CAPTURED", (int(gold), CyCity.getName())), iOwnerNew, 10, '', ColorTypes(10))

		return int(gold)
示例#3
0
 def OnCityBuilt(self, argsList):
     CyCity = argsList[0]
     iOwner = CyCity.getOwner()
     iPlayer = GC.getGame().getActivePlayer()
     if self.getCheckForDomVictory():
         if iOwner == iPlayer:
             self.CheckForAlerts(iOwner, False)
     if self.options.isShowCityFoundedAlert():
         if iOwner != iPlayer:
             bRevealed = CyCity.isRevealed(GC.getActivePlayer().getTeam(),
                                           False)
             if bRevealed or PlayerUtil.canSeeCityList(iOwner):
                 CyPlayer = GC.getPlayer(iOwner)
                 iColor = GC.getInfoTypeForString("COLOR_MAGENTA")
                 if bRevealed:
                     msg = TRNSLTR.getText(
                         "TXT_KEY_MORECIV4LERTS_CITY_FOUNDED",
                         (CyPlayer.getName(), CyCity.getName()))
                     icon = "Art/Interface/Buttons/Actions/foundcity.dds"
                     CvUtil.sendMessage(msg, iPlayer,
                                        EVENT_MESSAGE_TIME_LONG, icon,
                                        ColorTypes(iColor), CyCity.getX(),
                                        CyCity.getY(), True, True)
                 else:
                     msg = TRNSLTR.getText(
                         "TXT_KEY_MORECIV4LERTS_CITY_FOUNDED_UNSEEN",
                         (CyPlayer.getName(), CyCity.getName()))
                     self._addMessageNoIcon(iPlayer, msg, iColor)
示例#4
0
def doImmigrantPlacementAI(CyUnit,
                           CyCity,
                           CyPlayer=None,
                           iPlayer=None,
                           bJoin=False):
    iX = CyCity.getX()
    iY = CyCity.getY()
    if CyUnit.getX() != iX or CyUnit.getY() != iY:
        CyUnit.getGroup().pushMission(MissionTypes.MISSION_MOVE_TO, iX, iY, 0,
                                      False, True, MissionAITypes.NO_MISSIONAI,
                                      CyUnit.plot(), CyUnit)
    elif bJoin:
        CyCity.setPopulation(CyCity.getPopulation() + 1)
        if CyPlayer.isHuman():
            szTxt = CyTranslator().getText("TXT_KEY_MSG_IMMIGRATION",
                                           (CyCity.getName(), ))
            CvUtil.sendMessage(szTxt,
                               iPlayer,
                               25,
                               CyUnit.getButton(),
                               ColorTypes(8),
                               iX,
                               iY,
                               True,
                               True,
                               szSound="AS2D_WELOVEKING")

        CyUnit.kill(0, -1)
示例#5
0
def addMessage(iPlayer,
               szTxt,
               icon=None,
               iX=-1,
               iY=-1,
               bOffArrow=False,
               bOnArrow=False):
    "Displays an on-screen message."
    """
	Make these alerts optionally show a delayable popup with various options.
	a) show: 

	Happy: Zoom to City, Turn OFF avoid growth, Whip (maybe?), Ignore
	Unhappy:  Zoom to City, Turn on Avoid Growth, Suggest cheapest military unit (with right civic), Open Resources screen in FA, Ignore. (for future = suggest building)

	Healthy: Zoom to City, Turn OFF avoid growth, Ignore
	Unhealthy:  Zoom to City, Turn on Avoid Growth, Whip population, Open Resources screen in FA, Ignore. (for future = suggest building)

	Growth: Zoom to City, Turn on avoid Growth, Whip, Ignore
	Starvation: Zoom to City, Turn on avoid Growth, Ignore

	Culture:  Zoom to City, Ignore
	"""
    CvUtil.sendMessage(szTxt, iPlayer, EVENT_MESSAGE_TIME_LONG, icon, -1, iX,
                       iY, bOffArrow, bOnArrow)
    def __eventReminderRecallBegin(self, argsList):
        global g_turnReminderTexts
        iPlayer = GAME.getActivePlayer()
        queue = self.reminders.get(iPlayer)
        if queue:
            iTurn = GAME.getGameTurn()
            yes = TRNSLTR.getText("TXT_KEY_POPUP_YES", ())
            no = TRNSLTR.getText("TXT_KEY_POPUP_NO", ())
            bLogging = g_autolog.isLogging() and ReminderOpt.isAutolog()
            bShowMsg = ReminderOpt.isShowMessage()
            bShowPop = ReminderOpt.isShowPopup()
            if bShowPop:
                iCount = 0
                prompt = TRNSLTR.getText("TXT_KEY_REMIND_NEXT_TURN_PROMPT", ())

            while not queue.isEmpty():
                nextTurn = queue.nextTurn()
                if nextTurn > iTurn:
                    break
                reminder = queue.pop()

                if nextTurn < iTurn:
                    print "[WARNING] Reminder - skipped turn %d: %s" % (
                        reminder.turn, reminder.message)
                    continue

                if bLogging:
                    g_autolog.writeLog("Reminder: %s" % reminder.message)

                if g_turnReminderTexts:
                    idx = g_turnReminderTexts.rfind("\n") + 1
                    if idx == -1:
                        idx += 1
                    else:
                        idx += 2
                    if CyInterface().determineWidth(
                            g_turnReminderTexts[idx:] +
                            reminder.message) > SR.x - SR.x / 7:
                        g_turnReminderTexts += "\n"
                    else:
                        g_turnReminderTexts += "; "
                g_turnReminderTexts += reminder.message

                if bShowMsg:
                    CvUtil.sendMessage(reminder.message, iPlayer, 10, "",
                                       ColorTypes(8))
                if bShowPop:
                    body = SR.aFontList[
                        4] + reminder.message + "\n" + SR.aFontList[5] + prompt
                    popup = CyPopup(RECALL_EVENT_ID,
                                    EventContextTypes.EVENTCONTEXT_SELF, True)
                    self.recall.append(reminder)
                    popup.setUserData((iCount, ))
                    iCount += 1
                    popup.setPosition(SR.x / 3, SR.y / 3)
                    popup.setBodyString(body, 1 << 0)
                    popup.addButton(yes)
                    popup.addButton(no)
                    popup.launch(False, PopupStates.POPUPSTATE_IMMEDIATE)
示例#7
0
def applySaltpeter(argsList):
    kTriggeredData = argsList[1]

    CyPlot = MAP.plot(kTriggeredData.iPlotX, kTriggeredData.iPlotY)
    if not CyPlot:
        return
    iPlayer = kTriggeredData.ePlayer

    event = GC.getEventInfo(argsList[0])
    iFood = event.getPlotExtraYield(YieldTypes.YIELD_FOOD)
    iProd = event.getPlotExtraYield(YieldTypes.YIELD_PRODUCTION)
    iComm = event.getPlotExtraYield(YieldTypes.YIELD_COMMERCE)
    sEventType = event.getType()

    # Add landmark for initial plot, if there is still a yield change
    placeLandmark(CyPlot, sEventType, iFood, iProd, iComm, True, -1)

    iForest = GC.getInfoTypeForString('FEATURE_FOREST')

    listPlots = []
    for i in range(MAP.numPlots()):
        CyPlot = MAP.plotByIndex(i)
        if (CyPlot.getOwner() == iPlayer and CyPlot.getFeatureType() == iForest
                and CyPlot.isHills()):
            iDistance = plotDistance(kTriggeredData.iPlotX,
                                     kTriggeredData.iPlotY, CyPlot.getX(),
                                     CyPlot.getY())
            if iDistance > 0:
                listPlots.append((iDistance, CyPlot))

    listPlots.sort()

    GAME = GC.getGame()
    iCount = CvRandomEventInterface.getSaltpeterNumExtraPlots()
    for plot in listPlots:
        if not iCount:
            break
        iCount -= 1
        iX = plot[1].getX()
        iY = plot[1].getY()
        GAME.setPlotExtraYield(iX, iY, YieldTypes.YIELD_COMMERCE, 1)
        szTxt = TRNSLTR.getText("TXT_KEY_EVENT_SALTPETER_DISCOVERED", ())
        CvUtil.sendMessage(szTxt, iPlayer, GC.getEVENT_MESSAGE_TIME(), "", -1,
                           iX, iY, True, True, 0, "", False)
        # Add landmark for other plots too.
        placeLandmark(plot[1], sEventType, iFood, iProd, iComm, True, -1)
示例#8
0
def onCombatResult(argsList):
    ##  First we check that the winning unit is a patisan and the loosing a seige or "armour" unit
    ##  There is a small chance that th unit will be captured.
    CyUnitW, CyUnitL = argsList

    if CyUnitW.getUnitType() == GC.getInfoTypeForString('UNIT_PARTISAN'):
        captrureChance = None
        iCombatL = CyUnitL.getUnitCombatType()
        if iCombatL == GC.getInfoTypeForString('UNITCOMBAT_SIEGE'):
            captrureChance = 10
        elif iCombatL in (GC.getInfoTypeForString('UNITCOMBAT_TRACKED'),
                          GC.getInfoTypeForString('UNITCOMBAT_WHEELED')):
            captrureChance = 5
        if captrureChance and GAME.getSorenRandNum(
                100, "Partisan capture unit") <= captrureChance:

            iPlayerW = CyUnitW.getOwner()
            CyPlayerW = GC.getPlayer(iPlayerW)

            iUnitL = CyUnitL.getUnitType()
            iX = CyUnitW.getX()
            iY = CyUnitW.getY()
            CyUnit = CyPlayerW.initUnit(iUnitL, iX, iY, UnitAITypes.NO_UNITAI,
                                        DirectionTypes.DIRECTION_NORTH)
            CyUnit.setDamage(75, False)
            CyUnit.finishMoves()

            iPlayerAct = GAME.getActivePlayer()
            if iPlayerAct == iPlayerW:
                CvUtil.sendMessage(
                    TRNSLTR.getText(
                        "TXT_KEY_PARTISAN_CAPTURE_UNIT2",
                        (GC.getUnitInfo(iUnitL).getDescription(), )),
                    iPlayerAct,
                    16, 'Art/Interface/Buttons/civics/despotism.dds',
                    ColorTypes(7), iX, iY, True, True)
            elif iPlayerAct == CyUnitL.getOwner():
                CvUtil.sendMessage(
                    TRNSLTR.getText(
                        "TXT_KEY_PARTISAN_CAPTURE_UNIT1",
                        (GC.getUnitInfo(iUnitL).getDescription(), )),
                    iPlayerAct,
                    16, 'Art/Interface/Buttons/civics/despotism.dds',
                    ColorTypes(44), iX, iY, True, True)
示例#9
0
def onCombatResult(argsList):
	CyUnitW, CyUnitL = argsList

	# Spartacus Capture Event
	if CyUnitW.getUnitClassType() == giSparticus:

		# Capture % Random # 0 to 3 or 25%
		if not GAME.getSorenRandNum(4, "Gods"):

			pClearPlot = findClearPlot(CyUnitL)

			CyPlot = CyUnitL.plot()
			if pClearPlot != -1 and CyPlot.getNumUnits() == 1:
				CyPlot = CyUnitL.plot()
				CyUnitL.setXY(pClearPlot.getX(), pClearPlot.getY(), False, True, True)
			else:
				CyPlot = CyUnitW.plot()

			iPlayer = CyUnitW.getOwner()
			GC.getPlayer(iPlayer).initUnit(giGladiator, CyPlot.getX(), CyPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH).finishMoves()

			CyUnitL.setDamage(100000, False)
			msg = TRNSLTR.getText("TXT_KEY_SPARTACUS_CAPTURE_SUCCESS",())
			icon = ',Art/Interface/Buttons/Units/ICBM.dds,Art/Interface/Buttons/Warlords_Atlas_1.dds,3,11'
			CvUtil.sendMessage(msg, iPlayer, 15, icon, ColorTypes(44), CyUnitL.getX(), CyUnitL.getY(), True, True, 0, "", False)


	# Field Medic
	if CyUnitW.isHasPromotion(giFieldMedic):
		# 10% chance
		if not GAME.getSorenRandNum(10, "Gods"):

			if not SDTK.sdObjectExists('Heroes', CyUnitW):
				iHealTurn = -1
			else:
				iHealTurn = SDTK.sdObjectGetVal( 'Heroes', CyUnitW, 'HealTurn' )

			if iHealTurn == None or GAME.getGameTurn() > iHealTurn:
				CyUnitW.setDamage(0, False)
				if not SDTK.sdObjectExists('Heroes', CyUnitW):
					SDTK.sdObjectInit('Heroes', CyUnitW, {})
				SDTK.sdObjectSetVal('Heroes', CyUnitW, 'HealTurn', GAME.getGameTurn())
示例#10
0
def onCombatResult(argsList):
    CyUnitW, CyUnitL = argsList

    # Captives
    # Check that the losing unit is not an animal and the unit does not have a capture type defined in the XML
    if (CyUnitW.isMadeAttack() and not CyUnitL.isAnimal()
            and CyUnitL.getDomainType() == giDomainLand
            and CyUnitW.getDomainType() == giDomainLand
            and CyUnitL.getCaptureUnitType() == -1):
        iCaptureProbability = CyUnitW.captureProbabilityTotal()
        iCaptureResistance = CyUnitL.captureResistanceTotal()
        iChance = iCaptureProbability - iCaptureResistance
        BugUtil.info(
            "CaptureSlaves: Chance to capture a captive is %d (%d - %d)",
            iChance, iCaptureProbability, iCaptureResistance)

        if iChance > GAME.getSorenRandNum(100, "Slave"):  # 0-99

            if CyUnitL.isHasUnitCombat(
                    GC.getInfoTypeForString('UNITCOMBAT_SPECIES_NEANDERTHAL')):
                iUnit = GC.getInfoTypeForString('UNIT_CAPTIVE_NEANDERTHAL')
                sMessage = TRNSLTR.getText("TXT_KEY_MSG_NEANDERTHAL_CAPTIVE",
                                           ())
            else:
                iUnit = GC.getInfoTypeForString('UNIT_CAPTIVE_MILITARY')
                sMessage = TRNSLTR.getText("TXT_KEY_MSG_MILITARY_CAPTIVE", ())

            iPlayerW = CyUnitW.getOwner()
            X = CyUnitW.getX()
            Y = CyUnitW.getY()
            CyUnit = GC.getPlayer(iPlayerW).initUnit(
                iUnit, X, Y, UnitAITypes.NO_UNITAI,
                DirectionTypes.NO_DIRECTION)
            if CyUnitW.isHiddenNationality():
                CyUnit.doHNCapture()
            if iPlayerW == GAME.getActivePlayer():
                CvUtil.sendMessage(sMessage, iPlayerW, 8,
                                   'Art/Interface/Buttons/Civics/Serfdom.dds',
                                   ColorTypes(44), X, Y, True, True)
示例#11
0
def doSmallRevolts(iPlayer, CyPlayer):

	if iPlayer > 39:
		raise "NPC does not revolt!"

	for city in CyPlayer.cities():

		revIdx = city.getRevolutionIndex()

		if revIdx <= 5 * RevDefs.revReadyDividend * RevDefs.revInstigatorThreshold / (4 * RevDefs.revReadyDivisor):
			continue

		if city.getOccupationTimer() > 0 or city.getRevolutionCounter() > 0 or RevData.getCityVal(city, 'SmallRevoltCounter') > 0:
			continue # Already in a revolt

		localRevIdx = city.getLocalRevIndex()
		if localRevIdx > 0:
			localFactor = 1 + localRevIdx / 3
			if localFactor > 10:
				localFactor = 10
		else:
			localFactor = localRevIdx - 1
			if localFactor < -15:
				localFactor = -15

		iOdds = localFactor + 100 * revIdx / (8 * RevDefs.alwaysViolentThreshold)
		if iOdds > 15:
			iOdds = 15

		if GAME.getSorenRandNum(100, "Rev: Small Revolt") < iOdds:
			szName = city.getName()
			print "[REV] Small revolt in %s with odds %d (%d idx, %d loc)" %(szName, iOdds, revIdx, localRevIdx)
			city.setOccupationTimer(2)

			RevData.setCityVal(city, 'SmallRevoltCounter', 6)

			szTxt = TRNSLTR.getText("TXT_KEY_REV_MESS_SMALL_REVOLT",()) % szName
			icon = CyArtFileMgr().getInterfaceArtInfo("INTERFACE_RESISTANCE").getPath()
			CvUtil.sendMessage(szTxt, iPlayer, 16, icon, ColorTypes(7), city.getX(), city.getY(), True, True, InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT, "AS2D_CITY_REVOLT", False)
示例#12
0
def doSmallRevolts(iPlayer, CyPlayer):

	CyCity, i = CyPlayer.firstCity(False)
	while CyCity:

		revIdx = CyCity.getRevolutionIndex()

		if revIdx > int(1.25*RevDefs.revReadyFrac*RevDefs.revInstigatorThreshold):

			if CyCity.getOccupationTimer() > 0 or CyCity.getRevolutionCounter() > 0 or RevData.getCityVal(CyCity, 'SmallRevoltCounter') > 0:
				CyCity, i = CyPlayer.nextCity(i, False)
				continue # Already in a revolt

			localRevIdx = CyCity.getLocalRevIndex()
			if localRevIdx > 0:
				localFactor = 1 + localRevIdx/3
				if localFactor > 10:
					localFactor = 10
			else:
				localFactor = localRevIdx - 1
				if localFactor < -15:
					localFactor = -15

			iOdds = int(100*revIdx/(8.0*RevDefs.alwaysViolentThreshold)) + localFactor
			if iOdds > 15:
				iOdds = 15

			if GAME.getSorenRandNum(100, "Rev: Small Revolt") < iOdds:
				szName = CyCity.getName()
				print "[REV] Small revolt in %s with odds %d (%d idx, %d loc)" %(szName, iOdds, revIdx, localRevIdx)
				CyCity.setOccupationTimer(2)

				RevData.setCityVal(CyCity, 'SmallRevoltCounter', 6)

				szTxt = TRNSLTR.getText("TXT_KEY_REV_MESS_SMALL_REVOLT",()) % szName
				icon = CyArtFileMgr().getInterfaceArtInfo("INTERFACE_RESISTANCE").getPath()
				CvUtil.sendMessage(szTxt, iPlayer, 16, icon, ColorTypes(7), CyCity.getX(), CyCity.getY(), True, True, InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT, "AS2D_CITY_REVOLT", False)

		CyCity, i = CyPlayer.nextCity(i, False)
示例#13
0
def give(GC, TRNSLTR, GAME, CyUnit, CyPlayer, CyCity=None, iPlayer=None):

    aStarSignList = ("PROMOTION_AQUARIUS", "PROMOTION_ARIES",
                     "PROMOTION_CANCER", "PROMOTION_CAPRICORN",
                     "PROMOTION_GEMINI", "PROMOTION_LEO", "PROMOTION_LIBRA",
                     "PROMOTION_PISCES", "PROMOTION_SAGITTARIUS",
                     "PROMOTION_SCORPIO", "PROMOTION_TAURUS",
                     "PROMOTION_VIRGO")

    iChance = GAME.getSorenRandNum(12, "Star Signs")  # integer 0-11
    iPromotion = GC.getInfoTypeForString(aStarSignList[iChance])
    CyUnit.setHasPromotion(iPromotion, True)

    if CyPlayer.isHuman():
        if CyCity:
            szTxt = TRNSLTR.getText("TXT_KEY_MESSAGE_STARSIGN_BUILD",
                                    (CyCity.getName(), ))
        else:
            szTxt = TRNSLTR.getText("TXT_KEY_MESSAGE_STARSIGN_CREATE", ())
            iPlayer = CyUnit.getOwner()
        szIcon = GC.getPromotionInfo(iPromotion).getButton()
        CvUtil.sendMessage(szTxt, iPlayer, 16, szIcon, ColorTypes(44),
                           CyUnit.getX(), CyUnit.getY(), True, True)
示例#14
0
def sendMessage(args):
    CvUtil.sendMessage(args[0], args[1], args[2], args[3], args[4], args[5],
                       args[6], args[7], args[8], args[9], args[10], args[11])
示例#15
0
    def checkReveal(self, pPlot, iTeam):

        iFeature = pPlot.getFeatureType()
        if iFeature == -1: return

        CyTeam = GC.getTeam(iTeam)
        if CyTeam.isNPC(): return

        GAME = GC.getGame()
        if GAME.GetWorldBuilderMode(): return

        FeatureInfo = GC.getFeatureInfo(iFeature)
        sType = FeatureInfo.getType()
        if sType.find("FEATURE_PLATY_") == -1: return

        if sType in self.lBigWonder:
            bFound = False
            for x in xrange(pPlot.getX() - 1, pPlot.getX() + 2):
                for y in xrange(pPlot.getY() - 1, pPlot.getY() + 2):
                    pAdjacentPlot = CyMap().plot(x, y)
                    if x == pPlot.getX() and y == pPlot.getY(): continue
                    if pAdjacentPlot.getFeatureType() == iFeature:
                        bFound = True
                        break
                if bFound: break
            if pAdjacentPlot.isRevealed(iTeam, False): return

        for iTeamX in xrange(GC.getMAX_PC_TEAMS()):
            if pPlot.isRevealed(iTeamX, False) and iTeamX != iTeam:
                bFirst = False
                break
            if sType in self.lBigWonder:
                if pAdjacentPlot.isRevealed(iTeamX, False) and iTeamX != iTeam:
                    bFirst = False
                    break
        else:
            bFirst = True
        if bFirst:
            iGold = self.iFirstGold * GC.getGameSpeedInfo(
                GAME.getGameSpeedType()).getUnitTradePercent() / 100

        import CvUtil
        TRNSLTR = CyTranslator()
        iPlayerAct = GAME.getActivePlayer()

        for iPlayerX in xrange(GC.getMAX_PC_PLAYERS()):
            CyPlayerX = GC.getPlayer(iPlayerX)
            iTeamX = CyPlayerX.getTeam()
            if iTeamX != iTeam:
                if bFirst and iPlayerX == iPlayerAct:
                    if CyTeam.isHasMet(iTeamX):
                        CvUtil.sendMessage(TRNSLTR.getText(
                            "TXT_MET_FIRST_WONDER",
                            (GC.getTeam(iTeam).getName(),
                             GC.getFeatureInfo(iFeature).getDescription())),
                                           iPlayerX,
                                           12,
                                           bForce=False)
                    else:
                        CvUtil.sendMessage(TRNSLTR.getText(
                            "TXT_NOT_MET_FIRST_WONDER",
                            (GC.getFeatureInfo(iFeature).getDescription(), )),
                                           iPlayerX,
                                           12,
                                           bForce=False)
                continue
            if iPlayerX == iPlayerAct:
                popupInfo = CyPopupInfo()
                popupInfo.setButtonPopupType(
                    ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
                popupInfo.setData1(iFeature)
                popupInfo.setData3(3)
                popupInfo.setText("showWonderMovie")
                popupInfo.addPopup(iPlayerX)
                CvUtil.sendMessage(TRNSLTR.getText(
                    "TXT_KEY_WONDERDISCOVERED_YOU",
                    (FeatureInfo.getDescription(), )),
                                   iPlayerX,
                                   12,
                                   FeatureInfo.getButton(),
                                   ColorTypes(44),
                                   pPlot.getX(),
                                   pPlot.getY(),
                                   True,
                                   True,
                                   bForce=False)
            if bFirst:
                CyPlayerX.changeGold(iGold)
                if iPlayerX == iPlayerAct:
                    CvUtil.sendMessage(TRNSLTR.getText(
                        "TXT_FIRST_FOUND_WONDER", (iGold, )),
                                       iPlayerX,
                                       12,
                                       None,
                                       ColorTypes(44),
                                       bForce=False)
示例#16
0
    def onBeginGameTurn(self, argsList):
        #timer = BugUtil.Timer('WoodlandCycle')
        plotIndex = [0] * self.iMaxIndex
        shuffleList(self.iMaxIndex, GAME.getMapRand(), plotIndex)
        # reduce activity by era
        iMaxCount = self.iMaxIndex / (3 * (GAME.getCurrentEra() + 1))
        iCount = 0
        while iCount < iMaxCount:
            iCount += 1
            if 25 <= GAME.getSorenRandNum(self.iFactorGS, "New"): continue

            bBurn = False
            plot = self.plots[plotIndex.pop()]
            iImp = plot.getImprovementType()
            iFeature = plot.getFeatureType()
            if iFeature == -1:
                if not GAME.getSorenRandNum(10, "New"):
                    if plot.canHaveFeature(
                            self.FEATURE_BAMBOO) and not GAME.getSorenRandNum(
                                10, "Bamboo"):
                        plot.setFeatureType(self.FEATURE_BAMBOO, 0)
                    elif plot.canHaveFeature(self.FEATURE_FOREST_YOUNG):
                        plot.setFeatureType(self.FEATURE_FOREST_YOUNG, 0)

            elif iFeature == self.FEATURE_FOREST_BURNT:
                plot.setFeatureType(-1, 0)
                if GAME.getSorenRandNum(3, "new forest"):
                    if plot.canHaveFeature(
                            self.FEATURE_BAMBOO) and not GAME.getSorenRandNum(
                                10, "Bamboo"):
                        plot.setFeatureType(self.FEATURE_BAMBOO, 0)
                    elif plot.canHaveFeature(self.FEATURE_FOREST_YOUNG):
                        plot.setFeatureType(self.FEATURE_FOREST_YOUNG, 0)

                if iImp != plot.getImprovementType(
                ) and plot.canHaveImprovement(iImp, -1, True):
                    plot.setImprovementType(iImp)

            elif iFeature == self.FEATURE_BAMBOO:
                if not GAME.getSorenRandNum(50, "Burn"):
                    bBurn = True
                    plot.setFeatureType(self.FEATURE_FOREST_BURNT, 0)

            elif iFeature == self.FEATURE_FOREST_YOUNG:
                iTerrain = plot.getTerrainType()
                if iTerrain == self.TERRAIN_TAIGA:
                    plot.setFeatureType(self.FEATURE_FOREST, 2)
                elif iTerrain in (self.TERRAIN_LUSH, self.TERRAIN_MUDDY):
                    plot.setFeatureType(self.FEATURE_FOREST, 0)
                else:
                    # Could do a 50-50 pine vs leafy, but I'll base the prob on neighbour ratio
                    iLeaf = 1
                    iPine = 2  # Head start for pine as leafy tend to dominate
                    # find neighbour variety
                    iX = plot.getX()
                    iY = plot.getY()
                    for x in xrange(iX - 1, iX + 2):
                        for y in xrange(iY - 1, iY + 2):
                            if x == iX and y == iY:
                                continue
                            plotX = MAP.plot(x, y)
                            if plotX and plotX.getFeatureType(
                            ) == self.FEATURE_FOREST:
                                iVariety = plotX.getFeatureVariety()
                                if iVariety:  # Count snowy as pine
                                    iPine += 1
                                else:
                                    iLeaf += 1

                    if 100 < GAME.getSorenRandNum(100 + 100 * iLeaf / iPine,
                                                  "Leafy"):
                        plot.setFeatureType(self.FEATURE_FOREST, 0)
                    else:  # Pine
                        plot.setFeatureType(self.FEATURE_FOREST, 1)

            elif iFeature == self.FEATURE_FOREST:
                iRand = GAME.getSorenRandNum(148, "forestChange")
                if iRand < 3:
                    bBurn = True
                    plot.setFeatureType(self.FEATURE_FOREST_BURNT, 0)
                elif iRand < 7:
                    plot.setFeatureType(self.FEATURE_FOREST_ANCIENT, 0)

            elif iFeature == self.FEATURE_FOREST_ANCIENT:
                iRand = GAME.getSorenRandNum(64, "Burn")
                if iRand < 4:
                    bBurn = True
                    plot.setFeatureType(self.FEATURE_FOREST_BURNT, 0)
                elif iRand == 4:
                    plot.setFeatureType(-1, 0)
                    if plot.canHaveFeature(self.FEATURE_JUNGLE):
                        plot.setFeatureType(self.FEATURE_JUNGLE, 0)
                    else:
                        plot.setFeatureType(self.FEATURE_FOREST_ANCIENT, 0)

            if bBurn:
                iPlayer = plot.getOwner()
                if iPlayer > -1 and iPlayer == GAME.getActivePlayer():
                    bActivePlayer = True
                    CyCity = plot.getWorkingCity()
                    if CyCity:
                        CvUtil.sendMessage(TRNSLTR.getText("TXT_KEY_FOREST_FIRE_CITY_VICINITY", (CyCity.getName(),)), iPlayer, 10, \
                         'Art/Terrain/Features/Forest_Burnt/ButtonBurntForest.dds', ColorTypes(13), plot.getX(), plot.getY(), True, True)
                    else:                        CvUtil.sendMessage(TRNSLTR.getText("TXT_KEY_FOREST_FIRE_REMOTE",()), iPlayer, 6, \
                    'Art/Terrain/Features/Forest_Burnt/ButtonBurntForest.dds', ColorTypes(4), plot.getX(), plot.getY(), True, True)
                else:
                    bActivePlayer = False

                if plot.isActiveVisible(GAME.isDebugMode(
                )) and not GC.getActivePlayer().isHumanDisabled():
                    point = plot.getPoint()
                    CyEngine().triggerEffect(
                        GC.getInfoTypeForString('EFFECT_FOREST_FIRE'), point)
                    CyAudioGame().Play3DSound("AS3D_FOREST_FIRE", point.x,
                                              point.y, point.z)

                for CyUnit in plot.units():
                    if CyUnit.canFight():
                        iHP = CyUnit.currHitPoints()
                        iDamage = 5 + GAME.getSorenRandNum(29, "Ouch")
                        if iHP > iDamage:
                            CyUnit.changeDamage(iDamage, -1)
                        else:
                            if bActivePlayer:
                                CvUtil.sendMessage(TRNSLTR.getText(
                                    "TXT_KEY_FOREST_FIRE_UNIT_LOST",
                                    (CyUnit.getName(), )),
                                                   iPlayer,
                                                   6,
                                                   eColor=ColorTypes(9))
                            CyUnit.kill(False, -1)
示例#17
0
def checkRebelBonuses(argsList):
	# Give bonuses to a rebel player who successfully captures one of their rebellious cities
	owner, playerType, pCity, bConquest, bTrade = argsList

	newOwnerID = pCity.getOwner()
	newOwner = GC.getPlayer(newOwnerID)
	newOwnerCiv = newOwner.getCivilizationType()
	oldOwnerID = pCity.getPreviousOwner()
	orgOwnerID = pCity.getOriginalOwner()

	# TODO: Handle case where city is acquired by disorganized rebels
	if newOwnerID == GC.getBARBARIAN_PLAYER() and pCity.getRevolutionCounter() > 0:
		print "[REV] City %s captured by barb rebels!" % pCity.getName()
		oldOwner = GC.getPlayer(oldOwnerID)

		if not oldOwnerID == orgOwnerID:
			orgOwner = GC.getPlayer(orgOwnerID)

		if pCity.countTotalCultureTimes100() > 100*100:
			if not oldOwnerID == pCity.findHighestCulture():
				cultOwner = GC.getPlayer(pCity.findHighestCulture())

	elif newOwnerCiv == RevData.getCityVal(pCity, 'RevolutionCiv'):

		# TODO: Check whether revolt is active in RevoltData
		if pCity.getReinforcementCounter() > 0 or (pCity.unhappyLevel(0) - pCity.happyLevel()) > 0:
			print "[REV] Rebellious pCity %s is captured by rebel identity %s (%d)!!!" %(pCity.getName(), newOwner.getCivilizationDescription(0), newOwnerCiv)

			newOwnerTeam = GC.getTeam(newOwner.getTeam())
			oldOwner = GC.getPlayer(oldOwnerID)
			oldOwnerTeam = GC.getTeam(oldOwner.getTeam())
			if oldOwnerTeam.isAVassal():
				for teamID in xrange(MAX_PC_TEAMS):
					if oldOwnerTeam.isVassal(teamID):
						oldOwnerTeam = GC.getTeam(teamID)

			ix = pCity.getX()
			iy = pCity.getY()

			[iWorker, iBestDefender, iCounter, iAttack] = RevUtils.getHandoverUnitTypes(pCity)

			newUnitList = []

			# Couple units regardless of rebel status
			newUnitList.append(newOwner.initUnit(iBestDefender, ix, iy, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH))
			if pCity.getPopulation() > 4:
				newUnitList.append(newOwner.initUnit(iCounter, ix, iy, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH))

			if newOwner.isRebel():
				# Extra benefits if still considered a rebel
				szTxt = TRNSLTR.getText("TXT_KEY_REV_MESS_YOUR_CAPTURE",())%(pCity.getName())
				icon = CyArtFileMgr().getInterfaceArtInfo("INTERFACE_RESISTANCE").getPath()
				sound = "AS2D_CITY_REVOLT"
				eMsgType = InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT
				iMsgTime = GC.getEVENT_MESSAGE_TIME()
				CvUtil.sendMessage(szTxt, newOwnerID, iMsgTime, icon, ColorTypes(8), ix, iy, True, True, eMsgType, sound, False)

				szTxt = TRNSLTR.getText("TXT_KEY_REV_MESS_REBEL_CONTROL",())%(newOwner.getCivilizationDescription(0),pCity.getName())
				CvUtil.sendMessage(szTxt, oldOwnerID, iMsgTime, None, ColorTypes(7), eMsgType=eMsgType, bForce=False)

				# Gold
				iGold = GAME.getSorenRandNum(min([80,8*pCity.getPopulation()]), 'Rev') + 8
				szTxt = TRNSLTR.getText("TXT_KEY_REV_MESS_YOUR_CAPTURE_GOLD",()) %(pCity.getName(),iGold)
				CvUtil.sendMessage(szTxt, newOwnerID, iMsgTime, icon, ColorTypes(8), ix, iy, False, False, eMsgType, sound, False)
				newOwner.changeGold(iGold)

				# Culture
				newCulVal = int( revCultureModifier*max([pCity.getCulture(oldOwnerID),pCity.countTotalCultureTimes100()/200]) )
				newPlotVal = int( revCultureModifier*max([pCity.plot().getCulture(oldOwnerID),pCity.plot().countTotalCulture()/2]) )
				RevUtils.giveCityCulture( pCity, newOwnerID, newCulVal, newPlotVal)

				# Extra units
				if iWorker != -1:
					newUnitList.append(newOwner.initUnit(iWorker, ix, iy, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH))
				if pCity.getPopulation() > 7:
					newUnitList.append(newOwner.initUnit(iBestDefender, ix, iy, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH))
				if pCity.getPopulation() > 4 and newOwnerTeam.getPower(True) < oldOwnerTeam.getPower(True)/4:
					newUnitList.append(newOwner.initUnit(iAttack, ix, iy, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH))

				if newOwner.getNumCities() <= 1:
					# Extra units for first city captured
					newUnitList.append(newOwner.initUnit(iCounter, ix, iy, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH))
					if newOwnerTeam.getPower(True) < oldOwnerTeam.getPower(True)/2:
						newUnitList.append(newOwner.initUnit(iBestDefender, ix, iy, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH))
						newUnitList.append(newOwner.initUnit(iAttack, ix, iy, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH))
					elif newOwnerTeam.getPower(True) < oldOwnerTeam.getPower(True):
						newUnitList.append(newOwner.initUnit(iAttack, ix, iy, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH))

				# Give a boat to island rebels
				if pCity.isCoastal(10) and pCity.area().getNumCities() < 3 and pCity.area().getNumTiles() < 25:
					iBestCombat = -1
					for iUnitX in xrange(GC.getNumUnitInfos()):
						info = GC.getUnitInfo(iUnitX)
						if (info.getDomainType() == DomainTypes.DOMAIN_SEA
						and info.getUnitAIType(UnitAITypes.UNITAI_ASSAULT_SEA)
						and newOwner.canTrain(iUnitX,False,False)
						):
							iCombat = info.getCombat()
							if iBestCombat < iCombat:
								bestUnit = info
								iBestUnit = iUnitX
								iBestCombat = iCombat

					if iBestCombat > -1:
						newOwner.initUnit(iBestUnit, ix, iy, UnitAITypes.UNITAI_ASSAULT_SEA, DirectionTypes.DIRECTION_SOUTH)
						print "Rev - Rebels get a %s to raid motherland" % bestUnit.getDescription()

				# Change city disorder timer to favor new player
				iTurns = pCity.getOccupationTimer()
				iTurns = iTurns/4 + 1
				pCity.setOccupationTimer(iTurns)

				# Temporary happiness boost
				pCity.changeRevSuccessTimer( int(iTurns + RevUtils.getGameSpeedMod()*15) )

				# Trigger golden age for rebel civ under certain circumstances
				revTurn = RevData.revObjectGetVal(newOwner, 'RevolutionTurn')
				if not revTurn == None and GAME.getGameTurn() - revTurn < 4*GAME.goldenAgeLength():
					if newOwner.getNumCities() == 3:
						if not newOwner.getCitiesLost():
							# By verifying they've never lost a city, gaurantee it doesn't happen multiple times
							szTxt = TRNSLTR.getText("TXT_KEY_REV_MESS_GOLDEN_AGE",())
							CvUtil.sendMessage(szTxt, newOwnerID, iMsgTime, icon, ColorTypes(8), ix, iy, False, False, eMsgType, sound, False)
							newOwner.changeGoldenAgeTurns( int(1.5*GAME.goldenAgeLength()) )

			else: # Conqueror not considered a rebel, fewer benefits
				# Culture
				newCulVal = int(revCultureModifier*max([pCity.getCulture(oldOwnerID)/2,pCity.countTotalCultureTimes100()/400]))
				newPlotVal = int(revCultureModifier*max([pCity.plot().getCulture(oldOwnerID)/2,pCity.plot().countTotalCulture()/4]))
				RevUtils.giveCityCulture(pCity, newOwnerID, newCulVal, newPlotVal)

				# Change city disorder timer to favor new player
				iTurns = pCity.getOccupationTimer()
				iTurns = min([iTurns, iTurns/3 + 1])
				pCity.setOccupationTimer(iTurns)

				# Temporary happiness boost
				pCity.changeRevSuccessTimer(int(iTurns + RevUtils.getGameSpeedMod()*6))

			# Injure free units
			for unit in newUnitList:
				if unit.canFight():
					iDamage = 20 + GAME.getSorenRandNum(20,'Rev - Injure unit')
					unit.setDamage(iDamage, oldOwnerID)

		else: # City once rebelled as this civ type, but not currently rebellious
			if LOG_DEBUG:
				print "[REV] %s, captured by former rebel identity: %s (%d)!"%(pCity.getName(),newOwner.getCivilizationDescription(0),newOwnerCiv)
			newCulVal = int( revCultureModifier*max([pCity.getCulture(oldOwnerID)/2,pCity.countTotalCultureTimes100()/400]) )
			newPlotVal = int( revCultureModifier*max([pCity.plot().getCulture(oldOwnerID)/2,pCity.plot().countTotalCulture()/4]) )
			RevUtils.giveCityCulture( pCity, newOwnerID, newCulVal, newPlotVal)

			iTurns = pCity.getOccupationTimer()
			iTurns = iTurns/2 + 1
			pCity.setOccupationTimer(iTurns)
示例#18
0
	def _addMessage(self, iPlayer, msg, icon, iX, iY, bOffArrow, bOnArrow, iColor):
		# Route it through the centralized handler
		CvUtil.sendMessage(msg, iPlayer, EVENT_MESSAGE_TIME_LONG, icon, ColorTypes(iColor), iX, iY, bOffArrow, bOnArrow)
    def onCityAcquired(self, argsList):
        iOwnerOld, iOwnerNew, CyCity, bConquest, bTrade = argsList
        if not bConquest: return

        iBasePercent = g_iBasePercent
        iPopPercent = g_iPopPercent
        if iBasePercent < 1 and iPopPercent < 1: return

        CyPlayerN = GC.getPlayer(iOwnerNew)
        if CyPlayerN.isNPC(): return

        if iPopPercent < 0:
            iPopPercent = 0
        elif iPopPercent > 100:
            iPopPercent = 100

        CyPlayerO = GC.getPlayer(iOwnerOld)
        CyTeamO = GC.getTeam(CyPlayerO.getTeam())
        CyTeamN = GC.getTeam(CyPlayerN.getTeam())

        bCheckPrereq = g_bCheckPrereq
        aList = []
        iTechsBehind = 0
        for iTech in range(GC.getNumTechInfos()):
            # Continue if the conquering team does have the tech
            if CyTeamN.isHasTech(iTech):
                continue
            # Continue if the old team doesn't have the tech
            if not CyTeamO.isHasTech(iTech):
                continue
            iTechsBehind += 1
            # Continue if the conquerer cannot research the technology
            if bCheckPrereq and not CyPlayerN.canResearch(iTech):
                continue
            # Append the technology to the possible technology list
            iCost = CyTeamN.getResearchCost(iTech)
            iProgress = CyTeamN.getResearchProgress(iTech)
            iRemaining = iCost - iProgress - 1
            if not iRemaining:
                continue
            # Append the technology to the possible technology list
            aList.append((iTech, iCost, iRemaining))

        if aList:

            iBasePercent += iTechsBehind
            charBeaker = GC.getCommerceInfo(
                CommerceTypes.COMMERCE_RESEARCH).getChar()
            iPopulation = CyCity.getPopulation() + 1
            fForce = (1 + iTechsBehind / 10.0) * iPopulation / (
                CyPlayerO.getTotalPopulation() + iPopulation)

            iMax = (iPopulation * iPopPercent)
            iCount = 0
            iLen = len(aList)
            szTxt = ""
            while iLen:
                iTech, iCost, iRemaining = aList.pop(
                    GAME.getSorenRandNum(iLen, "random"))
                iLen -= 1
                # Get the total number of technology points that will be transfered to the new city owner
                fTemp = 0
                if iPopPercent:
                    for i in xrange(iPopulation):
                        fTemp += 100 * (1.0 + GAME.getSorenRandNum(
                            iPopPercent, "TechConquest")) / iMax

                fPercent = iBasePercent + fTemp * fForce

                iBeakers = int(iCost * fPercent / (20 * (iCount + 5)))

                if iBeakers < 1: continue
                if iBeakers > iRemaining:
                    iBeakers = iRemaining

                # Increase the research progress for the new city owner
                CyTeamN.changeResearchProgress(iTech, iBeakers, iOwnerNew)

                szTxt += "\n\t" + GC.getTechInfo(iTech).getDescription(
                ) + u" <-> %i%c" % (iBeakers, charBeaker)
                iCount += 1

            if iOwnerNew == GAME.getActivePlayer():

                if iCount:  # Inform the player they got some new technology points
                    szTxt = TRNSLTR.getText(
                        "TXT_KEY_ENHANCED_TECH_CONQUEST_SUCESS",
                        ()) % (CyCity.getName(), szTxt)
                else:  # Inform the player they didn't get any new technologies
                    szTxt = TRNSLTR.getText(
                        "TXT_KEY_ENHANCED_TECH_CONQUEST_FAIL",
                        ()) + " %s" % (CyCity.getName())

                artPath = GC.getCivilizationInfo(
                    CyPlayerO.getCivilizationType()).getButton()
                CvUtil.sendMessage(szTxt, iOwnerNew, 20,
                                   artPath, ColorTypes(12), CyCity.getX(),
                                   CyCity.getY(), True, True)
示例#20
0
def onCityAcquired(argsList):
    iOwnerOld, iOwnerNew, CyCity, bConquest, bTrade = argsList

    if bConquest:
        CyPlayerOld = GC.getPlayer(iOwnerOld)
        if CyPlayerOld.isAlive():

            # Don't place partisan units if you capture your city back
            if CyCity.isOccupation():

                # Partisans only available with rifling tech
                CyTeamOld = GC.getTeam(CyPlayerOld.getTeam())
                if CyTeamOld.isHasTech(
                        GC.getInfoTypeForString("TECH_RIFLING")):

                    ################################################
                    ### get number of Partisan Units (nPartisan) ###
                    ################################################

                    # Get base nPartisan number
                    citysize = CyCity.getPopulation()
                    nPartisan = (citysize / 7) + 1

                    if citysize < 14:
                        rel_ativ = 1
                    else:
                        # Random number between 1 and 2-3 (depending on city size)
                        if citysize > 27:
                            rel_ativ = 3
                        else:
                            rel_ativ = 2
                        rel_ativ = 1 + GAME.getSorenRandNum(
                            rel_ativ,
                            "get number between 1 and 3 depending on city size"
                        )

                    # Add/subtract the random number from the nPartisan (depending on power)
                    if CyPlayerOld.getPower() > GC.getPlayer(
                            iOwnerNew).getPower():
                        # 60% chance for fewer partisans
                        if 6 > GAME.getSorenRandNum(
                                10, "Random for less Partisans"):
                            nPartisan -= rel_ativ
                    else:
                        # 40% chance for more partisans
                        if 5 < GAME.getSorenRandNum(
                                10, "Random for more Partisans"):
                            nPartisan += rel_ativ

                    # Change base nPartisan number depending on the culture of the conqPlayer in the city
                    # If the conqPlayer has 40% culture in the city, only create 60% of the number of the Partisans
                    nPartisan = int(
                        (nPartisan * 0.01) *
                        (100 -
                         CyCity.plot().calculateCulturePercent(iOwnerNew)))
                    if nPartisan < 0:
                        nPartisan = 0

                    # +1 partisans with protective trait (only loserPlayer) ###
                    if CyPlayerOld.hasTrait(
                            GC.getInfoTypeForString('TRAIT_PROTECTIVE')):
                        nPartisan += 1

                    if nPartisan:

                        ##########################
                        ### set Partisan Units ###
                        ##########################

                        ft_forest = GC.getFEATURE_FOREST()
                        ft_jungle = GC.getFEATURE_JUNGLE()
                        it_fort = GC.getInfoTypeForString("IMPROVEMENT_FORT")
                        # Check all city radius plots
                        iX = CyCity.getX()
                        iY = CyCity.getY()
                        firstRing = [(iX - 1, iY - 1), (iX - 1, iY),
                                     (iX - 1, iY - 1), (iX, iY - 1),
                                     (iX, iY + 1), (iX + 1, iY - 1),
                                     (iX + 1, iY), (iX + 1, iY + 1)]
                        plots = []
                        for iXLoop in range(iX - 3, iX + 4, 1):
                            for iYLoop in range(iY - 3, iY + 4, 1):

                                CyPlot = CyMap().plot(iXLoop, iYLoop)
                                if CyPlot.isNone() or CyPlot.isCity(
                                ) or CyPlot.isWater() or CyPlot.isImpassable():
                                    continue

                                if not CyPlot.isVisibleEnemyUnit(iOwnerOld):
                                    plots.append(CyPlot)
                                    # Doubles the chance to set the partisan in the inner city radius
                                    if (iXLoop, iYLoop) in firstRing:
                                        plots.append(CyPlot)
                                        # Increase the chance to set the partisan in the inner city radius with certain extras
                                        if CyPlot.isHills(
                                        ) or CyPlot.getFeatureType() in (
                                                ft_forest, ft_jungle
                                        ) or CyPlot.getImprovementType(
                                        ) == it_fort:
                                            for i in range(4):
                                                plots.append(CyPlot)
                        # Set partisan(s)
                        if plots:
                            iPlots = len(plots)

                            ########################################
                            ### identify tech related promotions ###
                            ########################################

                            # Promotion counts and booleans
                            drillpromotiontech = 0
                            combatpromotiontech = 0

                            bHasAssemblyLine = False
                            bHasIndustrialism = False
                            bHasRailroad = False
                            bHasRadio = False
                            bHasFascism = False

                            PROMOTION_WOODSMAN1 = GC.getInfoTypeForString(
                                "PROMOTION_WOODSMAN1")
                            PROMOTION_GUERILLA1 = GC.getInfoTypeForString(
                                "PROMOTION_GUERILLA1")

                            if CyTeamOld.isHasTech(
                                    GC.getInfoTypeForString(
                                        "TECH_ASSEMBLY_LINE")):
                                bHasAssemblyLine = True
                                drillpromotiontech += 1
                                PROMOTION_WOODSMAN2 = GC.getInfoTypeForString(
                                    "PROMOTION_WOODSMAN2")
                                PROMOTION_GUERILLA2 = GC.getInfoTypeForString(
                                    "PROMOTION_GUERILLA2")

                            if CyTeamOld.isHasTech(
                                    GC.getInfoTypeForString(
                                        "TECH_INDUSTRIALISM")):
                                bHasIndustrialism = True
                                drillpromotiontech += 1
                                PROMOTION_WOODSMAN3 = GC.getInfoTypeForString(
                                    "PROMOTION_WOODSMAN3")
                                PROMOTION_GUERILLA3 = GC.getInfoTypeForString(
                                    "PROMOTION_GUERILLA3")

                            if CyTeamOld.isHasTech(
                                    GC.getInfoTypeForString("TECH_ROCKETRY")):
                                drillpromotiontech += 1
                            if CyTeamOld.isHasTech(
                                    GC.getInfoTypeForString("TECH_PLASTICS")):
                                drillpromotiontech += 1

                            if CyTeamOld.isHasTech(
                                    GC.getInfoTypeForString("TECH_RAILROAD")):
                                bHasRailroad = True
                                PROMOTION_FLANKING1 = GC.getInfoTypeForString(
                                    'PROMOTION_FLANKING1')
                                bHasCombustion = False

                                if CyTeamOld.isHasTech(
                                        GC.getInfoTypeForString(
                                            "TECH_COMBUSTION")):
                                    bHasCombustion = True
                                    PROMOTION_FLANKING2 = GC.getInfoTypeForString(
                                        'PROMOTION_FLANKING2')

                            if CyTeamOld.isHasTech(
                                    GC.getInfoTypeForString("TECH_RADIO")):
                                bHasRadio = True
                                PROMOTION_MORALE = GC.getInfoTypeForString(
                                    'PROMOTION_MORALE')

                            if CyTeamOld.isHasTech(
                                    GC.getInfoTypeForString("TECH_FASCISM")):
                                bHasFascism = True
                            if CyTeamOld.isHasTech(
                                    GC.getInfoTypeForString(
                                        "TECH_PERSONAL_COMPUTERS")):
                                combatpromotiontech += 1
                            if CyTeamOld.isHasTech(
                                    GC.getInfoTypeForString("TECH_ROBOTICS")):
                                combatpromotiontech += 1
                            if CyTeamOld.isHasTech(
                                    GC.getInfoTypeForString(
                                        "TECH_COMPOSITES")):
                                combatpromotiontech += 1
                            if CyTeamOld.isHasTech(
                                    GC.getInfoTypeForString("TECH_LASER")):
                                combatpromotiontech += 1

                            if combatpromotiontech or bHasFascism:
                                p_combat1 = GC.getInfoTypeForString(
                                    "PROMOTION_COMBAT1")
                                p_combat2 = GC.getInfoTypeForString(
                                    "PROMOTION_COMBAT2")
                                p_combat3 = GC.getInfoTypeForString(
                                    "PROMOTION_COMBAT3")
                                p_combat4 = GC.getInfoTypeForString(
                                    "PROMOTION_COMBAT4")
                                p_combat5 = GC.getInfoTypeForString(
                                    "PROMOTION_COMBAT5")
                                p_combat6 = GC.getInfoTypeForString(
                                    "PROMOTION_COMBAT6")

                            if drillpromotiontech:
                                PROMOTION_DRILL1 = GC.getInfoTypeForString(
                                    "PROMOTION_DRILL1")
                                PROMOTION_DRILL2 = GC.getInfoTypeForString(
                                    "PROMOTION_DRILL2")
                                PROMOTION_DRILL3 = GC.getInfoTypeForString(
                                    "PROMOTION_DRILL3")
                                PROMOTION_DRILL4 = GC.getInfoTypeForString(
                                    "PROMOTION_DRILL4")

                            # Message related
                            iPlayerAct = GAME.getActivePlayer()
                            if iPlayerAct in (iOwnerNew, iOwnerOld):
                                szName = CyCity.getName()

                            # Start partisan generation
                            UNIT_PARTISAN = GC.getInfoTypeForString(
                                'UNIT_PARTISAN')
                            iCount = nPartisan
                            iDamage = 0

                            while iCount > 0:
                                iCount -= 1
                                CyPlot = plots[GAME.getSorenRandNum(
                                    iPlots, "Random CyPlot for Partisan")]
                                iiX = CyPlot.getX()
                                iiY = CyPlot.getY()
                                pNewUnit = CyPlayerOld.initUnit(
                                    UNIT_PARTISAN, iiX, iiY,
                                    UnitAITypes.UNITAI_ATTACK_CITY,
                                    DirectionTypes.NO_DIRECTION)

                                ################################
                                ### set aditional promotions ###
                                ################################

                                # Tech lvl depending promotions

                                # DRILL promotions
                                iDrillCount = drillpromotiontech
                                while iDrillCount > 0:
                                    iDrillCount -= 1
                                    if not pNewUnit.isHasPromotion(
                                            PROMOTION_DRILL1):
                                        pNewUnit.setHasPromotion(
                                            PROMOTION_DRILL1, True)
                                    elif not pNewUnit.isHasPromotion(
                                            PROMOTION_DRILL2):
                                        pNewUnit.setHasPromotion(
                                            PROMOTION_DRILL2, True)
                                    elif not pNewUnit.isHasPromotion(
                                            PROMOTION_DRILL3):
                                        pNewUnit.setHasPromotion(
                                            PROMOTION_DRILL3, True)
                                    elif not pNewUnit.isHasPromotion(
                                            PROMOTION_DRILL4):
                                        pNewUnit.setHasPromotion(
                                            PROMOTION_DRILL4, True)

                                if bHasRailroad:
                                    pNewUnit.setHasPromotion(
                                        PROMOTION_FLANKING1, True)
                                    if bHasCombustion:
                                        pNewUnit.setHasPromotion(
                                            PROMOTION_FLANKING2, True)
                                if bHasRadio:
                                    if GAME.getSorenRandNum(
                                            2, "Random Morale"):
                                        pNewUnit.setHasPromotion(
                                            PROMOTION_MORALE, True)

                                iCombatCount = combatpromotiontech
                                if bHasFascism:
                                    # 50% chance
                                    if GAME.getSorenRandNum(
                                            2, "Random Combat1/2"):
                                        iCombatCount += 1
                                while iCombatCount:
                                    iCombatCount -= 1
                                    if not pNewUnit.isHasPromotion(p_combat1):
                                        pNewUnit.setHasPromotion(
                                            p_combat1, True)
                                    elif not pNewUnit.isHasPromotion(
                                            p_combat2):
                                        pNewUnit.setHasPromotion(
                                            p_combat2, True)
                                    elif not pNewUnit.isHasPromotion(
                                            p_combat3):
                                        pNewUnit.setHasPromotion(
                                            p_combat3, True)
                                    elif not pNewUnit.isHasPromotion(
                                            p_combat4):
                                        pNewUnit.setHasPromotion(
                                            p_combat4, True)
                                    elif not pNewUnit.isHasPromotion(
                                            p_combat5):
                                        pNewUnit.setHasPromotion(
                                            p_combat5, True)
                                    elif not pNewUnit.isHasPromotion(
                                            p_combat6):
                                        pNewUnit.setHasPromotion(
                                            p_combat6, True)

                            # plot type depending promotions

                            # WOODSMAN promotion
                                if CyPlot.getFeatureType() in (ft_forest,
                                                               ft_jungle):
                                    pNewUnit.setHasPromotion(
                                        PROMOTION_WOODSMAN1, True)
                                    if bHasAssemblyLine:
                                        # 75% chance
                                        if GAME.getSorenRandNum(
                                                4, "Random Woodsman2"):
                                            pNewUnit.setHasPromotion(
                                                PROMOTION_WOODSMAN2, True)
                                            if bHasIndustrialism:
                                                # 75% chance, effectively 56%.
                                                if GAME.getSorenRandNum(
                                                        4, "Random Woodsman3"):
                                                    pNewUnit.setHasPromotion(
                                                        PROMOTION_WOODSMAN3,
                                                        True)

                                # GUERILLA promotion
                                if CyPlot.isHills():
                                    pNewUnit.setHasPromotion(
                                        PROMOTION_GUERILLA1, True)
                                    if bHasAssemblyLine:
                                        # 75% chance
                                        if GAME.getSorenRandNum(
                                                4, "Random Guerilla2"):
                                            pNewUnit.setHasPromotion(
                                                PROMOTION_GUERILLA2, True)
                                            if bHasIndustrialism:
                                                # 75% chance, effectively 56%.
                                                if GAME.getSorenRandNum(
                                                        4, "Random Guerilla3"):
                                                    pNewUnit.setHasPromotion(
                                                        PROMOTION_GUERILLA3,
                                                        True)

###########################################
### Random damage to nearby enemy units ###
###########################################

# Find all EnemyUnits near the partisan
                                lEnemyUnits = []
                                for CyPlotX in CyCity.plot().rect(1, 1):
                                    if CyPlotX.isVisibleEnemyUnit(iOwnerOld):
                                        for CyUnitX in CyPlotX.units():
                                            lEnemyUnits.append(CyUnitX)

                                if lEnemyUnits:

                                    # Random number between 1 and 5 (but not more than EnemyUnits near the partisan unit)
                                    n_EnemyUnits = len(lEnemyUnits)
                                    if n_EnemyUnits > 5:
                                        n_EnemyUnits = 5
                                    if n_EnemyUnits > 1:
                                        n_EnemyUnits = 1 + GAME.getSorenRandNum(
                                            n_EnemyUnits,
                                            "Random for how many eunits will suffer damage"
                                        )

                                    while n_EnemyUnits:
                                        n_EnemyUnits -= 1
                                        # Choose which EnemyUnit will suffer damage from partisan unit
                                        ppUnit = lEnemyUnits[
                                            GAME.getSorenRandNum(
                                                len(lEnemyUnits),
                                                "Random which eunit will suffer damage"
                                            )]
                                        # Random for how many damage the eunit will suffer from the partisan attack (15 - 30)
                                        iRand = GAME.getSorenRandNum(
                                            16, "rand damage") + 15

                                        # Check to not kill the unit
                                        iMaxDamage = ppUnit.getHP() - 1
                                        if iMaxDamage:
                                            if iRand > iMaxDamage:
                                                iRand = iMaxDamage

                                            ppUnit.changeDamage(iRand, 0)
                                            CyEngine().triggerEffect(
                                                GC.getInfoTypeForString(
                                                    "EFFECT_EXPLOSION_CITY"),
                                                ppUnit.plot().getPoint())
                                            iDamage += iRand

                                            if iPlayerAct == iOwnerNew:
                                                CvUtil.sendMessage(
                                                    "", iOwnerNew, -1,
                                                    'Art/Interface/Buttons/actions/destroy.dds',
                                                    ColorTypes(7),
                                                    ppUnit.getX(),
                                                    ppUnit.getY(), True, True)
                                            elif iPlayerAct == iOwnerOld:
                                                CvUtil.sendMessage(
                                                    "", iOwnerOld, -1,
                                                    'Art/Interface/Buttons/actions/destroy.dds',
                                                    ColorTypes(11),
                                                    ppUnit.getX(),
                                                    ppUnit.getY(), True, True)

                                if iPlayerAct == iOwnerNew:
                                    CvUtil.sendMessage(
                                        "", iOwnerNew, -1,
                                        'Art/Interface/Buttons/Units/sparth/guerilla.dds',
                                        ColorTypes(7), iiX, iiY, True, True, 1,
                                        'AS2D_CITY_REVOLT', False)
                                elif iPlayerAct == iOwnerOld:
                                    CvUtil.sendMessage(
                                        "", iOwnerOld, -1,
                                        'Art/Interface/Buttons/Units/sparth/guerilla.dds',
                                        ColorTypes(11), iiX, iiY, True, True,
                                        1, 'AS2D_CITY_REVOLT', False)

                            if iDamage < 1:
                                if iPlayerAct == iOwnerNew:
                                    CvUtil.sendMessage(
                                        TRNSLTR.getText(
                                            "TXT_KEY_PARTISAN_GAMETXT4",
                                            (szName, )), iOwnerNew, 16,
                                        'Art/Interface/Buttons/civics/despotism.dds',
                                        ColorTypes(7), iX, iY, True, True)
                                elif iPlayerAct == iOwnerOld:
                                    CvUtil.sendMessage(
                                        TRNSLTR.getText(
                                            "TXT_KEY_PARTISAN_GAMETXT3",
                                            (szName, )), iOwnerOld, 16,
                                        'Art/Interface/Buttons/civics/despotism.dds',
                                        ColorTypes(44), iX, iY, True, True)
                            else:
                                if iPlayerAct == iOwnerNew:
                                    CvUtil.sendMessage(
                                        TRNSLTR.getText(
                                            "TXT_KEY_PARTISAN_GAMETXT2",
                                            (szName, iDamage)), iOwnerNew, 16,
                                        'Art/Interface/Buttons/civics/despotism.dds',
                                        ColorTypes(7), iX, iY, True, True)
                                elif iPlayerAct == iOwnerOld:
                                    CvUtil.sendMessage(
                                        TRNSLTR.getText(
                                            "TXT_KEY_PARTISAN_GAMETXT1",
                                            (szName, iDamage)), iOwnerOld, 16,
                                        'Art/Interface/Buttons/civics/despotism.dds',
                                        ColorTypes(44), iX, iY, True, True)

                            # Reduce population
                            if citysize > 8:
                                CyCity.changePopulation(-nPartisan)
示例#21
0
	def CheckForAlerts(self, iPlayer, bBeginTurn):
		CyPlayer = GC.getPlayer(iPlayer)
		CyTeam = GC.getTeam(CyPlayer.getTeam())
		iGrowthCount = 0

		bCheck1 = self.options.isShowDomPopAlert()
		bCheck2 = bBeginTurn and self.options.isShowCityPendingExpandBorderAlert()

		if bCheck1 or bCheck2:
			# Check for cultural expansion and population growth
			icon = "Art/Interface/Buttons/General/Warning_popup.dds"
			iActiveTeam = GAME.getActiveTeam()
			for iPlayerX in xrange(GC.getMAX_PC_PLAYERS()):
				CyPlayerX = GC.getPlayer(iPlayerX)
				if not CyPlayerX.isAlive() or CyPlayerX.getTeam() != iActiveTeam:
					continue
				for cityX in CyPlayerX.cities():
					if cityX.getFoodTurnsLeft() == 1 and not cityX.isFoodProduction() and not cityX.AI_isEmphasize(5):
						iGrowthCount += 1
					if bCheck2 and cityX.getCultureLevel() != GC.getNumCultureLevelInfos() - 1:
						if cityX.getCulture(iPlayerX) + cityX.getCommerceRate(CommerceTypes.COMMERCE_CULTURE) >= cityX.getCultureThreshold():
							msg = TRNSLTR.getText("TXT_KEY_MORECIV4LERTS_CITY_TO_EXPAND",(cityX.getName(),))
							CvUtil.sendMessage(msg, iPlayer, EVENT_MESSAGE_TIME_LONG, icon, -1, cityX.getX(), cityX.getY(), True, True)

		# Check Domination Limit
		if self.getCheckForDomVictory() and GAME.isVictoryValid(3):
			# Population Limit
			if bCheck1 and iGrowthCount:
				iTotalPop = GAME.getTotalPopulation()
				if iTotalPop > 10:
					iTeamPop = CyTeam.getTotalPopulation()
					fPercent = iTeamPop * 100.0 / iTotalPop
					fPercentNext = (iTeamPop + iGrowthCount) * 100.0 / iTotalPop

					if iTeamPop + iGrowthCount != self.lastPopCount:
						fVictoryPercent = GAME.getAdjustedPopulationPercent(3) * 1.0
						iLimitPop = int(iTotalPop * fVictoryPercent / 100)

						if fPercent >= fVictoryPercent:
							msg = TRNSLTR.getText("TXT_KEY_MORECIV4LERTS_POP_EXCEEDS_LIMIT", (iTeamPop, (u"%.2f%%" % fPercent), iLimitPop, (u"%.2f%%" % fVictoryPercent)))
							self._addMessageNoIcon(iPlayer, msg)

						elif fPercentNext >= fVictoryPercent:
							msg = TRNSLTR.getText("TXT_KEY_MORECIV4LERTS_POP_GROWTH_EXCEEDS_LIMIT", (iTeamPop, iGrowthCount, (u"%.2f%%" % fPercentNext), iLimitPop, (u"%.2f%%" % fVictoryPercent)))
							self._addMessageNoIcon(iPlayer, msg)

						elif fVictoryPercent - fPercentNext < self.options.getDomPopThreshold():
							msg = TRNSLTR.getText("TXT_KEY_MORECIV4LERTS_POP_GROWTH_CLOSE_TO_LIMIT", (iTeamPop, iGrowthCount, (u"%.2f%%" % fPercentNext), iLimitPop, (u"%.2f%%" % fVictoryPercent)))
							self._addMessageNoIcon(iPlayer, msg)

						elif fVictoryPercent - fPercent < self.options.getDomPopThreshold():
							msg = TRNSLTR.getText("TXT_KEY_MORECIV4LERTS_POP_CLOSE_TO_LIMIT", (iTeamPop, (u"%.2f%%" % fPercent), iLimitPop, (u"%.2f%%" % fVictoryPercent)))
							self._addMessageNoIcon(iPlayer, msg)

						self.lastPopCount = iTeamPop + iGrowthCount
			# Land Limit
			if self.options.isShowDomLandAlert():
				iTeamLand = CyTeam.getTotalLand()
				if iTeamLand > 40 and iTeamLand != self.lastLandCount:
					iTotalLand = GC.getMap().getLandPlots()
					fVictoryPercent = GAME.getAdjustedLandPercent(3) * 1.0
					iLimitLand = int(iTotalLand * fVictoryPercent / 100)
					fPercent = (iTeamLand * 100.0) / iTotalLand

					if fPercent > fVictoryPercent:
						msg = TRNSLTR.getText("TXT_KEY_MORECIV4LERTS_LAND_EXCEEDS_LIMIT", (iTeamLand, (u"%.2f%%" % fPercent), iLimitLand, (u"%.2f%%" % fVictoryPercent)))
						self._addMessageNoIcon(iPlayer, msg)

					elif fVictoryPercent - fPercent < self.options.getDomLandThreshold():
						msg = TRNSLTR.getText("TXT_KEY_MORECIV4LERTS_LAND_CLOSE_TO_LIMIT", (iTeamLand, (u"%.2f%%" % fPercent), iLimitLand, (u"%.2f%%" % fVictoryPercent)))
						self._addMessageNoIcon(iPlayer, msg)

					self.lastLandCount = iTeamLand

		if not bBeginTurn: return
		#********#
		# Trades #
		# | || | #
		tradeData = TradeData()
		# Bonus
		if self.options.isShowBonusTradeAlert():
			desiredBonuses = TradeUtil.getDesiredBonuses(CyPlayer, CyTeam)
			tradesByPlayer = {}
			for CyPlayerX in TradeUtil.getBonusTradePartners(CyPlayer):
				will, wont = TradeUtil.getTradeableBonuses(CyPlayerX, iPlayer)
				tradesByPlayer[CyPlayerX.getID()] = will

			for iLoopPlayer, currentTrades in tradesByPlayer.iteritems():
				#Did he have trades avail last turn
				if self.PrevAvailBonusTrades.has_key(iLoopPlayer):
					previousTrades = self.PrevAvailBonusTrades[iLoopPlayer]
				else:
					previousTrades = set()
				#Determine new bonuses
				newTrades = currentTrades.difference(previousTrades).intersection(desiredBonuses)
				if newTrades:
					szNewTrades = self.buildBonusString(newTrades)
					msg = TRNSLTR.getText("TXT_KEY_MORECIV4LERTS_NEW_BONUS_AVAIL", (GC.getPlayer(iLoopPlayer).getName(), szNewTrades))
					self._addMessageNoIcon(iPlayer, msg)
				#Determine removed bonuses
				removedTrades = previousTrades.difference(currentTrades).intersection(desiredBonuses)
				if removedTrades:
					szRemovedTrades = self.buildBonusString(removedTrades)
					msg = TRNSLTR.getText("TXT_KEY_MORECIV4LERTS_BONUS_NOT_AVAIL", (GC.getPlayer(iLoopPlayer).getName(), szRemovedTrades))
					self._addMessageNoIcon(iPlayer, msg)
			#save curr trades for next time
			self.PrevAvailBonusTrades = tradesByPlayer
		# Tech
		if self.options.isShowTechTradeAlert():
			techsByPlayer = {}
			researchTechs = set()
			iTotalTechs = GC.getNumTechInfos()
			tradeData.ItemType = TradeableItems.TRADE_TECHNOLOGIES
			bCheck1 = True
			for CyPlayerX in TradeUtil.getTechTradePartners(CyPlayer):
				techsToTrade = set()
				for iTech in range(iTotalTechs):
					if bCheck1 and CyPlayer.canResearch(iTech):
						researchTechs.add(iTech)
					tradeData.iData = iTech
					if CyPlayerX.canTradeItem(iPlayer, tradeData, False):
						if CyPlayerX.getTradeDenial(iPlayer, tradeData) == DenialTypes.NO_DENIAL: # will trade
							techsToTrade.add(iTech)
				bCheck1 = False
				techsByPlayer[CyPlayerX.getID()] = techsToTrade

			for iLoopPlayer, currentTechs in techsByPlayer.iteritems():
				#Did he have trades avail last turn
				if self.PrevAvailTechTrades.has_key(iLoopPlayer):
					previousTechs = self.PrevAvailTechTrades[iLoopPlayer]
				else:
					previousTechs = set()
				#Determine new techs
				newTechs = currentTechs.difference(previousTechs).intersection(researchTechs)
				if newTechs:
					szNewTechs = self.buildTechString(newTechs)
					msg = TRNSLTR.getText("TXT_KEY_MORECIV4LERTS_NEW_TECH_AVAIL", (GC.getPlayer(iLoopPlayer).getName(), szNewTechs))
					self._addMessageNoIcon(iPlayer, msg)
				#Determine removed techs
				removedTechs = previousTechs.difference(currentTechs).intersection(researchTechs)
				if removedTechs:
					szRemovedTechs = self.buildTechString(removedTechs)
					msg = TRNSLTR.getText("TXT_KEY_MORECIV4LERTS_TECH_NOT_AVAIL", (GC.getPlayer(iLoopPlayer).getName(), szRemovedTechs))
					self._addMessageNoIcon(iPlayer, msg)
			#save curr trades for next time
			self.PrevAvailTechTrades = techsByPlayer
		# Map
		if self.options.isShowMapTradeAlert():
			tradeData.ItemType = TradeableItems.TRADE_MAPS
			oldSet = self.PrevAvailMapTrades
			TXT_KEY = "TXT_KEY_MORECIV4LERTS_MAP"
			willTrade = self.getTrades(TradeUtil.getMapTradePartners(CyPlayer), iPlayer, tradeData, oldSet, TXT_KEY)
			if willTrade != oldSet:
				self.PrevAvailMapTrades = willTrade
		# Open Borders
		if self.options.isShowOpenBordersTradeAlert():
			tradeData.ItemType = TradeableItems.TRADE_OPEN_BORDERS
			oldSet = self.PrevAvailOpenBordersTrades
			TXT_KEY = "TXT_KEY_MORECIV4LERTS_OPEN_BORDERS"
			willTrade = self.getTrades(TradeUtil.getOpenBordersTradePartners(CyPlayer), iPlayer, tradeData, oldSet, TXT_KEY)
			if willTrade != oldSet:
				self.PrevAvailOpenBordersTrades = willTrade
		# Defensive Pact
		if self.options.isShowDefensivePactTradeAlert():
			tradeData.ItemType = TradeableItems.TRADE_DEFENSIVE_PACT
			oldSet = self.PrevAvailDefensivePactTrades
			TXT_KEY = "TXT_KEY_MORECIV4LERTS_DEFENSIVE_PACT"
			willTrade = self.getTrades(TradeUtil.getDefensivePactTradePartners(CyPlayer), iPlayer, tradeData, oldSet, TXT_KEY)
			if willTrade != oldSet:
				self.PrevAvailDefensivePactTrades = willTrade
		# Alliance
		if self.options.isShowPermanentAllianceTradeAlert():
			tradeData.ItemType = TradeableItems.TRADE_PERMANENT_ALLIANCE
			oldSet = self.PrevAvailPermanentAllianceTrades
			TXT_KEY = "TXT_KEY_MORECIV4LERTS_PERMANENT_ALLIANCE"
			willTrade = self.getTrades(TradeUtil.getPermanentAllianceTradePartners(CyPlayer), iPlayer, tradeData, oldSet, TXT_KEY)
			if willTrade != oldSet:
				self.PrevAvailPermanentAllianceTrades = willTrade
		# Vassalage
		if self.options.isShowVassalTradeAlert():
			tradeData.ItemType = TradeableItems.TRADE_VASSAL
			oldSet = self.PrevAvailVassalTrades
			TXT_KEY = "TXT_KEY_MORECIV4LERTS_VASSAL"
			willTrade = self.getTrades(TradeUtil.getVassalTradePartners(CyPlayer), iPlayer, tradeData, oldSet, TXT_KEY)
			if willTrade != oldSet:
				self.PrevAvailVassalTrades = willTrade
		# Capitulate
		if self.options.isShowSurrenderTradeAlert():
			tradeData.ItemType = TradeableItems.TRADE_SURRENDER
			oldSet = self.PrevAvailSurrenderTrades
			TXT_KEY = "TXT_KEY_MORECIV4LERTS_SURRENDER"
			willTrade = self.getTrades(TradeUtil.getCapitulationTradePartners(CyPlayer), iPlayer, tradeData, oldSet, TXT_KEY)
			if willTrade != oldSet:
				self.PrevAvailSurrenderTrades = willTrade
		# Peace Treaty
		if self.options.isShowPeaceTradeAlert():
			tradeData.ItemType = TradeableItems.TRADE_PEACE_TREATY
			tradeData.iData = GC.getDefineINT("PEACE_TREATY_LENGTH")
			oldSet = self.PrevAvailPeaceTrades
			TXT_KEY = "TXT_KEY_MORECIV4LERTS_PEACE_TREATY"
			willTrade = self.getTrades(TradeUtil.getPeaceTradePartners(CyPlayer), iPlayer, tradeData, oldSet, TXT_KEY)
			if willTrade != oldSet:
				self.PrevAvailPeaceTrades = willTrade