phungus420
Deity
- Joined
- Mar 1, 2003
- Messages
- 6,296
As the title of the thread says, How do I write this? To give an example, I'll show the code I'm working on right now
I want to add in another elif (above the first) to look and see if the city has a harbor. Something like this:
Look as I may, I have been unable to find an example of this type of call, and would really apreciate the help. This is my first programming, outside of simple XML edits, so I think I'm doing good, considering this is only my second day of writing any real code, let alone python specific code, but I've hit a brick wall here, and need help.
Also does anyone know where I could find a list of the tech names, and building types python will be using. They don't follow the standard naming conventions used in XML (which brings up another point, how do I make a call for a tech or building I've added in the XML, which isn't in the core game?)
Code:
#CityDistModifier = distance to capitol with Communication Tech and building bonuses
cityDistModifier = plotDistance( pCity.getX(), pCity.getY(), capital.getX(), capital.getY())
cityDistModifier = min([cityDistModifier, 100]) - 3
if( not pCity.isConnectedTo(capital) ) :
cityDistModifier = 2*cityDistModifier
elif( gc.getTeam(pPlayer.getTeam()).isHasTech(self.iWheelTech) ) :
cityDistModifier = 0.9*cityDistModifier
else:
cityDistModifier = 1.2*cityDistModifier
I want to add in another elif (above the first) to look and see if the city has a harbor. Something like this:
Code:
#CityDistModifier = distance to capitol with Communication Tech and building bonuses
cityDistModifier = plotDistance( pCity.getX(), pCity.getY(), capital.getX(), capital.getY())
cityDistModifier = min([cityDistModifier, 100]) - 3
if( not pCity.isConnectedTo(capital) ) :
cityDistModifier = 2*cityDistModifier
[B] #elif( pCityHasbuildingclass(Harbor) ) :
#cityDistModifier = 0.8*cityDistModifier[/B]
elif( gc.getTeam(pPlayer.getTeam()).isHasTech(self.iWheelTech) ) :
cityDistModifier = 0.9*cityDistModifier
else:
cityDistModifier = 1.2*cityDistModifier
Also does anyone know where I could find a list of the tech names, and building types python will be using. They don't follow the standard naming conventions used in XML (which brings up another point, how do I make a call for a tech or building I've added in the XML, which isn't in the core game?)