BTS: UI mod -- Power

codetoad

Chieftain
Joined
Jul 23, 2006
Messages
21
Can anyone help. I would like to mode the Main ui player score section to show each player power rating along with score etc (subject to espionage ability).

Can this be done? Any suggestions on where to start?


codeoad
 
The scoreboard is in CvMainInterface.py. I'm not sure what level of experience you have, so ask questions if you need clarification.

You'll need to add Python code to that file. You can certainly get a player's power -- CyPlayer.getPower() -- and you can see which player's allow you to get their power rating. Sample code is in CvInfoScreen, where it determines which civs to put into the dropdown on the graph.

Code:
for iMissionLoop in range(gc.getNumEspionageMissionInfos()):
	if (gc.getEspionageMissionInfo(iMissionLoop).isSeeDemographics()):
		iDemographicsMission = iMissionLoop

...

if (self.pActivePlayer.canDoEspionageMission(iDemographicsMission, iLoopPlayer, NULL_PLOT, -1)):

The first chunk determines which of the espionage missions is the right one. The last line checks if the active player -- the human -- can do that mission.

I like this idea. I'll see if I can do it right now. My CvMainInterface.py is in a modified state as it is, so you'll need to test it yourself. :) Besides, Zebra9 will probably beat me to it. :p
 
As a variation on this idea, how about having the scoreboard alternate between showing/sorting by score and power rating. So it shows the scores of all players for a few seconds, then it resorts and shows the power ratings of those players you can see, leaving the others at the bottom or invisible, whatever.

My reasoning is that while the power value is handy, it's also your rank within the graph that is important. I guess it could instead just show your value and rank -- e.g.

3724: Xerxes (#2 362) ...
2950: Amadeus (#1 428) ...

Thoughts?
 
Here's an untested stab at the simple method. You'll need to copy CvMainInterface.py from the Assets\Python\Screens directory in your BtS install folder to the same place in Custom Assets in your My Games\BtS directory. Then modify the copy.

There are two blocks of code to insert, delineated below using "# BUG ..." comments. Look for the surrounding code to find where to insert.

Around line 2888:

Code:
		if ((CyInterface().getShowInterface() != InterfaceVisibility.INTERFACE_HIDE_ALL and CyInterface().getShowInterface() != InterfaceVisibility.INTERFACE_MINIMAP_ONLY)):
			if (CyInterface().isScoresVisible() and not CyInterface().isCityScreenUp() and CyEngine().isGlobeviewUp() == false):

# BUG - Power Rating - start
				NULL_PLOT = CyMap().plot(-1,-1) # used below in canDoEspionageMission()
				iDemographicsMission = -1
				for iMissionLoop in range(gc.getNumEspionageMissionInfos()):
					if (gc.getEspionageMissionInfo(iMissionLoop).isSeeDemographics()):
						iDemographicsMission = iMissionLoop
						break
# BUG - Power Rating - end

				i = gc.getMAX_CIV_TEAMS() - 1
				while (i > -1):

Around line 2967:

Code:
										if (((gc.getPlayer(ePlayer).getTeam() == gc.getGame().getActiveTeam()) and (gc.getTeam(gc.getGame().getActiveTeam()).getNumMembers() > 1)) or (gc.getTeam(gc.getPlayer(ePlayer).getTeam()).isVassal(gc.getGame().getActiveTeam())) or gc.getGame().isDebugMode() or bEspionageCanSeeResearch):
											if (gc.getPlayer(ePlayer).getCurrentResearch() != -1):
												szTempBuffer = u"-%s (%d)" %(gc.getTechInfo(gc.getPlayer(ePlayer).getCurrentResearch()).getDescription(), gc.getPlayer(ePlayer).getResearchTurnsLeft(gc.getPlayer(ePlayer).getCurrentResearch(), True))
												szBuffer = szBuffer + szTempBuffer
										
# BUG - Power Rating - start
										if (iDemographicsMission != -1
											and gc.getActivePlayer().canDoEspionageMission(iDemographicsMission, ePlayer, NULL_PLOT, -1)):
											iPower = gc.getPlayer(ePlayer).getPower()
											cPower = gc.getGame().getSymbolID(FontSymbols.STRENGTH_CHAR)
											szTempBuffer = u"-%d%c" %(iPower, cPower)
											szBuffer = szBuffer + szTempBuffer
# BUG - Power Rating - end
										
										if (CyGame().isNetworkMultiPlayer()):
											szBuffer = szBuffer + CyGameTextMgr().getNetStats(ePlayer)

I say "around" because I have already modified my file with other changes. Just use "find" command.
 
When I tried that the entire score when away. I took a look at the surrounding code and came up with this single snippet. It seem to be working.

Code:
									if (((gc.getPlayer(ePlayer).getTeam() == gc.getGame().getActiveTeam()) and (gc.getTeam(gc.getGame().getActiveTeam()).getNumMembers() > 1)) or (gc.getTeam(gc.getPlayer(ePlayer).getTeam()).isVassal(gc.getGame().getActiveTeam())) or gc.getGame().isDebugMode() or bEspionageCanSeeResearch):
											if (gc.getPlayer(ePlayer).getCurrentResearch() != -1):
												szTempBuffer = u"-%s (%d)" %(gc.getTechInfo(gc.getPlayer(ePlayer).getCurrentResearch()).getDescription(), gc.getPlayer(ePlayer).getResearchTurnsLeft(gc.getPlayer(ePlayer).getCurrentResearch(), True))
												szBuffer = szBuffer + szTempBuffer

# BUG - Power Rating - start
										bExpionageCanSeePower = false
										for iMissionLoop in range(gc.getNumEspionageMissionInfos()):
											if (gc.getEspionageMissionInfo(iMissionLoop).isSeeDemographics()):
												bExpionageCanSeePower = gc.getPlayer(gc.getGame().getActivePlayer()).canDoEspionageMission(iMissionLoop, ePlayer, CyMap().plot(-1,-1), -1)
												break

										if (((gc.getPlayer(ePlayer).getTeam() == gc.getGame().getActiveTeam())
											and (gc.getTeam(gc.getGame().getActiveTeam()).getNumMembers() > 1))
											or (gc.getTeam(gc.getPlayer(ePlayer).getTeam()).isVassal(gc.getGame().getActiveTeam()))
											or gc.getGame().isDebugMode()
											or gc.getPlayer(ePlayer).isHuman()
											or bExpionageCanSeePower):
											iPower = gc.getPlayer(ePlayer).getPower()
											cPower = gc.getGame().getSymbolID(FontSymbols.STRENGTH_CHAR)
											szTempBuffer = u"-%d%c" %(iPower, cPower)
											szBuffer = szBuffer + szTempBuffer
# BUG - Power Rating - end

										if (CyGame().isNetworkMultiPlayer()):
											szBuffer = szBuffer + CyGameTextMgr().getNetStats(ePlayer)

Thanks for all the help. I welcome any comments on the changes I made.
 
I just had a chance to test it, and there indeed is a bug in it. In the game most objects have both an integer representation (player #, tech ID, city ID, etc) and an object (CyPlayer, CyCity, TechInfo). Unfortunately, the game's APIs make it easy to mix up.

gc.getGame().getActivePlayer() -> player #
gc.getActivePlayer() -> CyPlayer

The only change that should be necessary (as it fixed for me) is to change

Code:
bExpionageCanSeePower = gc.getGame().getActivePlayer().canDoEspionageMission(...)

to

Code:
bExpionageCanSeePower = gc.getActivePlayer().canDoEspionageMission(...)

But if yours works, why change it? :) I'll edit my post above for others.
 
Back
Top Bottom