Requesting following features

probably... well while I was away from the mere mention of a computer I tried to reorganize the modevents into classes on paper (:lol:) didn't get very far as I forgot the class syntax and had no means to find it :rolleyes: but I thought about it for a while and really couldn't think how it would be advantageous to use the subclasses for each event... there really isn't any specialk methods needed or any sort of need for it... Any ideas on how to make the most of classes for this instance?
Basically, you could see what the various events have in common. A class is like a template and you could clone events with class instances. You simply supply each with different parameters - or just a identifier that can be used as a key for looking up the settings in a global dictionary.

The same with sub-classes: Look what I did with the Rebellion code. If I remember correctly there is a main Rebellion class defining many things and universal rules and methods. Then, every variety of rebellion is a separate sub-class that inherits some of the attributes of the main class, while building on it and even changing some other things. And the actual rebellions taking place in the game are of course instances of some or another of these classes.

So, you could have a main ScenarioEvent class. It could in itself only be used for the most basic types of events, like adding text messages or launching pop-ups. But there would be sub-classes that add to and change the basic ScenarioEvent class. So you could have SpawnEvent, FlipEvent, MissionEvent, SenateEvent and so on classes.

If you post what you have currently I could look into reshaping it into a class and data setup for you. You'd be able to build further on the foundations.

Also the big one is still the senate feature :mischief: which I acutally need to look back into to actually remember what I was even doing :p if possible you could do some of that...
I have little insight into what you're trying to do, but spontaneously I'm thinking that there would be a class for these missions, and that you could put all the settings into some data-structure.

Untill I get back home and attempt the Restriction code I can't tell if I actually understand what to do :p
If you define what you need in a clear fashion it would be very easy for me to just get this done for you. Like what the area(s) and associated player(s) are? Unless you really wanna handle it on your own. :D
 
might I add that in the original function you had the CyGame instance repeating :p
Code:
def isDate(iDate):
        """
        Returns True if the current game date is the first game turn past the iDate
        (integer) date. Otherwise returns False.
        """
        return CyGame().getTurnYear(CyGame().getGameTurn() +1) > iDate and CyGame().getGameTurnYear() <= iDate <= iDate
 
mod events code: (a lot of changes need to be made!) and senate code (a lot of incomplete bits... some I automatically see the solution to :p)
Spoiler :
Code:
from eNums import *
from Helpers import *
from Rebellion import EastRomanEmpire
#Make sure ALL dates are correct for new calendar

#Data Storage!#
def setupCounter():
    setGlobalData("iMissionCounter", 0)

def setupKill():
    setGlobalData("bMariusFired", False)

def increaseMissionCounter():
    iMissionCounter = getGlobalData("iMissionCounter")
    setGlobalData("iMissionCounter", iMissionCounter + 1)

def killMariusCode():
    setGlobalData("bMariusFired", True)

def setRomeExtraXP():
	"""
	Sets a boolean flag to True that can be accessed though the name "bExtraXP" 
	or with the function isRomeExtraxP.
	"""
	setPlayerData(pointer("Rome", playerID), "bExtraXP", True)

def getMariusFired():
    return getGlobalData("bMariusFired")

##Spartacus rebellion##
iSpartacusYear = "-74:1" #-100
spartacusHeader = "TXT_KEY_MODEVENTS_SPARTICUS_HEADER"
spartacusMessage1 = "TXT_KEY_MODEVENTS_SPARTICUS_MESSAGE1"
spartacusMessage2 = "TXT_KEY_MODEVENTS_SPARTICUS_MESSAGE2"
#unit definitions: coordinates, player, number to be spawned, unit type (defined by Utils)#
tSpartacus = (27, 15) #Change!
eSpartacus = eItalianRebels
iSpartacusUnitNumber = 4
eSpartacusUnit = eAxeman
def eventSpartacus():
    if isDate(iSpartacusYear):
        addMessage(spartacusMessage2, (), eWhite)
        spawnUnits(eSpartacus, eSpartacusUnit, tSpartacus, iSpartacusUnitNumber)
        if isHuman("Rome"):
            showPopup(spartacusHeader, spartacusMessage1)

