Skip to content
Snippets Groups Projects
lib_unittype.cpp 2.79 KiB
Newer Older
  • Learn to ignore specific revisions
  • #include "library.h"
    
    namespace py = pybind11;
    
    void define_unittype(py::module & m)
    {
        py::class_<UnitType>(m, "UnitType")
    
            .def(py::init<const sc2::UnitTypeID &, IDABot &>())
    
            .def_property_readonly("unit_typeid", [](UnitType & unit_type) { return static_cast<sc2::UNIT_TYPEID>(unit_type.getAPIUnitType()); })
    
            .def_property_readonly("name", &UnitType::getName)
            .def_property_readonly("race", &UnitType::getRace)
    
    David Bergström's avatar
    David Bergström committed
            .def_property_readonly("movement_speed", &UnitType::getMovementSpeed)
    
            .def_property_readonly("is_valid", &UnitType::isValid)
            .def_property_readonly("is_building", &UnitType::isBuilding)
    
            .def_property_readonly("is_combat_unit", &UnitType::isCombatUnit, "The unit is not any of the following: worker, supply provider, building, larva, egg")
    
            .def_property_readonly("is_supply_provider", &UnitType::isSupplyProvider)
            .def_property_readonly("is_resource_depot", &UnitType::isResourceDepot)
            .def_property_readonly("is_refinery", &UnitType::isRefinery)
            .def_property_readonly("is_detector", &UnitType::isDetector)
            .def_property_readonly("is_geyser", &UnitType::isGeyser)
            .def_property_readonly("is_mineral", &UnitType::isMineral)
            .def_property_readonly("is_worker", &UnitType::isWorker)
            .def_property_readonly("is_morphed_building", &UnitType::isMorphedBuilding)
            // Not implemented in CommandCenter
            //.def_property_readonly("can_attack", &UnitType::canAttack)
            //.def_property_readonly("can_Move", &UnitType::canMove)
            .def_property_readonly("is_addon", &UnitType::isAddon)
            .def_property_readonly("attack_range", &UnitType::getAttackRange)
            .def_property_readonly("tile_width", &UnitType::tileWidth)
            .def_property_readonly("tile_height", &UnitType::tileHeight)
            .def_property_readonly("supply_provided", &UnitType::supplyProvided)
            .def_property_readonly("supply_required", &UnitType::supplyRequired)
            .def_property_readonly("mineral_price", &UnitType::mineralPrice)
            .def_property_readonly("gas_price", &UnitType::gasPrice)
            .def_property_readonly("is_overlord", &UnitType::isOverlord)
            .def_property_readonly("is_larva", &UnitType::isLarva)
            .def_property_readonly("is_egg", &UnitType::isEgg)
            .def_property_readonly("is_queen", &UnitType::isQueen)
            .def_property_readonly("is_tank", &UnitType::isTank)
    
            .def("__hash__", [](const UnitType & unit_type) { return std::hash<CCUnitID>{}(unit_type.getAPIUnitType()); })
            .def(py::self == py::self)
    
            .def("__repr__", [](const UnitType & unit_type) { return "<UnitType: '" + unit_type.getName() + "'>"; });
    
            // Not implemented in CommandCenter
            //.def("whatBuilds", &UnitType::whatBuilds);
    
    David Bergström's avatar
    David Bergström committed
    }