sc2.helpers.control_group module
class ControlGroup(set): def __init__(self, units): super().__init__({unit.tag for unit in units}) def __hash__(self): return hash(tuple(sorted(list(self)))) def select_units(self, units): return units.filter(lambda unit: unit.tag in self) def missing_unit_tags(self, units): return {t for t in self if units.find_by_tag(t) is None} @property def amount(self) -> int: return len(self) @property def empty(self) -> bool: return self.amount == 0 def add_unit(self, unit): self.add(unit.tag) def add_units(self, units): for unit in units: self.add_unit(unit) def remove_unit(self, unit): self.remove(unit.tag) def remove_units(self, units): for unit in units: self.remove(unit.tag)
Classes
class ControlGroup
set() -> new empty set object set(iterable) -> new set object
Build an unordered collection of unique elements.
class ControlGroup(set): def __init__(self, units): super().__init__({unit.tag for unit in units}) def __hash__(self): return hash(tuple(sorted(list(self)))) def select_units(self, units): return units.filter(lambda unit: unit.tag in self) def missing_unit_tags(self, units): return {t for t in self if units.find_by_tag(t) is None} @property def amount(self) -> int: return len(self) @property def empty(self) -> bool: return self.amount == 0 def add_unit(self, unit): self.add(unit.tag) def add_units(self, units): for unit in units: self.add_unit(unit) def remove_unit(self, unit): self.remove(unit.tag) def remove_units(self, units): for unit in units: self.remove(unit.tag)
Ancestors (in MRO)
- ControlGroup
- builtins.set
- builtins.object
Static methods
def __init__(
self, units)
Initialize self. See help(type(self)) for accurate signature.
def __init__(self, units): super().__init__({unit.tag for unit in units})
def add_unit(
self, unit)
def add_unit(self, unit): self.add(unit.tag)
def add_units(
self, units)
def add_units(self, units): for unit in units: self.add_unit(unit)
def missing_unit_tags(
self, units)
def remove_unit(
self, unit)
def remove_unit(self, unit): self.remove(unit.tag)
def remove_units(
self, units)
def remove_units(self, units): for unit in units: self.remove(unit.tag)
def select_units(
self, units)
def select_units(self, units): return units.filter(lambda unit: unit.tag in self)
Instance variables
var amount
var empty