##Macedonia Rebellion##
iMacedoniaYear = "12:7" #0
macedoniaHeader = "TXT_KEY_MODEVENTS_MACEDONIA_HEADER"
macedoniaMessage1 = "TXT_KEY_MODEVENTS_MACEDONIA_MESSAGE1"
macedoniaMessage2 = "TXT_KEY_MODEVENTS_MACEDONIA_MESSAGE2"
#unit definitions: coordinates, player, number to be spawned, unit type (defined by Utils)#
tMacedonia = (42, 25)
eMacedoniaCity = eHellenicRebels
eMacedoniaArmy = eBarbarian
iMacedoniaCityUnitNumber1 = 3
iMacedoniaCityUnitNumber2 = 3
iMacedoniaArmyUnitNumber = 3
eMacedoniaUnit1 = eAdvancedSpearman
eMacedoniaUnit2 = eArcher
sMacedoniaCityName = "Thessalonica"
iCitySize = 2
iCityDistance = 3
def eventMacedonia():
    if isDate(iMacedoniaYear):
        addMessage(macedoniaMessage2, (), eWhite)
        if isPlotOwner(tMacedonia, -1) == True and checkCityProximity(tMacedonia, iCityDistance) == True: 
            spawnUnits(eMacedoniaCity, eMacedoniaUnit2, tMacedonia, iMacedoniaCityUnitNumber1)
            spawnUnits(eMacedoniaCity, eMacedoniaUnit1, tMacedonia, iMacedoniaCityUnitNumber2)
            spawnCity(tMacedonia, eHellenicRebels, sMacedoniaCityName, iCitySize)
            if isHuman("Greece"):
                showPopup(macedoniaHeader, macedoniaMessage1)
        elif isPlotOwner(tMacedonia, eHellenicRebels) == True and checkCityProximity(tMacedonia, iCityDistance) == True: 
            spawnUnits(eMacedoniaCity, eMacedoniaUnit2, tMacedonia, iMacedoniaCityUnitNumber1)
            spawnUnits(eMacedoniaCity, eMacedoniaUnit1, tMacedonia, iMacedoniaCityUnitNumber2)
            spawnCity(tMacedonia, eHellenicRebels, sMacedoniaCityName, iCitySize)
            if isHuman("Greece"):
                showPopup(macedoniaHeader, macedoniaMessage1)
        else:
            spawnUnits(eMacedoniaArmy, eMacedoniaUnit1, tMacedonia, iMacedoniaArmyUnitNumber)
            if isHuman("Greece"):
                showPopup(macedoniaHeader, macedoniaMessage1)    

##Byzantium Senate Prompt##
iSenateYear = "316:4" #1050
iSenateEndYear = "383:10" #1350
iSenateGold = 1000
senateHeader = "TXT_KEY_MODEVENTS_SENATE_HEADER"
senateMessage1 = "TXT_KEY_MODEVENTS_SENATE_MESSAGE1"
senateMessage2 = "TXT_KEY_MODEVENTS_SENATE_MESSAGE2"
senateMessage3 = "TXT_KEY_MODEVENTS_SENATE_MESSAGE3"
senateMessage4 = "TXT_KEY_MODEVENTS_SENATE_MESSAGE4"  
tByzantium = (46, 27)
def eventSenate():
    if isHuman("Rome"):
        if isDate(iSenateYear):
            if isPlotOwner(tByzantium, eRome) == False and isPlotCity(tByzantium) == True:
                showPopup(senateHeader, senateMessage1)
            else:
                showPopup(senateHeader, senateMessage2)
        elif isDate(iSenateEndYear):
            if isPlotOwner(tByzantium, eRome) == True and isPlotCity(tByzantium) == True:
                giveGold(iSenateGold, eRome)
                showPopup(senateHeader, senateMessage3)
                increaseMissionCounter()
            else:
                showPopup(senateHeader, senateMessage4)

##ERE spawn!##
iEREYear = "395:1" #1400
tERE1 = (39, 0) #Change!
tERE2 = (83, 51) #Change!
def eventERE():
    if isDate(iEREYear):
        lDefectingCities = getPlayerAreaCities(tERE1, tERE2, eRome)
        EastRomanEmpire.initCivilWar(Civ("Rome"), lDefectingCities)

