コード例 #1
0
ファイル: Tester.py プロジェクト: markourm/fall
	def onCityLost(self, argsList):
		'City Lost'
		city = argsList[0]
		player = PyPlayer(city.getOwner())

		CvUtil.pyPrint('City %s was lost by Player %d Civilization %s'
			%(city.getName(), player.getID(), player.getCivilizationName()))
コード例 #2
0
ファイル: Tester.py プロジェクト: markourm/fall
	def onGreatPersonBorn(self, argsList):
		'Unit Promoted'
		pUnit, iPlayer, pCity = argsList
		player = PyPlayer(iPlayer)
		if pUnit.isNone() or pCity.isNone():
				return

		CvUtil.pyPrint('A %s was born for %s in %s' %(pUnit.getName(), player.getCivilizationName(), pCity.getName()))
コード例 #3
0
ファイル: Tester.py プロジェクト: markourm/fall
	def onReligionFounded(self, argsList):
		'Religion Founded'

		iReligion, iFounder = argsList
		player = PyPlayer(iFounder)

		CvUtil.pyPrint('Player %d Civilization %s has founded %s'
			%(iFounder, player.getCivilizationName(), gc.getReligionInfo(iReligion).getDescription()))
コード例 #4
0
ファイル: Tester.py プロジェクト: markourm/fall
	def showRevSuccessPopup( self ) :
		
		bodStr = ""
		pPlayer = gc.getActivePlayer()
		
		pPyPlayer = PyPlayer( pPlayer.getID() )
		
		for city in pPyPlayer.getCityList() :
			pCity = city.GetCy()
			bodStr += "%s: %d"%(pCity.getName(),pCity.getRevSuccessTimer())
			bodStr += "\n"
		 
		popup = PyPopup.PyPopup()
		popup.setBodyString( bodStr )
		popup.launch()
コード例 #5
0
ファイル: Tester.py プロジェクト: keldath/kmod-adv-Doto
    def showStrandedPopup(self):

        bodStr = "Stranded units by player:\n"
        for iPlayer in range(0, gc.getMAX_PLAYERS()):
            pPlayer = gc.getPlayer(iPlayer)

            if (pPlayer.isAlive()):

                bodStr += "\n\n%d: %s" % (
                    iPlayer, pPlayer.getCivilizationDescription(0))

                unitList = PyPlayer(iPlayer).getUnitList()

                for pUnit in unitList:

                    pGroup = pUnit.getGroup()
                    if (pGroup.getHeadUnit().getID() == pUnit.getID()):
                        if (pGroup.isStranded()):
                            bodStr += "\n   %s (%d units) at (%d, %d)" % (
                                pUnit.getName(), pGroup.getNumUnits(),
                                pUnit.getX(), pUnit.getY())

        popup = PyPopup.PyPopup()
        popup.setBodyString(bodStr)
        popup.launch()
コード例 #6
0
    def setName(self):

        popup = PyPopup.PyPopup(RevDefs.setNamePopup, contextType=EventContextTypes.EVENTCONTEXT_ALL)
        popup.setBodyString("Change name of a civ")
        popup.addSeparator()

        popup.createPythonEditBox("Name", "New name for player, eg jdog5000", 0)
        popup.createPythonEditBox("Desc", "New name for civ, eg American Empire", 1)
        popup.createPythonEditBox("Short", "New name for civ, eg America", 2)
        popup.createPythonEditBox("Adj", "New name for civ, eg American", 3)

        popup.createPythonPullDown("This AI Player", 1)
        for i in range(0, gc.getMAX_CIV_PLAYERS()):
            player = PyPlayer(i)
            if not player.isNone():
                if player.isAlive():
                    popup.addPullDownString("%s of the %s" % (player.getName(), player.getCivilizationName()), i, 1)

        popup.addButton("None")
        CvUtil.pyPrint("Launching pick human popup")
        popup.launch()
コード例 #7
0
ファイル: Tester.py プロジェクト: markourm/fall
	def setName( self ) :

		popup = PyPopup.PyPopup(RevDefs.setNamePopup,contextType = EventContextTypes.EVENTCONTEXT_ALL)
		popup.setBodyString( 'Change name of a civ' )
		popup.addSeparator()

		popup.createPythonEditBox( 'Name', 'New name for player, eg jdog5000', 0)
		popup.createPythonEditBox( 'Desc', 'New name for civ, eg American Empire', 1)
		popup.createPythonEditBox( 'Short', 'New name for civ, eg America', 2)
		popup.createPythonEditBox( 'Adj', 'New name for civ, eg American', 3)

		popup.createPythonPullDown( 'This AI Player', 1 )
		for i in range(0,gc.getMAX_CIV_PLAYERS()) :
			player = PyPlayer(i)
			if( not player.isNone() ) :
				if( player.isAlive() ) :
					popup.addPullDownString( "%s of the %s"%(player.getName(),player.getCivilizationName()), i, 1 )

		popup.addButton('None')
		CvUtil.pyPrint('Launching pick human popup')
		popup.launch()
