Requesting following features

Add this to your mod and use getDateForTurn() instead of getTurnMonthForGame().
Code:
class GameDate:

        index = [iStartYear * 12]

        def __init__(self):
                iStartYear = Game.getStartYear()
                eGameSpeed = Game.getGameSpeedType()
                pSpeedInfo = gc.getGameSpeedInfo(eGameSpeed)
                iGameMonth = iStartYear * 12
                iIncrement = 0
                while iIncrement < pSpeedInfo.getNumTurnIncrements():
                        pTurnInfo = pSpeedInfo.getGameTurnInfo(iIncrement)
                        iTurn = 0
                        while iTurn < pTurnInfo.iNumGameTurnsPerIncrement:
                                iGameMonth += pTurnInfo.iMonthIncrement
                                self.index.append(iGameMonth)
                                iTurn += 1
                        iIncrement += 1

def getDateForTurn(iTurn):
        return GameDate.index[iTurn]

GameDate()
This would pretty much automate the whole thing, and it should only add some second of lag at startup (since this is when the custom Python in your mod is loaded).
 
I created a SenateOutcome class for the rewards/punishments. It should approximate you already have in your mod:
Spoiler :
Code:
class SenateOutcome:

        def changeGold(self, iChange):
                """
                Grants iChange of Gold. A negative value will subtract Gold.
                """
                pass
        
        def grantUnit(self, eUnit):
                """
                Spawns one free unit in capital of eUnit type.
                """
                pass
        
        def grantGoldenAge(self, iNumTurns):
                """
                Starts a Golden Age for iNumTurns.
                """
                pass
        
        def changeHappiness(self, iChange):
                """
                Adds iChange number of happy faces in all cities. A negative value adds unhappy citizens.
                """
                pass

        def grantUpgrade(self):
                "?"
                pass

        def grantBuilding(self):
                "?"
                pass

        def grantCivic(self):
                "?"
                pass
        
        def grantTech(self):
                "?"
                pass

        def rebelUnit(self, eUnit):
                """
                Spawns rebel unit.
                """
                pass

        def destroyBuilding(self):
                "?"
                pass

        def anarchyTurns(self, iNumTurns):
                """
                Makes Civ go into Anarchy for iNumTurns.
                """
                pass
                
        def civilWar(self):
                """
                Causes Civ to go into Civil War.
                """
                pass

        tRewards = (
                ( changeGold, 100, 2 ),
                ( grantUnit, ePretorian, 1 ),
                ( grantGoldenAge, 6, 1 ),
                ( changeHappiness, 1, 3 ),
                ( grantUpgrade, None, 1 ),
                ( grantBuilding, None, 1 ),
                ( grantCivic, None, 1 ),
                ( grantTech, None, 1 )
                )

        tPenalties = (
                ( changeGold, -200, 3 ),
                ( rebelUnit, eSwordsman, 2),
                ( changeHappiness, -1, 4),
                ( destroyBuilding, None, 2),
                ( anarchyTurns, 1, 2),
                ( civilWar, None, 1)
                )

        lArrays = [tRewards, tPenalties]
        iRewards, iPenalties = range(2)
        arrayIndexSpanDict = dict()

        def __init__(self):
                self.setupWeighIndexes()

        def getWeightSpan(self, tData):
                iCount = 0
                for iWeigh in (tValues[2] for tValues in tData):
                        iCount += iWeigh
                return iCount

        def setupWeighIndexes(self):
                for tData in self.lArrays:
                        self.arrayIndexSpanDict[tData] = self.getWeightSpan(tData)

        def getArray(self, iArray):
                return self.lArrays[iArray]

        def senateOutcomeByIndex(self, iArray, iIndex):
                tData = self.getArray[iArray]
                self.fireFunction(tData[iIndex][0], tData[iIndex][1])

        def randSenateOutcome(self, iArray):
                tData = self.getArray[iArray]
                iArrayIndexSpan = self.arrayIndexSpanDict[tData]
                iRand = getRandNum(iArrayIndexSpan) + 1
                iCount = 0
                for tValues in tData:
                        function, iArgument, iWeigh = tValues
                        iCount += iWeigh
                        if iCount => iRand:
                                self.fireFunction(function, iArgument)
                                return

        def fireFunction(self, function, iArgument):
                if iArgument == None:
                        function()
                else:
                        function(iArgument)

outcome = SenateOutcome()
I realize this is somewhat... sophisticated. :p Basically, you have two values; SenateOutcome.iReward and SenateOutcome.iPenalties - you use these to call on either random outcomes or by index.

