Пример #1
1
def initNoCustomAssetsSetting():
    """
	Checks if the NoCustomAssets setting is enabled when running as a mod.
	"""
    global _noCustomAssetsSettingInitDone
    if _noCustomAssetsSettingInitDone:
        return
    if isMod():
        global _noCustomAssets
        # EF: don't check game option because BUG is initialized only once at startup
        # 		if CyGame().isOption(GameOptionTypes.GAMEOPTION_LOCK_MODS):
        # 			_noCustomAssets = True
        # 			BugUtil.debug("BugPath - Lock Modified Assets is set")
        # 		else:
        if getModDir() and getModFolder():
            BugUtil.debug("BugPath - checking for NoCustomAssets")
            try:
                from configobj import ConfigObj

                config = ConfigObj(join(getModDir(), getModFolder() + ".ini"), encoding="utf_8")
                _noCustomAssets = config["CONFIG"].as_bool("NoCustomAssets")
            except:
                BugUtil.trace("BugPath - failed to parse mod INI file for NoCustomAssets")
        BugUtil.info("BugPath - NoCustomAssets is %s", _noCustomAssets)
    _noCustomAssetsSettingInitDone = True
Пример #2
0
def onCombatResult(argsList):
	CyUnitW, CyUnitL = argsList

	# Captives
	if CyUnitW.isMadeAttack() and not CyUnitL.isAnimal() and CyUnitL.getDomainType() == giDomainLand and CyUnitW.getDomainType() == giDomainLand:
		# Check that the losing unit is not an animal and the unit does not have a capture type defined in the XML
		if CyUnitL.getCaptureUnitType((gc.getPlayer(CyUnitL.getOwner())).getCivilizationType()) == -1:

			iCaptureProbability = CyUnitW.captureProbabilityTotal()
			iCaptureResistance = CyUnitL.captureResistanceTotal()
			iChance = iCaptureProbability - iCaptureResistance
			if iChance > 100:
				iChance = 100
			BugUtil.info("CaptureSlaves: Chance to capture a captive is %d (%d - %d)", iChance, iCaptureProbability, iCaptureResistance)

			iRandom = CyGame().getSorenRandNum(100, "Slave") # 0-99
			if iChance > iRandom:
				if CyUnitL.isHasUnitCombat(gc.getInfoTypeForString('UNITCOMBAT_SPECIES_NEANDERTHAL')):
					iUnit = gc.getInfoTypeForString('UNIT_CAPTIVE_NEANDERTHAL')
					sMessage = CyTranslator().getText("TXT_KEY_MESSAGE_NEANDERTHAL_CAPTIVE",())
				else:
					iUnit = gc.getInfoTypeForString('UNIT_CAPTIVE_MILITARY')
					sMessage = CyTranslator().getText("TXT_KEY_MESSAGE_MILITARY_CAPTIVE",())

				iPlayerW = CyUnitW.getOwner()
				CyPlayerW = gc.getPlayer(iPlayerW)
				X = CyUnitW.getX()
				Y = CyUnitW.getY()
				CyUnit = CyPlayerW.initUnit(iUnit, X, Y, UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
				if CyUnitW.isHiddenNationality():
					CyUnit.doHNCapture()
				if CyPlayerW.isHuman():
					CyInterface().addMessage(iPlayerW, False, 15, sMessage, '', 0, 'Art/Interface/Buttons/Civics/Serfdom.dds', ColorTypes(44), X, Y, True, True)
Пример #3
0
def init():
    """
	Checks for the presence of the BUFFY DLL and sets the global flags.
	"""
    if isEnabled():
        if BugPath.isMac():
            BugUtil.debug("BUFFY is not active on Mac (no DLL)")
        else:
            try:
                if gc.isBuffy():
                    global IS_DLL_PRESENT, IS_DLL_IN_CORRECT_PATH, IS_ACTIVE
                    IS_DLL_PRESENT = True
                    IS_ACTIVE = True
                    BugUtil.info("BUFFY is active (API version %d)",
                                 gc.getBuffyApiVersion())
                    try:
                        dllPath = gc.getGame().getDLLPath()
                        exePath = gc.getGame().getExePath()
                        dllPathThenUp3 = os.path.dirname(
                            os.path.dirname(os.path.dirname(dllPath)))
                        if dllPathThenUp3 == exePath:
                            IS_DLL_IN_CORRECT_PATH = True
                    except:
                        pass  # DLL path is borked
            except:
                BugUtil.info("BUFFY is not active (no DLL)")
Пример #4
0
 def isReplayWinner(self, replay):
     szWinText = localText.getText("TXT_KEY_GAME_WON", ("(.*)", "(.*)"))
     reWinText = re.compile(szWinText)
     leaderGroup = 1
     typeGroup = 2
     leader = replay.getLeaderName()
     msgNum = replay.getNumReplayMessages() - 1
     BugUtil.debug("scanning replay for %s with %d msgs", leader,
                   msgNum + 1)
     count = 0
     while msgNum >= 0:
         msg = replay.getReplayMessageText(msgNum)
         if count > 100:
             BugUtil.debug("no victory message in first 100; skipping")
             break
         matches = reWinText.match(msg)
         if matches:
             type = matches.group(typeGroup)
             if leader in matches.group(leaderGroup).split('/'):
                 BugUtil.info("replay: %s win for %s", type, leader)
                 return True, type
             BugUtil.info("replay: %s loss for %s", type, leader)
             return False, type
         msgNum -= 1
     return False, localText.getText("TXT_KEY_NONE", ())
Пример #5
0
def initNoCustomAssetsSetting():
    """
	Checks if the NoCustomAssets setting is enabled when running as a mod.
	"""
    global _noCustomAssetsSettingInitDone
    if _noCustomAssetsSettingInitDone:
        return
    if isMod():
        global _noCustomAssets
        # EF: don't check game option because BUG is initialized only once at startup
        #		if CyGame().isOption(GameOptionTypes.GAMEOPTION_LOCK_MODS):
        #			_noCustomAssets = True
        #			BugUtil.debug("BugPath - Lock Modified Assets is set")
        #		else:
        if getModDir() and getModFolder():
            BugUtil.debug("BugPath - checking for NoCustomAssets")
            try:
                from configobj import ConfigObj
                config = ConfigObj(join(getModDir(),
                                        getModFolder() + ".ini"),
                                   encoding='utf_8')
                _noCustomAssets = config["CONFIG"].as_bool("NoCustomAssets")
            except:
                BugUtil.trace(
                    "BugPath - failed to parse mod INI file for NoCustomAssets"
                )
        BugUtil.info("BugPath - NoCustomAssets is %s", _noCustomAssets)
    _noCustomAssetsSettingInitDone = True
Пример #6
0
 def handle(self, element, how, module, function, toModule, asName, dll):
     dll = BugDll.decode(dll)
     if self.isDllOkay(element, dll):
         BugUtil.extendFunction(module, function, toModule, asName, how)
     else:
         BugUtil.info(
             "BugConfig - ignoring <%s> %s.%s, requires dll version %s",
             element.tag, module, function, self.resolveDll(element, dll))
Пример #7
0
 def _getMod(self, id):
     if id in self._mods:
         return self._mods[id]
     elif not self._inited:
         BugUtil.info("BugCore - creating uninitialized mod %s", id)
         return self._newMod(id)
     else:
         BugUtil.error("BugCore - invalid mod %s", id)
Пример #8
0
	def _getMod(self, id):
		if id in self._mods:
			return self._mods[id]
		elif not self._inited:
			BugUtil.info("BugCore - creating uninitialized mod %s", id)
			return self._newMod(id)
		else:
			BugUtil.error("BugCore - invalid mod %s", id)
Пример #9
0
    def _getMod(self, mod_id):
        'get mod by id'
        if mod_id in self._mods:
            return self._mods[mod_id]
        if not self._inited:
            BugUtil.info("BugCore - creating uninitialized mod %s", mod_id)
            return self._newMod(mod_id)

        raise BugUtil.error("BugCore - invalid mod %s", mod_id)
Пример #10
0
 def handle(self, element, module, clazz, dll):
     dll = BugDll.decode(dll)
     if self.isDllOkay(element, dll):
         BugUtil.callFunction(module, clazz,
                              CvEventInterface.getEventManager(),
                              *element.args, **element.kwargs)
     else:
         BugUtil.info(
             "BugConfig - ignoring <%s> from %s.%s, requires dll version %s",
             element.tag, module, clazz, self.resolveDll(element, dll))
Пример #11
0
def registerSymbol(key, symbol, ordinal):
	BugUtil.info("FontUtil - registering symbol '%s' for %d", key, ordinal)
	if key in keySymbols:
		raise BugUtil.ConfigError("duplicate font symbol key '%s'" % key)
	if symbol in symbolPrimaryKeys:
		raise BugUtil.ConfigError("duplicate font symbol for key '%s'" % key)
	keySymbols[key] = symbol
	symbolPrimaryKeys[symbol] = key
	symbolOrdinals[symbol] = ordinal
	symbolChars[symbol] = u"%c" % ordinal
def registerSymbol(key, symbol, ordinal):
    BugUtil.info("FontUtil - registering symbol '%s' for %d", key, ordinal)
    if key in keySymbols:
        raise BugUtil.ConfigError("duplicate font symbol key '%s'" % key)
    if symbol in symbolPrimaryKeys:
        raise BugUtil.ConfigError("duplicate font symbol for key '%s'" % key)
    keySymbols[key] = symbol
    symbolPrimaryKeys[symbol] = key
    symbolOrdinals[symbol] = ordinal
    symbolChars[symbol] = u"%c" % ordinal
Пример #13
0
	def handle(self, element, module, function, immediate, dll):
		immediate = self.isTrue(immediate)
		dll = BugDll.decode(dll)
		if self.isDllOkay(element, dll):
			func = BugUtil.getFunction(module, function, True, *element.args, **element.kwargs)
			if immediate:
				func()
			else:
				BugInit.addInit(module, func)
		else:
			BugUtil.info("BugConfig - ignoring <%s> %s.%s, requires dll version %s", element.tag, module, function, self.resolveDll(element, dll))
Пример #14
0
 def handle(self, element, type, module, function, dll):
     dll = BugDll.decode(dll)
     if self.isDllOkay(element, dll):
         CvEventInterface.getEventManager().addEventHandler(
             type,
             BugUtil.getFunction(module, function, True, *element.args,
                                 **element.kwargs))
     else:
         BugUtil.info(
             "BugConfig - ignoring <%s> %s, requires dll version %s",
             element.tag, type, self.resolveDll(element, dll))
Пример #15
0
	def handle(self, element, module, function, immediate, dll):
		immediate = self.isTrue(immediate)
		dll = BugDll.decode(dll)
		if self.isDllOkay(element, dll):
			func = BugUtil.getFunction(module, function, True, *element.args, **element.kwargs)
			if immediate:
				func()
			else:
				BugInit.addInit(module, func)
		else:
			BugUtil.info("BugConfig - ignoring <%s> %s.%s, requires dll version %s", element.tag, module, function, self.resolveDll(element, dll))
Пример #16
0
 def handle(self, element, keys, module, function, dll):
     dll = BugDll.decode(dll)
     if self.isDllOkay(element, dll):
         CvEventInterface.getEventManager().addShortcutHandler(
             keys,
             BugUtil.getFunction(module, function, *element.args,
                                 **element.kwargs))
     else:
         BugUtil.info(
             "InputUtil - ignoring <%s> %s, requires dll version %s",
             element.tag, keys, self.resolveDll(element, dll))
Пример #17
0
 def handle(self, element, how, module, function, toModule, asName, dll):
     dll = BugDll.decode(dll)
     if self.isDllOkay(element, dll):
         BugUtil.extendFunction(module, function, toModule, asName, how)
     else:
         BugUtil.info(
             "BugConfig - ignoring <%s> %s.%s, requires dll version %s",
             element.tag,
             module,
             function,
             self.resolveDll(element, dll),
         )
Пример #18
0
 def handle(self, element, module, clazz, dll):
     dll = BugDll.decode(dll)
     if self.isDllOkay(element, dll):
         BugUtil.callFunction(module, clazz, CvEventInterface.getEventManager(), *element.args, **element.kwargs)
     else:
         BugUtil.info(
             "BugConfig - ignoring <%s> from %s.%s, requires dll version %s",
             element.tag,
             module,
             clazz,
             self.resolveDll(element, dll),
         )
Пример #19
0
 def handle(self, element, type, module, function, dll):
     dll = BugDll.decode(dll)
     if self.isDllOkay(element, dll):
         CvEventInterface.getEventManager().addEventHandler(
             type, BugUtil.getFunction(module, function, True, *element.args, **element.kwargs)
         )
     else:
         BugUtil.info(
             "BugConfig - ignoring <%s> %s, requires dll version %s",
             element.tag,
             type,
             self.resolveDll(element, dll),
         )
Пример #20
0
	def handle(self, element, id, name, fromKey, offset, dll):
		dll = BugDll.decode(dll)
		if self.isDllOkay(element, dll):
			if not fromKey:
				if not self.lastSymbol:
					raise BugUtil.ConfigError("<%s> %s requires an offset symbol" % (element.tag, id))
				fromKey = self.lastSymbol
			if offset is None:
				offset = 1
			else:
				offset = int(offset)
			self.lastSymbol = addOffsetSymbol(id, fromKey, offset, name)
		else:
			BugUtil.info("FontUtil - ignoring <%s> %s, requires dll version %s", element.tag, id, self.resolveDll(element, dll))
Пример #21
0
 def handle(self, element, module, clazz, handlers, listeners, override,
            log, dll):
     override = self.isTrue(override)
     dll = BugDll.decode(dll)
     if self.isDllOkay(element, dll):
         if clazz:
             utils = BugUtil.callFunction(module, clazz)
             element.setState("gameutils", utils)
             if handlers or listeners:
                 if handlers:
                     for handler in handlers.replace(",", " ").split():
                         addHandler(BugUtil.bindFunction(utils, handler),
                                    override, log)
                 if listeners:
                     for listener in listeners.replace(",", " ").split():
                         func = None
                         if not listener.endswith(LISTENER_SUFFIX):
                             try:
                                 func = BugUtil.bindFunction(
                                     utils, listener + LISTENER_SUFFIX)
                             except BugUtil.ConfigError:
                                 pass
                         if not func:
                             try:
                                 func = BugUtil.bindFunction(
                                     utils, listener)
                             except BugUtil.ConfigError:
                                 raise BugUtil.ConfigError(
                                     "Game utils %s.%s must define function %s or %s",
                                     module, clazz, listener,
                                     listener + "Listener")
                         addListener(func, log)
             else:
                 addClassUtils(utils, override, log)
         else:
             if handlers or listeners:
                 if handlers:
                     for handler in handlers.replace(",", " ").split():
                         addHandler(BugUtil.lookupFunction(module, handler),
                                    override, log)
                 if listeners:
                     for listener in listeners.replace(",", " ").split():
                         addListener(
                             BugUtil.lookupFunction(module, listener), log)
             else:
                 addModuleUtils(BugUtil.lookupModule(module), override, log)
     else:
         BugUtil.info(
             "BugGameUtils - ignoring <%s> %s.%s, requires dll version %s",
             element.tag, module, clazz, self.resolveDll(element, dll))
Пример #22
0
    def onLoadGame(self, argsList):
        """
		Load saved reminders.
		"""
        self.clearReminders()
        queues = SdToolKit.sdGetGlobal(SD_MOD_ID, SD_QUEUES_ID)
        if queues:
            self.setReminders(queues)
        else:
            # check for old save format (single queue)
            queue = SdToolKit.sdGetGlobal(SD_MOD_ID, SD_QUEUE_ID)
            if queue:
                BugUtil.info("Reminder - Converting single-queue format")
                self.setReminders(Reminders(queue))
                SdToolKit.sdDelGlobal(SD_MOD_ID, SD_QUEUE_ID)
	def onLoadGame(self, argsList):
		"""
		Load saved reminders.
		"""
		self.clearReminders()
		queues = SdToolKit.sdGetGlobal(SD_MOD_ID, SD_QUEUES_ID)
		if queues:
			self.setReminders(queues)
		else:
			# check for old save format (single queue)
			queue = SdToolKit.sdGetGlobal(SD_MOD_ID, SD_QUEUE_ID)
			if queue:
				BugUtil.info("Reminder - Converting single-queue format")
				self.setReminders(Reminders(queue))
				SdToolKit.sdDelGlobal(SD_MOD_ID, SD_QUEUE_ID)
Пример #24
0
def init():
	"""
	Checks for the presence of the BUG DLL and grabs its Python API version if found.
	"""
	try:
		if gc.isBull():
			global IS_PRESENT, VERSION
			IS_PRESENT = True
			VERSION = gc.getBullApiVersion()
			BugUtil.info("BugDll - %s %s, API version %d", gc.getBullName(), gc.getBullVersion(), VERSION)
			if hasattr(CyGlobalContext, "setIsBug"):
				import BugInit
				BugInit.addInit("setIsBug", setIsBug)
			else:
				BugUtil.debug("BugDll - setIsBug() not found")
	except:
		BugUtil.debug("BugDll - BULL not present")
Пример #25
0
def createWidget(name):
	"""
	Creates and returns the next unique WidgetTypes constant to be used with custom UI widgets.
	
	If <name> already exists, a warning is logged and the widget is returned.
	Otherwise the new widget is assigned to WidgetTypes.<name> and returned.
	"""
	if hasattr(WidgetTypes, name):
		BugUtil.warn("WidgetTypes.%s already exists", name)
		return getattr(WidgetTypes, name)
	else:
		global g_nextWidget
		BugUtil.info("WidgetUtil - WidgetTypes.%s = %d", name, g_nextWidget)
		widget = WidgetTypes(g_nextWidget)
		setattr(WidgetTypes, name, widget)
		g_nextWidget += 1
		return widget
Пример #26
0
def createWidget(name):
	"""
	Creates and returns the next unique WidgetTypes constant to be used with custom UI widgets.
	
	If <name> already exists, a warning is logged and the widget is returned.
	Otherwise the new widget is assigned to WidgetTypes.<name> and returned.
	"""
	if hasattr(WidgetTypes, name):
		BugUtil.warn("WidgetTypes.%s already exists", name)
		return getattr(WidgetTypes, name)
	else:
		global g_nextWidget
		BugUtil.info("WidgetUtil - WidgetTypes.%s = %d", name, g_nextWidget)
		widget = WidgetTypes(g_nextWidget)
		setattr(WidgetTypes, name, widget)
		g_nextWidget += 1
		return widget
Пример #27
0
def init():
    """
	Checks for the presence of the BUG DLL and grabs its Python API version if found.
	"""
    try:
        if gc.isBull():
            global IS_PRESENT, VERSION
            IS_PRESENT = True
            VERSION = gc.getBullApiVersion()
            BugUtil.info("BugDll - %s %s, API version %d", gc.getBullName(),
                         gc.getBullVersion(), VERSION)
            if hasattr(CyGlobalContext, "setIsBug"):
                import BugInit
                BugInit.addInit("setIsBug", setIsBug)
            else:
                BugUtil.debug("BugDll - setIsBug() not found")
    except:
        BugUtil.debug("BugDll - BULL not present")
Пример #28
0
	def handle(self, element, name, type, default, module, handler, listener, log, dll):
		dll = BugDll.decode(dll)
		if self.isDllOkay(element, dll):
			utils = element.getState("gameutils")
			if utils:
				func = BugUtil.bindFunction(utils, handler)
				if listener:
					listenerFunc = BugUtil.bindFunction(utils, listener)
			elif not module:
				raise BugUtil.ConfigError("Element <%s> requires attribute module or be enclosed in <gameutils> that defines a class", element.tag)
			else:
				func = BugUtil.lookupFunction(module, handler)
				if listener:
					listenerFunc = BugUtil.lookupFunction(module, listener)
			createCallback(name, func, self.createValue(type, default), log)
			if listener:
				addNamedListener(name, listenerFunc, log)
		else:
			BugUtil.info("BugGameUtils - ignoring <%s> %s, requires dll version %s", element.tag, name, self.resolveDll(element, dll))
Пример #29
0
	def handle(self, element, module, clazz, handlers, listeners, override, log, dll):
		override = self.isTrue(override)
		dll = BugDll.decode(dll)
		if self.isDllOkay(element, dll):
			if clazz:
				utils = BugUtil.callFunction(module, clazz)
				element.setState("gameutils", utils)
				if handlers or listeners:
					if handlers:
						for handler in handlers.replace(",", " ").split():
							addHandler(BugUtil.bindFunction(utils, handler), override, log)
					if listeners:
						for listener in listeners.replace(",", " ").split():
							func = None
							if not listener.endswith(LISTENER_SUFFIX):
								try:
									func = BugUtil.bindFunction(utils, listener + LISTENER_SUFFIX)
								except BugUtil.ConfigError:
									pass
							if not func:
								try:
									func = BugUtil.bindFunction(utils, listener)
								except BugUtil.ConfigError:
									raise BugUtil.ConfigError("Game utils %s.%s must define function %s or %s", 
											module, clazz, listener, listener + "Listener")
							addListener(func, log)
				else:
					addClassUtils(utils, override, log)
			else:
				if handlers or listeners:
					if handlers:
						for handler in handlers.replace(",", " ").split():
							addHandler(BugUtil.lookupFunction(module, handler), override, log)
					if listeners:
						for listener in listeners.replace(",", " ").split():
							addListener(BugUtil.lookupFunction(module, listener), log)
				else:
					addModuleUtils(BugUtil.lookupModule(module), override, log)
		else:
			BugUtil.info("BugGameUtils - ignoring <%s> %s.%s, requires dll version %s", element.tag, module, clazz, self.resolveDll(element, dll))
Пример #30
0
def onCombatResult(argsList):
    CyUnitW, CyUnitL = argsList

    # Captives
    # Check that the losing unit is not an animal and the unit does not have a capture type defined in the XML
    if (CyUnitW.isMadeAttack() and not CyUnitL.isAnimal()
            and CyUnitL.getDomainType() == giDomainLand
            and CyUnitW.getDomainType() == giDomainLand
            and CyUnitL.getCaptureUnitType() == -1):
        iCaptureProbability = CyUnitW.captureProbabilityTotal()
        iCaptureResistance = CyUnitL.captureResistanceTotal()
        iChance = iCaptureProbability - iCaptureResistance
        BugUtil.info(
            "CaptureSlaves: Chance to capture a captive is %d (%d - %d)",
            iChance, iCaptureProbability, iCaptureResistance)

        if iChance > GAME.getSorenRandNum(100, "Slave"):  # 0-99

            if CyUnitL.isHasUnitCombat(
                    GC.getInfoTypeForString('UNITCOMBAT_SPECIES_NEANDERTHAL')):
                iUnit = GC.getInfoTypeForString('UNIT_CAPTIVE_NEANDERTHAL')
                sMessage = TRNSLTR.getText("TXT_KEY_MSG_NEANDERTHAL_CAPTIVE",
                                           ())
            else:
                iUnit = GC.getInfoTypeForString('UNIT_CAPTIVE_MILITARY')
                sMessage = TRNSLTR.getText("TXT_KEY_MSG_MILITARY_CAPTIVE", ())

            iPlayerW = CyUnitW.getOwner()
            X = CyUnitW.getX()
            Y = CyUnitW.getY()
            CyUnit = GC.getPlayer(iPlayerW).initUnit(
                iUnit, X, Y, UnitAITypes.NO_UNITAI,
                DirectionTypes.NO_DIRECTION)
            if CyUnitW.isHiddenNationality():
                CyUnit.doHNCapture()
            if iPlayerW == GAME.getActivePlayer():
                CvUtil.sendMessage(sMessage, iPlayerW, 8,
                                   'Art/Interface/Buttons/Civics/Serfdom.dds',
                                   ColorTypes(44), X, Y, True, True)
Пример #31
0
Файл: Buffy.py Проект: AP-ML/DTM
def init():
    """
	Checks for the presence of the BUFFY DLL and sets the global flags.
	"""
    if isEnabled():
        if BugPath.isMac():
            BugUtil.debug("BUFFY is not active on Mac (no DLL)")
        else:
            try:
                if gc.isBuffy():
                    global IS_DLL_PRESENT, IS_DLL_IN_CORRECT_PATH, IS_ACTIVE
                    IS_DLL_PRESENT = True
                    IS_ACTIVE = True
                    BugUtil.info("BUFFY is active (API version %d)", gc.getBuffyApiVersion())
                    try:
                        dllPath = gc.getGame().getDLLPath()
                        exePath = gc.getGame().getExePath()
                        dllPathThenUp3 = os.path.dirname(os.path.dirname(os.path.dirname(dllPath)))
                        if dllPathThenUp3 == exePath:
                            IS_DLL_IN_CORRECT_PATH = True
                    except:
                        pass  # DLL path is borked
            except:
                BugUtil.info("BUFFY is not active (no DLL)")
Пример #32
0
	def isReplayWinner(self, replay):
		szWinText = localText.getText("TXT_KEY_GAME_WON", ("(.*)", "(.*)"))
		reWinText = re.compile(szWinText)
		leaderGroup = 1
		typeGroup = 2
		leader = replay.getLeaderName()
		msgNum = replay.getNumReplayMessages() - 1
		BugUtil.debug("scanning replay for %s with %d msgs", leader, msgNum + 1)
		count = 0
		while msgNum >= 0:
			msg = replay.getReplayMessageText(msgNum)
			if count > 100:
				BugUtil.debug("no victory message in first 100; skipping")
				break
			matches = reWinText.match(msg)
			if matches:
				type = matches.group(typeGroup)
				if leader in matches.group(leaderGroup).split('/'):
					BugUtil.info("replay: %s win for %s", type, leader)
					return True, type
				BugUtil.info("replay: %s loss for %s", type, leader)
				return False, type
			msgNum -= 1
		return False, localText.getText("TXT_KEY_NONE", ())
Пример #33
0
	def handle(self, element, keys, module, function, dll):
		dll = BugDll.decode(dll)
		if self.isDllOkay(element, dll):
			CvEventInterface.getEventManager().addShortcutHandler(keys, BugUtil.getFunction(module, function, *element.args, **element.kwargs))
		else:
			BugUtil.info("InputUtil - ignoring <%s> %s, requires dll version %s", element.tag, keys, self.resolveDll(element, dll))
Пример #34
0
def safeInfoPath(message, path):
    try:
        BugUtil.info(message, path)
    except:
        pass
Пример #35
0
def safeInfoPath(message, path):
    try:
        BugUtil.info(message, path)
    except:
        pass