Alrik2002
Warlord
Hi,
I´ve merged the agriculture Mod in my Mod. In the CvEventManager get.ActivePlayer is used to send messages. But for multiplayer games every human player would get the message, since everyone is the active player at his computer.
How could I change this so that only the person, which unit has build the improvement will get the message? Alternative it could be the person to which the culture the plot belongs.
Here is the code which is used now, the lines with the messages are red:
Thank you very much!!!
I´ve merged the agriculture Mod in my Mod. In the CvEventManager get.ActivePlayer is used to send messages. But for multiplayer games every human player would get the message, since everyone is the active player at his computer.
How could I change this so that only the person, which unit has build the improvement will get the message? Alternative it could be the person to which the culture the plot belongs.
Here is the code which is used now, the lines with the messages are red:
Code:
def onImprovementBuilt(self, argsList):
'Improvement Built'
iImprovement, iX, iY = argsList
## Terraform Begin (avain)
if(iImprovement==gc.getInfoTypeForString('IMPROVEMENT_FOREST')):
pPlot = CyMap().plot(iX, iY)
pPlot.setBonusType(-1)
## CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'A tree nursery has matured into a Forest!','AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/TerrainFeatures/Forest.dds',ColorTypes(8),iX,iY,True,True)
pPlot.setFeatureType(gc.getInfoTypeForString('FEATURE_FOREST'), 0)
pPlot.setImprovementType(-1)
###neuBeginn Popup1 terraforming
pPlot = CyMap().plot(iX, iY)
if iImprovement == gc.getInfoTypeForString('IMPROVEMENT_LANDAUFSCHUETTUNG'):
pPlot.setPlotType(PlotTypes.PLOT_LAND, True, True)
pPlot.setImprovementType(-1)
iPlayerNum = 0
for iPlayer in range(gc.getMAX_PLAYERS()):
player = gc.getPlayer(iPlayer)
if player.isAlive():
iPlayerNum = iPlayerNum + 1
if player.isHuman():
CyCamera().JustLookAtPlot( CyMap().plot(iX, iY))
popupInfo = CyPopupInfo()
popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
popupInfo.setText(CyTranslator().getText("TXT_KEY_POPUP_SELECT_TERRAINTYPE",()))
popupInfo.setData1(iPlayer)
popupInfo.setData2(iX)
popupInfo.setData3(iY)
popupInfo.setOnClickedPythonCallback("SelectTerrainType")
popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_GRAS", ()), "")
popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_EBENE", ()), "")
popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_WÜSTE", ()), "")
popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_TUNDRA", ()), "")
popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_SCHNEE", ()), "")
popupInfo.addPopup(iPlayer)
###Ende Popup1
pPlot = CyMap().plot(iX, iY)
if iImprovement == gc.getInfoTypeForString('IMPROVEMENT_LANDVERAENDERUNG'):
pPlot.setImprovementType(-1)
iPlayerNum = 0
for iPlayer in range(gc.getMAX_PLAYERS()):
player = gc.getPlayer(iPlayer)
if player.isAlive():
iPlayerNum = iPlayerNum + 1
if player.isHuman():
CyCamera().JustLookAtPlot( CyMap().plot(iX, iY))
popupInfo = CyPopupInfo()
popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
popupInfo.setText(CyTranslator().getText("TXT_KEY_POPUP_SELECT_TERRAINTYPE",()))
popupInfo.setData1(iPlayer)
popupInfo.setData2(iX)
popupInfo.setData3(iY)
popupInfo.setOnClickedPythonCallback("SelectTerrainType")
popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_GRAS", ()), "")
popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_EBENE", ()), "")
popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_WÜSTE", ()), "")
popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_TUNDRA", ()), "")
popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_SCHNEE", ()), "")
popupInfo.addPopup(iPlayer)
###Ende Popups
if iImprovement == gc.getInfoTypeForString('IMPROVEMENT_LANDABTRAGUNG'):
pPlot.setPlotType(PlotTypes.PLOT_OCEAN, True, True)
pPlot.setImprovementType(-1)
if iImprovement == gc.getInfoTypeForString('IMPROVEMENT_PLATTMACHEN'):
pPlot.setPlotType(PlotTypes.PLOT_LAND, True, True)
pPlot.setImprovementType(-1)
###Ende alles
# Aggriculture Mod
# Purpose: Places a agricultural bonus on plot upon worker
# completion of an improvement (Corn, Rice or Wheat)
iPlayerID = gc.getPlayer(CyGame().getActivePlayer()).getID()
player = gc.getPlayer(iPlayerID)
if (iImprovement == gc.getInfoTypeForString('IMPROVEMENT_CORN')) :
pPlot = CyMap().plot(iX, iY)
pPlot.setImprovementType(-1)
pPlot.setBonusType(gc.getInfoTypeForString("BONUS_CORN"))
if (player.isAlive() and player.isHuman()):
[COLOR="Red"]CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'Mais wurde gepflanzt!','AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/general/happy_person.dds',ColorTypes(8),iX,iY,False,False)[/COLOR]
if (iImprovement == gc.getInfoTypeForString('IMPROVEMENT_RICE')) :
pPlot = CyMap().plot(iX, iY)
pPlot.setImprovementType(0)
pPlot.setBonusType(gc.getInfoTypeForString("BONUS_RICE"))
if (player.isAlive() and player.isHuman()):
[COLOR="Red"]CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'Reis wurde gepflanzt!','AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/general/happy_person.dds',ColorTypes(8),iX,iY,False,False)[/COLOR]
if (iImprovement == gc.getInfoTypeForString('IMPROVEMENT_WHEAT')) :
pPlot = CyMap().plot(iX, iY)
pPlot.setImprovementType(0)
pPlot.setBonusType(gc.getInfoTypeForString("BONUS_WHEAT"))
if (player.isAlive() and player.isHuman()):
[COLOR="Red"]CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'Weizen wurde gepflanzt!','AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/general/happy_person.dds',ColorTypes(8),iX,iY,False,False)[/COLOR]
# End Aggriculture Mod
if (not self.__LOG_IMPROVEMENT):
return
CvUtil.pyPrint('Improvement %s was built at %d, %d'
%(PyInfo.ImprovementInfo(iImprovement).getDescription(), iX, iY))
Thank you very much!!!