Hi everybody, looking for some advice on a couple of functions I would like to adapt for my Mod.
These relate to Nuclear Weapons, I want to make it a more complex process to be able to build Nukes. Part of this process is to have two projects each which, at the moment, enable a building for all players but I want to make it so the projects enable the buildings for team players instead.
So using snapple232's Team Manhattan Project mod I can have nukes enabled only if a team builds the project and for the buildings I have added code that is adapted from the mod. I'm going to test this, but its quite complex to set up a test so I want to ask if you can see any obvious syntax error with it?
I also want to bring in a vote to have Nuclear Weapons scraped, so that if passed all nukes that have been built, will be removed for the game. I don't want to have a vote that stops you building nukes though. So I've adapted JoshW's True Disarmament Mod using just a part of it. So again can you see any errors and a secondary question once the vote is passed and the world is free of nukes will players be able to build more weapons? the vanilla vote to ban nukes is disabled in the xml by setting the bvalid tag to 0 (I don't know if that will effect my new abolish nukes vote or not)
(this is the code I adapted)
These relate to Nuclear Weapons, I want to make it a more complex process to be able to build Nukes. Part of this process is to have two projects each which, at the moment, enable a building for all players but I want to make it so the projects enable the buildings for team players instead.
So using snapple232's Team Manhattan Project mod I can have nukes enabled only if a team builds the project and for the buildings I have added code that is adapted from the mod. I'm going to test this, but its quite complex to set up a test so I want to ask if you can see any obvious syntax error with it?
Spoiler :
Code:
def cannotConstruct(self,argsList):
pCity = argsList[0]
eBuilding = argsList[1]
bContinue = argsList[2]
bTestVisible = argsList[3]
bIgnoreCost = argsList[4]
iPlayer = gc.getPlayer(pCity.getOwner())
iTeam = gc.getTeam(pCity.getTeam())
if eBuilding == gc.getInfoTypeForString("BUILDING_THORP") or eBuilding == gc.getInfoTypeForString("BUILDING_NUCLEAR_TEST_SITE"):
if iTeam.getProjectCount(gc.getInfoTypeForString("PROJECT_MANHATTAN_PROJECT")) == false:
if iTeam.getProjectCount(gc.getInfoTypeForString("PROJECT_HYDROGEN_BOMB")) == false:
return True
return False
I also want to bring in a vote to have Nuclear Weapons scraped, so that if passed all nukes that have been built, will be removed for the game. I don't want to have a vote that stops you building nukes though. So I've adapted JoshW's True Disarmament Mod using just a part of it. So again can you see any errors and a secondary question once the vote is passed and the world is free of nukes will players be able to build more weapons? the vanilla vote to ban nukes is disabled in the xml by setting the bvalid tag to 0 (I don't know if that will effect my new abolish nukes vote or not)
(this is the code I adapted)
Spoiler :
Code:
class CvGameUtils:
"Miscellaneous game functions"
def __init__(self):
self.m_dResolutionUnitAbol = {
gc.getInfoTypeForString("VOTE_ABOL_NUKES") : ("UNIT_ICBM","UNIT_TACTICAL_NUKE")
}
Spoiler :
Code:
def canTrain(self,argsList):
pCity = argsList[0]
eUnit = argsList[1]
bContinue = argsList[2]
bTestVisible = argsList[3]
if not bTestVisible:
for iVote in range(gc.getNumVoteInfos()):
if gc.getGame().isVotePassed(iVote):
if self.m_dResolutionUnitAbol.has_key(iVote):
for iLoopPlayer in range(gc.getMAX_PLAYERS()):
if (gc.getPlayer(iLoopPlayer).isAlive() and not gc.getPlayer(iLoopPlayer).isBarbarian()):
for szAbolishedUnit in self.m_dResolutionUnitAbol[iVote]:
killList = PyPlayer(iLoopPlayer).getUnitsOfType(gc.getInfoTypeForString(szAbolishedUnit))
for pUnit in killList:
pUnit.kill(true, iLoopPlayer)
return True
return False