What is the easiest way to find which city a specific wonder is in?

Just go to your Info screen and look for Top Cities/Wonders. It's the last icon on the bar that has all your advisor icons.
 
RogerBacon said:
What is the easiest way to find which city a specific wonder is in? Like, for example, I want to find the city that has the Colossus.

Roger Bacon

Roger,

I am assuming you are talking about how to find programmatically which city has a specific wonder right? The you need to use this snippet of code:
[PRE]
# wonderID = gc.getInfoTypeForString("BUILDING_HOLLYWOOD")
wonderID = gc.getInfoTypeForString("BUILDING_GREAT_LIGHTHOUSE")

city = self.findWonder(wonderID)
if(city):
CyInterface().addImmediateMessage(city.getName(),"")


# This assumes that the iBuildingType value you are sending in is for a unique building
# and not something like barracks. If that is the case then you will get the id of the first
# city with a barracks
def findWonder(self,iBuildingType):
'CyCity - city containing wonder"

# Get all of the players in the game
playerList = PyGame.getCivPlayerList()

for i in range(len(playerList)):

player = playerList

# Get the list of cities the player has
cityList = player.getCityList()
for j in range(len(cityList)):

city = cityList[j]

if(city.hasBuilding(iBuildingType)):
return city

return
[/PRE]

The old code did not work, I have updated and tested the code and it works now.
 
TheLopez said:
Roger,

I am assuming you are talking about how to find programmatically which city has a specific wonder right? The you need to use this snippet of code:
[PRE]
# This assumes that the iBuildingType value you are sending in is for a unique building
# and not something like barracks. If that is the case then you will get the id of the first
# city with a barracks
def findWonder(self,iBuildingType):
"iCityID - ID of city containing wonder, -1 if not built"

# Get all of the players in the game
playerList = PyGame.getCivPlayerList(self)

for i in range(len(playerList)):
player = playList

# Get the list of cities the player has
cityList = player.getCityList()

for j in range(len(cityList)):
city = cityList[j]

if(city.hasBuilding(iBuildingType)):
return city.getID()
return -1
[/PRE]


Very cool!
 
Thanks TheLopez, that's just what I was looking for. Now I've just got to remember WHY I needed that code. :confused: I've got so many mod ideas floating around in my head that I lose track of them all.

Roger Bacon
 
RogerBacon said:
Umm... I can't find any getCivPlayerList() or getCityList() function anywhere. Are you sure that code works for you?

Roger Bacon

Yep, it works for me. I'll attach the entire file if you want.
Just change the extension back to .py and add it to the python directory.

Add this:
import CvMBEventManager

normalEventManager = CvMBEventManager.CvMBEventManager()

to your CvEventInterface.py class in the EntryPoints directory. The CvMBEventManager class is set right now to find the first palace building, but you can change it to any buildings/wonders to get the city.
 

Attachments

Thanks TheLopez. It works now. I wasn't importing CvMainInterface.

The object returned in findWonder is a PyCity object. I need a CyCity object. Do you know any way to convert from a PyCity object to a CyCity object? I need the function getConscriptUnit() and CyCity has that but PyCity doesn't.

Roger Bacon
 
RogerBacon said:
Thanks TheLopez. It works now. I wasn't importing CvMainInterface.

The object returned in findWonder is a PyCity object. I need a CyCity object. Do you know any way to convert from a PyCity object to a CyCity object? I need the function getConscriptUnit() and CyCity has that but PyCity doesn't.

Roger Bacon

Sure, that's really easy. city.city.getConscriptUnit()
 
Back
Top Bottom