##AI Rome City flip/Army##
iRomeYear = "316:4" #Change!
iRomeYear2 = "383:10" #Change!
tByzantium = (46, 27)
romanMessage = "TXT_KEY_MODEVENTS_ROMEQUEST_MESSAGE"
pRome = pointer(eRome)
iRomeUnits = 1
x = 0
def eventRomeQuest():
    if not isHuman("Rome") and pRome.isAlive():
        if isPlotCity(tByzantium) and isDate(iRomeYear):
            addMessage(romanMessage, (getPlotCity(tByzantium).getName(),), eWhite) #Blue/Cyan?
            for pTile in getCityRadiusTiles(tByzantium):
                spawnUnits(eRome, ePraetorian, pTile, iRomeUnits)
                x += 1
            spawnUnits(eRome, getIndex("Unit", "Quintrireme"), getRandomCoords(getCityRadiusTiles(tByzantium, True)), Round((x * iRomeUnits)/3, True))
        elif isPlotCity(tByzantium) and isDate(iRomeYear2) and not isPlotOwner(tByzantium, eRome):
            flipCity(eRome, getPlotCity(tByzantium))

##ERE Reinforce##
iNumCities = 4
iReinforceDate = "395:4" #Change!
tERETop = (0, 0) #Change!
tEREBottom = (0, 0) #Change!
reinforceMessage = "TXT_KEY_MODEVENTS_REINFORCE_MESSAGE"
pByzantium = instance(eByzantium)
iEREUnits = 3
def eventReinforce():
    if getNumPlayerCities(eByzantium) < iNumCities and isDate(iReinforceDate) and pByzantium.isAlive():
        for pCity in findAreaCities(tEREBottom, tERETop):
            if not pCity.isCapital():
                flipCity(eByzantium, pCity)
                spawnCityGarrison(pByzantium, pCity, iEREUnits)
                addMessage(reinforceMessage, (), eWhite) #Blue/Cyan?

##Marius Reform##
iMissionsNeeded = 1
iCitiesNeeded = 10
mariusHeader = "TXT_KEY_MODEVENTS_MARIUS_HEADER"
mariusMessage1 = "TXT_KEY_MODEVENTS_MARIUS_MESSAGE1"
mariusMessage2 = "TXT_KEY_MODEVENTS_MARIUS_MESSAGE2"
def eventMarius():
    if getNumPlayerCities(eRome) >= iCitiesNeeded and getGlobalData("iMissionCounter") >= iMissionsNeeded and getMariusFired() == False:
        if isHuman("Rome"):
            showPopup(mariusHeader, mariusMessage1)
        addMessage(mariusMessage2, (), eWhite)
        print "this is eventMarius() calling!"
        killMariusCode()
and the senate code:
Code:
from Helpers import *
from Rebellion import *
#Constants#
MainHeader = "Senate Feature"
MainMessage = "This feature is specifically for Rome and gives them missions which can result in\
rewards or penalties. There are various different missions and conditions"
SenateHeader = "Senate"
freeTechMessage = "The senate has granted you a free tech!"
freeCivicMessage = "The senate has granted you a free tech!"
tAfricaCoords1 = (0, 0)
tAfricaCoords2 = (0, 0)
tBritonCoords1 = (0, 0)
tBritonCoords2 = (0, 0)
tGaulCoords1 = (0, 0)
tGaulCoords2 = (0, 0)
tIberiaCoords1 = (0, 0)
tIberiaCoords2 = (0, 0)
tGermaniaCoords1 = (0, 0)
tGermaniaCoords2 = (0, 0)
tGreeceCoords1 = (0, 0)
tGreeceCoords2 = (0, 0)
tEgyptCoords1 = (0, 0)
tEgyptCoords2 = (0, 0)
    

## main functions
def loopCities(name, bCapital=True, bReverse=True):
        """
        Used for looping. Yields one CyCity instance belonging to name (string) at a time. The bCapital (boolean)
        argument determines whether or not the capital city should also be included, and the bReverse (boolean)
        argument yields the cities in reversed order. Both are set to True by default.
        """
        lCityList = getCityList(name, bReverse)
        for pCity in (city.GetCy() for city in lCityList):
                if not bCapital and pCity.isCapital(): continue
                yield pCity

def getCityList(name, bReverse=False):
        """
        Returns a list array of valid CyCity instances belonging to the name (string) Civilization. Setting the bReverse
        argument to a True value reverses the order of the list.
        """
        lCities = instance(name).get(PyPlayer).getCityList()
        if bReverse:
                lCities.reverse()
        return lCities

def getLastCity(name):
        """
        Returns the last CyCity instance of name (string) civilization.
        """
        lCityList = getCityList(name)
        return lCityList[len(lCityList) - 1]

