示例#1
0
	def spawnConquerors(self, iPlayer, iPreferredTarget, tTL, tBR, iNumTargets, iYear, iIntervalTurns, iWarPlan = WarPlanTypes.WARPLAN_TOTAL):
		lCities = []
		for city in utils.getAreaCities(utils.getPlotList(tTL, tBR)):
			if city.getOwner() != iPlayer and not gc.getTeam(city.getOwner()).isVassal(iPlayer):
				lCities.append(city)
				
		capital = gc.getPlayer(iPlayer).getCapitalCity()
		
		lTargetCities = []
		for i in range(iNumTargets):
			if len(lCities) == 0: break
			
			targetCity = utils.getHighestEntry(lCities, lambda x: -utils.calculateDistance(x.getX(), x.getY(), capital.getX(), capital.getY()) + int(x.getOwner() == iPreferredTarget) * 1000)
			lTargetCities.append(targetCity)
			lCities.remove(targetCity)
			
		lOwners = []
		for city in lTargetCities:
			if city.getOwner() not in lOwners:
				lOwners.append(city.getOwner())
				
		if iPreferredTarget not in lOwners and gc.getPlayer(iPreferredTarget).isAlive():
			gc.getTeam(iPlayer).declareWar(iPreferredTarget, True, iWarPlan)
				
		for iOwner in lOwners:
			gc.getTeam(iPlayer).declareWar(iOwner, True, iWarPlan)
			CyInterface().addMessage(iOwner, False, iDuration, CyTranslator().getText("TXT_KEY_UP_CONQUESTS_TARGET", (gc.getPlayer(iPlayer).getCivilizationShortDescription(0),)), "", 0, "", ColorTypes(iWhite), -1, -1, True, True)
			
		for city in lTargetCities:
			iExtra = 0
			if utils.getHumanID() not in [iPlayer, city.getOwner()]: iExtra = 1 #max(1, gc.getPlayer(iPlayer).getCurrentEra())
			
			tPlot = utils.findNearestLandPlot((city.getX(), city.getY()), iPlayer)
			
			iBestInfantry = utils.getBestInfantry(iPlayer)
			iBestSiege = utils.getBestSiege(iPlayer)
			
			if iPlayer == iGreece:
				iBestInfantry = iHoplite
				iBestSiege = iCatapult
			
			utils.makeUnitAI(iBestInfantry, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 2 + iExtra)
			utils.makeUnitAI(iBestSiege, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 1 + 2*iExtra)
			
			if iPlayer == iTamils:
				utils.makeUnitAI(iWarElephant, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 1)
				
			if iPlayer == iSpain:
				utils.makeUnitAI(utils.getBestCavalry(iPlayer), iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 2 * iExtra)
	def spawnConquerors(self, iPlayer, iPreferredTarget, tTL, tBR, iNumTargets, iYear, iIntervalTurns, iWarPlan = WarPlanTypes.WARPLAN_TOTAL):
		lCities = []
		for city in utils.getAreaCities(utils.getPlotList(tTL, tBR)):
			if city.getOwner() != iPlayer and not gc.getTeam(city.getOwner()).isVassal(iPlayer):
				lCities.append(city)
				
		capital = gc.getPlayer(iPlayer).getCapitalCity()
		
		lTargetCities = []
		for i in range(iNumTargets):
			if len(lCities) == 0: break
			
			targetCity = utils.getHighestEntry(lCities, lambda x: -utils.calculateDistance(x.getX(), x.getY(), capital.getX(), capital.getY()) + int(x.getOwner() == iPreferredTarget) * 1000)
			lTargetCities.append(targetCity)
			lCities.remove(targetCity)
			
		lOwners = []
		for city in lTargetCities:
			if city.getOwner() not in lOwners:
				lOwners.append(city.getOwner())
				
		if iPreferredTarget not in lOwners and gc.getPlayer(iPreferredTarget).isAlive():
			gc.getTeam(iPlayer).declareWar(iPreferredTarget, True, iWarPlan)
				
		for iOwner in lOwners:
			gc.getTeam(iPlayer).declareWar(iOwner, True, iWarPlan)
			CyInterface().addMessage(iOwner, False, iDuration, CyTranslator().getText("TXT_KEY_UP_CONQUESTS_TARGET", (gc.getPlayer(iPlayer).getCivilizationShortDescription(0),)), "", 0, "", ColorTypes(iWhite), -1, -1, True, True)
			
		for city in lTargetCities:
			iExtra = 0
			if utils.getHumanID() not in [iPlayer, city.getOwner()]: iExtra = 1
			
			tPlot = utils.findNearestLandPlot((city.getX(), city.getY()), iPlayer)
			
			iBestInfantry = utils.getBestInfantry(iPlayer)
			iBestSiege = utils.getBestSiege(iPlayer)
			
			if iPlayer == iGreece:
				iBestInfantry = iGreekHoplite
				iBestSiege = iCatapult
			
			utils.makeUnitAI(iBestInfantry, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 2 + iExtra)
			utils.makeUnitAI(iBestSiege, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 1 + 2*iExtra)
			
			if iPlayer == iTamils:
				utils.makeUnitAI(iWarElephant, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 1)
