Flintlock1415
Emperor
I was working on converting my Python to Beyond the Sword, and I decided I wanted to make the code run in modules rather than exist in the eventmanager file. Most of the functions seemed pretty straight forward, but there was one that puzzled me. I'm not too sure about how Python modules work with each other, so I don't exactly know what I can place where.
My main goal is to minimize the amount of code that goes into the event manager.
Here is the code from my old eventmanager:
What the code does is check to see that Normandy has declared war on the HRE, and pops a message as well as gives the HRE a knight in one of their cities. I just want to get as much of the code as possible into a separate module (as well as gain a better understanding as to how they work.)
Thanks!
My main goal is to minimize the amount of code that goes into the event manager.
Here is the code from my old eventmanager:
PHP:
def onChangeWar(self, argsList):
'War Status Changes'
bIsWar = argsList[0]
iTeam = argsList[1]
iRivalTeam = argsList[2]
if (bIsWar):
iCiv = gc.getPlayer(gc.getTeam(iTeam).getLeaderID()).getCivilizationType()
iRivalCiv = gc.getPlayer(gc.getTeam(iRivalTeam).getLeaderID()).getCivilizationType()
iNormandy = gc.getInfoTypeForString("CIVILIZATION_NORMANDY")
iHRE = gc.getInfoTypeForString("CIVILIZATION_HRE")
## Checks to make sure Normandy is attacking HRE
if iCiv == iNormandy and iRivalCiv == iHRE:
## Sends message to Normandy
CyInterface().addImmediateMessage("The Pope does not approve of your actions", "")
iPlayer = gc.getTeam(iRivalTeam).getLeaderID()
pPlayer = gc.getPlayer(iPlayer)
iHenry = gc.getInfoTypeForString("LEADER_HENRYIV")
iKnight = gc.getInfoTypeForString("UNIT_KNIGHT")
## Checks that HenryIV is the leader
if pPlayer.getLeaderType() == iHenry:
## Gives Henry a Knight in Liege
pPlayer.initUnit(iKnight, 79, 14, UnitAITypes.NO_UNITAI)
Thanks!
