100%Learning to read the API - and to fully understand it - is critical for any kind of effective Python modding.
methinks, what's needed most, would be descriptions in telegram style (in the existing API) ... but what was his name ... sysiphos?(I've actually contemplated writing a API tutorial.)





Now my project has come to its end: the last extensions (now including "random" unittypes, comparison of culture levels in the cities & ownership of surrounding plots) to the Rebel tutorial are completely tested & ready to play (all necessary included in the package below).
It may also be used as a quarry of helpful statements (in rebellion context) or sandbox for experiments in Python programming - as my first steps were also just learning about the making of and modifications to the great original Rebels.py! (My first nomads.py):
Spoiler :
Code:
from CvPythonExtensions import *
from PyHelpers import *
from Popup import PyPopup
gc = CyGlobalContext()
cyGame = CyGame()
cyMap = CyMap()
pyGame = PyGame()
pyBarbarian = PyPlayer(gc.getBARBARIAN_PLAYER())
def showPopup():
modPopup = PyPopup()
modPopup.setHeaderString("Tutorial")
modPopup.setBodyString("This is a Python tutorial.\n\nby Baldyr")
modPopup.launch()
def checkTurn():
for pyPlayer in pyGame.getCivPlayerList():
for pyCity in pyPlayer.getCityList():
cyCity = pyCity.GetCy()
if cyCity.isDisorder() and cyCity.getCulturePercentAnger() and not cyCity.isNeverLost():
if cyGame.getSorenRandNum(100, "rebels") < 5:
lPlots=[]
iCityX, iCityY = cyCity.getX(), cyCity.getY()
for iX in range(iCityX - 1, iCityX + 2):
for iY in range(iCityY - 1, iCityY + 2):
cyPlot = cyMap.plot(iX, iY)
if cyPlot.isWater() or cyPlot.isPeak() or cyPlot.isCity(): continue
lPlots.append(cyPlot)
iNumPlots = len(lPlots)
if iNumPlots:
iNumRebels = max(1, cyCity.getMilitaryHappinessUnits() / 4)
eUnitType = cyCity.getConscriptUnit()
while iNumRebels:
cyPlot = lPlots[cyGame.getSorenRandNum(iNumPlots, "spawn")]
pyBarbarian.initUnit(eUnitType, cyPlot.getX(), cyPlot.getY())
iNumRebels -= 1
Btw, concerning the MinorRevolt() class I want to add some thoughts:
Code:
self.iNumUnits = max(1, min(iUnhappyLevel - iAngryPopulation, iPopulation))
Code:
self.iNumUnits = max(1, min(iHappyLevel, iPopulation))
Code:
self.iNumUnits = min(iHappyLevel, iPopulation)