コード例 #8
0
	def refreshScreen(self):

		self.deleteAllWidgets()

		if (self.iTargetPlayer != -1):

			# Create a new screen, called EspionageAdvisor, using the file EspionageAdvisor.py for input
			screen = self.getScreen()

			pActivePlayer = gc.getPlayer(self.iActivePlayer)
			pActiveTeam = gc.getTeam(pActivePlayer.getTeam())

			iPlayerLoop = 0

			for iPlayerID in self.aiKnownPlayers:

				iX = 0
				iY = 15 #+ (148 * iPlayerLoop)#(110 * iPlayerLoop)

				pTargetPlayer = gc.getPlayer(iPlayerID)
				iTargetTeam = pTargetPlayer.getTeam()

				attach = "LeaderContainer%d" % (iPlayerID)

				szName = "SpendingText%d" %(iPlayerID)
				self.aszSpendingTexts.append(szName)
				szText = u"<font=2>" + localText.getText("TXT_KEY_ESPIONAGE_SCREEN_SPENDING_WEIGHT", ()) + ": %d</font>" %(pActivePlayer.getEspionageSpendingWeightAgainstTeam(iTargetTeam))
				screen.deleteWidget(szName)
				screen.setLabelAt( szName, attach, szText, 0, 85, iY, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 );

				szName = "AmountText%d" %(iPlayerID)

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

				screen.deleteWidget(szName)
				screen.setLabelAt( szName, attach, szText, 0, 247, iY - 1, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 );

				szName = "SpendingIcon%d" %(iPlayerID)
				if (pActivePlayer.getEspionageSpendingWeightAgainstTeam(iTargetTeam) > 0):
					szText = u"<font=2>%c</font>" %(gc.getCommerceInfo(CommerceTypes.COMMERCE_ESPIONAGE).getChar())
				else:
					szText = u""

				screen.deleteWidget(szName)
				screen.setLabelAt( szName, attach, szText, 0, 3, iY - 9, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 );


				iPlayerLoop += 1

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

				pTargetPlayer = gc.getPlayer(self.iTargetPlayer)
				pyTargetPlayer = PyPlayer(self.iTargetPlayer)

				# List of Cities
				self.szCityListBox = self.getNextWidgetName()
				screen.addListBoxGFC(self.szCityListBox, "", self.X_CITY_LIST, self.Y_CITY_LIST, self.W_CITY_LIST, self.H_CITY_LIST, TableStyles.TABLE_STYLE_STANDARD)
				screen.enableSelect(self.szCityListBox, True)
				screen.setStyle(self.szCityListBox, "Table_StandardCiv_Style")

				# Loop through target's cities, see which are visible and add them to the list
				apCityList = pyTargetPlayer.getCityList()

				iLoop = 0

				for pyCity in apCityList:

					pCity = pyCity.GetCy()

					if (pCity.isRevealed(pActivePlayer.getTeam(), false)):
						screen.appendListBoxString( self.szCityListBox, pCity.getName(), WidgetTypes.WIDGET_GENERAL, pCity.getID(), 0, CvUtil.FONT_LEFT_JUSTIFY )

						if (self.iActiveCityID == -1 or pTargetPlayer.getCity(self.iActiveCityID).isNone()):
							self.iActiveCityID = pCity.getID()

						if (self.iActiveCityID == pCity.getID()):
							screen.setSelectedListBoxStringGFC(self.szCityListBox, iLoop)

						iLoop += 1

				#screen.updateListBox(self.szCityListBox)

				self.W_TABLE_0 = self.W_EFFECTS_LIST
				self.W_TABLE_1 = 0
				self.W_TABLE_2 = self.W_EFFECTS_COSTS_LIST
				self.W_TABLE_3 = 20

				szEffectsTable = self.getNextWidgetName()
				szHelpText = localText.getText("TXT_KEY_ESPIONAGE_PASSIVE_AUTOMATIC", ())
				screen.addTableControlGFCWithHelp(szEffectsTable, 4, self.X_EFFECTS_LIST, self.Y_EFFECTS_LIST, self.W_EFFECTS_LIST + self.W_EFFECTS_COSTS_LIST + self.W_TABLE_1 + self.W_TABLE_3, self.H_EFFECTS_LIST, False, False, 32,32, TableStyles.TABLE_STYLE_STANDARD, szHelpText)
				screen.setTableColumnHeader(szEffectsTable, 0, "", self.W_TABLE_0)
				screen.setTableColumnHeader(szEffectsTable, 1, "", self.W_TABLE_1)
				screen.setTableColumnHeader(szEffectsTable, 2, "", self.W_TABLE_2)
				screen.setTableColumnHeader(szEffectsTable, 3, "", self.W_TABLE_3)

				szMissionsTable = self.getNextWidgetName()
				szHelpText = localText.getText("TXT_KEY_ESPIONAGE_MISSIONS_SPY", ())
				screen.addTableControlGFCWithHelp(szMissionsTable, 4, self.X_MISSIONS_LIST, self.Y_MISSIONS_LIST, self.W_MISSIONS_LIST + self.W_MISSIONS_COSTS_LIST + self.W_TABLE_1 + self.W_TABLE_3, self.H_MISSIONS_LIST, False, False, 32,32, TableStyles.TABLE_STYLE_STANDARD, szHelpText)
				screen.setTableColumnHeader(szMissionsTable, 0, "", self.W_TABLE_0)
				screen.setTableColumnHeader(szMissionsTable, 1, "", self.W_TABLE_1)
				screen.setTableColumnHeader(szMissionsTable, 2, "", self.W_TABLE_2)
				screen.setTableColumnHeader(szMissionsTable, 3, "", self.W_TABLE_3)


				# Loop through all Missions
				for iMissionLoop in range(gc.getNumEspionageMissionInfos()):

					pMission = gc.getEspionageMissionInfo(iMissionLoop)

					if (pMission.getCost() != -1):

						# Only passive effects
						if (pMission.isPassive()):

							pPlot = None

							if (self.iActiveCityID != -1 and pMission.isTargetsCity()):

								pActiveCity = gc.getPlayer(self.iTargetPlayer).getCity(self.iActiveCityID)
								pPlot = pActiveCity.plot()


							if (self.iActiveCityID != -1 or not pMission.isTargetsCity()):

								iCost = pActivePlayer.getEspionageMissionCost(iMissionLoop, self.iTargetPlayer, pPlot, -1)

								szTechText = ""
								if (pMission.getTechPrereq() != -1):
									szTechText = " (%s)" %(gc.getTechInfo(pMission.getTechPrereq()).getDescription())

								szText = pMission.getDescription() + szTechText

								if (pMission.getTechPrereq() != -1):
									pTeam = gc.getTeam(pActivePlayer.getTeam())
									if (not pTeam.isHasTech(pMission.getTechPrereq())):
										szText = u"<color=255,0,0,0>%s</color>" %(szText)

								iRow = screen.appendTableRow(szEffectsTable)
								screen.setTableText(szEffectsTable, 0, iRow, szText, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
								screen.setTableText(szEffectsTable, 2, iRow, str(iCost), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_RIGHT_JUSTIFY)

						# Active Mission
						else:

							if (self.iSelectedMission == -1):
								self.iSelectedMission = iMissionLoop

							pPlot = -1
							if (self.iActiveCityID != -1):
								pPlot = pActiveCity.plot()
							else:
								pPlot = None

							iCost = pActivePlayer.getEspionageMissionCost(iMissionLoop, self.iTargetPlayer, pPlot, -1)

							szTechText = ""
							if (pMission.getTechPrereq() != -1):
								szTechText = " (%s)" %(gc.getTechInfo(pMission.getTechPrereq()).getDescription())

							szText = pMission.getDescription() + szTechText

							if (pMission.getTechPrereq() != -1):
								pTeam = gc.getTeam(pActivePlayer.getTeam())
								if (not pTeam.isHasTech(pMission.getTechPrereq())):
									szText = u"<color=255,0,0,0>%s</color>" %(szText)

							iRow = screen.appendTableRow(szMissionsTable)
							screen.setTableText(szMissionsTable, 0, iRow, szText, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
							if iCost > 0:
								screen.setTableText(szMissionsTable, 2, iRow, str(iCost), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_RIGHT_JUSTIFY)

		return 0
コード例 #9
0
    def refreshScreen(self):

        self.deleteAllWidgets()

        if (self.iTargetPlayer != -1):

            # Create a new screen, called EspionageAdvisor, using the file EspionageAdvisor.py for input
            screen = self.getScreen()

            pActivePlayer = gc.getPlayer(self.iActivePlayer)
            pActiveTeam = gc.getTeam(pActivePlayer.getTeam())

            iPlayerLoop = 0

            for iPlayerID in self.aiKnownPlayers:

                iX = 0
                iY = 15  #+ (148 * iPlayerLoop)#(110 * iPlayerLoop)

                pTargetPlayer = gc.getPlayer(iPlayerID)
                iTargetTeam = pTargetPlayer.getTeam()

                attach = "LeaderContainer%d" % (iPlayerID)

                szName = "SpendingText%d" % (iPlayerID)
                self.aszSpendingTexts.append(szName)
                szText = u"<font=2>" + localText.getText(
                    "TXT_KEY_ESPIONAGE_SCREEN_SPENDING_WEIGHT",
                    ()) + ": %d</font>" % (
                        pActivePlayer.getEspionageSpendingWeightAgainstTeam(
                            iTargetTeam))
                screen.deleteWidget(szName)
                screen.setLabelAt(szName, attach, szText, 0, 85, iY,
                                  self.Z_CONTROLS, FontTypes.TITLE_FONT,
                                  WidgetTypes.WIDGET_GENERAL, -1, -1)

                szName = "AmountText%d" % (iPlayerID)

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

                screen.deleteWidget(szName)
                screen.setLabelAt(szName, attach, szText, 0, 247, iY - 1,
                                  self.Z_CONTROLS, FontTypes.TITLE_FONT,
                                  WidgetTypes.WIDGET_GENERAL, -1, -1)

                szName = "SpendingIcon%d" % (iPlayerID)
                if (pActivePlayer.getEspionageSpendingWeightAgainstTeam(
                        iTargetTeam) > 0):
                    szText = u"<font=2>%c</font>" % (gc.getCommerceInfo(
                        CommerceTypes.COMMERCE_ESPIONAGE).getChar())
                else:
                    szText = u""

                screen.deleteWidget(szName)
                screen.setLabelAt(szName, attach, szText, 0, 3, iY - 9,
                                  self.Z_CONTROLS, FontTypes.TITLE_FONT,
                                  WidgetTypes.WIDGET_GENERAL, -1, -1)

                iPlayerLoop += 1

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

                pTargetPlayer = gc.getPlayer(self.iTargetPlayer)
                pyTargetPlayer = PyPlayer(self.iTargetPlayer)

                # List of Cities
                self.szCityListBox = self.getNextWidgetName()
                screen.addListBoxGFC(self.szCityListBox, "", self.X_CITY_LIST,
                                     self.Y_CITY_LIST, self.W_CITY_LIST,
                                     self.H_CITY_LIST,
                                     TableStyles.TABLE_STYLE_STANDARD)
                screen.enableSelect(self.szCityListBox, True)
                screen.setStyle(self.szCityListBox, "Table_StandardCiv_Style")

                # Loop through target's cities, see which are visible and add them to the list
                apCityList = pyTargetPlayer.getCityList()

                iLoop = 0

                for pyCity in apCityList:

                    pCity = pyCity.GetCy()

                    if (pCity.isRevealed(pActivePlayer.getTeam(), false)):
                        screen.appendListBoxString(self.szCityListBox,
                                                   pCity.getName(),
                                                   WidgetTypes.WIDGET_GENERAL,
                                                   pCity.getID(), 0,
                                                   CvUtil.FONT_LEFT_JUSTIFY)

                        if (self.iActiveCityID == -1 or pTargetPlayer.getCity(
                                self.iActiveCityID).isNone()):
                            self.iActiveCityID = pCity.getID()

                        if (self.iActiveCityID == pCity.getID()):
                            screen.setSelectedListBoxStringGFC(
                                self.szCityListBox, iLoop)

                        iLoop += 1

                #screen.updateListBox(self.szCityListBox)

                self.W_TABLE_0 = self.W_EFFECTS_LIST
                self.W_TABLE_1 = 0
                self.W_TABLE_2 = self.W_EFFECTS_COSTS_LIST
                self.W_TABLE_3 = 20

                szEffectsTable = self.getNextWidgetName()
                szHelpText = localText.getText(
                    "TXT_KEY_ESPIONAGE_PASSIVE_AUTOMATIC", ())
                screen.addTableControlGFCWithHelp(
                    szEffectsTable, 4, self.X_EFFECTS_LIST,
                    self.Y_EFFECTS_LIST,
                    self.W_EFFECTS_LIST + self.W_EFFECTS_COSTS_LIST +
                    self.W_TABLE_1 + self.W_TABLE_3, self.H_EFFECTS_LIST,
                    False, False, 32, 32, TableStyles.TABLE_STYLE_STANDARD,
                    szHelpText)
                screen.setTableColumnHeader(szEffectsTable, 0, "",
                                            self.W_TABLE_0)
                screen.setTableColumnHeader(szEffectsTable, 1, "",
                                            self.W_TABLE_1)
                screen.setTableColumnHeader(szEffectsTable, 2, "",
                                            self.W_TABLE_2)
                screen.setTableColumnHeader(szEffectsTable, 3, "",
                                            self.W_TABLE_3)

                szMissionsTable = self.getNextWidgetName()
                szHelpText = localText.getText(
                    "TXT_KEY_ESPIONAGE_MISSIONS_SPY", ())
                screen.addTableControlGFCWithHelp(
                    szMissionsTable, 4, self.X_MISSIONS_LIST,
                    self.Y_MISSIONS_LIST,
                    self.W_MISSIONS_LIST + self.W_MISSIONS_COSTS_LIST +
                    self.W_TABLE_1 + self.W_TABLE_3, self.H_MISSIONS_LIST,
                    False, False, 32, 32, TableStyles.TABLE_STYLE_STANDARD,
                    szHelpText)
                screen.setTableColumnHeader(szMissionsTable, 0, "",
                                            self.W_TABLE_0)
                screen.setTableColumnHeader(szMissionsTable, 1, "",
                                            self.W_TABLE_1)
                screen.setTableColumnHeader(szMissionsTable, 2, "",
                                            self.W_TABLE_2)
                screen.setTableColumnHeader(szMissionsTable, 3, "",
                                            self.W_TABLE_3)

                # Loop through all Missions
                for iMissionLoop in range(gc.getNumEspionageMissionInfos()):

                    pMission = gc.getEspionageMissionInfo(iMissionLoop)

                    if (pMission.getCost() != -1):

                        # Only passive effects
                        if (pMission.isPassive()):

                            pPlot = None

                            if (self.iActiveCityID != -1
                                    and pMission.isTargetsCity()):

                                pActiveCity = gc.getPlayer(
                                    self.iTargetPlayer).getCity(
                                        self.iActiveCityID)
                                pPlot = pActiveCity.plot()

                            if (self.iActiveCityID != -1
                                    or not pMission.isTargetsCity()):

                                iCost = pActivePlayer.getEspionageMissionCost(
                                    iMissionLoop, self.iTargetPlayer, pPlot,
                                    -1)

                                szTechText = ""
                                if (pMission.getTechPrereq() != -1):
                                    szTechText = " (%s)" % (gc.getTechInfo(
                                        pMission.getTechPrereq()).
                                                            getDescription())

                                szText = pMission.getDescription() + szTechText

                                if (pMission.getTechPrereq() != -1):
                                    pTeam = gc.getTeam(pActivePlayer.getTeam())
                                    if (not pTeam.isHasTech(
                                            pMission.getTechPrereq())):
                                        szText = u"<color=255,0,0,0>%s</color>" % (
                                            szText)

                                iRow = screen.appendTableRow(szEffectsTable)
                                screen.setTableText(szEffectsTable, 0, iRow,
                                                    szText, "",
                                                    WidgetTypes.WIDGET_GENERAL,
                                                    -1, -1,
                                                    CvUtil.FONT_LEFT_JUSTIFY)
                                screen.setTableText(szEffectsTable, 2, iRow,
                                                    str(iCost), "",
                                                    WidgetTypes.WIDGET_GENERAL,
                                                    -1, -1,
                                                    CvUtil.FONT_RIGHT_JUSTIFY)

                        # Active Mission
                        else:

                            if (self.iSelectedMission == -1):
                                self.iSelectedMission = iMissionLoop

                            pPlot = -1
                            if (self.iActiveCityID != -1):
                                pPlot = pActiveCity.plot()
                            else:
                                pPlot = None

                            iCost = pActivePlayer.getEspionageMissionCost(
                                iMissionLoop, self.iTargetPlayer, pPlot, -1)

                            szTechText = ""
                            if (pMission.getTechPrereq() != -1):
                                szTechText = " (%s)" % (gc.getTechInfo(
                                    pMission.getTechPrereq()).getDescription())

                            szText = pMission.getDescription() + szTechText

                            if (pMission.getTechPrereq() != -1):
                                pTeam = gc.getTeam(pActivePlayer.getTeam())
                                if (not pTeam.isHasTech(
                                        pMission.getTechPrereq())):
                                    szText = u"<color=255,0,0,0>%s</color>" % (
                                        szText)

                            iRow = screen.appendTableRow(szMissionsTable)
                            screen.setTableText(szMissionsTable, 0, iRow,
                                                szText, "",
                                                WidgetTypes.WIDGET_GENERAL, -1,
                                                -1, CvUtil.FONT_LEFT_JUSTIFY)
                            if iCost > 0:
                                screen.setTableText(szMissionsTable, 2, iRow,
                                                    str(iCost), "",
                                                    WidgetTypes.WIDGET_GENERAL,
                                                    -1, -1,
                                                    CvUtil.FONT_RIGHT_JUSTIFY)

        return 0
コード例 #10
0
	def refreshMissionTab(self):
		if (self.iTargetPlayer != -1):
			# Create a new screen, called EspionageAdvisor, using the file EspionageAdvisor.py for input
			screen = self.getScreen()

			pActivePlayer = gc.getPlayer(self.iActivePlayer)
			pActiveTeam = gc.getTeam(pActivePlayer.getTeam())

			for iPlayerID in self.aiKnownPlayers:
				self.refreshMissionTab_LeftLeaderPanel(screen, pActivePlayer, iPlayerID)

			# Is there any other players which have been met?
			if (self.iTargetPlayer != -1):
				pTargetPlayer = gc.getPlayer(self.iTargetPlayer)
				pyTargetPlayer = PyPlayer(self.iTargetPlayer)

				# List of Cities
				screen.addListBoxGFC(self.CityListBoxWidget, "", self.X_CITY_LIST, self.Y_CITY_LIST, self.W_CITY_LIST, self.H_CITY_LIST, TableStyles.TABLE_STYLE_STANDARD)
				screen.enableSelect(self.CityListBoxWidget, True)
				screen.setStyle(self.CityListBoxWidget, "Table_StandardCiv_Style")

				if self.CityMissionToggle == CITYMISSION_CITY:
					# Loop through target's cities, see which are visible and add them to the list
					apCityList = pyTargetPlayer.getCityList()

					iLoop = 0
					for pyCity in apCityList:
						pCity = pyCity.GetCy()
						szCityName = self.getCityNameText(pCity, self.iActivePlayer, self.iTargetPlayer)

						if ((EspionageOpt.isEnabled()
							and pCity.isRevealed(pActivePlayer.getTeam(), false))
						or (not EspionageOpt.isEnabled()
							and pCity.isRevealed(pActivePlayer.getTeam(), false))):
							screen.appendListBoxString(self.CityListBoxWidget, szCityName, WidgetTypes.WIDGET_GENERAL, pCity.getID(), 0, CvUtil.FONT_LEFT_JUSTIFY )

							if (self.iActiveCityID == -1 or pTargetPlayer.getCity(self.iActiveCityID).isNone()):
								self.iActiveCityID = pCity.getID()

							if (self.iActiveCityID == pCity.getID()):
								screen.setSelectedListBoxStringGFC(self.CityListBoxWidget, iLoop)

							iLoop += 1

				elif self.CityMissionToggle == CITYMISSION_MISSION:
					# active missions only
					iLoop = 0
					for iMissionLoop in range(gc.getNumEspionageMissionInfos()):
						pMission = gc.getEspionageMissionInfo(iMissionLoop)
						if (pMission.getCost() != -1):
							if pMission.isTargetsCity():
								screen.appendListBoxString(self.CityListBoxWidget, pMission.getDescription(), WidgetTypes.WIDGET_GENERAL, iMissionLoop, 0, CvUtil.FONT_LEFT_JUSTIFY )

								if (self.iActiveMissionID == -1):
									self.iActiveMissionID = iMissionLoop

								if (self.iActiveMissionID == iMissionLoop):
									screen.setSelectedListBoxStringGFC(self.CityListBoxWidget, iLoop)

								iLoop += 1

				self.W_TABLE_0 = self.W_EFFECTS_LIST
				self.W_TABLE_1 = 0
				self.W_TABLE_2 = self.W_EFFECTS_COSTS_LIST
				self.W_TABLE_3 = 20

				szHelpText = localText.getText("TXT_KEY_ESPIONAGE_PASSIVE_AUTOMATIC", ())
				screen.addTableControlGFCWithHelp(self.EffectsTableWidget, 4, self.X_EFFECTS_LIST, self.Y_EFFECTS_LIST, self.W_EFFECTS_LIST + self.W_EFFECTS_COSTS_LIST + self.W_TABLE_1 + self.W_TABLE_3, self.H_EFFECTS_LIST, False, False, 32,32, TableStyles.TABLE_STYLE_STANDARD, szHelpText)
				screen.setTableColumnHeader(self.EffectsTableWidget, 0, "", self.W_TABLE_0)
				screen.setTableColumnHeader(self.EffectsTableWidget, 1, "", self.W_TABLE_1)
				screen.setTableColumnHeader(self.EffectsTableWidget, 2, "", self.W_TABLE_2)
				screen.setTableColumnHeader(self.EffectsTableWidget, 3, "", self.W_TABLE_3)

				if self.CityMissionToggle == CITYMISSION_CITY:
					szHelpText = localText.getText("TXT_KEY_ESPIONAGE_MISSIONS_SPY", ())
				else:
					szHelpText = ""
				screen.addTableControlGFCWithHelp(self.MissionsTableWidget, 4, self.X_MISSIONS_LIST, self.Y_MISSIONS_LIST, self.W_MISSIONS_LIST + self.W_MISSIONS_COSTS_LIST + self.W_TABLE_1 + self.W_TABLE_3, self.H_MISSIONS_LIST, False, False, 32,32, TableStyles.TABLE_STYLE_STANDARD, szHelpText)
				screen.setTableColumnHeader(self.MissionsTableWidget, 0, "", self.W_TABLE_0)
				screen.setTableColumnHeader(self.MissionsTableWidget, 1, "", self.W_TABLE_1)
				screen.setTableColumnHeader(self.MissionsTableWidget, 2, "", self.W_TABLE_2)
				screen.setTableColumnHeader(self.MissionsTableWidget, 3, "", self.W_TABLE_3)

				# Loop through passive Missions
				for iMissionLoop in range(gc.getNumEspionageMissionInfos()):
					pMission = gc.getEspionageMissionInfo(iMissionLoop)
					if (pMission.getCost() != -1):
						if (pMission.isPassive()):
							if (self.CityMissionToggle == CITYMISSION_CITY
							or (self.CityMissionToggle == CITYMISSION_MISSION
							and not pMission.isTargetsCity())):
								szTable = self.EffectsTableWidget
								szText, szCost = self.getTableTextCost(self.iActivePlayer, self.iTargetPlayer, iMissionLoop, self.iActiveCityID)
								iRow = screen.appendTableRow(szTable)
								screen.setTableText(szTable, 0, iRow, szText, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
								screen.setTableText(szTable, 2, iRow, szCost, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_RIGHT_JUSTIFY)

				if self.CityMissionToggle == CITYMISSION_CITY:
					# Loop through active Missions
					# Primary list is cities, secondary list is missions
					for iMissionLoop in range(gc.getNumEspionageMissionInfos()):
						pMission = gc.getEspionageMissionInfo(iMissionLoop)
						if (pMission.getCost() != -1):
							if (not pMission.isPassive()):
								szTable = self.MissionsTableWidget
								szText, szCost = self.getTableTextCost(self.iActivePlayer, self.iTargetPlayer, iMissionLoop, self.iActiveCityID)
								iRow = screen.appendTableRow(szTable)
								screen.setTableText(szTable, 0, iRow, szText, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
								screen.setTableText(szTable, 2, iRow, szCost, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_RIGHT_JUSTIFY)

				elif self.CityMissionToggle == CITYMISSION_MISSION:
					# Loop through target's cities, see which are visible and add them to the list
					# Primary list is missions, secondary list is cities
					apCityList = pyTargetPlayer.getCityList()

					for pyCity in apCityList:
						pCity = pyCity.GetCy()
						if (pCity.isRevealed(pActivePlayer.getTeam(), false)):

							szTable = self.MissionsTableWidget
							szText, szCost = self.getTableTextCost(self.iActivePlayer, self.iTargetPlayer, self.iActiveMissionID, pCity.getID())
							iRow = screen.appendTableRow(szTable)
							screen.setTableText(szTable, 0, iRow, szText, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
							if (pCity.isRevealed(pActivePlayer.getTeam(), false)):
								screen.setTableText(szTable, 2, iRow, szCost, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_RIGHT_JUSTIFY)

		return 0
コード例 #11
0
    def refreshScreen(self):

        self.deleteAllWidgets()

        if (self.iTargetPlayer != -1):

            # Create a new screen, called EspionageAdvisor, using the file EspionageAdvisor.py for input
            screen = self.getScreen()

            pActivePlayer = gc.getPlayer(self.iActivePlayer)
            pActiveTeam = gc.getTeam(pActivePlayer.getTeam())

            self.drawEspionageSlider()  # advc.120c

            iPlayerLoop = 0

            for iPlayerID in self.aiKnownPlayers:

                iX = 0
                iY = 15  #+ (148 * iPlayerLoop)#(110 * iPlayerLoop)

                pTargetPlayer = gc.getPlayer(iPlayerID)
                iTargetTeam = pTargetPlayer.getTeam()

                attach = "LeaderContainer%d" % (iPlayerID)

                szName = "SpendingText%d" % (iPlayerID)
                self.aszSpendingTexts.append(szName)
                szText = u"<font=2>" + localText.getText(
                    "TXT_KEY_ESPIONAGE_SCREEN_SPENDING_WEIGHT",
                    ()) + ": %d</font>" % (
                        pActivePlayer.getEspionageSpendingWeightAgainstTeam(
                            iTargetTeam))
                screen.deleteWidget(szName)
                screen.setLabelAt(szName, attach, szText, 0, 85, iY,
                                  self.Z_CONTROLS, FontTypes.TITLE_FONT,
                                  WidgetTypes.WIDGET_GENERAL, -1, -1)

                szName = "AmountText%d" % (iPlayerID)

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

                screen.deleteWidget(szName)
                screen.setLabelAt(szName, attach, szText, 0, 247, iY - 1,
                                  self.Z_CONTROLS, FontTypes.TITLE_FONT,
                                  WidgetTypes.WIDGET_GENERAL, -1, -1)

                szName = "SpendingIcon%d" % (iPlayerID)
                if (pActivePlayer.getEspionageSpendingWeightAgainstTeam(
                        iTargetTeam) > 0):
                    szText = u"<font=2>%c</font>" % (gc.getCommerceInfo(
                        CommerceTypes.COMMERCE_ESPIONAGE).getChar())
                else:
                    szText = u""

                screen.deleteWidget(szName)
                screen.setLabelAt(szName, attach, szText, 0, 3, iY - 9,
                                  self.Z_CONTROLS, FontTypes.TITLE_FONT,
                                  WidgetTypes.WIDGET_GENERAL, -1, -1)

                iPlayerLoop += 1

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

                pTargetPlayer = gc.getPlayer(self.iTargetPlayer)
                pyTargetPlayer = PyPlayer(self.iTargetPlayer)
                iTargetTeam = pTargetPlayer.getTeam()  # advc.120d
                # List of Cities
                self.szCityListBox = self.getNextWidgetName()
                screen.addListBoxGFC(self.szCityListBox, "", self.X_CITY_LIST,
                                     self.Y_CITY_LIST, self.W_CITY_LIST,
                                     self.H_CITY_LIST,
                                     TableStyles.TABLE_STYLE_STANDARD)
                screen.enableSelect(self.szCityListBox, True)
                screen.setStyle(self.szCityListBox, "Table_StandardCiv_Style")

                # Loop through target's cities, see which are visible and add them to the list
                apCityList = pyTargetPlayer.getCityList()

                iLoop = 0

                for pyCity in apCityList:

                    pCity = pyCity.GetCy()

                    if (pCity.isRevealed(pActivePlayer.getTeam(), false)):
                        screen.appendListBoxString(self.szCityListBox,
                                                   pCity.getName(),
                                                   WidgetTypes.WIDGET_GENERAL,
                                                   pCity.getID(), 0,
                                                   CvUtil.FONT_LEFT_JUSTIFY)

                        if (self.iActiveCityID == -1 or pTargetPlayer.getCity(
                                self.iActiveCityID).isNone()):
                            self.iActiveCityID = pCity.getID()

                        if (self.iActiveCityID == pCity.getID()):
                            screen.setSelectedListBoxStringGFC(
                                self.szCityListBox, iLoop)

                        iLoop += 1

                #screen.updateListBox(self.szCityListBox)

                self.W_TABLE_0 = self.W_EFFECTS_LIST
                self.W_TABLE_1 = 0
                self.W_TABLE_2 = self.W_EFFECTS_COSTS_LIST
                self.W_TABLE_3 = 20

                szEffectsTable = self.getNextWidgetName()
                szHelpText = localText.getText(
                    "TXT_KEY_ESPIONAGE_PASSIVE_AUTOMATIC", ())
                screen.addTableControlGFCWithHelp(
                    szEffectsTable, 4, self.X_EFFECTS_LIST,
                    self.Y_EFFECTS_LIST,
                    self.W_EFFECTS_LIST + self.W_EFFECTS_COSTS_LIST +
                    self.W_TABLE_1 + self.W_TABLE_3, self.H_EFFECTS_LIST,
                    False, False, 32, 32, TableStyles.TABLE_STYLE_STANDARD,
                    szHelpText)
                screen.setTableColumnHeader(szEffectsTable, 0, "",
                                            self.W_TABLE_0)
                screen.setTableColumnHeader(szEffectsTable, 1, "",
                                            self.W_TABLE_1)
                screen.setTableColumnHeader(szEffectsTable, 2, "",
                                            self.W_TABLE_2)
                screen.setTableColumnHeader(szEffectsTable, 3, "",
                                            self.W_TABLE_3)

                szMissionsTable = self.getNextWidgetName()
                szHelpText = localText.getText(
                    "TXT_KEY_ESPIONAGE_MISSIONS_SPY", ())
                # <advc.120d>
                if not pActivePlayer.canSpy():
                    szHelpText = localText.getText("TXT_KEY_ESPIONAGE_NO_SPY",
                                                   ())  # </advc.120d>
                screen.addTableControlGFCWithHelp(
                    szMissionsTable, 4, self.X_MISSIONS_LIST,
                    self.Y_MISSIONS_LIST,
                    self.W_MISSIONS_LIST + self.W_MISSIONS_COSTS_LIST +
                    self.W_TABLE_1 + self.W_TABLE_3, self.H_MISSIONS_LIST,
                    False, False, 32, 32, TableStyles.TABLE_STYLE_STANDARD,
                    szHelpText)
                screen.setTableColumnHeader(szMissionsTable, 0, "",
                                            self.W_TABLE_0)
                screen.setTableColumnHeader(szMissionsTable, 1, "",
                                            self.W_TABLE_1)
                screen.setTableColumnHeader(szMissionsTable, 2, "",
                                            self.W_TABLE_2)
                screen.setTableColumnHeader(szMissionsTable, 3, "",
                                            self.W_TABLE_3)

                # Loop through all Missions
                for iPass in range(3):  # advc.120d
                    for iMissionLoop in range(
                            gc.getNumEspionageMissionInfos()):

                        pMission = gc.getEspionageMissionInfo(iMissionLoop)
                        if (pMission.getCost() == -1):
                            continue  # advc
                        # <advc.120d>
                        isSabotage = False
                        if pMission.getDestroyProjectCostFactor(
                        ) + pMission.getDestroyBuildingCostFactor(
                        ) + pMission.getDestroyProductionCostFactor(
                        ) > 0 or pMission.isDestroyImprovement():
                            isSabotage = True
                        isSteal = False
                        if pMission.getBuyTechCostFactor(
                        ) + pMission.getStealTreasuryTypes() > 0:
                            isSteal = True
                        if (iPass < 2) == isSabotage or (iPass > 0) == isSteal:
                            continue
                        # Moved up:
                        pActiveCity = gc.getPlayer(self.iTargetPlayer).getCity(
                            self.iActiveCityID)
                        # </advc.120d>
                        # Only passive effects
                        if (pMission.isPassive()):

                            pPlot = None

                            if (self.iActiveCityID != -1
                                    and pMission.isTargetsCity()):
                                pPlot = pActiveCity.plot()

                            if (self.iActiveCityID != -1
                                    or not pMission.isTargetsCity()):

                                iCost = pActivePlayer.getEspionageMissionCost(
                                    iMissionLoop, self.iTargetPlayer, pPlot,
                                    -1)

                                szTechText = ""
                                if (pMission.getTechPrereq() != -1):
                                    szTechText = " (%s)" % (gc.getTechInfo(
                                        pMission.getTechPrereq()).
                                                            getDescription())

                                szText = pMission.getDescription() + szTechText

                                if (pMission.getTechPrereq() != -1):
                                    pTeam = gc.getTeam(pActivePlayer.getTeam())
                                    if (not pTeam.isHasTech(
                                            pMission.getTechPrereq())):
                                        szText = u"<color=255,0,0,0>%s</color>" % (
                                            szText)
                                # <advc.120d>
                                costStr = str(iCost)
                                if pActivePlayer.canDoEspionageMission(
                                        iMissionLoop, self.iTargetPlayer,
                                        pPlot, 0):
                                    costStr = localText.changeTextColor(
                                        costStr,
                                        gc.getInfoTypeForString("COLOR_GREEN"))
                                # </advc.120d>
                                iRow = screen.appendTableRow(szEffectsTable)
                                screen.setTableText(szEffectsTable, 0, iRow,
                                                    szText, "",
                                                    WidgetTypes.WIDGET_GENERAL,
                                                    -1, -1,
                                                    CvUtil.FONT_LEFT_JUSTIFY)
                                screen.setTableText(szEffectsTable, 2, iRow,
                                                    costStr, "",
                                                    WidgetTypes.WIDGET_GENERAL,
                                                    -1, -1,
                                                    CvUtil.FONT_RIGHT_JUSTIFY)

                        # Active Mission
                        else:
                            # <advc.120d>
                            if not pActivePlayer.canSpy():
                                continue  # </advc.120d>
                            if (self.iSelectedMission == -1):
                                self.iSelectedMission = iMissionLoop

                            pPlot = -1
                            if (self.iActiveCityID != -1):
                                pPlot = pActiveCity.plot()
                            else:
                                pPlot = None

                            iCost = pActivePlayer.getEspionageMissionCost(
                                iMissionLoop, self.iTargetPlayer, pPlot, -1)

                            szTechText = ""
                            if (pMission.getTechPrereq() != -1):
                                szTechText = " (%s)" % (gc.getTechInfo(
                                    pMission.getTechPrereq()).getDescription())
                            # <advc.120d>
                            elif pMission.getBuyTechCostFactor(
                            ) > 0 and iCost > 0 and pActivePlayer.canSeeTech(
                                    self.iTargetPlayer):
                                stealTech = pActivePlayer.getStealCostTech(
                                    self.iTargetPlayer)
                                if stealTech >= 0:
                                    szTechText = " (%s)" % (gc.getTechInfo(
                                        stealTech).getDescription())
                            missingPrereq = False
                            # </advc.120d>
                            szText = pMission.getDescription() + szTechText

                            if (pMission.getTechPrereq() != -1):
                                pTeam = gc.getTeam(pActivePlayer.getTeam())
                                if (not pTeam.isHasTech(
                                        pMission.getTechPrereq())):
                                    szText = u"<color=255,0,0,0>%s</color>" % (
                                        szText)
                                    missingPrereq = True
                            # <advc.120d>
                            costStr = "(n/a)"
                            if iCost > 0:
                                costStr = str(iCost)
                                if pActiveTeam.getEspionagePointsAgainstTeam(
                                        iTargetTeam) >= iCost:
                                    costStr = localText.changeTextColor(
                                        costStr,
                                        gc.getInfoTypeForString("COLOR_GREEN"))
                            # Secret costs
                            if pMission.getBuyTechCostFactor(
                            ) > 0 and not pActivePlayer.canSeeTech(
                                    self.iTargetPlayer):
                                # This can't happen so long as Alphabet enables both Spies and tech trading
                                costStr = "?"
                            # Display the Destroy missions as a single item
                            elif isSabotage:
                                if pMission.getDestroyProductionCostFactor(
                                ) > 0:
                                    costStr = "?"
                                    szText = localText.getText(
                                        "TXT_KEY_ESPIONAGE_SABOTAGE", ())
                                elif pMission.getDestroyProjectCostFactor(
                                ) <= 0 or iCost <= 0:
                                    continue
                            if pMission.getStealTreasuryTypes(
                            ) > 0 and iCost > 0:
                                if not missingPrereq:
                                    iAmount = pActivePlayer.getEspionageGoldQuantity(
                                        iMissionLoop, self.iTargetPlayer,
                                        pActiveCity)
                                    if iAmount > 0:
                                        szText += " (%s)" % (localText.getText(
                                            "TXT_KEY_ESPIONAGE_STEAL_AMOUNT",
                                            (iAmount, )))
                                else:  # Don't give away AI gold if the player can't actually steal gold
                                    costStr = "?"
                            iRow = screen.appendTableRow(szMissionsTable)
                            screen.setTableText(szMissionsTable, 2, iRow,
                                                costStr, "",
                                                WidgetTypes.WIDGET_GENERAL, -1,
                                                -1, CvUtil.FONT_RIGHT_JUSTIFY)
                            # The line below: Moved down </advc.120d>
                            screen.setTableText(szMissionsTable, 0, iRow,
                                                szText, "",
                                                WidgetTypes.WIDGET_GENERAL, -1,
                                                -1, CvUtil.FONT_LEFT_JUSTIFY)
        return 0