Calling a specific outcome by index value (here 2):
Code:
outcome.senateOutcomeByIndex(SenateOutcome.iReward, 2)
This will fire the grantUnit() method with the argument from the rewards list.

Calling a random outcome:
Code:
outcome.randomSenateOutcome(SenateOutcome.iPenalty)
If you wanna use this setup, then you can simply start adding to either the body of code or the description of each reward/penalty method. Those that you want me to do you obviously need to document in great detail, because I shouldn't be guessing what it is you need those to do.
 
great! I will document when I have time (possibly tonight!) and get started on some, and test isdate :p (again :lol:)
 
wait a minute where should the GameDate Class go?
 
Goodie. I just updated the submitted code.
 
wait a minute where should the GameDate Class go?
Where ever you can hook it up with isDate(). Probably in the same module. Just slap it at the bottom for now.
 
maybee it should go in eNums later :p makes sense :p
 
oh come on.. silly mistake from you...
Code:
class GameDate:

        index = [[B]iStartYear[/B] * 12]

        def __init__(self):
                [B]iStartYear[/B] = Game.getStartYear()
spot the mistake :p

changed to this:
Code:
class GameDate:
        index = [[B]Game.getStartYear() * 12[/B]]
        def __init__(self):
                eGameSpeed = Game.getGameSpeedType()
                pSpeedInfo = gc.getGameSpeedInfo(eGameSpeed)
                iIncrement = 0
                iGameMonth = [B]Game.getStartYear() * 12[/B]
                while iIncrement < pSpeedInfo.getNumTurnIncrements():
                        pTurnInfo = pSpeedInfo.getGameTurnInfo(iIncrement)
                        iTurn = 0
                        while iTurn < pTurnInfo.iNumGameTurnsPerIncrement:
                                iGameMonth += pTurnInfo.iMonthIncrement
                                self.index.append(iGameMonth)
                                iTurn += 1
                        iIncrement += 1
GameDate()
 
ok I have no idea what's happening...

Traceback (most recent call last):

File "CvScreensInterface", line 705, in forceScreenRedraw

File "CvMainInterface", line 729, in redraw

File "CvMainInterface", line 1755, in updateGameDataStrings

File "CvMainInterface", line 1804, in updateTimeText

RuntimeError: unidentifiable C++ exception
ERR: Python function forceScreenRedraw failed, module CvScreensInterface
Traceback (most recent call last):

File "CvScreensInterface", line 689, in forceScreenUpdate

File "CvMainInterface", line 680, in updateScreen

File "CvMainInterface", line 1804, in updateTimeText

RuntimeError: unidentifiable C++ exception
ERR: Python function forceScreenUpdate failed, module CvScreensInterface

appearing in the hundreds.... could it be the calendar?
Spoiler :

<GameSpeedInfo>
<Type>GAMESPEED_NORMAL</Type>
<Description>TXT_KEY_GAMESPEED_NORMAL</Description>
<Help>TXT_KEY_GAMESPEED_NORMAL_HELP</Help>
<iGrowthPercent>100</iGrowthPercent>
<iTrainPercent>100</iTrainPercent>
<iConstructPercent>100</iConstructPercent>
<iCreatePercent>100</iCreatePercent>
<iResearchPercent>100</iResearchPercent>
<iBuildPercent>100</iBuildPercent>
<iImprovementPercent>100</iImprovementPercent>
<iGreatPeoplePercent>100</iGreatPeoplePercent>
<iCulturePercent>100</iCulturePercent>
<iAnarchyPercent>100</iAnarchyPercent>
<iBarbPercent>100</iBarbPercent>
<iFeatureProductionPercent>100</iFeatureProductionPercent>
<iUnitDiscoverPercent>100</iUnitDiscoverPercent>
<iUnitHurryPercent>100</iUnitHurryPercent>
<iUnitTradePercent>100</iUnitTradePercent>
<iUnitGreatWorkPercent>100</iUnitGreatWorkPercent>
<iGoldenAgePercent>100</iGoldenAgePercent>
<iHurryPercent>100</iHurryPercent>
<iHurryConscriptAngerPercent>100</iHurryConscriptAngerPercent>
<iInflationPercent>30</iInflationPercent>
<iInflationOffset>-90</iInflationOffset>
<iVictoryDelayPercent>100</iVictoryDelayPercent>
<GameTurnInfos>
<GameTurnInfo>
<iMonthIncrement>84</iMonthIncrement>
<iTurnsPerIncrement>1</iTurnsPerIncrement>
</GameTurnInfo>
<GameTurnInfo>
<iMonthIncrement>72</iMonthIncrement>
<iTurnsPerIncrement>10</iTurnsPerIncrement>
</GameTurnInfo>
<GameTurnInfo>
<iMonthIncrement>24</iMonthIncrement>
<iTurnsPerIncrement>100</iTurnsPerIncrement> </GameTurnInfo>
<GameTurnInfo>
<iMonthIncrement>12</iMonthIncrement>
<iTurnsPerIncrement>1</iTurnsPerIncrement>
</GameTurnInfo>
<GameTurnInfo>
<iMonthIncrement>27</iMonthIncrement>
<iTurnsPerIncrement>208</iTurnsPerIncrement>
</GameTurnInfo>
<GameTurnInfo>
<iMonthIncrement>1</iMonthIncrement>
<iTurnsPerIncrement>180</iTurnsPerIncrement>
</GameTurnInfo>