def getRandCity(name):
        """
        Returns a random CyCity instance belonging to the name (string) civilization. No cities causes exception!
        """
        lCityList = getCityList(name)
        iRandCity = getRandNum(len(lCityList), "getRandCity()")
        return lCityList[iRandCity]

def getRandBuilding(pCity, bPresent=True):
        pCivilizationInfo = gc.getCivilizationInfo(pCity.getCivilizationType())
        iNumBuildingClasses = gc.getNumBuildingClassInfos()
        iStartingBuildingClass = getRandNum(iNumBuildingClasses, "getRandBuilding()")
        for i in range(iNumBuildingClasses):
                eBuildingClass = (iStartingBuildingClass + i) % iNumBuildingClasses
                eBuilding = pCivilizationInfo.getCivilizationBuildings(eBuildingClass)
                if isBuilding(pCity, eBuilding) == bPresent:
                        return eBuilding
        return -1

def getBuildingClassType(eBuilding):
        """
        Returns the BuildingClassType (integer) of eBuilding (integer).
        """
        return gc.getBuildingInfo(eBuilding).getBuildingClassType()

def isBuilding(pCity, eBuilding):
        """
        Returns True if eBuilding is present in pCity. Otherwise returns False.
        """
        return pCity.getNumRealBuildings(eBuilding) == 1
        
def isWonder(eBuilding):
        """
        Returns True if eBuilding (integer) is a National Wonder, a World Wonder or a Project. Otherwise returns False.
        """
        pBuildingClassInfo = gc.getBuildingClassInfo(getBuildingClassType(eBuilding))
        return ( pBuildingClassInfo.getMaxGlobalInstances() == 1
                 or pBuildingClassInfo.getMaxPlayerInstances() == 1
                 or pBuildingClassInfo.getMaxTeamInstances() == 1 )

def buildingOutput(pCity, eBuilding, iFood=0, iProduction=0, iCommerce=0):
        """
        Adds or subtracts the integer amount of iFood, iProduction or iCommerce from the associated YieldType of
        eBuildingClass (integer) in pCity.
        """
        eBuildingClass = getBuildingClassType(eBuilding)
        tOutputChange = iFood, iProduction, iCommerce
        for iYield in range(len(tOutputChange)):
                pCity.setBuildingYieldChange(eBuildingClass, iYield, tOutputChange[iYield])
                
def getRandReward():
    random = getRandNum(100)
    if random >= 0 and random <= 11:
        Gold(1000, eRome)
    elif random >= 12 and random <= 23:
        Unit(ePraetorian, getCapital(eRome), 2)
    elif random >= 24 and random <= 35:
        GoldenAge(6)
    elif random >= 36 and random <= 47:
        Happy(1)
    elif random >= 48 and random <= 59:
        pass #upgrade
    elif random >= 60 and random <= 71
        Build()
    elif random >= 72 and random <= 83:
        FreeCivic()
    elif random >= 84 and random <= 95:
        FreeTech("rome")
    else:
        pass #city gift
    
def getRandDate():
    random = getRandNum(100)
    if random >= 0 and random <= 9:
        date = 3000 #add date type
    elif random >= 10 and random <= 9:
        date = 3000 #add date type
    elif random >= 20 and random <= 29:
        date = 3000 #add date type
    elif random >= 30 and random <= 39:
        date = 3000 #add date type
    elif random >= 40 and random <= 49:
        date = 3000 #add date type
    elif random >= 50 and random <= 59:
        date = 3000 #add date type
    elif random >= 60 and random <= 69:
        date = 3000 #add date type
    elif random >= 70 and random <= 79:
        date = 3000 #add date type
    elif random >= 80 and random <= 89:
        date = 3000 #add date type
    else:
        date = 3000 #add date type
    return date

def getRandEndDate():
    random = getRandNum(100)
    if random >= 0 and random <= 9:
        enddate = 3000 #add date type
    elif random >= 10 and random <= 9:
        enddate = 3000 #add date type
    elif random >= 20 and random <= 29:
        enddate = 3000 #add date type
    elif random >= 30 and random <= 39:
        enddate = 3000 #add date type
    elif random >= 40 and random <= 49:
        enddate = 3000 #add date type
    elif random >= 50 and random <= 59:
        enddate = 3000 #add date type
    elif random >= 60 and random <= 69:
        enddate = 3000 #add date type
    elif random >= 70 and random <= 79:
        enddate = 3000 #add date type
    elif random >= 80 and random <= 89:
        enddate = 3000 #add date type
    else:
        enddate = 3000 #add date type
    return date

