diff --git a/python-api-src/library.cpp b/python-api-src/library.cpp index cc8cd5d6b81095433dc1ae35f42721f733e6e795..4850443d573408aa619f23692c61904509798330 100644 --- a/python-api-src/library.cpp +++ b/python-api-src/library.cpp @@ -85,7 +85,7 @@ PYBIND11_MODULE(library, m) .def("on_step", &IDABot::OnStep) .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") + .def("get_my_units", &IDABot::GetMyUnits, "Returns a list of all your units") .def("get_player_race", &IDABot::GetPlayerRace, "Returns the players race, useful if you play Race.Random") .def("debug_create_unit", &IDABot::DebugCreateUnit, "This method creates the nr (INT) of units on the position :class:`library.Point2D`, the unit belongs to the Player Constant", "unit_type"_a, "p"_a, "player_id"_a = 0, "count"_a = 1) .def("debug_kill_unit", &IDABot::DebugKillUnit, "Kill the unit from debug mode") @@ -123,8 +123,10 @@ PYBIND11_MODULE(library, m) .def_property_readonly("current_supply", &IDABot::GetCurrentSupply, "How much supply we are currently using") .def_property_readonly("max_supply", &IDABot::GetMaxSupply, "How much supply we can currently use") .def_property_readonly("gas", &IDABot::GetGas, "How much gas we currently have") - .def_property_readonly("current_frame", &IDABot::GetCurrentFrame, "Which frame we are currently on"); - + .def_property_readonly("current_frame", &IDABot::GetCurrentFrame, "Which frame we are currently on") + .def_property_readonly("score", &IDABot::GetScore, "The score") + .def_property_readonly("player_result", &IDABot::GetPlayerResults, "The resut for player") + ; diff --git a/src/IDABot.cpp b/src/IDABot.cpp index 8a5fbf7ef07cfaee5f3edb394938cf60c6b8241a..ba787dfe9c70dc2cd3d527584a370ef1a9e49a4d 100644 --- a/src/IDABot.cpp +++ b/src/IDABot.cpp @@ -1,5 +1,6 @@ #include "IDABot.h" #include "Util.h" +#include "sc2api/sc2_score.h" IDABot::IDABot() @@ -381,6 +382,21 @@ float IDABot::UpgradeResearchTime(sc2::UpgradeID upgrade_id) const } float IDABot::RadiusEffect(sc2::EffectID effect_id) const -{ +{ return Observation()->GetEffectData()[effect_id].radius; +} + +float IDABot::GetScore() const +{ + return Observation()->GetScore().score; +} + +const sc2::GameResult IDABot::GetPlayerResults() const { + + for each (auto var in (Observation()->GetResults())) + { + if (var.player_id == Observation()->GetPlayerID()) return var.result; + } + std::cout << "The player can not be found" << std::endl; + return sc2::GameResult::Undecided; } \ No newline at end of file diff --git a/src/IDABot.h b/src/IDABot.h index 84e38978f0c93f1328d5a6506b4f8495e0b7d5d8..009be4101afd133395b61823cd8975ed5dca7ab6 100644 --- a/src/IDABot.h +++ b/src/IDABot.h @@ -93,6 +93,10 @@ public: float UpgradeResearchTime(sc2::UpgradeID upgrade_id) const; float RadiusEffect(sc2::EffectID effect_id) const; + float GetScore() const; + + const sc2::GameResult GetPlayerResults() const; + // Not needed, just convenience functions