Skip to content
Snippets Groups Projects
Commit 9f40a31f authored by David Bergström's avatar David Bergström
Browse files

Rework the enum, yet not enum classes in the Python API

parent bca5c873
No related branches found
No related tags found
No related merge requests found
......@@ -29,14 +29,10 @@ PYBIND11_MODULE(library, m)
.value("Protoss", sc2::Race::Protoss)
.value("Random", sc2::Race::Random);
// Stupid anonymous enum, used as int everywhere. Best work-around I could think of.
py::module players = m.def_submodule("Players", "Constants for referring to players");
players.attr("Self") = (int) Players::Self;
players.attr("Enemy") = (int) Players::Enemy;
players.attr("Neutral") = (int) Players::Neutral;
players.attr("Ally") = (int) Players::Ally;
players.attr("Size") = (int) Players::Size; // These are probably used for
players.attr("None") = (int) Players::None; // creating arrays of fixed length??
m.attr("PLAYER_SELF") = py::int_((int) Players::Self);
m.attr("PLAYER_ENEMY") = py::int_((int) Players::Enemy);
m.attr("PLAYER_NEUTRAL") = py::int_((int) Players::Neutral);
m.attr("PLAYER_ALLY") = py::int_((int) Players::Ally);
/*
TODO: These also needs to be defined
......@@ -87,24 +83,22 @@ PYBIND11_MODULE(library, m)
.value("CheatMoney", sc2::Difficulty::CheatMoney)
.value("CheatInsane", sc2::Difficulty::CheatInsane);
py::class_<sc2::Color>(m, "Color")
.def(py::init<>())
.def(py::init<int, int, int>())
.def_readwrite("r", &sc2::Color::r)
.def_readwrite("g", &sc2::Color::g)
.def_readwrite("b", &sc2::Color::b);
py::module colors = m.def_submodule("Colors", "Constants for common colors");
colors.attr("White") = sc2::Colors::White;
colors.attr("Red") = sc2::Colors::Red;
colors.attr("Green") = sc2::Colors::Green;
colors.attr("Yellow") = sc2::Colors::Yellow;
colors.attr("Blue") = sc2::Colors::Blue;
colors.attr("Teal") = sc2::Colors::Teal;
colors.attr("Purple") = sc2::Colors::Purple;
colors.attr("Black") = sc2::Colors::Black;
colors.attr("Gray") = sc2::Colors::Gray;
m.def("create_participants", &sc2::CreateParticipant, "Create participant from agent");
m.def("create_computer", &sc2::CreateComputer, "Create participant from built-in Starcraft computer");
py::class_<sc2::Color> color(m, "Color");
color.def(py::init<>());
color.def(py::init<int, int, int>(), "r"_a, "g"_a, "b"_a);
color.def_readwrite("r", &sc2::Color::r);
color.def_readwrite("g", &sc2::Color::g);
color.def_readwrite("b", &sc2::Color::b);
color.attr("WHITE") = sc2::Colors::White;
color.attr("RED") = sc2::Colors::Red;
color.attr("GREEN") = sc2::Colors::Green;
color.attr("YELLOW") = sc2::Colors::Yellow;
color.attr("BLUE") = sc2::Colors::Blue;
color.attr("TEAL") = sc2::Colors::Teal;
color.attr("PURPLE") = sc2::Colors::Purple;
color.attr("BLACK") = sc2::Colors::Black;
color.attr("GRAY") = sc2::Colors::Gray;
m.def("create_participants", &sc2::CreateParticipant, "Create participant from bot", "race"_a, "bot"_a);
m.def("create_computer", &sc2::CreateComputer, "Create participant from built-in Starcraft computer", "race"_a, "difficulty"_a);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment