Add assert to unit.build and unit.build_gas
@@ -1117,7 +1117,8 @@ class Unit:
:param position:
:param queue:
"""
- # TODO: add asserts to make sure "position" is not a Point2 or Point3 if "unit" is extractor / refinery / assimilator
+ if unit in {UnitTypeId.EXTRACTOR, UnitTypeId.ASSIMILATOR, UnitTypeId.REFINERY}:
+ assert isinstance(position, Unit), f"When building the gas structure, the target needs to be a unit (the vespene geysir) not the position of the vespene geysir."
return self(self._bot_object._game_data.units[unit.value].creation_ability.id, target=position, queue=queue)
def build_gas(self, target_geysir: Unit, queue: bool = False) -> UnitCommand:
@@ -1130,8 +1131,8 @@ class Unit:
:param target_geysir:
:param queue:
"""
- # TODO: add asserts to make sure "target_geysir" is not a Point2 or Point3
gas_structure_type_id: UnitTypeId = race_gas[self._bot_object.race]
+ assert isinstance(target_geysir, Unit), f"When building the gas structure, the target needs to be a unit (the vespene geysir) not the position of the vespene geysir."
return self(
self._bot_object._game_data.units[gas_structure_type_id.value].creation_ability.id,
target=target_geysir,
