moopoo
King
Hey I keep reading in the codes you put up, "arglist". What's an Arglist?
As Aussie said, it is an "argument list". It is similar to argument unpacking, except what Firaxis did was define each function as accepting a single argument, a list, which contains all of the real arguments.Hey I keep reading in the codes you put up, "arglist". What's an Arglist?
def cannotTrain(pCity, eUnit, bContinue, bTestVisible):
# do something
return False
# And would call the function like this
if cannotTrain(pCity, eUnit, bContinue, bTestVisible):
pass
def cannotTrain(argsList):
pCity = argsList[0]
eUnit = argsList[1]
bContinue = argsList[2]
bTestVisible = argsList[3]
# do something
return False
# And would call the function like this
# Pack the list first
argsList = (pCity, eUnit, bContinue, bTestVisible)
# Then call it
if cannotTrain(argsList):
pass
def cannotTrain(argsList):
pCity, eUnit, bContinue, bTestVisible = argsList
# do something
return False
def blah(*lArgs):
pass
def betaReligion1(argsList):
# CyInterface().addImmediateMessage("betaReligion1 function called", "")
kTriggeredData = argsList[1]
player = gc.getPlayer(kTriggeredData.ePlayer)
game = gc.getGame()
ifailuretest = game.getSorenRandNum(100, "")
if ifailuretest < 70:
(loopCity, iter) = player.firstCity(false)
while(loopCity):
loopCity.changeHurryAngerTimer(10)
(loopCity, iter) = player.nextCity(iter, false)
messagestring = "Our suppression of this dangerous cult has been successfull."
CyInterface().addMessage(kTriggeredData.ePlayer, false, gc.getEVENT_MESSAGE_TIME(), messagestring, "", InterfaceMessageTypes.MESSAGE_TYPE_INFO, None, gc.getInfoTypeForString("COLOR_WHITE"), -1, -1, true, true)
# CyInterface().addImmediateMessage("Our suppression of this dangerous cult has been successfull.", "")
return
unfounded = []
for iReligion in range(gc.getNumReligionInfos()):
if not game.isReligionFounded(iReligion):
unfounded.append(iReligion)
if len(unfounded) > 0:
unfounded.sort()
ifound = unfounded[0]
player.foundReligion(ifound, ifound, True)
(loopCity, iter) = player.firstCity(false)
while(loopCity):
loopCity.changeHurryAngerTimer(10)
loopCity.changeHurryAngerTimer(10)
(loopCity, iter) = player.nextCity(iter, false)
messagestring = "Our failed attempt to suppress this budding new religion has caused widespread unhappiness."
CyInterface().addMessage(kTriggeredData.ePlayer, false, gc.getEVENT_MESSAGE_TIME(), messagestring, "", InterfaceMessageTypes.MESSAGE_TYPE_INFO, None, gc.getInfoTypeForString("COLOR_WHITE"), -1, -1, true, true)
# CyInterface().addImmediateMessage("Our failed attempt to suppress this budding new religion has caused widespread unhappiness.", "")
return
messagestring = "Extreme measures have proved unnecessary. The new sect has failed to gain a widespread following, it is already fading into obscurity."
CyInterface().addMessage(kTriggeredData.ePlayer, false, gc.getEVENT_MESSAGE_TIME(), messagestring, "", InterfaceMessageTypes.MESSAGE_TYPE_INFO, None, gc.getInfoTypeForString("COLOR_WHITE"), -1, -1, true, true)
return
def betaReligion2(argsList):
# CyInterface().addImmediateMessage("betaReligion2 function called", "")
kTriggeredData = argsList[1]
player = gc.getPlayer(kTriggeredData.ePlayer)
game = gc.getGame()
ifailuretest = game.getSorenRandNum(100, "")
if ifailuretest < 20:
messagestring = "The new sect has failed to gain a widespread following. It is already fading into obscurity."
CyInterface().addMessage(kTriggeredData.ePlayer, false, gc.getEVENT_MESSAGE_TIME(), messagestring, "", InterfaceMessageTypes.MESSAGE_TYPE_INFO, None, gc.getInfoTypeForString("COLOR_WHITE"), -1, -1, true, true)
# CyInterface().addImmediateMessage("The new sect has failed to gain a widespread following. It is already fading into obscurity.", "")
return
unfounded = []
for iReligion in range(gc.getNumReligionInfos()):
if not game.isReligionFounded(iReligion):
unfounded.append(iReligion)
if len(unfounded) > 0:
unfounded.sort()
ifound = unfounded[0]
player.foundReligion(ifound, ifound, True)
(loopCity, iter) = player.firstCity(false)
while(loopCity):
loopCity.changeHappinessTimer(10)
(loopCity, iter) = player.nextCity(iter, false)
messagestring = "The new sect is rapidly gaining a widespread following. The people are gratefull for your tolerence."
CyInterface().addMessage(kTriggeredData.ePlayer, false, gc.getEVENT_MESSAGE_TIME(), messagestring, "", InterfaceMessageTypes.MESSAGE_TYPE_INFO, None, gc.getInfoTypeForString("COLOR_WHITE"), -1, -1, true, true)
# CyInterface().addImmediateMessage("The new sect is rapidly gaining a widespread following. The people are gratefull for your tolerence.", "")
return
messagestring = "The new sect has failed to gain a widespread following. It is already fading into obscurity."
CyInterface().addMessage(kTriggeredData.ePlayer, false, gc.getEVENT_MESSAGE_TIME(), messagestring, "", InterfaceMessageTypes.MESSAGE_TYPE_INFO, None, gc.getInfoTypeForString("COLOR_WHITE"), -1, -1, true, true)
return
def betaReligion3(argsList):
# CyInterface().addImmediateMessage("betaReligion3 function called", "")
kTriggeredData = argsList[1]
player = gc.getPlayer(kTriggeredData.ePlayer)
game = gc.getGame()
# player.changeGold(-10)
ifailuretest = game.getSorenRandNum(100, "")
if ifailuretest < 10:
messagestring = "Despite our support, the new sect has failed to gain a widespread following. It is already fading into obscurity"
CyInterface().addMessage(kTriggeredData.ePlayer, false, gc.getEVENT_MESSAGE_TIME(), messagestring, "", InterfaceMessageTypes.MESSAGE_TYPE_INFO, None, gc.getInfoTypeForString("COLOR_WHITE"), -1, -1, true, true)
# CyInterface().addImmediateMessage("Despite our support, the new sect has failed to gain a widespread following. It is already fading into obscurity", "")
return
unfounded = []
for iReligion in range(gc.getNumReligionInfos()):
if not game.isReligionFounded(iReligion):
unfounded.append(iReligion)
if len(unfounded) > 0:
unfounded.sort()
ifound = unfounded[0]
player.foundReligion(ifound, ifound, True)
(loopCity, iter) = player.firstCity(false)
while(loopCity):
# loopCity.changeExtraHappiness(2)
loopCity.changeHappinessTimer(20)
(loopCity, iter) = player.nextCity(iter, false)
messagestring = "Your generous support for this budding new religion has met with widespread approval. Our people's spiritual lives will be greatly enhanced by this flourishing new faith."
CyInterface().addMessage(kTriggeredData.ePlayer, false, gc.getEVENT_MESSAGE_TIME(), messagestring, "", InterfaceMessageTypes.MESSAGE_TYPE_INFO, None, gc.getInfoTypeForString("COLOR_WHITE"), -1, -1, true, true)
# CyInterface().addImmediateMessage("Your generous support for this budding new religion has met with widespread approval. Our people's spiritual lives will be greatly enhanced by this flourishing new faith.", "")
return
messagestring = "Despite our support, the new sect has failed to gain a widespread following. It is already fading into obscurity."
CyInterface().addMessage(kTriggeredData.ePlayer, false, gc.getEVENT_MESSAGE_TIME(), messagestring, "", InterfaceMessageTypes.MESSAGE_TYPE_INFO, None, gc.getInfoTypeForString("COLOR_WHITE"), -1, -1, true, true)
return