Requesting following features

ok, while dealing with a syntax error in catapult construct I when reloaded the game and played the next turn and datastorage popups appear:

Traceback (most recent call last):

File "CvEventInterface", line 23, in onEvent

File "CvEventManager", line 187, in handleEvent

File "CvEventManager", line 627, in onUnitBuilt

File "CustomFeatures", line 149, in grantExtraXP

File "ModEvents", line 27, in getMariusFired

File "DataStorage", line 60, in getGlobalData

KeyError: 'bMariusFired'
ERR: Python function onEvent failed, module CvEventInterface
Traceback (most recent call last):

File "CvEventInterface", line 23, in onEvent

File "CvEventManager", line 187, in handleEvent

File "CvEventManager", line 627, in onUnitBuilt

File "CustomFeatures", line 149, in grantExtraXP

File "ModEvents", line 27, in getMariusFired

File "DataStorage", line 60, in getGlobalData

KeyError: 'bMariusFired'
ERR: Python function onEvent failed, module CvEventInterface
Traceback (most recent call last):

File "CvEventInterface", line 23, in onEvent

File "CvEventManager", line 187, in handleEvent

File "CvEventManager", line 627, in onUnitBuilt

File "CustomFeatures", line 149, in grantExtraXP

File "ModEvents", line 27, in getMariusFired

File "DataStorage", line 60, in getGlobalData

KeyError: 'bMariusFired'
ERR: Python function onEvent failed, module CvEventInterface
Traceback (most recent call last):

File "CvEventInterface", line 23, in onEvent

File "CvEventManager", line 187, in handleEvent

File "CvEventManager", line 627, in onUnitBuilt

File "CustomFeatures", line 149, in grantExtraXP

File "ModEvents", line 27, in getMariusFired

File "DataStorage", line 60, in getGlobalData

KeyError: 'bMariusFired'
ERR: Python function onEvent failed, module CvEventInterface
Traceback (most recent call last):

File "CvEventInterface", line 23, in onEvent

File "CvEventManager", line 187, in handleEvent

File "CvEventManager", line 627, in onUnitBuilt

File "CustomFeatures", line 149, in grantExtraXP

File "ModEvents", line 27, in getMariusFired

File "DataStorage", line 60, in getGlobalData

KeyError: 'bMariusFired'
ERR: Python function onEvent failed, module CvEventInterface
Traceback (most recent call last):

File "CvEventInterface", line 23, in onEvent

File "CvEventManager", line 187, in handleEvent

File "CvEventManager", line 627, in onUnitBuilt

File "CustomFeatures", line 149, in grantExtraXP

File "ModEvents", line 27, in getMariusFired

File "DataStorage", line 60, in getGlobalData

KeyError: 'bMariusFired'
ERR: Python function onEvent failed, module CvEventInterface
Traceback (most recent call last):

File "CvEventInterface", line 23, in onEvent

File "CvEventManager", line 187, in handleEvent

File "CvEventManager", line 627, in onUnitBuilt

File "CustomFeatures", line 149, in grantExtraXP

File "ModEvents", line 27, in getMariusFired

File "DataStorage", line 60, in getGlobalData

KeyError: 'bMariusFired'
ERR: Python function onEvent failed, module CvEventInterface
Traceback (most recent call last):

File "CvEventInterface", line 23, in onEvent

File "CvEventManager", line 187, in handleEvent

File "CvEventManager", line 627, in onUnitBuilt

File "CustomFeatures", line 149, in grantExtraXP

File "ModEvents", line 27, in getMariusFired

File "DataStorage", line 60, in getGlobalData

KeyError: 'bMariusFired'
ERR: Python function onEvent failed, module CvEventInterface
Traceback (most recent call last):

File "CvEventInterface", line 23, in onEvent

File "CvEventManager", line 187, in handleEvent

File "CvEventManager", line 392, in onBeginGameTurn

File "ModEvents", line 124, in eventMarius

