dacubz145
Deity
thanks 

if CyMap().getMapScriptName () =="1914.CivBeyondSwordWBSave":
if iGameTurn == 3:
iBatmanTeam = -1
iRobinTeam = -1
iSupermanTeam = -1
iSpidermanTeam = -1
iJokerTeam = -1
for iPlayerX in range(gc.getMAX_CIV_PLAYERS()):
pPlayerX = gc.getPlayer(iPlayerX)
if pPlayerX.isAlive():
if pPlayerX.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_TURK"):
iBatmanTeam = pPlayerX.getTeam()
if pPlayerX.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_TURK"):
iRobinTeam = pPlayerX.getTeam()
if pPlayerX.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_ROBIN"):
iSupermanTeam = pPlayerX.getTeam()
if pPlayerX.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_ROBIN"):
iSpidermanTeam = pPlayerX.getTeam()
if pPlayerX.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_ROBIN"):
iJokerTeam = pPlayerX.getTeam()
if iBatmanTeam > -1 and iRobinTeam > -1 and iBatmanTeam != iRobinTeam:
gc.getTeam(iBatmanTeam).declareWar(iRobinTeam)
if iSupermanTeam > -1 and iRobinTeam > -1 and iSupermanTeam != iRobinTeam:
gc.getTeam(iSupermanTeam).declareWar(iRobinTeam)
if iSpidermanTeam > -1 and iRobinTeam > -1 and iSpidermanTeam != iRobinTeam:
gc.getTeam(iSpidermanTeam).declareWar(iRobinTeam)
if iJokerTeam > -1 and iRobinTeam > -1 and iJokerTeam != iRobinTeam:
gc.getTeam(iJokerTeam).declareWar(iRobinTeam)
That makes sence to me, but the part i bolded confuses me a bit. It sounds similar to a switch statement in java, if it is one of those, it will skip the rest. But with elif it does not need to be activated correct? Meaning if i have six civs it checks for, and its not one of those, it will just discount it correct?You can say so, although if there are gonna be alot of players, you might want to use elif in the loop instead of if for all the if statements.
Eg:
if playerX is Chinese:
Batman is playerX
if playerX is Arabian:
Robin is playerX
Change to
if playerX is Chinese:
Batman is playerX
elif playerX is Arabian:
Robin is playerX
Since a player is either Chinese or Arabian, using elif instead of if, if he is Chinese, the rest will be skipped
if CyMap().getMapScriptName () =="1914.CivBeyondSwordWBSave":
if iGameTurn == 10:
iBatmanTeam = -1
iRobinTeam = -1
iSupermanTeam = -1
iSpidermanTeam = -1
iJokerTeam = -1
for iPlayerX in range(gc.getMAX_CIV_PLAYERS()):
pPlayerX = gc.getPlayer(iPlayerX)
if pPlayerX.isAlive():
if pPlayerX.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_TURK"):
iBatmanTeam = pPlayerX.getTeam()
if pPlayerX.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_RUSSIA"):
iRobinTeam = pPlayerX.getTeam()
if pPlayerX.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_SERBIA"):
iSupermanTeam = pPlayerX.getTeam()
if pPlayerX.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_BRITAIN"):
iSpidermanTeam = pPlayerX.getTeam()
if pPlayerX.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_FRANCE"):
iJokerTeam = pPlayerX.getTeam()
if iBatmanTeam > -1 and iRobinTeam > -1 and iBatmanTeam != iRobinTeam:
iBatmanTeam.declareWar(iRobinTeam, True, 5)
if iSupermanTeam > -1 and iRobinTeam > -1 and iSupermanTeam != iRobinTeam:
iSupermanTeam.declareWar(iRobinTeam, True, 5)
if iSpidermanTeam > -1 and iRobinTeam > -1 and iSpidermanTeam != iRobinTeam:
iSpidermanTeam.declareWar(iRobinTeam, True, 5)
if iJokerTeam > -1 and iRobinTeam > -1 and iJokerTeam != iRobinTeam:
iJokerTeam.declareWar(iRobinTeam, True, 5)
Code:def onEndGameTurn(self, argsList): 'Called at the end of the end of each turn' iGameTurn = argsList[0] ## Batman fights Robin ## if CyMap().getMapScriptName () =="1914.CivBeyondSwordWBSave": if iGameTurn == 5: iBatmanTeam = -1 iRobinTeam = -1 for iPlayerX in range(gc.getMAX_CIV_PLAYERS()): pPlayerX = gc.getPlayer(iPlayerX) if pPlayerX.isAlive(): if pPlayerX.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_BATMAN"): iBatmanTeam = pPlayerX.getTeam() if pPlayerX.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_ROBIN"): iRobinTeam = pPlayerX.getTeam() if iBatmanTeam > -1 and iRobinTeam > -1 and iBatmanTeam != iRobinTeam: gc.getTeam(iBatmanTeam).declareWar(iRobinTeam, true, -1)
you put in a CyTeam instance instead of the iTeam.
also you seem to have missed another variable
VOID declareWar (TeamType eTeam, BOOL bNewDiplo, WarPlanType eWarPlan)
so instead try pAttackingTeam.declareWar(iDefendingTeam, True, eWarPlan)
where eWarPlan is the number representing either:
-1 = NO_WARPLAN
0 = WARPLAN_ATTACKED_RECENT
1 = WARPLAN_ATTACKED
2 = WARPLAN_PREPARING_LIMITED
3 = WARPLAN_PREPARING_TOTAL
4 = WARPLAN_LIMITED
5 = WARPLAN_TOTAL
6 = WARPLAN_DOGPILE
remember to use the API to check your methods!
Btw, I am writing a guide on how to use the API and basic python scripts so when thats done take a look(that includes you plat, you need to make sure it is up to scratch
)
Not sure what the answer is. I switched the declare war thing like he said
did i miss something??