From 054598a2b31068302511067e422f4b2513d546ce Mon Sep 17 00:00:00 2001
From: Ludvig Fors <ludfo119@student.liu.se>
Date: Tue, 19 Nov 2019 18:27:57 +0100
Subject: [PATCH] Added chat functionallity making the bot able to send
 messages to the game chat for everyone to see. Used by calling
 self.send_chat(<message>).

---
 python-api-src/library.cpp | 1 +
 src/IDABot.cpp             | 6 ++++++
 src/IDABot.h               | 2 ++
 3 files changed, 9 insertions(+)

diff --git a/python-api-src/library.cpp b/python-api-src/library.cpp
index dd1bc0cfd..bfdb607e9 100644
--- a/python-api-src/library.cpp
+++ b/python-api-src/library.cpp
@@ -74,6 +74,7 @@ PYBIND11_MODULE(library, m)
         .def(py::init())
         .def("on_game_start", &IDABot::OnGameStart)
         .def("on_step", &IDABot::OnStep)
+		.def("send_chat", &IDABot::SendChat, "Send a message to the game chat", "message"_a)
         .def("get_all_units", &IDABot::GetAllUnits, "Returns a list of all units")
         .def("get_my_units", &IDABot::GetMyUnits, "Returns a list of all units beloning to the player")
         .def("get_player_race", &IDABot::GetPlayerRace)
diff --git a/src/IDABot.cpp b/src/IDABot.cpp
index c12fe5ab7..9c182ae62 100644
--- a/src/IDABot.cpp
+++ b/src/IDABot.cpp
@@ -199,6 +199,12 @@ BuildingPlacer & IDABot::GetBuildingPlacer()
     return m_buildingPlacer;
 }
 
+
+void IDABot::SendChat(const std::string & message)
+{
+	Actions()->SendChat(message);
+}
+
 const TypeData & IDABot::Data(const UnitType & type) const
 {
 	return m_techTree.getData(type);
diff --git a/src/IDABot.h b/src/IDABot.h
index eca954f01..ba86ce6c4 100644
--- a/src/IDABot.h
+++ b/src/IDABot.h
@@ -46,6 +46,8 @@ public:
     CCPosition GetStartLocation() const;
     BuildingPlacer & GetBuildingPlacer();
 
+	void SendChat(const std::string & message);
+
     int GetCurrentFrame() const;
     int GetMinerals() const;
     int GetCurrentSupply() const;
-- 
GitLab