示例#3
0
def checkturn(iGameTurn):
    # 阿根廷出生前1回合,设置马岛,并将马岛设置为阿根廷的UHV
    if iGameTurn == getTurnForYear(1805): #1805
        tPlot=(41,6)
        iPlayer=iEngland
        iBestInfantry = utils.getBestInfantry(iPlayer)
        gc.getMap().plot(tPlot[0], tPlot[1]).setPlotType(PlotTypes.PLOT_HILLS, True, True)
        Resources.Resources().createResource(41, 7, iFish)
        foundCity(iEngland,tPlot,"Falkland",3)
        #utils.makeUnitAI(iSettler, iEngland, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 1)
        utils.makeUnitAI(iBestInfantry, iEngland, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 1+gc.getGame().getHandicapType())
        pass
        #self.createResource(88, 37, iHorse)
    if iGameTurn == getTurnForYear(1870): #1805
        if(utils.getHumanID()==iArgentina):
            if(gc.getPlayer(iBrazil).isAlive() and gc.getPlayer(iArgentina).isAlive()):
                pass
                #declareWar(iBrazil,iArgentina)
    def onGoldenAge(self, argsList):
        iPlayer = argsList[0]

        if not data.players[iPlayer].bFirstGoldenAge:
            data.players[iPlayer].bFirstGoldenAge = True
            capital = gc.getPlayer(iPlayer).getCapitalCity()

            if iPlayer in [iPolynesia, iVikings, iIndonesia, iNetherlands]:
                utils.makeUnit(iSettler, iPlayer,
                               (capital.getX(), capital.getY()), 2)
                utils.makeUnit(utils.getBestWorker(iPlayer), iPlayer,
                               (capital.getX(), capital.getY()), 1)
                utils.makeUnit(iWorkboat, iPlayer,
                               (capital.getX(), capital.getY()), 1)
                utils.makeUnit(utils.getBestInfantry(iPlayer), iPlayer,
                               (capital.getX(), capital.getY()), 1)
                utils.makeUnit(utils.getBestCounter(iPlayer), iPlayer,
                               (capital.getX(), capital.getY()), 1)
                utils.makeUnit(utils.getBestDefender(iPlayer), iPlayer,
                               (capital.getX(), capital.getY()), 1)
                utils.makeUnit(utils.getBestShip(iPlayer), iPlayer,
                               (capital.getX(), capital.getY()), 4)

            elif iPlayer in [iMaya, iInca, iAztecs, iCongo]:
                utils.makeUnit(iSettler, iPlayer,
                               (capital.getX(), capital.getY()), 2)
                utils.makeUnit(utils.getBestWorker(iPlayer), iPlayer,
                               (capital.getX(), capital.getY()), 1)
                utils.makeUnit(utils.getBestInfantry(iPlayer), iPlayer,
                               (capital.getX(), capital.getY()), 3)
                utils.makeUnit(utils.getBestCounter(iPlayer), iPlayer,
                               (capital.getX(), capital.getY()), 3)
                utils.makeUnit(utils.getBestDefender(iPlayer), iPlayer,
                               (capital.getX(), capital.getY()), 3)

            else:
                utils.makeUnit(utils.getBestWorker(iPlayer), iPlayer,
                               (capital.getX(), capital.getY()), 1)
                utils.makeUnit(utils.getBestInfantry(iPlayer), iPlayer,
                               (capital.getX(), capital.getY()), 2)
                utils.makeUnit(utils.getBestCounter(iPlayer), iPlayer,
                               (capital.getX(), capital.getY()), 2)
                utils.makeUnit(utils.getBestDefender(iPlayer), iPlayer,
                               (capital.getX(), capital.getY()), 2)
                utils.makeUnit(utils.getBestSiege(iPlayer), iPlayer,
                               (capital.getX(), capital.getY()), 1)
                utils.makeUnit(utils.getBestCavalry(iPlayer), iPlayer,
                               (capital.getX(), capital.getY()), 1)

                if iPlayer == iHarappa:
                    utils.makeUnit(iCityBuilder, iPlayer,
                                   (capital.getX(), capital.getY()), 2)

                elif iPlayer == iAmerica:
                    utils.makeUnit(iPioneer, iPlayer,
                                   (capital.getX(), capital.getY()), 2)

                else:
                    utils.makeUnit(iSettler, iPlayer,
                                   (capital.getX(), capital.getY()), 2)

        sta.onGoldenAge(iPlayer)
    def spawnConquerors(self,
                        iPlayer,
                        iPreferredTarget,
                        tTL,
                        tBR,
                        iNumTargets,
                        iYear,
                        iIntervalTurns,
                        iWarPlan=WarPlanTypes.WARPLAN_TOTAL):
        if not gc.getPlayer(iPlayer).isAlive():
            for iTech in sta.getResurrectionTechs(iPlayer):
                gc.getTeam(gc.getPlayer(iPlayer).getTeam()).setHasTech(
                    iTech, True, iPlayer, False, False)

        lCities = []
        for city in utils.getAreaCities(utils.getPlotList(tTL, tBR)):
            if city.getOwner() != iPlayer and not gc.getTeam(
                    city.getOwner()).isVassal(iPlayer):
                if (gc.getDefineINT("AIWAR_PY_CANNOT_DO_AIWAR_TO_HUMAN") > 0
                        and (city.getOwner() == utils.getHumanID())):
                    pass
                else:
                    lCities.append(city)

        capital = gc.getPlayer(iPlayer).getCapitalCity()

        lTargetCities = []
        for i in range(iNumTargets):
            if len(lCities) == 0: break

            targetCity = utils.getHighestEntry(
                lCities, lambda x: -utils.calculateDistance(
                    x.getX(), x.getY(), capital.getX(), capital.getY()) + int(
                        x.getOwner() == iPreferredTarget) * 1000)
            lTargetCities.append(targetCity)
            lCities.remove(targetCity)

        lOwners = []
        for city in lTargetCities:
            if city.getOwner() not in lOwners:
                lOwners.append(city.getOwner())

        if iPreferredTarget >= 0 and iPreferredTarget not in lOwners and gc.getPlayer(
                iPreferredTarget).isAlive():
            if (gc.getDefineINT("AIWAR_PY_CANNOT_DO_AIWAR_TO_HUMAN") > 0
                    and (iPreferredTarget == utils.getHumanID())):
                pass
            else:
                self.declareWar(iPlayer, iPreferredTarget, iWarPlan)

        for iOwner in lOwners:
            self.declareWar(iPlayer, iOwner, iWarPlan)
            CyInterface().addMessage(
                iOwner, False, iDuration,
                CyTranslator().getText(
                    "TXT_KEY_UP_CONQUESTS_TARGET",
                    (gc.getPlayer(iPlayer).getCivilizationShortDescription(0),
                     )), "", 0, "", ColorTypes(iWhite), -1, -1, True, True)
