######## PEASANT_REBELLION ###########
#Peasant Rebellion by Headlock.
www.Civfanatics.com
def canTriggerPeasantRebellion(argsList):
kTriggeredData = argsList[0]
pPlayer = gc.getPlayer(kTriggeredData.ePlayer)
pTeam = gc.getTeam(pPlayer.getTeam())
# If Barbarians are disabled in this game, this event will not occur.
if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_NO_BARBARIANS):
return false
# Let's be fair -- civ can't currently be at war.
if pTeam.getAtWarCount(true) > 0:
return false
# At least one civ on the board must know TECH_LIBERALISM
bFoundValid = false
iTech = CvUtil.findInfoTypeNum(gc.getTechInfo, gc.getNumTechInfos(), 'TECH_LIBERALISM')
for iPlayer in range(gc.getMAX_CIV_PLAYERS()):
loopPlayer = gc.getPlayer(iPlayer)
if loopPlayer.isAlive():
if gc.getTeam(loopPlayer.getTeam()).isHasTech(iTech):
bFoundValid = true
break
if not bFoundValid:
return false
# Find an eligible plot
map = gc.getMap()
for i in range(map.numPlots()):
plot = map.plotByIndex(i)
if (plot.getOwner() == kTriggeredData.ePlayer and not plot.isWater() and not plot.isImpassable() and not plot.isCity() and plot.getNumUnits() > 0 and plot.area().getCitiesPerPlayer(kTriggeredData.ePlayer) > 0):
return true
return false
# and plot.area().getCitiesPerPlayer(kTriggeredData.ePlayer) > 0
def getHelpPeasantRebellion2(argsList):
iEvent = argsList[0]
kTriggeredData = argsList[1]
szHelp = localText.getText("TXT_KEY_EVENT_PEASANT_REBELLION_HELP_2", ())
return szHelp
# and plot.area().getCitiesPerPlayer(kTriggeredData.ePlayer) > 0
def applyPeasantRebellion2(argsList):
iEvent = argsList[0]
kTriggeredData = argsList[1]
pPlayer = gc.getPlayer(kTriggeredData.ePlayer)
listPlots = []
map = gc.getMap()
for i in range(map.numPlots()):
plot = map.plotByIndex(i)
if (plot.getOwner() == kTriggeredData.ePlayer and not plot.isWater() and not plot.isImpassable() and not plot.isCity() and plot.getNumUnits() > 0 and plot.area().getCitiesPerPlayer(kTriggeredData.ePlayer) > 0):
listPlots.append(i)
if 0 == len(listPlots):
return
plot = map.plotByIndex(listPlots[gc.getGame().getSorenRandNum(len(listPlots), "Peasant Rebellion event location")])
if map.getWorldSize() == CvUtil.findInfoTypeNum(gc.getWorldInfo, gc.getNumWorldInfos(), 'WORLDSIZE_DUEL'):
iNumUnits1 = 3
iNumUnits2 = 1
elif map.getWorldSize() == CvUtil.findInfoTypeNum(gc.getWorldInfo, gc.getNumWorldInfos(), 'WORLDSIZE_TINY'):
iNumUnits1 = 4
iNumUnits2 = 1
elif map.getWorldSize() == CvUtil.findInfoTypeNum(gc.getWorldInfo, gc.getNumWorldInfos(), 'WORLDSIZE_SMALL'):
iNumUnits1 = 5
iNumUnits2 = 2
elif map.getWorldSize() == CvUtil.findInfoTypeNum(gc.getWorldInfo, gc.getNumWorldInfos(), 'WORLDSIZE_STANDARD'):
iNumUnits1 = 6
iNumUnits2 = 2
elif map.getWorldSize() == CvUtil.findInfoTypeNum(gc.getWorldInfo, gc.getNumWorldInfos(), 'WORLDSIZE_LARGE'):
iNumUnits1 = 7
iNumUnits2 = 3
else:
iNumUnits1 = 5
iNumUnits2 = 2
iUnitType1 = CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_PIKEMAN')
iUnitType2 = CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_ARCHER')
barbPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER())
for i in range(iNumUnits1):
barbPlayer.initUnit(iUnitType1, plot.getX(), plot.getY(), UnitAITypes.UNITAI_ATTACK_CITY_LEMMING, DirectionTypes.DIRECTION_SOUTH)
for i in range(iNumUnits2):
barbPlayer.initUnit(iUnitType2, plot.getX(), plot.getY(), UnitAITypes.UNITAI_ATTACK_CITY_LEMMING, DirectionTypes.DIRECTION_SOUTH)