Python help for Beyond the Sword

Roamty

BTS
Joined
Nov 30, 2005
Messages
538
Location
South Park
Python
# The Great Tori Gate at Miyajima Island (What? You've never heard of it?)
# by
# Roger Bacon
Can someone code this to work with Beyond the Sword as is works with Vanilla need to update it to work with Beyond the Sword.


from CvPythonExtensions import *
import CvUtil
import PyHelpers # LOQ
import sys
import Popup as PyPopup
import pickle # LOQ 2005-10-12
import CvMainInterface
# The Great Tori Gate at Miyajima Island (What? You've never heard of it?)
# by
# Roger Bacon
# 1/21/2006
# If you don't have the Shinto mod you will have to change a few things to make this work. See the readMe.txt
# globals
gc = CyGlobalContext()
PyPlayer = PyHelpers.PyPlayer # LOQ
PyInfo = PyHelpers.PyInfo
theGame = CyGame()
PyGame = PyHelpers.PyGame()
toriGateAncientEraDictionary = { 'UNIT_CHARIOT' : 'UNIT_CHARIOT', 'UNIT_SPEARMAN' : 'UNIT_SPEARMAN', 'UNIT_AXEMAN' : 'UNIT_AXEMAN', 'UNIT_ARCHER' : 'UNIT_ARCHER'}
toriGateClassicalEraDictionary = { 'UNIT_SWORDSMAN' : 'UNIT_SWORDSMAN', 'UNIT_WAR_ELEPHANT' : 'UNIT_WAR_ELEPHANT', 'UNIT_CATAPULT' : 'UNIT_CATAPULT', 'UNIT_HORSE_ARCHER' : 'UNIT_HORSE_ARCHER'}
class Wonders:
def onBeginPlayerTurn(self, argsList):
'Called at the beginning of a players turn'
iGameTurn, iPlayer = argsList
pPlayer = PyPlayer(iPlayer)
if ( iGameTurn % 5 != 0): # We only make a unit every 5 turns
return

