sc2simulator/setup/unitSelection.py
def generateUpgrades(scenario, playerID, options):
    """identify the upgrades corresponding to the specified options"""
    if playerID == 1:   upgradeStr = options.upgrades
    else:               upgradeStr = options.enemyUpgrades
    if not upgradeStr: return # upgrades weren't specified for this player
    if not techtree:
        raise ValueError(("cannot determine upgrades without the sc2techTree "\
            " (given: %s)")%(upgradeStr))
    for techPart in re.split("[,:;]+", upgradeStr):
        try:
            techKey = int(techPart)
            tech = sc2techTree.getUpgradeByID(techKey)[0]
        except ValueError: # not an integer -- assume an exact match key string
            techKey = techPart
            try:  tech = sc2techTree.getUpgrade(techKey)
            except KeyError:
                raise KeyError("could not identify upgrade: '%s'"%(techKey))
        except IndexError:
            raise IndexError("could not identify upgrade ID: '%s'"%(techKey))
        scenario.addUpgrade(playerID, tech)
identify the upgrades corresponding to the specified options
identify the upgrades corresponding to the specified options
identify the upgrades corresponding to the specified options
def generateUpgrades(scenario, playerID, options):
    if playerID == 1:   upgradeStr = options.upgrades
    else:               upgradeStr = options.enemyUpgrades
    if not upgradeStr: return 
    if not techtree:
        raise ValueError(("cannot determine upgrades without the sc2techTree "\
            " (given: %s)")%(upgradeStr))
    for techPart in re.split("[,:;]+", upgradeStr):
        try:
            techKey = int(techPart)
            tech = sc2techTree.getUpgradeByID(techKey)[0]
        except ValueError: 
            techKey = techPart
            try:  tech = sc2techTree.getUpgrade(techKey)
            except KeyError:
                raise KeyError("could not identify upgrade: '%s'"%(techKey))
        except IndexError:
            raise IndexError("could not identify upgrade ID: '%s'"%(techKey))
        scenario.addUpgrade(playerID, tech)
def generateUpgrades ( scenario , playerID , options ) : if playerID == 1 : upgradeStr = options . upgrades else : upgradeStr = options . enemyUpgrades if not upgradeStr : return if not techtree : raise ValueError ( ( "cannot determine upgrades without the sc2techTree " " (given: %s)" ) % ( upgradeStr ) ) for techPart in re . split ( "[,:;]+" , upgradeStr ) : try : techKey = int ( techPart ) tech = sc2techTree . getUpgradeByID ( techKey ) [ 0 ] except ValueError : techKey = techPart try : tech = sc2techTree . getUpgrade ( techKey ) except KeyError : raise KeyError ( "could not identify upgrade: '%s'" % ( techKey ) ) except IndexError : raise IndexError ( "could not identify upgrade ID: '%s'" % ( techKey ) ) scenario . addUpgrade ( playerID , tech )
identify the upgrades corresponding to the specified options
identify the upgrades corresponding to the specified options
"""identify the upgrades corresponding to the specified options""" # upgrades weren't specified for this player # not an integer -- assume an exact match key string
scenario
playerID
options