def initCity(pCity): if revObjectExists(pCity): revObjectWipe(pCity) if revObjectInit(pCity, RevDefs.cityData): setCityVal(pCity, 'RevIdxHistory', RevDefs.initRevIdxHistory()) return True return False
def initCity(pCity): if (revObjectExists(pCity)): revObjectWipe(pCity) success = revObjectInit(pCity, RevDefs.cityData) if (success): setCityVal(pCity, 'RevIdxHistory', RevDefs.initRevIdxHistory()) return True else: return False
def initCity(pCity): if( revObjectExists(pCity) ) : revObjectWipe(pCity) success = revObjectInit( pCity, RevDefs.cityData ) if( success ) : setCityVal( pCity, 'RevIdxHistory', RevDefs.initRevIdxHistory() ) return True else : return False
def getCityVal(pCity, var): val = revObjectGetVal(pCity, var) if val is None and var not in RevDefs.cityData.keys(): initCity(pCity) print "Error! Var ", var, " is not a valid cityData variable" assert (False) if var == 'RevIdxHistory': if val == None: revIdxHist = RevDefs.initRevIdxHistory() setCityVal(pCity, 'RevIdxHistory', revIdxHist) return revIdxHist if len(val.keys()) < len(RevDefs.revIdxHistKeyList): for key in RevDefs.revIdxHistKeyList: if not val.has_key(key): print "Warning! RevIdxHistory missing key ", key, ", initializing it" val[key] = [0] return val
def getCityVal(pCity, var): val = revObjectGetVal( pCity, var ) if( val == None and var not in RevDefs.cityData.keys() ) : initCity( pCity ) print "Error! Var ", var, " is not a valid cityData variable" assert( False ) if( var == 'RevIdxHistory' ) : if( val == None ) : revIdxHist = RevDefs.initRevIdxHistory() setCityVal( pCity, 'RevIdxHistory', revIdxHist ) return revIdxHist else : if( len(val.keys()) < len(RevDefs.revIdxHistKeyList) ) : for key in RevDefs.revIdxHistKeyList : if( not val.has_key(key) ) : print "Warning! RevIdxHistory missing key ", key, ", initializing it" val[key] = [0] return val
def updateRevolutionIndices( argsList ) : owner,playerType,pCity,bConquest,bTrade = argsList newOwnerID = pCity.getOwner() newOwner = GC.getPlayer(newOwnerID) newOwnerCiv = newOwner.getCivilizationType() oldOwnerID = pCity.getPreviousOwner() orgOwnerID = pCity.getOriginalOwner() if( newOwner.isNPC() ) : return newRevIdx = 400 changeRevIdx = -40 if( bConquest ) : # Occupied cities also rack up rev points each turn newRevIdx += pCity.getRevolutionIndex()/4 newRevIdx = min( [newRevIdx, 600] ) if( pCity.plot().calculateCulturePercent( newOwnerID ) > 90 ) : changeRevIdx -= 75 newRevIdx -= 100 elif( pCity.plot().calculateCulturePercent( newOwnerID ) > 40 ) : changeRevIdx -= 35 newRevIdx -= 60 elif( pCity.plot().calculateCulturePercent( newOwnerID ) > 20 ) : changeRevIdx -= 30 elif( bTrade ) : newRevIdx += pCity.getRevolutionIndex()/3 newRevIdx = min( [newRevIdx, 650] ) if( pCity.plot().calculateCulturePercent( newOwnerID ) > 90 ) : newRevIdx -= 50 else : # Probably cultural conversion newRevIdx -= 100 if( pCity.plot().calculateCulturePercent( newOwnerID ) > 50 ) : changeRevIdx -= 25 if( newOwner.isRebel() and newOwnerCiv == RevData.getCityVal(pCity, 'RevolutionCiv') ) : changeRevIdx -= 50 newRevIdx -= 200 elif( newOwnerID == pCity.getOriginalOwner() ) : changeRevIdx -= 25 newRevIdx -= 100 if( pCity.getHighestPopulation() < 6 ) : changeRevIdx += 20 newRevIdx -= 50 changeRevIdx = int(math.floor( cityAcquiredModifier*changeRevIdx + .5 )) print " Revolt - Acquisition of %s by %s reduces rev indices by %d" %(pCity.getName(), newOwner.getCivilizationDescription(0), changeRevIdx) iCityID = pCity.getID() for pListCity in newOwner.cities(): if pListCity.getID() != iCityID: pListCity.changeRevolutionIndex(changeRevIdx) revIdxHist = RevData.getCityVal(pListCity,'RevIdxHistory') revIdxHist['Events'][0] += changeRevIdx RevData.updateCityVal(pListCity, 'RevIdxHistory', revIdxHist) print " Revolt - New rev idx for %s is %d" %(pCity.getName(), newRevIdx) pCity.setRevolutionIndex( newRevIdx ) pCity.setRevIndexAverage( newRevIdx ) pCity.setRevolutionCounter( acquiredTurns ) pCity.setReinforcementCounter( 0 ) RevData.updateCityVal( pCity, 'RevIdxHistory', RevDefs.initRevIdxHistory() ) if newOwner.isRebel(): if newOwner.getNumCities() > 1 and RevData.revObjectGetVal(newOwner, 'CapitalName') == CvUtil.convertToStr(pCity.getName()): # Rebel has captured their instigator city, make this their capital print "[REV] Rebel %s have captured their instigator city, %s! Moving capital." %(newOwner.getCivilizationDescription(0), pCity.getName()) if newOwner.isHuman(): # TODO: support this with a popup question pass else: eCapitalBuilding = GC.getInfoTypeForString(RevDefs.sXMLPalace) oldCapital = newOwner.getCapitalCity() oldCapital.setNumRealBuilding(eCapitalBuilding, 0) pCity.setNumRealBuilding(eCapitalBuilding, 1) # Ripple effects through other rebellious cities for cityX in GC.getPlayer(oldOwnerID).cities(): reinfCount = cityX.getReinforcementCounter() if reinfCount > 2 and RevData.getCityVal(cityX, 'RevolutionCiv') == newOwner.getCivilizationType(): if reinfCount < 5: reinfCount = 2 else: reinfCount -= 2 print "[REV] Accelerating reinforcement in " + cityX.getName() # Setting below two will turn off reinforcement if reinfCount < 2: reinfCount = 2 cityX.setReinforcementCounter(reinfCount)