def getReward(Reward, iReward):
    if Reward == 1:
        Gold(iReward, eRome)
    elif Reward == 2:
        Unit(ePraetorian, getCapital(eRome), iReward)
    elif Reward == 3:
        GoldenAge(iReward)
    elif Reward == 4:
        Happy(iReward)
    elif Reward == 5:
        pass #upgrade
    elif Reward == 6:
        Build()
    elif Reward == 7:
        FreeCivic()
    elif Reward == 8:
        FreeTech("rome")
    else:
        pass #city gift
    
def getPenalty(Penalty, iPenalty):
    if Penalty == 1:
        GoldDeduct(iPenalty, eRome)
    elif Penalty == 2:
        RebelUnit(eSwordsman, iPenalty)
    elif Penalty == 3:
        Unhappy(iPenalty)
    elif Penalty == 4:
        BuildingDest()
    elif Penalty == 5:
        Anarchy(iPenalty)
    else:
        CivilWar()


# rewards

def Gold(iChange, ePlayer):
    giveGold(iChange, ePlayer)
def Unit(eUnitType, tCoords, iNum):
    spawnUnits(eRome, eUnitType, tCoords, iNum)
def GoldenAge(iTurns):
    giveGoldenAge(eRome, iTurns)
def Happy(iHappiness):
    lCities = getCityList("rome")
    for pCity in (city.GetCy() for city in lCities):
        pCity.changeExtraHappiness(iHappiness)
def UpgradeBuild():
    pass
def Build():
    targetCity = getRandCity("rome")
    building = getRandBuilding(targetCity, bPresent=False)
    if not isWonder(building):
        targetCity.setNumRealBuilding(building, 1)
def FreeCivic():
        bBasic = True
        pPlayer = gc.getPlayer(eRome)
                if bBasic == True:
                        pCivic = gc.getInfoTypeForString('CIVIC_REPUBLIC')
                        if pPlayer.isCivic(pCivic):
                                pPlayer.setCivics(0, pCivic)
                                showPopup(senateHeader, freeCivicMessage)
                        else:
                                print "No usable civic for FreeCivic()"
                                
                else:
                        pass


def FreeTech(player, header=freeTechMessage):
    pPlayer = instance(player).get(CyPlayer)
    if pPlayer.isHuman():
        pPlayer.chooseTech(1, header, False)
    else:
        pPlayer.AI_chooseFreeTech()
def CitySelect():
    pass

# penalties
def GoldDeduct(iChange, ePlayer):
    giveGold(-iChange, ePlayer)
def RebelUnit(eUnitType, iNum):
        tCoords = (0, 0)#get radius of Rome!
        spawnUnits(eItalianRebels, eUnitType, tCoords, iNum)
def Unhappy(iHappiness):
    lCities = getCityList("rome")
    for pCity in (city.GetCy() for city in lCities):
        pCity.changeExtraHappiness(-iHappiness)
        pass
def BuildingDest():
    targetCity = getRandCity("rome")
    building = getRandBuilding(targetCity, bPresent=True)
    if not isWonder(building):
        targetCity.setNumRealBuilding(building, 0)
def Anarchy(iAnarchy):
    pPlayer = instance(player).get(CyPlayer)
    pPlayer.changeAnarchyTurns(iAnarchy)
def CivilWar():
    condition = False #add standard conditioning
    if condition:
        lCities = 
        CivilWar.initCivilWar(instance("Rome"), lCities)
    else:
        lCities = 
        CivilWar.initCivilWar(instance("Rome"), lCities)
    
## data storage
def increaseMissionCounter():
    iMissionCounter = getGlobalData("iMissionCounter")
    setGlobalData("iMissionCounter", iMissionCounter + 1)

## classes

