From ed9501d2b5e5d9368642c0ee12fd99f9dc88d223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Bergstr=C3=B6m?= <davbe125@student.liu.se> Date: Thu, 28 Jun 2018 09:36:47 +0200 Subject: [PATCH] Make units storable in dictionaries and sets in Python --- python-api-src/lib_unit.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python-api-src/lib_unit.cpp b/python-api-src/lib_unit.cpp index 8f06816..2bebbd7 100644 --- a/python-api-src/lib_unit.cpp +++ b/python-api-src/lib_unit.cpp @@ -37,5 +37,7 @@ void define_unit(py::module & m) .def("build_target", &Unit::buildTarget) .def("train", &Unit::train) .def("morph", &Unit::morph) + .def("__hash__", [](const Unit & unit) { return std::hash<CCUnitID>{}(unit.getID()); }) + .def(py::self == py::self) .def("__repr__", [](const Unit & unit) { return "<Unit of type: '" + unit.getType().getName() + "'>"; }); } -- GitLab