## Sid Meier's Civilization 4
## Copyright Firaxis Games 2005
## 
## CvAoDEventManager
## This class is passed an argsList from CvAppInterface.onEvent
## The argsList can contain anything from mouse location to key info
## The EVENTLIST that are being notified can be found 


from CvPythonExtensions import *
import CvUtil
import CvScreensInterface
import CvDebugTools
import CvWBPopups
import PyHelpers
import Popup as PyPopup
import CvCameraControls
import CvTopCivs
import CvEventManager
import CvIntroMovieScreen
import sys
	
gc = CyGlobalContext()
localText = CyTranslator()
PyPlayer = PyHelpers.PyPlayer
PyInfo = PyHelpers.PyInfo
DefaultUnitAI = UnitAITypes.NO_UNITAI

# The main bits
###################################################
class CvAoDEventManager(CvEventManager.CvEventManager):
	def __init__(self):
		# initialize base class
		self.parent = CvEventManager.CvEventManager
		self.parent.__init__(self)

	def onGameStart(self, argsList):
                # display mod's intro movie
                introMovie = CvIntroMovieScreen.CvIntroMovieScreen()
        	introMovie.interfaceScreen()
        	
		# display DoM message
		for iPlayer in range(gc.getMAX_PLAYERS()):
			player = gc.getPlayer(iPlayer)
			if (player.isAlive() and player.isHuman()):
				popupInfo = CyPopupInfo()
				popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
				popupInfo.setText(u"showDawnOfMan")
				popupInfo.addPopup(iPlayer)
		
	def onBeginGameTurn(self, argsList):
		iGameTurn = argsList[0]
		
		# Age of Discovery events
		self.turnChecker(iGameTurn)

