本文整理汇总了Python中CvEventInterface类的典型用法代码示例。如果您正苦于以下问题:Python CvEventInterface类的具体用法?Python CvEventInterface怎么用?Python CvEventInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CvEventInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onLoad
def onLoad(argsList):
'Called when a file is loaded'
import pickle
import CvEventInterface
loadDataStr=argsList[0]
if len(loadDataStr):
CvEventInterface.onEvent( ('OnLoad',pickle.loads(loadDataStr),0,0,0,0,0 ) )
示例2: doHotSeatCheck
def doHotSeatCheck(args):
"""
Called during EndPlayerTurn, fires SwitchHotSeatPlayer event during a hot seat
game when the active player's turn ends.
"""
iGameTurn, ePlayer = args
game = gc.getGame()
if game.isHotSeat() and ePlayer == game.getActivePlayer():
CvEventInterface.getEventManager().fireEvent("SwitchHotSeatPlayer", ePlayer)
示例3: handle
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),
)
示例4: calculateScore
def calculateScore(self,argsList):
ePlayer = argsList[0]
bFinal = argsList[1]
bVictory = argsList[2]
FinalFrontier = CvEventInterface.getEventManager().FinalFrontier
iMaxPopulation = FinalFrontier.iMaxPopulation
iPopulationScore = CvUtil.getScoreComponent(gc.getPlayer(ePlayer).getPopScore(), gc.getGame().getInitPopulation(), iMaxPopulation, gc.getDefineINT("SCORE_POPULATION_FACTOR"), True, bFinal, bVictory)
printd("Pop Score Stuff")
printd(gc.getPlayer(ePlayer).getPopScore())
printd(gc.getGame().getInitPopulation())
printd(iMaxPopulation)
printd(iPopulationScore)
iPlayerLandScore = gc.getPlayer(ePlayer).getTotalLand()
iLandScore = CvUtil.getScoreComponent(iPlayerLandScore , gc.getGame().getInitLand(), gc.getGame().getMaxLand(), gc.getDefineINT("SCORE_LAND_FACTOR"), True, bFinal, bVictory)
printd("Land Score Stuff")
printd(iPlayerLandScore)
printd(gc.getGame().getInitLand())
printd(gc.getGame().getMaxLand())
printd(iLandScore)
iTechScore = CvUtil.getScoreComponent(gc.getPlayer(ePlayer).getTechScore(), gc.getGame().getInitTech(), gc.getGame().getMaxTech(), gc.getDefineINT("SCORE_TECH_FACTOR"), True, bFinal, bVictory)
iWondersScore = CvUtil.getScoreComponent(gc.getPlayer(ePlayer).getWondersScore(), gc.getGame().getInitWonders(), gc.getGame().getMaxWonders(), gc.getDefineINT("SCORE_WONDER_FACTOR"), False, bFinal, bVictory)
iTotalScore = int(iLandScore + iWondersScore + iTechScore + iPopulationScore)
printd("Player %d Score: %d Pop: %d Land: %d Tech: %d Wonders: %d" %(ePlayer, iTotalScore, iPopulationScore, iLandScore, iTechScore, iWondersScore))
return iTotalScore
示例5: getBuildingCostMod
def getBuildingCostMod(self, argsList):
iPlayer, iCityID, iBuilding = argsList
iCostMod = -1 # Any value > 0 will be used
FinalFrontier = CvEventInterface.getEventManager().FinalFrontier
iCostMod = FinalFrontier.getBuildingCostMod(iPlayer, iCityID, iBuilding)
return iCostMod
示例6: getUnitCostMod
def getUnitCostMod(self, argsList):
iPlayer, iUnit = argsList
iCostMod = -1 # Any value > 0 will be used
FinalFrontier = CvEventInterface.getEventManager().FinalFrontier
iCostMod = FinalFrontier.getUnitCostMod(iPlayer, iUnit)
return iCostMod
示例7: AI_chooseProduction
def AI_chooseProduction(self,argsList):
pCity = argsList[0]
FinalFrontier = CvEventInterface.getEventManager().FinalFrontier
bOverride = FinalFrontier.getAI().doCityAIProduction(pCity)
return bOverride
示例8: onSave
def onSave():
'Here is your chance to save data. This function should return a string'
import CvWBDesc
import pickle
import CvEventInterface
# if the tutorial is active, it will save out the Shown Messages list
saveDataStr = pickle.dumps( CvEventInterface.onEvent( ('OnSave',0,0,0,0,0 ) ) )
return saveDataStr
示例9: preGameStart
def preGameStart():
import CvScreensInterface
# BUG - core - start
import CvEventInterface
CvEventInterface.getEventManager().fireEvent("PreGameStart")
# BUG - core - end
if not CyGame().isPitbossHost():
NiTextOut("Initializing font icons")
# Load dynamic font icons into the icon map
CvUtil.initDynamicFontIcons()
# if not CyGame().isPitbossHost():
# # Preload the tech chooser..., only do this release builds, in debug build we may not be raising the tech chooser
# if (not gc.isDebugBuild()):
# NiTextOut("Preloading tech chooser")
# CvScreensInterface.showTechChooser(argsList)
# CvScreensInterface.techChooser.hideScreen()
NiTextOut("Loading main interface...")
CvScreensInterface.showMainInterface()
示例10: AI_unitUpdate
def AI_unitUpdate(self,argsList):
pUnit = argsList[0]
FinalFrontier = CvEventInterface.getEventManager().FinalFrontier
bOverride = false
# Only do it for actual AI units, not automated human ones
pPlayer = gc.getPlayer(pUnit.getOwner())
if (not pPlayer.isHuman()) and (not pPlayer.isBarbarian()) and pPlayer.isAlive() and (not pUnit.isNone()) and (not pUnit.isDead()):
iConstructShip = gc.getInfoTypeForString(gc.getDefineSTRING("CONSTRUCT_SHIP"))
if (pUnit.getUnitClassType() == iConstructShip):
bOverride = FinalFrontier.getAI().doConstructionShipAI(pUnit)
return bOverride
示例11: onKbdEvent
def onKbdEvent(argsList):
"""
Event handler for keyboard events, checks keys against the hotkey list and opens the screen or closes it on match
"""
eventType, key, mouseX, mouseY, plotX, plotY = argsList
eventManager = CvEventInterface.getEventManager()
if ( eventType == eventManager.EventKeyDown ):
stroke = InputUtil.Keystroke(key, eventManager.bAlt, eventManager.bCtrl, eventManager.bShift)
if stroke in keys:
if overlayScreen.isOpen():
hideOverlayScreen()
else:
showOverlayScreen()
return 1
return 0
示例12: __init__
def __init__(self, game=None, attrs=None):
if game is None:
game = BugCore.game
self.game = game
self.eventManager = CvEventInterface.getEventManager()
self.options = BugOptions.getOptions()
self.optionsScreen = CvScreensInterface.getBugOptionsScreen()
self.attrs = attrs
self.mod = None
self.iniFile = None
self.section = None
self.option = None
self.screen = None
self.symbol = None
示例13: request
def request(self, webserver):
gamedata = createGameData()
newState = not webserver.compareGamedata(gamedata)
# Check if CvGame::doTurn is currently running.
# Try ness for mods without the DLL changes for bGameTurnProcessing
inconsistentState = False
try:
inconsistentState = CvEventInterface.getEventManager(
).bGameTurnProcessing
except AttributeError:
for iPlayer in range(gc.getMAX_CIV_PLAYERS()):
if gc.getPlayer(iPlayer).isTurnActive():
inconsistentState = True
break
except:
pass
# PB.consoleOut("Webupload request %i" % (self.requestCounter,))
self.requestCounter += 1
if (not inconsistentState
and (newState or not self.reduceTraffic or
self.requestCounter % self.reduceFactor == 0)
):
params = urllib.urlencode(
{'action': 'update', 'id': self.gameId,
'pwHash': self.pwHash, 'info':
simplejson.dumps(
{'return': 'ok', 'info': gamedata})})
else:
# Minimal alive message.
gamedataMinimal = {"turnTimer": gamedata.get("turnTimer")}
if gamedata["turnTimer"] == 1:
gamedataMinimal["turnTimerValue"] = gamedata.get(
"turnTimerValue")
params = urllib.urlencode(
{'action': 'update', 'id': self.gameId, 'pwHash': self.pwHash, 'info':
simplejson.dumps(
{'return': 'ok', 'info': gamedataMinimal})})
try:
# f = urllib.urlopen("%s?%s" % (url,params) ) # GET method
urllib.urlopen(self.url, params) # POST method
except:
# PB.consoleOut("Webupload failed")
pass
示例14: canPickPlot
def canPickPlot(self, argsList):
pPlot = argsList[0]
pGodsOfOld=CvEventInterface.getEventManager()
if GodsOfOld.iPushButton == 2:
if pPlot.isCoastalLand():
return true
else:
return false
if GodsOfOld.iPushButton == 3:
if pPlot.isCity():
iCoords = ( pPlot.getX(), pPlot.getY() )
if pGodsOfOld.lPlagueCities.count( iCoords ) == 0:
return true
else:
return false
else:
return false
return true
示例15: handle
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))