From ec5e8f3f86f110ec9e25ea5d8318898b5a8c02d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Bergstr=C3=B6m?= <davbe125@student.liu.se> Date: Tue, 3 Jul 2018 13:16:10 +0200 Subject: [PATCH] Add hash and compare methods to UnitType class --- python-api-src/lib_unittype.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python-api-src/lib_unittype.cpp b/python-api-src/lib_unittype.cpp index 66851b6d6..b8aa24de4 100644 --- a/python-api-src/lib_unittype.cpp +++ b/python-api-src/lib_unittype.cpp @@ -37,6 +37,8 @@ void define_unittype(py::module & m) .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 -- GitLab