class Mission: #simple take city, like byzantium prompt
    def __init__(self, tCityCoords, Message1, Message2, ePlayer, Message3, MessageHold, iStartYear = None, iEndYear = None\
                 , Reward = None, Penalty = None, iReward = None, iPenalty = None):
        self.tCityCoords = tCityCoords
        self.iReward = iReward
        self.iPenalty = iPenalty
        self.Message1 = Message1
        self.Message2 = Message2
        self.Player = ePlayer
        self.Message3 = Message3
        self.MessageHold = MessageHold
        self.Start = iStartYear
        self.End = iEndYear
        self.Reward = Reward
        self.Penalty = Penalty
        self.iReward = iReward
        self.iPenalty = iPenalty
    def Condition(self):
        if not self.Start and self.End == None:
            if isDate(self.Start):
                if isPlotOwner(self.tCityCoords, self.ePlayer) == False and isPlotCity(self.tCityCoords) == True:
                   showPopup(SenateHeader, self.Message1)
                else:
                    Hold(Mission).holdCondition()
            elif isDate(self.End):
                if isPlotOwner(self.tCityCoords, self.ePlayer) and isPlotCity(self.tCityCoords):
                    showPopup(SenateHeader, self.Message2)
                    if self.Reward == None:
                        getRandReward()
                        increaseMissionCounter()
                    else:
                        getReward(self.Reward, self.iReward)
                        increaseMissionCounter()
                else:
                    showPopup(SenateHeader, self.Message3)
                    if self.Penalty == None:
                        pass #getRandPenalty()
                    else:
                        getPenalty(self.Penalty, self.iPenalty)
                        
        else:
            if isDate(getRandDate()):
                if isPlotOwner(getRandCoords(), self.ePlayer) == False and isPlotCity(getRandCoords()) == True:
                    showPopup(SenateHeader, "The Senate requests you take the city of %s1!")
                else:
                    Hold().Condition()
            elif isDate(getRandEndDate()):
                if isPlotOwner(getRandCoords(), self.eRome) and isPlotCity(getRandCoords):
                    showPopup(SenateHeader, "you have succeeded in your mission!")
                    getRandReward()
                    increaseMissionCounter()
                else:
                    showPopup(SenateHeader, "you have failed the senate!")
                    pass #getRandPenalty()
class Hold(Mission):
        def __init__(self, tCityCoords, Message1, Message2, ePlayer, Message3, iStartYear = None, iEndYear = None\
                     , Reward = None, Penalty = None, iReward = None, iPenalty = None):
                self.tCoords = tCityCoords
                self.MessageCommence = Message1
                self.MessageSuccess = Message2
                self.Player = ePlayer
                self.MessageFail = Message3
                self.Start = iStartYear
                self.End = iEndYear
                self.Reward = Reward
                self.Penalty = Penalty
                self.iReward = iReward
                self.iPenalty = iPenalty
        def holdCondition(self):
                if not self.Start and self.End == None:
                        if isDate(self.Start):
                                if isPlotOwner(self.tCoords, self.Player) == True and isPlotCity(self.tCoords):
                                        showPopup(SenateHeader, self.MessageCommence)
                        elif isDate(self.End):
                                if isPlotOwner(self.tCoords, self.Player) == True and isPlotCity(self.tCoords):
                                        showPopup(SenateHeader, self.MessageSuccess)
                                        if self.Reward == None:
                                                getRandReward()
                                                increaseMissionCounter()
                                        else:
                                                getReward(self.Reward, self.iReward)
                                                increaseMissionCounter()
                                else:
                                        showPopup(SenateHeader, self.MessageFail)
                                        if self.Penalty == None:
                                                #getRandPenalty()
                                        else:
                                                getPenalty(self.Penalty, self.iPenalty)
                else:
                        if isDate(getRandDate()):
                                if isPlotOwner(getRandCoords(), self.Player) == True and isPlotCity(getRandCoords()) == True:
                                        showPopup(SenateHeader, "The Senate requests you hold the city of %s1!")
                        elif isDate(self.End):
                                if isPlotOwner(getRandCoords(), self.Player) == True and isPlotCity(getRandCoords()):
                                        showPopup(SenateHeader, "you have succeeded in your mission!")
                                        getRandReward()
                                        increaseMissionCounter()
                                else:
                                        showPopup(SenateHeader, "you have failed the senate!")
                                        pass #getRandPenalty

class War(Mission):
        def __init__(self, eWarPlayer, Message1, Message2, Message3, ePlayer, iStartYear = None, iEndyear = None\
                     , Reward = None, Penalty = None, iReward = None, iPenalty = None):
                self.WarPlayer = eWarPlayer
                self.MessageCommence = Message1
                self.MessageSuccess = Message2
                self.MessageFail = Message3
                self.Player = ePlayer
                self.Start = iStartYear
                self.End = iEndYear
                self.Reward = Reward
                self.Penalty = Penalty
                self.iReward = iReward
                self.iPenalty = iPenalty
        def warCondition(self):
                if not self.Start and self.End == None:
                        pass
                        
                
                              
                
                            
                        
                
                    
