diff --git a/python-api-src/library.cpp b/python-api-src/library.cpp index 4850443d573408aa619f23692c61904509798330..7b26f478df19ab67ec679e237012a4526ab1e810 100644 --- a/python-api-src/library.cpp +++ b/python-api-src/library.cpp @@ -83,6 +83,7 @@ PYBIND11_MODULE(library, m) .def(py::init()) .def("on_game_start", &IDABot::OnGameStart) .def("on_step", &IDABot::OnStep) + .def("on_game_end", &IDABot::OnGameEnd) .def("send_chat", &IDABot::SendChat, "Sends the string 'message' to the game chat", "message"_a) .def("get_all_units", &IDABot::GetAllUnits, "Returns a list of all visible units, including minerals and geysers") .def("get_my_units", &IDABot::GetMyUnits, "Returns a list of all your units") @@ -113,6 +114,7 @@ PYBIND11_MODULE(library, m) .def("upgrade_gas_cost", &IDABot::UpgradeGasCost, "Vespene/gas cost of researching the upgrade", "upgrade"_a) .def("upgrade_research_time", &IDABot::UpgradeResearchTime, "Time in GameLoops to research this upgrade", "upgrade"_a) .def("effect_radius", &IDABot::RadiusEffect, "Size of the circle the effect impacts", "effect"_a) + .def("save_replay", &IDABot::SaveReplay, "Saves the game as a replay", "path"_a) .def_property_readonly("base_location_manager", &IDABot::Bases, "An instance of the class :class:`library.BaseLocationManager`") .def_property_readonly("tech_tree", &IDABot::GetTechTree, "An instance of the class :class:`library.TechTree`") .def_property_readonly("map_tools", &IDABot::Map, "An instance of the class :class:`library.MapTools`") diff --git a/python-api-src/library.h b/python-api-src/library.h index 3f9114d0685218dec0f51e838031976f622c5709..9fb76f35e9de7251f9a3d6f64875498d7e182e94 100644 --- a/python-api-src/library.h +++ b/python-api-src/library.h @@ -60,6 +60,15 @@ public: OnStep ); } + void OnGameEnd() override + { + PYBIND11_OVERLOAD_NAME( + void, + IDABot, + "on_game_end", + OnGameEnd + ); + } }; diff --git a/src/IDABot.cpp b/src/IDABot.cpp index b89e54161dea402caf415ca68d7e0541b3f47335..6b55eb58899cf063ef01627a58d6194ee3bc34c0 100644 --- a/src/IDABot.cpp +++ b/src/IDABot.cpp @@ -403,4 +403,8 @@ const sc2::GameResult IDABot::GetPlayerResults() const { } std::cout << "The player can not be found" << std::endl; return sc2::GameResult::Undecided; +} + +bool IDABot::SaveReplay(const std::string& path) { + return this->Control()->SaveReplay(path); } \ No newline at end of file diff --git a/src/IDABot.h b/src/IDABot.h index 009be4101afd133395b61823cd8975ed5dca7ab6..7df2a52c95af77a6b2e1d10c9627a7039e11bc5a 100644 --- a/src/IDABot.h +++ b/src/IDABot.h @@ -97,6 +97,8 @@ public: const sc2::GameResult GetPlayerResults() const; + bool SaveReplay(const std::string & path); + // Not needed, just convenience functions