#wonderID = gc.getInfoTypeForString("BUILDING_ORACLE") # Use this if you are not using the Shinto mod
wonderID = gc.getInfoTypeForString("BUILDINGCLASS_TORI_GATE")
city = self.findWonder(wonderID, pPlayer)
if(city):
# Determine the era here
pPlayer = gc.getPlayer(iPlayer)
theRealEra = pPlayer.getCurrentEra()
eraInfo = gc.getEraInfo(theRealEra)
era = eraInfo.getDescription()
# Now we make a list of which units the Statue can produce
toriGateDictionary = { 'UNIT_WARRIOR' : 'UNIT_WARRIOR'}
if (theRealEra == 0): # Ancient Era
if ( pPlayer.canTrain(gc.getInfoTypeForString("UNIT_CHARIOT"), false, false)):
updateDictionary = { 'UNIT_CHARIOT' : 'UNIT_CHARIOT'}
toriGateDictionary.update(updateDictionary)
if ( pPlayer.canTrain(gc.getInfoTypeForString("UNIT_SPEARMAN"), false, false)):
updateDictionary = { 'UNIT_SPEARMAN' : 'UNIT_SPEARMAN'}
toriGateDictionary.update(updateDictionary)
if ( pPlayer.canTrain(gc.getInfoTypeForString("UNIT_AXEMAN"), false, false)):
updateDictionary = { 'UNIT_AXEMAN' : 'UNIT_AXEMAN'}
toriGateDictionary.update(updateDictionary)
if ( pPlayer.canTrain(gc.getInfoTypeForString("UNIT_ARCHER"), false, false)):
updateDictionary = { 'UNIT_ARCHER' : 'UNIT_ARCHER'}
toriGateDictionary.update(updateDictionary)
if (theRealEra == 1): # Classical Era
if ( pPlayer.canTrain(gc.getInfoTypeForString("UNIT_SWORDSMAN"), false, false)):
updateDictionary = { 'UNIT_SWORDSMAN' : 'UNIT_SWORDSMAN'}
toriGateDictionary.update(updateDictionary)
if ( pPlayer.canTrain(gc.getInfoTypeForString("UNIT_WAR_ELEPHANT"), false, false)):
updateDictionary = { 'UNIT_WAR_ELEPHANT' : 'UNIT_WAR_ELEPHANT'}
toriGateDictionary.update(updateDictionary)
if ( pPlayer.canTrain(gc.getInfoTypeForString("UNIT_CATAPULT"), false, false)):
updateDictionary = { 'UNIT_CATAPULT' : 'UNIT_CATAPULT'}
toriGateDictionary.update(updateDictionary)
if ( pPlayer.canTrain(gc.getInfoTypeForString("UNIT_HORSE_ARCHER"), false, false)):
updateDictionary = { 'UNIT_HORSE_ARCHER' : 'UNIT_HORSE_ARCHER'}
toriGateDictionary.update(updateDictionary)
if (theRealEra == 2): # Medieval Era
if ( pPlayer.canTrain(gc.getInfoTypeForString("UNIT_CROSSBOWMAN"), false, false)):
updateDictionary = { 'UNIT_CROSSBOWMAN' : 'UNIT_CROSSBOWMAN'}
toriGateDictionary.update(updateDictionary)
if ( pPlayer.canTrain(gc.getInfoTypeForString("UNIT_KNIGHT"), false, false)):
updateDictionary = { 'UNIT_KNIGHT' : 'UNIT_KNIGHT'}
toriGateDictionary.update(updateDictionary)
if ( pPlayer.canTrain(gc.getInfoTypeForString("UNIT_PIKEMAN"), false, false)):
updateDictionary = { 'UNIT_PIKEMAN' : 'UNIT_PIKEMAN'}
toriGateDictionary.update(updateDictionary)
if ( pPlayer.canTrain(gc.getInfoTypeForString("UNIT_LONGBOWMAN"), false, false)):
updateDictionary = { 'UNIT_LONGBOWMAN' : 'UNIT_LONGBOWMAN'}
toriGateDictionary.update(updateDictionary)
if (theRealEra > 2): # The Statue only makes units up to the medieval Era
return
if (theRealEra == 1 and len(toriGateDictionary) == 1): # We're in the Classical era but haven't researched a classical unit yet.
toriGateDictionary.update(toriGateAncientEraDictionary)
if (theRealEra == 2 and len(toriGateDictionary) == 1): # We're in the Medieval era but haven't researched a medieval unit yet.
toriGateDictionary.update(toriGateClassicalEraDictionary)
if ( len(toriGateDictionary) > 1):
if (toriGateDictionary.has_key('UNIT_WARRIOR')):
del toriGateDictionary['UNIT_WARRIOR'] # No one really wants to get a warrior
# convert the dictionary to an ordered list
unitList = toriGateDictionary.keys()
# Pick a unit from the list
iRandNum = gc.getGame().getMapRand().get(len(unitList), "toriGate Random Unit Roll")
# Create the unit
pPlayer.initUnit(gc.getInfoTypeForString(unitList[iRandNum]), city.getX(), city.getY(), UnitAITypes.NO_UNITAI)
message4 = " The Sacred Tori Gate has attracted a %s to our cause." %(gc.getUnitInfo((gc.getInfoTypeForString(unitList[iRandNum]))).getDescription())
CyInterface().addImmediateMessage(message4,"")
CvUtil.pyPrint(message4)

def findWonder(self,iBuildingType, player):
'CyCity - city containing wonder'

# Get the list of cities the player has
cityList = player.getCityList()
for j in range(len(cityList)):
city = cityList[j]
if(city.hasBuilding(iBuildingType)):
return city
return
 
Tori Gate Mod with Shinto [Beyond the Sword] Needs Tori Python Wonders updated to work with
Beyond the Sword to make this mod fully working in Beyond the Sword. At this time all works but Tori Gate. Zebra 9 is working on this.
I Thankyou Zebra 9

Tori Gate Mod with ShintoBTS for Beyond the Sword
you can get it here: http://hosted.filefront.com/roamty/
 
Have you tryed using it with BtS already. Because when I looked at it yesterday and compared it to my findings it appears that it should work. If it isn't I will change a few things that could be problems (need BtS to be sure).
 
Yes I have try with BTS Already this is the only thing that does not work, I got all others in the mod updated to work but Tori. Thanks for your help in this because I want to add BARRAGE to this mod Zebra 9
 
Top Bottom