File "DataStorage", line 60, in getGlobalData

KeyError: 'iMissionCounter'
ERR: Python function onEvent failed, module CvEventInterface
Traceback (most recent call last):

File "CvEventInterface", line 23, in onEvent

File "CvEventManager", line 187, in handleEvent

File "CvEventManager", line 400, in onEndGameTurn

File "CustomFeatures", line 111, in flipRebelCiv

File "DataStorage", line 60, in getGlobalData

KeyError: 'eMajorFlipPlayer'
ERR: Python function onEvent failed, module CvEventInterface

whats this about?
 
This probably just means that the game session never initialized the custom values. Because the syntax error exception. You need to address the error and restart the game.
 
but I did I fixed the syntax error exited the game and reloaded?
 
Try starting a new game altogether, because the default values are set onBeginGame (or whatever) - not on loadGame (or whatever).
 
:( I was having such a great game... playing as briton conquored the picts and started to build an army to attack europe... oh well :D

edit: so should I just continue with the class I had already written for the senate?

maybee there can be a 1.31 patch which includes your class instead of mine :D
 
It would be possible to set those values manually while the game was running, but I doubt its worth the effort. :p Being able to access the console would help.
 
|I think I can but it isn't that useful lol... it is weird and you can't paste code and that fire code you posted doesn't work in it

I think the shortcut key is shift + @

it is the one shown in your tutorial :D
 
Note that there are two consoles - and only the one that says Python 2.4.1 is the Python console. The other one is... some other console.

What "fire code", by the way?
 
Aha, but you need to be in slavery in order to trigger the event. Or did you get an exception?

The console is actually useful for testing, but you of course need to familiarize yourself with it first.
 
ah maybee thats the problem I was having then :D because I could spawn units and stuff...
 
I was wondering for my senate mission class: I am looking around for coding inspiration and every time I look in rebellion I always wonder about what methods are, could you give me little explaination on methods and how I should go about making my class?
 
The examples was exactly what I intended to make for you, but basically there should be a main class that defines default methods for stuff like checking if conditions are met, for firing the actual reward, stuff like that. Each sub-class would then only include their own versions of these methods when the default methods aren't sufficient. Like each reward sub-class would have its own method for granting the appropriate reward. Something like that.
 
so how is a method set out exactly...? or should I just copy the overall layout of rebellion as a basis?

the problem is with the rebels module I look at it thing I understand then an oddity appears and I get confused again :lol:
 
Lets dissect the Rebels module instead. Don't just copy-paste random stuff and try to alter it. The you'd be better of not using classes at all.

What is unclear to you at this point? Object Oriented Programming is covered in the textbook (chapters 12-15).
 
I meant copy the way its made not copy it :lol: I will look at the textbook in the mean time this is what I have (albeit very messy because I have decided to be awkard)
Spoiler :

Code:
from eNums import *
from Helpers 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"


## main functions

# 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():
    pass
def UpgradeBuild():
    pass
def Build():
    pass
def FreeCivic():
    pass
def FreeTech():
    pass
def CitySelect():
    pass

# penalties
def GoldDeduct(iChange, ePlayer):
    giveGold(-iChange, ePlayer)
def RebelUnit(eUnitType, tCoords, iNum):
    spawnUnits(eItalianRebels, eUnitType, tCoords, iNum)
def Unhappy():
    pass
def BuildingDest():
    pass
def Anarchy():
    pass
def CivilWar():
    pass
    
## data storage
def increaseMissionCounter():
    iMissionCounter = getGlobalData("iMissionCounter")
    setGlobalData("iMissionCounter", iMissionCounter + 1)

## classes

class Mission: #simple take city, like byzantium prompt
class Wonder(Mission):
class AreaControl(Mission):
class CivicChange(Mission):
class Peace(Mission):
class War(Mission):
class ExpandMelee(Mission):
class ExpandNavy(Mission):


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

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

very primitive... anyway I need help with these functions:
Unhappy() - makes city unhappy
BuildingDest() - destroyes a building in a city
Anarchy() - gives iTurns of anarchy
CivilWar() - fires civil war somehow
Happy() - makes city happy
UpgradeBuild() - upgrades build e.g happiness and defence ext
Build() - makes a building
FreeCivic() - allows for civic swap (found an api method for this)
FreeTech() - allows free tech
CitySelect() - allows player to build a city...

should be able to handle the class contruction for now...
I am not really sure why I am confused... maybee something to do with the @method things... I'm sure I will understand eventually...

edit: the random comment lines are about the conditions for a mission
also need help with the getDate() just not with it with that atm :lol:
 
Yeah, I'd like to be able to reply with a sample module based on what you just posted, but that would have to wait. (I'm actually a bit hung-over today. :p) You should be able to figure most of those rewards/punishments on your own, simply by looking in the API. The civil war one would how ever be sparked with this (class) method:
Code:
class CivilWar(Rebellion):
...
    @classmethod
    def initCivilWar(cls, pCivPlayer, lDefectingCities):
        pRebelHQ = [B]cls.initRebellions(pCivPlayer, lDefectingCities)[/B]
        if pRebelHQ:
            pRebelHQ.setRebelHQ()
