Skip to content
Snippets Groups Projects
Commit e132326a authored by Rojikku98's avatar Rojikku98
Browse files

Added player info

parent 408e8926
No related branches found
No related tags found
No related merge requests found
...@@ -100,8 +100,18 @@ PYBIND11_MODULE(library, m) ...@@ -100,8 +100,18 @@ PYBIND11_MODULE(library, m)
.def("on_game_end", &IDAReplayObserver::OnGameEnd) .def("on_game_end", &IDAReplayObserver::OnGameEnd)
.def("get_all_units", &IDAReplayObserver::GetAllUnits, "Returns a list of all units") .def("get_all_units", &IDAReplayObserver::GetAllUnits, "Returns a list of all units")
.def("get_player_race", &IDAReplayObserver::GetPlayerRace,"player_id"_a) .def("get_player_race", &IDAReplayObserver::GetPlayerRace,"player_id"_a)
.def("get_replay_path", &IDAReplayObserver::GetReplayPath)
.def("get_result_for_player", &IDAReplayObserver::GetResultForPlayer, "player_id"_a)
; ;
py::enum_<sc2::GameResult>(m, "GameResult")
.value("Win", sc2::GameResult::Win)
.value("Loss", sc2::GameResult::Loss)
.value("Tie", sc2::GameResult::Tie)
.value("Undecided", sc2::GameResult::Undecided);
py::class_<sc2::PlayerSetup>(m, "PlayerSetup"); py::class_<sc2::PlayerSetup>(m, "PlayerSetup");
py::enum_<sc2::Difficulty>(m, "Difficulty") py::enum_<sc2::Difficulty>(m, "Difficulty")
......
...@@ -57,19 +57,19 @@ const std::vector<ReplayUnit>& IDAReplayObserver::GetAllUnits() const ...@@ -57,19 +57,19 @@ const std::vector<ReplayUnit>& IDAReplayObserver::GetAllUnits() const
return m_allUnits; return m_allUnits;
} }
CCRace IDAReplayObserver::GetPlayerRace(int player) const CCRace IDAReplayObserver::GetPlayerRace(int player)
{
return ReplayControl()->GetReplayInfo().players[player].race;
}
std::string IDAReplayObserver::GetReplayPath()
{ {
auto playerID = Observation()->GetPlayerID(); return ReplayControl()->GetReplayInfo().replay_path;
for (auto & playerInfo : Observation()->GetGameInfo().player_info) }
{
if (playerInfo.player_id == playerID)
{
return playerInfo.race_actual;
}
}
BOT_ASSERT(false, "Failed to find the player's race!"); sc2::GameResult IDAReplayObserver::GetResultForPlayer(int player)
return sc2::Race::Random; {
return ReplayControl()->GetReplayInfo().players[player].game_result;
} }
...@@ -25,7 +25,9 @@ public: ...@@ -25,7 +25,9 @@ public:
ReplayUnit GetUnit(const CCUnitID tag) const; ReplayUnit GetUnit(const CCUnitID tag) const;
const std::vector<ReplayUnit> & GetAllUnits() const; const std::vector<ReplayUnit> & GetAllUnits() const;
CCRace GetPlayerRace(int player) const; CCRace GetPlayerRace(int player);
std::string GetReplayPath();
sc2::GameResult GetResultForPlayer(int player);
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment