def syntax_error(self, message): raise BugUtil.ConfigError("error parsing configuration: %s", message)
def getHandler(tag): try: return g_handlers[tag] except KeyError: raise BugUtil.ConfigError("unknown configuration element %s", tag)
def _checkEvent(self, eventType): """Raises ConfigError if the eventType is undefined.""" if not self.hasEvent(eventType): raise BugUtil.ConfigError("Event '%s' is undefined" % eventType)
def __init__(self, logging=None, noLogEvents=None): CvEventManager.CvEventManager.__init__(self) global g_eventManager if g_eventManager is not None: raise BugUtil.ConfigError("BugEventManager already created") g_eventManager = self if logging is None: self.setLogging(DEFAULT_LOGGING) else: self.setLogging(logging) if noLogEvents is None: self.setNoLogEvents(DEFAULT_NOLOG_EVENTS) else: self.setNoLogEvents(noLogEvents) self.bDbg = False self.bMultiPlayer = False self.bAllowCheats = False # used to register shortcut handlers self.shortcuts = {} # init fields for BeginActivePlayerTurn self.resetActiveTurn() # map the initial EventHandlerMap values into the new data structure for eventType, eventHandler in self.EventHandlerMap.iteritems(): self.setEventHandler(eventType, eventHandler) # add new core events; see unused sample handlers below for argument lists self.addEvent("PreGameStart") self.addEvent("BeginActivePlayerTurn") self.addEvent("SwitchHotSeatPlayer") self.addEvent("LanguageChanged") self.addEvent("ResolutionChanged") self.addEvent("PythonReloaded") # add events used by this event manager self.addEventHandler("kbdEvent", self.onKbdEvent) self.addEventHandler("OnLoad", self.resetActiveTurn) self.addEventHandler("GameStart", self.resetActiveTurn) self.addEventHandler("gameUpdate", self.onGameUpdate) # BULL events self.addEvent("unitUpgraded") self.addEvent("unitCaptured") self.addEvent("combatWithdrawal") self.addEvent("combatRetreat") self.addEvent("combatLogCollateral") self.addEvent("combatLogFlanking") self.addEvent("playerRevolution") self.CustomEvents = { 7614: ('RiseAndFallPopupEvent', self.rnfEventApply7614, self.rnfEventBegin7614), 7615: ('FlipPopupEvent', self.rnfEventApply7615, self.rnfEventBegin7615), 7616: ('VotePopupEvent', self.congEventApply7616, self.congEventBegin7616), 7617: ('AskCityPopupEvent', self.congEventApply7617, self.congEventBegin7617), 7618: ('DecisionPopupEvent', self.congEventApply7618, self.congEventBegin7618), 7619: ('InvitationPopupEvent', self.congEventApply7619, self.congEventBegin7619), 7620: ('BribePopupEvent', self.congEventApply7620, self.congEventBegin7620), 7621: ('GoldPopupEvent', self.congEventApply7621, self.congEventBegin7621), 7622: ('ResurrectionEvent', self.rnfEventApply7622, self.rnfEventBegin7622), 7623: ('AskNoCityPopupEvent', self.congEventApply7623, self.congEventBegin7623), #7624 : ('ReformationEvent', self.relEventApply7624, self.relEventBegin7624), 7625: ('AskColonialCityEvent', self.rnfEventApply7625, self.rnfEventBegin7625), #7626 : ('OrthodoxyEvent', self.relEventApply7626, self.relEventBegin7626), #7627 : ('PersecutionEvent', self.rnfEventApply7627, self.rnfEventBegin7627), 7628: ('RespawnPopupEvent', self.rnfEventApply7628, self.rnfEventBegin7628), 7629: ('ByzantineBriberyEvent', self.rnfEventApply7629, self.rnfEventBegin7629), } # --> INSERT EVENT HANDLER INITIALIZATION HERE <-- CvRFCEventHandler.CvRFCEventHandler(self) self.rnf = RiseAndFall.RiseAndFall() self.rel = Religions.Religions()
def getOption(self, id): """Returns the Option with the given ID or raises an error if not found.""" if (id in self.options): return self.options[id] else: raise BugUtil.ConfigError("Missing option: %s", id)
def getFile(self, id): """Returns the IniFile with the given ID.""" if (id in self.files): return self.files[id] else: raise BugUtil.ConfigError("Missing file: %s", id)