#####修改开始#####
#消息传送区
        if (gc.getDefineINT("PYTHON_USE_ADVANCE_ALERT") == 1):  #参数控制
            if iPlayer == iGreece:
                tem_text = '世界军事速递:亚历山大东征开始了!其麾下的军队正在横扫欧亚大陆!'
                CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                         iDuration, tem_text, "", 0, "",
                                         ColorTypes(iWhite), -1, -1, True,
                                         True)
    #			utils.show('军事速递:亚历山大东征开始了!')
            if iPlayer == iRome:
                tem_text = '世界军事速递:罗马帝国正在崛起,其军队所向披靡!'
                CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                         iDuration, tem_text, "", 0, "",
                                         ColorTypes(iWhite), -1, -1, True,
                                         True)
    #			utils.show('军事速递:罗马帝国正在崛起,其军队所向披靡!')
            if iPlayer == iMongolia:
                tem_text = '世界军事速递:蒙古帝国正在崛起,成吉思汗的军队所向披靡!'
                CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                         iDuration, tem_text, "", 0, "",
                                         ColorTypes(iWhite), -1, -1, True,
                                         True)
    #			utils.show('军事速递:蒙古帝国正在崛起,成吉思汗的军队所向披靡!')
            if iPlayer == iTurks:
                tem_text = '世界军事速递:突厥帝国正在崛起,其军队所向披靡!'
                CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                         iDuration, tem_text, "", 0, "",
                                         ColorTypes(iWhite), -1, -1, True,
                                         True)
    #			utils.show('军事速递:突厥帝国正在崛起,其军队所向披靡!')
    #百年战争
            if iPlayer == iEngland and iYear <= 1450 and iYear >= 1250:
                tem_text = '&#33521;&#27861;&#30334;&#24180;&#25112;&#20105;&#30340;&#33125;&#39118;&#34880;&#38632;&#27491;&#24335;&#25289;&#24320;&#24119;&#24149;&#65281;'
                CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                         iDuration, tem_text, "", 0, "",
                                         ColorTypes(iWhite), -1, -1, True,
                                         True)
    #			utils.show('&#20891;&#20107;&#36895;&#36882;&#65306;&#31361;&#21413;&#24093;&#22269;&#27491;&#22312;&#23835;&#36215;&#65292;&#20854;&#20891;&#38431;&#25152;&#21521;&#25259;&#38753;&#65281;')
    #圣女贞德
            if iPlayer == iFrance and iYear <= 1550 and iYear >= 1350:
                tem_text = '&#22307;&#22899;&#36126;&#24503;&#21796;&#36215;&#20102;&#27861;&#22269;&#20154;&#27665;&#30340;&#27665;&#26063;&#24863;&#65292;&#27861;&#22269;&#20154;&#27665;&#20026;&#20102;&#25421;&#21355;&#23478;&#22253;&#32780;&#25112;&#65281;'
                CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                         iDuration, tem_text, "", 0, "",
                                         ColorTypes(iWhite), -1, -1, True,
                                         True)
    #			utils.show('&#20891;&#20107;&#36895;&#36882;&#65306;&#31361;&#21413;&#24093;&#22269;&#27491;&#22312;&#23835;&#36215;&#65292;&#20854;&#20891;&#38431;&#25152;&#21521;&#25259;&#38753;&#65281;')
    #十字军
            if iPlayer == iEngland and iYear <= 1200 and iYear >= 1000:
                tem_text = '&#36720;&#21160;&#20013;&#19996;&#21644;&#27431;&#27954;&#30340;&#21313;&#23383;&#20891;&#19996;&#24449;&#24320;&#22987;&#20102;&#65281;'
                CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                         iDuration, tem_text, "", 0, "",
                                         ColorTypes(iWhite), -1, -1, True,
                                         True)
    #			utils.show('&#20891;&#20107;&#36895;&#36882;&#65306;&#31361;&#21413;&#24093;&#22269;&#27491;&#22312;&#23835;&#36215;&#65292;&#20854;&#20891;&#38431;&#25152;&#21521;&#25259;&#38753;&#65281;')
    #萨拉丁
            if iPlayer == iEgypt and iYear <= 1300 and iYear >= 1100:
                tem_text = '&#24180;&#36731;&#30340;&#39046;&#34966;&#33832;&#25289;&#19969;&#29575;&#39046;&#20891;&#38431;&#21521;&#21313;&#23383;&#20891;&#21457;&#36215;&#29467;&#28872;&#30340;&#36827;&#25915;&#65281;'
                CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                         iDuration, tem_text, "", 0, "",
                                         ColorTypes(iWhite), -1, -1, True,
                                         True)
    #			utils.show('&#20891;&#20107;&#36895;&#36882;&#65306;&#31361;&#21413;&#24093;&#22269;&#27491;&#22312;&#23835;&#36215;&#65292;&#20854;&#20891;&#38431;&#25152;&#21521;&#25259;&#38753;&#65281;')
    #拿破仑战争
            if iPlayer == iFrance and iYear <= 1900 and iYear >= 1700:
                tem_text = '&#25343;&#30772;&#20177;&#30340;&#20891;&#38431;&#27491;&#22312;&#27431;&#27954;&#25152;&#21521;&#25259;&#38753;&#65281;'
                CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                         iDuration, tem_text, "", 0, "",
                                         ColorTypes(iWhite), -1, -1, True,
                                         True)
    #			utils.show('&#20891;&#20107;&#36895;&#36882;&#65306;&#31361;&#21413;&#24093;&#22269;&#27491;&#22312;&#23835;&#36215;&#65292;&#20854;&#20891;&#38431;&#25152;&#21521;&#25259;&#38753;&#65281;')
            if iYear <= 1930 and iYear >= 1900:
                tem_text = '&#31532;&#19968;&#27425;&#19990;&#30028;&#22823;&#25112;&#27491;&#22312;&#36827;&#34892;&#65281;'
                CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                         iDuration, tem_text, "", 0, "",
                                         ColorTypes(iWhite), -1, -1, True,
                                         True)
    #			utils.show('&#20891;&#20107;&#36895;&#36882;&#65306;&#31361;&#21413;&#24093;&#22269;&#27491;&#22312;&#23835;&#36215;&#65292;&#20854;&#20891;&#38431;&#25152;&#21521;&#25259;&#38753;&#65281;')
            if iYear <= 1960 and iYear >= 1930:
                tem_text = '&#31532;&#20108;&#27425;&#19990;&#30028;&#22823;&#25112;&#27491;&#22312;&#36827;&#34892;&#65281;'
                CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                         iDuration, tem_text, "", 0, "",
                                         ColorTypes(iWhite), -1, -1, True,
                                         True)

    #			utils.show('&#20891;&#20107;&#36895;&#36882;&#65306;&#31361;&#21413;&#24093;&#22269;&#27491;&#22312;&#23835;&#36215;&#65292;&#20854;&#20891;&#38431;&#25152;&#21521;&#25259;&#38753;&#65281;')