# AoD Events
###################################################

	def turnChecker(self, iTurn):
		
                # Civ inits
                self.iEnglandID = 0
                self.iFranceID = 1
                self.iSpainID = 2
                self.iPortugalID = 5
                self.iHollandID = 7
                self.iScotlandID = 10
                self.iSaxonyID = 3
                self.iGenoaID = 4
                self.iArabID = 6
                self.iMayaID = 8
                self.iAztecID = 9
                self.iNativeID = 11
                self.iNumPlayers = 12

                # Tech inits
                iOptics = 56
                iGalleons = 80
                iSignalling = 100
                iSextant = 113

                # initialise unit IDs
                self.iCaravelID = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_CARAVEL')
                self.iPikemanID = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_PIKEMAN')
                self.iSettlerID = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_SETTLER')
                self.iTraderCaravelID = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_TRADER_CARAVEL')
                self.iTraderGalleonID = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_TRADER_GALLEON')
                self.iTraderIndiamanID = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_TRADER_INDIAMAN')
                self.iPirateCaravelID = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_PIRATE_CARAVEL')
                self.iPirateGalleonID = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_PIRATE_GALLEON')
                self.iPirateFrigateID = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_PIRATE_FRIGATE')

		# Setup players for use in this function
		pEngland = gc.getPlayer(self.iEnglandID)
		pFrance = gc.getPlayer(self.iFranceID)
		pSpain = gc.getPlayer(self.iSpainID)
		pPortugal = gc.getPlayer(self.iPortugalID)
		pHolland = gc.getPlayer(self.iHollandID)
		pScotland = gc.getPlayer(self.iScotlandID)
		pSaxony = gc.getPlayer(self.iSaxonyID)
		pGenoa = gc.getPlayer(self.iGenoaID)
		pArab = gc.getPlayer(self.iArabID)
		
		# Colonizer helper every 20 turns on average
                if iTurn > 1 and iTurn < 150:
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event Start')
                    if iRndNum < 5:			# 5% chance
                        if (not pEngland.isHuman() and pEngland.isAlive()):
                            pEngland.initUnit(self.iCaravelID, 92, 51, UnitAITypes.UNITAI_SETTLER_SEA)
                            pEngland.initUnit(self.iPikemanID, 92, 51, UnitAITypes.UNITAI_COUNTER)
                            pEngland.initUnit(self.iSettlerID, 92, 51, UnitAITypes.UNITAI_SETTLE)
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event Start')
                    if iRndNum < 5:			# 5% chance
                        if (not pFrance.isHuman() and pFrance.isAlive()):
                            pFrance.initUnit(self.iCaravelID, 88, 47, UnitAITypes.UNITAI_SETTLER_SEA)
                            pFrance.initUnit(self.iPikemanID, 88, 47, UnitAITypes.UNITAI_COUNTER)
                            pFrance.initUnit(self.iSettlerID, 88, 47, UnitAITypes.UNITAI_SETTLE)
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event Start')
                    if iRndNum < 5:			# 5% chance
                        if (not pSpain.isHuman() and pSpain.isAlive()):
                            pSpain.initUnit(self.iCaravelID, 77, 26, UnitAITypes.UNITAI_SETTLER_SEA)
                            pSpain.initUnit(self.iPikemanID, 77, 26, UnitAITypes.UNITAI_COUNTER)
                            pSpain.initUnit(self.iSettlerID, 77, 26, UnitAITypes.UNITAI_SETTLE)
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event Start')
                    if iRndNum < 5:			# 5% chance
                        if (not pPortugal.isHuman() and pPortugal.isAlive()):
                            pPortugal.initUnit(self.iCaravelID, 75, 31, UnitAITypes.UNITAI_SETTLER_SEA)
                            pPortugal.initUnit(self.iPikemanID, 75, 31, UnitAITypes.UNITAI_COUNTER)
                            pPortugal.initUnit(self.iSettlerID, 75, 31, UnitAITypes.UNITAI_SETTLE)
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event Start')
                    if iRndNum < 5:			# 5% chance
                        if (not pHolland.isHuman() and pHolland.isAlive()):
                            pHolland.initUnit(self.iCaravelID, 103, 54, UnitAITypes.UNITAI_SETTLER_SEA)
                            pHolland.initUnit(self.iPikemanID, 103, 54, UnitAITypes.UNITAI_COUNTER)
                            pHolland.initUnit(self.iSettlerID, 103, 54, UnitAITypes.UNITAI_SETTLE)

		# Pirate helper every 20 turns on average
                if iTurn > 15:
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event')
                    if iRndNum < 5:
                        if(not pEngland.isHuman() and pEngland.isAlive()):
                            pCity = pEngland.getCoastalAWCity()
                            if(pCity.isValid()):
                                if (gc.getTeam(pEngland.getTeam()).isHasTech(iSignalling)):
                                    pEngland.initUnit(self.iPirateFrigateID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                                elif (gc.getTeam(pEngland.getTeam()).isHasTech(iGalleons)):
                                    pEngland.initUnit(self.iPirateGalleonID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                                elif (gc.getTeam(pEngland.getTeam()).isHasTech(iOptics)):
                                    pEngland.initUnit(self.iPirateCaravelID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event')
                    if iRndNum < 5:
                        if(not pFrance.isHuman() and pFrance.isAlive()):
                            pCity = pFrance.getCoastalAWCity()
                            if(pCity.isValid()):
                                if (gc.getTeam(pFrance.getTeam()).isHasTech(iSignalling)):
                                    pFrance.initUnit(self.iPirateFrigateID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                                elif (gc.getTeam(pFrance.getTeam()).isHasTech(iGalleons)):
                                    pFrance.initUnit(self.iPirateGalleonID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                                elif (gc.getTeam(pFrance.getTeam()).isHasTech(iOptics)):
                                    pFrance.initUnit(self.iPirateCaravelID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event')
                    if iRndNum < 5:
                        if(not pSpain.isHuman() and pSpain.isAlive()):
                            pCity = pSpain.getCoastalAWCity()
                            if(pCity.isValid()):
                                if (gc.getTeam(pSpain.getTeam()).isHasTech(iSignalling)):
                                    pSpain.initUnit(self.iPirateFrigateID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                                elif (gc.getTeam(pSpain.getTeam()).isHasTech(iGalleons)):
                                    pSpain.initUnit(self.iPirateGalleonID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                                elif (gc.getTeam(pSpain.getTeam()).isHasTech(iOptics)):
                                    pSpain.initUnit(self.iPirateCaravelID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event')
                    if iRndNum < 5:
                        if(not pPortugal.isHuman() and pPortugal.isAlive()):
                            pCity = pPortugal.getCoastalAWCity()
                            if(pCity.isValid()):
                                if (gc.getTeam(pPortugal.getTeam()).isHasTech(iSignalling)):
                                    pPortugal.initUnit(self.iPirateFrigateID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                                elif (gc.getTeam(pPortugal.getTeam()).isHasTech(iGalleons)):
                                    pPortugal.initUnit(self.iPirateGalleonID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                                elif (gc.getTeam(pPortugal.getTeam()).isHasTech(iOptics)):
                                    pPortugal.initUnit(self.iPirateCaravelID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event')
                    if iRndNum < 5:
                        if(not pHolland.isHuman() and pHolland.isAlive()):
                            pCity = pHolland.getCoastalAWCity()
                            if(pCity.isValid()):
                                if (gc.getTeam(pHolland.getTeam()).isHasTech(iSignalling)):
                                    pHolland.initUnit(self.iPirateFrigateID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                                elif (gc.getTeam(pHolland.getTeam()).isHasTech(iGalleons)):
                                    pHolland.initUnit(self.iPirateGalleonID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                                elif (gc.getTeam(pHolland.getTeam()).isHasTech(iOptics)):
                                    pHolland.initUnit(self.iPirateCaravelID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event')
                    if iRndNum < 5:
                        if(not pScotland.isHuman() and pScotland.isAlive()):
                            pCity = pScotland.getCoastalAWCity()
                            if(pCity.isValid()):
                                if (gc.getTeam(pScotland.getTeam()).isHasTech(iSignalling)):
                                    pScotland.initUnit(self.iPirateFrigateID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                                elif (gc.getTeam(pScotland.getTeam()).isHasTech(iGalleons)):
                                    pScotland.initUnit(self.iPirateGalleonID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                                elif (gc.getTeam(pScotland.getTeam()).isHasTech(iOptics)):
                                    pScotland.initUnit(self.iPirateCaravelID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event')
                    if iRndNum < 5:
                        if(not pSaxony.isHuman() and pSaxony.isAlive()):
                            pCity = pSaxony.getCoastalAWCity()
                            if(pCity.isValid()):
                                if (gc.getTeam(pSaxony.getTeam()).isHasTech(iSignalling)):
                                    pSaxony.initUnit(self.iPirateFrigateID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                                elif (gc.getTeam(pSaxony.getTeam()).isHasTech(iGalleons)):
                                    pSaxony.initUnit(self.iPirateGalleonID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                                elif (gc.getTeam(pSaxony.getTeam()).isHasTech(iOptics)):
                                    pSaxony.initUnit(self.iPirateCaravelID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event')
                    if iRndNum < 5:
                        if(not pGenoa.isHuman() and pGenoa.isAlive()):
                            pCity = pGenoa.getCoastalAWCity()
                            if(pCity.isValid()):
                                if (gc.getTeam(pGenoa.getTeam()).isHasTech(iSignalling)):
                                    pGenoa.initUnit(self.iPirateFrigateID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                                elif (gc.getTeam(pGenoa.getTeam()).isHasTech(iGalleons)):
                                    pGenoa.initUnit(self.iPirateGalleonID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                                elif (gc.getTeam(pGenoa.getTeam()).isHasTech(iOptics)):
                                    pGenoa.initUnit(self.iPirateCaravelID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event')
                    if iRndNum < 5:
                        if(not pArab.isHuman() and pArab.isAlive()):
                            pCity = pArab.getCoastalAWCity()
                            if(pCity.isValid()):
                                if (gc.getTeam(pArab.getTeam()).isHasTech(iSignalling)):
                                    pArab.initUnit(self.iPirateFrigateID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                                elif (gc.getTeam(pArab.getTeam()).isHasTech(iGalleons)):
                                    pArab.initUnit(self.iPirateGalleonID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                                elif (gc.getTeam(pArab.getTeam()).isHasTech(iOptics)):
                                    pArab.initUnit(self.iPirateCaravelID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_EXPLORE_SEA)
                            
		# Trader generator every 5 turns on average
                if iTurn > 0:
                    pCity = pEngland.getCapitalCity()
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event')
                    if iRndNum < 20:
                        if(pEngland.isAlive()):
                            pTempCity = pEngland.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pEngland.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pEngland.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pEngland.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pEngland.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            if(pCity.getX() < 70):
                                if (gc.getTeam(pEngland.getTeam()).isHasTech(iSextant)):
                                    pEngland.initUnit(self.iTraderIndiamanID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                                elif (gc.getTeam(pEngland.getTeam()).isHasTech(iGalleons)):
                                    pEngland.initUnit(self.iTraderGalleonID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                                elif (gc.getTeam(pEngland.getTeam()).isHasTech(iOptics)):
                                    pEngland.initUnit(self.iTraderCaravelID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                    pCity = pFrance.getCapitalCity()
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event')
                    if iRndNum < 20:
                        if(pFrance.isAlive()):
                            pTempCity = pFrance.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pFrance.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pFrance.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pFrance.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pFrance.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            if(pCity.getX() < 70):
                                if (gc.getTeam(pFrance.getTeam()).isHasTech(iSextant)):
                                    pFrance.initUnit(self.iTraderIndiamanID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                                elif (gc.getTeam(pFrance.getTeam()).isHasTech(iGalleons)):
                                    pFrance.initUnit(self.iTraderGalleonID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                                elif (gc.getTeam(pFrance.getTeam()).isHasTech(iOptics)):
                                    pFrance.initUnit(self.iTraderCaravelID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                    pCity = pSpain.getCapitalCity()
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event')
                    if iRndNum < 20:
                        if(pSpain.isAlive()):
                            pTempCity = pSpain.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pSpain.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pSpain.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pSpain.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pSpain.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            if(pCity.getX() < 70):
                                if (gc.getTeam(pSpain.getTeam()).isHasTech(iSextant)):
                                    pSpain.initUnit(self.iTraderIndiamanID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                                elif (gc.getTeam(pSpain.getTeam()).isHasTech(iGalleons)):
                                    pSpain.initUnit(self.iTraderGalleonID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                                elif (gc.getTeam(pSpain.getTeam()).isHasTech(iOptics)):
                                    pSpain.initUnit(self.iTraderCaravelID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                    pCity = pPortugal.getCapitalCity()
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event')
                    if iRndNum < 20:
                        if(pPortugal.isAlive()):
                            pTempCity = pPortugal.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pPortugal.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pPortugal.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pPortugal.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pPortugal.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            if(pCity.getX() < 70):
                                if (gc.getTeam(pPortugal.getTeam()).isHasTech(iSextant)):
                                    pPortugal.initUnit(self.iTraderIndiamanID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                                elif (gc.getTeam(pPortugal.getTeam()).isHasTech(iGalleons)):
                                    pPortugal.initUnit(self.iTraderGalleonID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                                elif (gc.getTeam(pPortugal.getTeam()).isHasTech(iOptics)):
                                    pPortugal.initUnit(self.iTraderCaravelID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                    pCity = pHolland.getCapitalCity()
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event')
                    if iRndNum < 20:
                        if(pHolland.isAlive()):
                            pTempCity = pHolland.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pHolland.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pHolland.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pHolland.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pHolland.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            if(pCity.getX() < 70):
                                if (gc.getTeam(pHolland.getTeam()).isHasTech(iSextant)):
                                    pHolland.initUnit(self.iTraderIndiamanID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                                elif (gc.getTeam(pHolland.getTeam()).isHasTech(iGalleons)):
                                    pHolland.initUnit(self.iTraderGalleonID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                                elif (gc.getTeam(pHolland.getTeam()).isHasTech(iOptics)):
                                    pHolland.initUnit(self.iTraderCaravelID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                    pCity = pScotland.getCapitalCity()
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event')
                    if iRndNum < 20:
                        if(pScotland.isAlive()):
                            pTempCity = pScotland.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pScotland.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pScotland.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pScotland.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pScotland.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            if(pCity.getX() < 70):
                                if (gc.getTeam(pScotland.getTeam()).isHasTech(iSextant)):
                                    pScotland.initUnit(self.iTraderIndiamanID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                                elif (gc.getTeam(pScotland.getTeam()).isHasTech(iGalleons)):
                                    pScotland.initUnit(self.iTraderGalleonID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                                elif (gc.getTeam(pScotland.getTeam()).isHasTech(iOptics)):
                                    pScotland.initUnit(self.iTraderCaravelID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                    pCity = pSaxony.getCapitalCity()
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event')
                    if iRndNum < 20:
                        if(pSaxony.isAlive()):
                            pTempCity = pSaxony.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pSaxony.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pSaxony.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pSaxony.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pSaxony.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            if(pCity.getX() < 70):
                                if (gc.getTeam(pSaxony.getTeam()).isHasTech(iSextant)):
                                    pSaxony.initUnit(self.iTraderIndiamanID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                                elif (gc.getTeam(pSaxony.getTeam()).isHasTech(iGalleons)):
                                    pSaxony.initUnit(self.iTraderGalleonID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                                elif (gc.getTeam(pSaxony.getTeam()).isHasTech(iOptics)):
                                    pSaxony.initUnit(self.iTraderCaravelID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                    pCity = pGenoa.getCapitalCity()
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event')
                    if iRndNum < 20:
                        if(pGenoa.isAlive()):
                            pTempCity = pGenoa.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pGenoa.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pGenoa.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pGenoa.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pGenoa.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            if(pCity.getX() < 70):
                                if (gc.getTeam(pGenoa.getTeam()).isHasTech(iSextant)):
                                    pGenoa.initUnit(self.iTraderIndiamanID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                                elif (gc.getTeam(pGenoa.getTeam()).isHasTech(iGalleons)):
                                    pGenoa.initUnit(self.iTraderGalleonID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                                elif (gc.getTeam(pGenoa.getTeam()).isHasTech(iOptics)):
                                    pGenoa.initUnit(self.iTraderCaravelID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                    pCity = pArab.getCapitalCity()
                    iRndNum = gc.getGame().getSorenRandNum(100, 'AoD - Random Event')
                    if iRndNum < 20:
                        if(pArab.isAlive()):
                            pTempCity = pArab.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pArab.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pArab.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pArab.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            pTempCity = pArab.getCoastalNWCity()
                            if(pTempCity.getX() < 70):
                                pCity = pTempCity
                            if(pCity.getX() < 70):
                                if (gc.getTeam(pArab.getTeam()).isHasTech(iSextant)):
                                    pArab.initUnit(self.iTraderIndiamanID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                                elif (gc.getTeam(pArab.getTeam()).isHasTech(iGalleons)):
                                    pArab.initUnit(self.iTraderGalleonID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)
                                elif (gc.getTeam(pArab.getTeam()).isHasTech(iOptics)):
                                    pArab.initUnit(self.iTraderCaravelID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK_SEA)

		# Insert all game turn events here
#		print("Turn is: %d" %(iTurn))
#		if (iTurn == 4 + self.iTurnOffset):
#			self.Nov_1775()
#		elif (iTurn == 6 + self.iTurnOffset):
#			self.Jan_1776()

# AoD Utilities
###################################################
                