Because this is a "class method" you don't use it with a CiviWar class instance, but you rather invoke it on the CivilWar class itself. (The cls parameter is in fact a reference to the class. An instance method would have self as the first parameter instead.) So, looking at the method definition line there are two additional parameters, namely pCivPlayer and lDefectingCities. Since the CivPlayer instance should always be the Roman one, you can simply provide instance("Rome") as the parameter. This leaves you with a list array of defecting cities, and this is something you need to whip up before invoking the CivilWar.initCivilWar() method.

The method is really just a wrapper for the CivilWar.initRebellions() (class) method. Which returns an instance of the CivilWar class - the rebellion that is happening at the rebel capital. The rest of the method is about calling the CivilWar.setRebelHQ() method for setting up the rebel capital.

This is the initRebellions() method:
Code:
    @classmethod
    def initRebellions(cls, pCivPlayer, lDefectingCities):
        tLargestCity = 0, None
        for pCity in lDefectingCities:
            pCivilWar = [B]CivilWar(pCivPlayer, pCity)[/B]
            appendRebellion(pCivilWar)
            pCivilWar.setActivate()
            iPopulation = pCity.getPopulation()
            if iPopulation > tLargestCity[0]:
                tLargestCity = iPopulation, pCivilWar
        return tLargestCity[1]
It does two things; sets up individual CivilWar instances for each city part of the lDefectingCities list. And it figures out which of the cities has the larges population - and returns the CivilWar instance of that city. See above.

edit: Things will become much clearer once you read through the mentioned chapters in the textbook. I myself made a point fully understanding the card came code example used in these chapters. It took me awhile, but once I figured it out I knew Object Oriented Programming...
 
I don't truly understand... so what will I have to put in my function

how can I list the defecting cities for use as lDefectingCities?
 
The method invocation looks like this:
Code:
CivilWar.initCivilWar(instance("Rome"), lCities)
And yes, this still leaves you with the issue of setting up a list of cities - CyCity objects. There are several ways of getting hold of these:
Spoiler :
CyPlayer.getCity() - if you know the city ID
CyPlot.getPlotCity() - if you know the location of the city
PyPlayer.getCityList() - if you wanna include all cities...

So it basically comes down to figuring out what cities you wanna include as rebels. I'm guessing this depends on the Senate Mission... Look at this as a practical programming lesson, then.

The default way to fire the CivilWar.initCivilWar() method involves looking up what cities are unhappy, how unhappy, and if there are enough unhappy cities. And in the last case the method is fired - with those same cities as part of the city list array. This is part of the code that is run on each turn by the Rebellion module.
 
Back
Top Bottom