#class Wonder(Mission):
#class AreaControl(Mission):
#class CivicChange(Mission):
#class Peace(Mission):
#class War(Mission):
#class ExpandMelee(Mission):
#class ExpandNavy(Mission):

##pre-defined missions
#Byzantium Prompt
iByzantiumStartYear = 1050
iByzantiumEndYear = 1350
iByzantiumGold = 1000
iByzantiumPenalty = 0
byzantiumMessage1 = "The glorius Senate of Rome requests that you take the city of Byzantium. If you take it and hold it at the end of 30 turns (turn 195) you will be greatly rewarded"
byzantiumMessage2 = "The glorius Senate of Rome wishes that you make sure that you keep control of Byzantium by the end of 30 turns (turn 195). If you successful, you will be rewarded!"
tByzantium = (46, 23)

Byzantium = Mission(tByzantium, byzantiumMessage1, "insert success message here", eRome, "insert fail message here", byzantiumMessage2, iByzantiumStartYear, iByzantiumEndYear, 1, 1, iByzantiumGold, iByzantiumPenalty)
Byzantium.Condition()

#date
#wonder built
#peace
#war
#military deficiency
#naval deficiency
#not owning area + date (could be rand)
#city not owned + date

#misc senate relation
def gloriusAchieve():
    iDates = 3800 or 3000 or 0 #to be edited
    if isDate(iDates):
        if isAreaOwner(eRome, tAfricaCoords1, tAfricaCoords2) == True:
            print "acheive africa at: "#, getDate()
        if isAreaOwner(eRome, tBritonCoords1, tBritonCoords2) == True:
            print "acheive briton at: "#, getDate()
        if isAreaOwner(eRome, tGaulCoords1, tGaulCoords2) == True:
            print "acheive gaul at: "#, getDate()
        if isAreaOwner(eRome, tIberiaCoords1, tIberiaCoords2) == True:
            print "acheive spain at: "#, getDate()
        if isAreaOwner(eRome, tGermaniaCoords1, tGermaniaCoords2) == True:
            print "acheive germania at: "#, getDate()
        if isAreaOwner(eRome, tGreeceCoords1, tGreeceCoords2) == True:
            print "acheive greece at: "#, getDate()
        if isAreaOwner(eRome, tEgyptCoords1, tEgyptCoords2) == True:
            print "acheive egypt at: "#, getDate()
        else:
            print "no acheive at: "#, getDate()

also in your isDate() function... does it make the event fire on the desired turn or the one after? if it fires one turn after (like the other does) would it be changed to the desired turn by this:
Code:
def isDate2(date):
        tDate = date.partition(":")
        iMonthDate = int(tDate[0]) * 12 + int(tDate[2]) - 1
        iGameTurn = Game.getGameTurn()
        return ( getDateForTurn([B]iGameTurn[/B]) >= iMonthDate
                 and getDateForTurn([B]iGameTurn - 1[/B]) < iMonthDate )
 
I'll try to skim through your work and see what I come up with, if anything.
 
Just test what you have and we can sort how to change it later, if necessary. It should be as easy as changing the operators in the expression. No problem.
 
if you ever have time I wouldn't mind hearing how you engineered civplayer :p I was looking at it earlier while fixing a mistake in my code (used pointer() instead of instance())
 
umm exception and I don't have a clue why...

Traceback (most recent call last):

File "CvEventInterface", line 23, in onEvent

File "CvEventManager", line 188, in handleEvent

File "CvEventManager", line 385, in onBeginGameTurn

File "ModEvents", line 41, in eventSpartacus

File "Helpers", line 34, in isDate

AttributeError: 'str' object has no attribute 'partition'
ERR: Python function onEvent failed, module CvEventInterface

with the line being

iSpartacusYear = "-74:1" #-100
if isDate(iSpartacusYear)

using your isDate()... any ideas?

edit: unless partition is unavailable with civ4's version of python?
 
Oh, crap. Back to the drawing board.

ps Incidentally, I'm writing the CivPlayer documentation right now :)
 
