sc2simulator/setup/treeSelection.py
def isValidSelection(unit):
        """verify that this unit doesn't violate any of the determined rules"""
        if not unit.isUnit:                  return False
        if unit.isStructure:
            if not unit.weapons:             return False # only defense structures are allowed units
            if not rules.allowDefense:       return False # defense structures are only allowed if specified
        if  rules.air    and not unit.isAir: return False
        if  rules.ground and     unit.isAir: return False
        if  unit.dps     > rules.maxdps:     return False
        if  unit.hits    > rules.maxhp:      return False
        cost = unit.cost
        if  cost.mineral > rules.mineral:    return False
        if  cost.vespene > rules.vespene:    return False
        if -cost.supply  > rules.supply:     return False
        if ms and unit.name == "Mothership": return False # at most one mothership can be picked
        return True
verify that this unit doesn't violate any of the determined rules
verify that this unit doesn't violate any of the determined rules
verify that this unit doesn ' t violate any of the determined rules
def isValidSelection(unit):
        if not unit.isUnit:                  return False
        if unit.isStructure:
            if not unit.weapons:             return False 
            if not rules.allowDefense:       return False 
        if  rules.air    and not unit.isAir: return False
        if  rules.ground and     unit.isAir: return False
        if  unit.dps     > rules.maxdps:     return False
        if  unit.hits    > rules.maxhp:      return False
        cost = unit.cost
        if  cost.mineral > rules.mineral:    return False
        if  cost.vespene > rules.vespene:    return False
        if -cost.supply  > rules.supply:     return False
        if ms and unit.name == "Mothership": return False 
        return True
def isValidSelection ( unit ) : if not unit . isUnit : return False if unit . isStructure : if not unit . weapons : return False if not rules . allowDefense : return False if rules . air and not unit . isAir : return False if rules . ground and unit . isAir : return False if unit . dps > rules . maxdps : return False if unit . hits > rules . maxhp : return False cost = unit . cost if cost . mineral > rules . mineral : return False if cost . vespene > rules . vespene : return False if - cost . supply > rules . supply : return False if ms and unit . name == "Mothership" : return False return True
verify that this unit doesn't violate any of the determined rules
verify that this unit doesn ' t violate any of the determined rules
"""verify that this unit doesn't violate any of the determined rules""" # only defense structures are allowed units # defense structures are only allowed if specified # at most one mothership can be picked
unit