Is it possible to intercept in python (or SDK) the moment your turn is complete?

Maniac

Apolyton Sage
Joined
Nov 27, 2004
Messages
5,603
Location
Gent, Belgium
You know, when you have moved all your units, when that green circle in the lower right side turns red?

I'd like a sound to play at that moment.

Currently I have:

Code:
	def onEndPlayerTurn(self, argsList):
		'Called at the end of a players turn'
		iGameTurn, iPlayer = argsList

		pPlayer = gc.getPlayer(iPlayer)
		if pPlayer.isHuman():
			CyInterface().playGeneralSound("AS2D_TURN_COMPLETE")

but that plays right AFTER clicking the right circle to end the turn.

OnEndTurnReady doesn't seem to do anything.

Is there a way?
 
Perhaps a work around with CvMainInterface.updateScreen ...
 
Thanks for the hint. I've found this below. Not sure what to do though. Should I insert a sound after END_TURN_OVER_HIGHLIGHT or END_TURN_OVER_DARK, whatever these may exactly mean?

Code:
	# Will update the end Turn Button
	def updateEndTurnButton( self ):

		global g_eEndTurnButtonState
		
		screen = CyGInterfaceScreen( "MainInterface", CvScreenEnums.MAIN_INTERFACE )

		if ( CyInterface().shouldDisplayEndTurnButton() and CyInterface().getShowInterface() == InterfaceVisibility.INTERFACE_SHOW ):
		
			eState = CyInterface().getEndTurnState()
			
			bShow = False
			
			if ( eState == EndTurnButtonStates.END_TURN_OVER_HIGHLIGHT ):
				screen.setEndTurnState( "EndTurnButton", u"Red" )
				bShow = True
			elif ( eState == EndTurnButtonStates.END_TURN_OVER_DARK ):
				screen.setEndTurnState( "EndTurnButton", u"Red" )
				bShow = True
			elif ( eState == EndTurnButtonStates.END_TURN_GO ):
				screen.setEndTurnState( "EndTurnButton", u"Green" )
				bShow = True
			
			if ( bShow ):
				screen.showEndTurn( "EndTurnButton" )
			else:
				screen.hideEndTurn( "EndTurnButton" )
			
			if ( g_eEndTurnButtonState == eState ):
				return
				
			g_eEndTurnButtonState = eState
			
		else:
			screen.hideEndTurn( "EndTurnButton" )

		return 0
 
I don't know , CyInterface is not in the SDK. You should make some tests I think. Just a guess , perhaps it's the difference when you play with time limited turns !?

Tcho !
 
Back
Top Bottom