Lets try this:
Code:
        [COLOR="Red"]l[/COLOR]Date = date.[COLOR="Red"]split[/COLOR](":")
        iMonthDate = int([COLOR="Red"]l[/COLOR]Date[0]) * 12 + int([COLOR="Red"]l[/COLOR]Date[2]) - 1
 
I always feel a sense of acheivement when God-Emperor drops by :p (who is ironically at emperor posts :p)

aww I liked that method, maybee someone should dtry and update civ4's python :lol:

I will try the new method when I can!
 
The CivPlayer utility has been released and full documentation is available. (The documentation has been available all along within the module ;))
 
I looked at your events and senate code, and I can't say I have any clear ideas on how to reshape it into some other setup. It would be easier to make something from the ground-up, but chances are that it wouldn't be what you need.

Did you ever consider tapping into the built-in Random Events Interface for setting up events in XML and supplying call-ups and call-backs in Python?

I already did a custom scenario events interface, and I can say as much as it is quite i big job, actually. :p
 
well the senate code doesn't need reshaping but it needs completing :p some of the functions and classes need to be worked on, if you could do that it would be a big help, I can tell you what everything needs to do fi you are able to do it...
 
Yeah, sure put it down in some great detail, otherwise I'll get stuck immediately. Do you feel that you need something like helper functions to do different tasks? So that you can put the whole thing together yourself by calling on those functions.
 
well as you go through the getReward/Penalty and the RandReward/Penalty functions you will see some passed conditions these need to be filled with the appropriate function (commented next to it) these functions actually need to be made, when I get time later I will explain what every class and function should do...
 
Ok, got it. I'm gonna reshape this... thing completely:
Code:
def getRandReward():
    random = getRandNum(100)
    if random >= 0 and random <= 11:
        Gold(1000, eRome)
    elif random >= 12 and random <= 23:
        Unit(ePraetorian, getCapital(eRome), 2)
    elif random >= 24 and random <= 35:
        GoldenAge(6)
    elif random >= 36 and random <= 47:
        Happy(1)
    elif random >= 48 and random <= 59:
        pass #upgrade
    elif random >= 60 and random <= 71
        Build()
    elif random >= 72 and random <= 83:
        FreeCivic()
    elif random >= 84 and random <= 95:
        FreeTech("rome")
    else:
        pass #city gift
The logic is sound, but I have something a little bit... more sophisticated in mind. You'll end up with a data-structure where you can enter any number of rewards (in this case - the same will be applied to the punishments and other... stuff). Instead of a percentile chance you'll have a weigh value which allows you to adjust and tweak individual entries with the whole thing adjusting itself dynamically. This will make it easy to expand, edit and tweak during both development and the testing.

It will be a thing of beauty :D even if I'm not entirely sure how to make all of it happen. Yet. But here-in lies the challenge. The fun.

If you compile a list of functions with a complete set of argument settings and description, it should be a breeze to crank those out for you. Fun, fun, fun! ;)
 
This is my - preliminary - solution:
Code:
lRewards = [
        ( grantGold, 100, 2 ),
        ( grantUnit, ePretorian, 1 ),
        ( grantGoldenAge, 6, 1 ),
        ( grantHappiness, 1, 3 ),
        ( grantUpgrade, None, 1 ),
        ( grantBuilding, None, 1 ),
        ( grantCivic, None, 1 ),
        ( grantFreeTech, None, 1 )
        ]

def getRewardSpan():
        iCount = 0
        for iWeigh in (tValues[2] for tValues in lRewards):
                iCount += iWeigh
        return iCount

iRandRewardIndexSpan = getRewardSpan()

def grantRandReward():
        iRand = getRandNum(iRandRewardIndexSpan) + 1
        iCount = 0
        for tValues in lRewards:
                function, iArgument, iWeigh = tValues
                iCount += iWeigh
                if iCount => iRand:
                        if iArgument == None:
                                function()
                        else:
                                function(iArgument)
                        return
What you need to edit is the lRewards array at the top. The first value in each entry is in fact a function name, so those need to be defined for it to work. The second value is an argument used with that function. (A None value means that no argument is to be used with the function.) The third and last value is the reward weigh. So if most rewards have weigh 1 (one) then the gold reward (2) would be twice as likely, and the happiness reward (3) would be tree times as likely.

This example assumes that we make brand new wrapper functions for all the rewards. In the meanwhile we can just set up dummy functions for these:
Code:
def grantBuilding():
        pass
What do you think?
 
Back
Top Bottom