#####修改结束#####
####修改开始####
        for city in lTargetCities:
            iExtra = 0 + 2
            # 			if utils.getHumanID() not in [iPlayer, city.getOwner()]:
            # 				iExtra += 1 #max(1, gc.getPlayer(iPlayer).getCurrentEra())
            #
            # 			if iPlayer == iMongolia and utils.getHumanID() != iPlayer:
            # 				iExtra += 1

            tPlot = utils.findNearestLandPlot((city.getX(), city.getY()),
                                              iPlayer)
            if (tPlot):

                iBestInfantry = utils.getBestInfantry(iPlayer)
                iBestSiege = utils.getBestSiege(iPlayer)

                if iPlayer == iGreece:
                    iBestInfantry = iHoplite
                    iBestSiege = iCatapult
                if iPlayer == iMongolia:
                    iBestInfantry = iKeshik
                    iExtra += 2

                if iPlayer == iCarthage and iYear <= 150:
                    iExtra = 0
                    iBestInfantry = iWarElephant
                    tem_text = '&#36838;&#22826;&#22522;&#30340;&#27721;&#23612;&#25300;&#23558;&#20891;&#32763;&#36234;&#20102;&#38463;&#23572;&#21329;&#26031;&#23665;&#65292;&#20986;&#29616;&#22312;&#31859;&#20848;&#38468;&#36817;&#65281;'
                    CyInterface().addMessage(gc.getGame().getActivePlayer(),
                                             False, iDuration,
                                             tem_text, "", 0, "",
                                             ColorTypes(iWhite), -1, -1, True,
                                             True)
                if iPlayer == iBarbarian and iYear <= 150:
                    iExtra = -1
                    iBestInfantry = iMilitia
                    utils.makeUnitAI(iBestInfantry, iPlayer, tPlot,
                                     UnitAITypes.UNITAI_ATTACK_CITY, 1)
                    utils.makeUnitAI(iLightSwordsman, iPlayer, tPlot,
                                     UnitAITypes.UNITAI_ATTACK_CITY, 1)
                    tem_text = '&#26031;&#24052;&#36798;&#20811;&#26031;&#21561;&#21709;&#20102;&#21453;&#25239;&#32599;&#39532;&#30340;&#36215;&#20041;&#21495;&#35282;&#65281;'
                    CyInterface().addMessage(gc.getGame().getActivePlayer(),
                                             False, iDuration,
                                             tem_text, "", 0, "",
                                             ColorTypes(iWhite), -1, -1, True,
                                             True)
                if iPlayer == iEngland and iYear <= 1500:
                    iExtra -= 0
                    iBestInfantry = iLongbowman
    #				utils.makeUnitAI(iBestInfantry, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 2)
    #				iBestSiege = iCatapult
                if (iPlayer == iEngland and iYear <= 1250) or (
                        iPlayer == iHolyRome
                        and iYear <= 1250) or (iPlayer == iFrance
                                               and iYear <= 1250):
                    iExtra -= 1

    #				iBestInfantry = iLongbowman
    #				utils.makeUnitAI(iBestInfantry, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 2)
    #				iBestSiege = iCatapult
                if iPlayer == iTurks and iYear <= 1250:
                    iExtra -= 2

                if iYear >= 1800:
                    iExtra += 1
                if iYear >= 1900:
                    iExtra += 1
                if iYear >= 1930:
                    iExtra += 1
                if iPreferredTarget == utils.getHumanID() and iYear >= 1300:
                    iExtra = gc.getGame().getHandicapType() + 1

                utils.makeUnitAI(iBestInfantry, iPlayer, tPlot,
                                 UnitAITypes.UNITAI_ATTACK_CITY,
                                 max(2 + iExtra, 1))
                utils.makeUnitAI(iBestSiege, iPlayer, tPlot,
                                 UnitAITypes.UNITAI_ATTACK_CITY,
                                 max(1 + iExtra, 1))
                ####修改结束#####
                if iPlayer == iGreece:
                    utils.makeUnitAI(iCompanion, iPlayer, tPlot,
                                     UnitAITypes.UNITAI_ATTACK_CITY, 1)

                if iPlayer == iTamils:
                    utils.makeUnitAI(iWarElephant, iPlayer, tPlot,
                                     UnitAITypes.UNITAI_ATTACK_CITY, 1)

                if iPlayer == iSpain:
                    utils.makeUnitAI(utils.getBestCavalry(iPlayer), iPlayer,
                                     tPlot, UnitAITypes.UNITAI_ATTACK_CITY,
                                     2 * iExtra)

                if iPlayer == iTurks:
                    utils.makeUnitAI(utils.getBestCavalry(iPlayer), iPlayer,
                                     tPlot, UnitAITypes.UNITAI_ATTACK_CITY,
                                     2 + iExtra)