you think I need to give the calendar a custom name and not use standard?
 
Not sure, but I seem to recall that each GameTurnInfo's total months, iMonthIncrement * iTurnsPerIncrement, needs to be evenly divisible by 12. Your first two are not.
 
Use this:
Code:
class GameDate:

        def __init__(self):
                eGameSpeed = Game.getGameSpeedType()
                iStartYear = Game.getStartYear()
                pSpeedInfo = gc.getGameSpeedInfo(eGameSpeed)
                iGameMonth = iStartYear * 12
                self.index = [iGameMonth]
                iIncrement = 0
                while iIncrement < pSpeedInfo.getNumTurnIncrements():
                        pTurnInfo = pSpeedInfo.getGameTurnInfo(iIncrement)
                        iTurn = 0
                        while iTurn < pTurnInfo.iNumGameTurnsPerIncrement:
                                iGameMonth += pTurnInfo.iMonthIncrement
                                self.index.append(iGameMonth)
                                iTurn += 1
                        iIncrement += 1

def getDateForTurn(iTurn):
        return GameDate.index[iTurn]

GameDate()
 
so then this would would work:
Code:
				<GameTurnInfo>
					<iMonthIncrement>84</iMonthIncrement>
					<iTurnsPerIncrement>1</iTurnsPerIncrement>
				</GameTurnInfo>
				<GameTurnInfo>
					<iMonthIncrement>72</iMonthIncrement>
					<iTurnsPerIncrement>10</iTurnsPerIncrement>
				</GameTurnInfo>
				<GameTurnInfo>
					<iMonthIncrement>24</iMonthIncrement>
					<iTurnsPerIncrement>100</iTurnsPerIncrement>				</GameTurnInfo>
				<GameTurnInfo>
					<iMonthIncrement>12</iMonthIncrement>
					<iTurnsPerIncrement>1</iTurnsPerIncrement>
				</GameTurnInfo>
				<GameTurnInfo>
					<iMonthIncrement>27</iMonthIncrement>
					<iTurnsPerIncrement>208</iTurnsPerIncrement>
				</GameTurnInfo>
				<GameTurnInfo>
					<iMonthIncrement>1</iMonthIncrement>
					<iTurnsPerIncrement>180</iTurnsPerIncrement>
				</GameTurnInfo>
 
All code I've submitted should always automatically adapt to any imaginable game speed/calendar settings. This is, in fact, the whole point. Because then you can edit, change and tweak things anyway you like, without having to re-calculate any pre-calculated values. The code is doing it on-the-fly for you.

If you only had one single month increments in your scenario, then it would be really easy.
 
yeah but then it misses the dates... All I do is remove 1 or 2 turns from the total I need to go between dates and then do a modulo division, this remainder becomes the increment for the remainding 1 or 2 turns :p previously I did it with months instead of years which meant it didn't add up (as god emperor said :p) it should be fixed now, I will check when I can (40 mins :p)
 
"Misses the date?"
 
yeah for example I want the ERE exactly on the date 395:1 this requires actually defining the dates :p by taking the total years and turns between 2 dates (eg 74 bc and 395 ad (actually did this one) and doing the method described above. I would have done a single increment but I had the oppotunity to make the calendar historic so I did... only harm me :p (I also needed to make sure after that date the game ended with minimal addition to the years (so I use 1 month increments after 395:1)
 
Did you even test what I submitted, or are you just mouthing your own hypothesis?
 
I had to wait until today because of that whole error with the calendar... I can test it now!
 
Because my code works. Its already tested. And if it doesn't work, then we need to fix the version you're using. And if you really need something else, then we can adjust thing to accommodate. Have a little faith.
 
Back
Top Bottom