<reponame>etzhang416/sharpy-bot-eco<filename>sharpy-sc2/sharpy/plans/require/enemy_building_exists.py
import warnings

from sc2 import UnitTypeId

from sharpy.plans.require.require_base import RequireBase


class EnemyBuildingExists(RequireBase):
    """
    Checks if enemy has units of the type based on the information we have seen.
    """

    def __init__(self, unit_type: UnitTypeId, count: int = 1):
        assert unit_type is not None and isinstance(unit_type, UnitTypeId)
        assert count is not None and isinstance(count, int)
        super().__init__()

        self.unit_type = unit_type
        self.count = count

    def check(self) -> bool:
        enemy_count = self.knowledge.known_enemy_units(self.unit_type).amount
        if enemy_count is None:
            return False

        if enemy_count >= self.count:
            return True

        return False


class RequiredEnemyBuildingExists(EnemyBuildingExists):
    def __init__(self, unit_type: UnitTypeId, count: int = 1):
        warnings.warn(
            "'RequiredEnemyBuildingExists' is deprecated, use 'EnemyBuildingExists' instead", DeprecationWarning, 2
        )
        super().__init__(unit_type, count)

import warnings

from sc2 import UnitTypeId

from sharpy.plans.require.require_base import RequireBase


class EnemyBuildingExists(RequireBase):
    """
    Checks if enemy has units of the type based on the information we have seen.
    """

    def __init__(self, unit_type: UnitTypeId, count: int = 1):
        assert unit_type is not None and isinstance(unit_type, UnitTypeId)
        assert count is not None and isinstance(count, int)
        super().__init__()

        self.unit_type = unit_type
        self.count = count

    def check(self) -> bool:
        enemy_count = self.knowledge.known_enemy_units(self.unit_type).amount
        if enemy_count is None:
            return False

        if enemy_count >= self.count:
            return True

        return False


class RequiredEnemyBuildingExists(EnemyBuildingExists):
    def __init__(self, unit_type: UnitTypeId, count: int = 1):
        warnings.warn(
            "'RequiredEnemyBuildingExists' is deprecated, use 'EnemyBuildingExists' instead", DeprecationWarning, 2
        )
        super().__init__(unit_type, count)
Checks if enemy has units of the type based on the information we have seen.