@@ -75,11 +75,9 @@ class GameTab
7575 custom = R"( {"customGameLobby":{"configuration":{"gameMode":"PRACTICETOOL","gameMutator":"","gameServerRegion":"","mapId":11,"mutators":{"id":1},"spectatorPolicy":"AllAllowed","teamSize":1},"lobbyName":"KBot","lobbyPassword":null},"isCustom":true})" ;
7676 }
7777
78- static bool fill = false ;
7978 if (ImGui::Button (" Practice Tool 5v5" ))
8079 {
8180 custom = R"( {"customGameLobby":{"configuration":{"gameMode":"PRACTICETOOL","gameMutator":"","gameServerRegion":"","mapId":11,"mutators":{"id":1},"spectatorPolicy":"AllAllowed","teamSize":5},"lobbyName":"KBot","lobbyPassword":null},"isCustom":true})" ;
82- fill = true ;
8381 }
8482
8583 if (ImGui::Button (" Clash" ))
@@ -121,6 +119,76 @@ class GameTab
121119
122120 // "id" 1- blind 2- draft -4 all random 6- tournament draft
123121
122+ ImGui::NextColumn ();
123+
124+ static std::vector<std::pair<int , std::string>>botChamps;
125+ if (botChamps.empty ())
126+ {
127+ std::string getBots = http->Request (" GET" , " https://127.0.0.1/lol-lobby/v2/lobby/custom/available-bots" , " " , auth->leagueHeader , " " , " " , auth->leaguePort );
128+ Json::CharReaderBuilder builder;
129+ const std::unique_ptr<Json::CharReader> reader (builder.newCharReader ());
130+ JSONCPP_STRING err;
131+ Json::Value root;
132+ if (reader->parse (getBots.c_str (), getBots.c_str () + static_cast <int >(getBots.length ()), &root, &err))
133+ {
134+ if (root.isArray ())
135+ {
136+ for (Json::Value::ArrayIndex i = 0 ; i < root.size (); i++)
137+ {
138+ std::pair<int , std::string>temp = { root[i][" id" ].asInt (),root[i][" name" ].asString () };
139+ botChamps.emplace_back (temp);
140+ }
141+ std::sort (botChamps.begin (), botChamps.end (), [](std::pair<int , std::string> a, std::pair<int , std::string >b) {return a.second < b.second ; });
142+ }
143+ }
144+ }
145+
146+ static int indexBots = 0 ; // Here we store our selection data as an index.
147+ const char * labelBots = " Bot" ;
148+ if (!botChamps.empty ())
149+ labelBots = botChamps[indexBots].second .c_str ();
150+ if (ImGui::BeginCombo (" ##comboBots" , labelBots, 0 ))
151+ {
152+ for (int n = 0 ; n < botChamps.size (); n++)
153+ {
154+ const bool is_selected = (indexBots == n);
155+ if (ImGui::Selectable (botChamps[n].second .c_str (), is_selected))
156+ indexBots = n;
157+
158+ if (is_selected)
159+ ImGui::SetItemDefaultFocus ();
160+ }
161+ ImGui::EndCombo ();
162+ }
163+ std::vector<std::string>difficulties = { " NONE" ," EASY" ," MEDIUM" ," HARD" ," UBER" ," TUTORIAL" ," INTRO" };
164+ static int indexDifficulty = 0 ; // Here we store our selection data as an index.
165+ const char * labelDifficulty = difficulties[indexDifficulty].c_str ();
166+
167+ if (ImGui::BeginCombo (" ##comboDifficulty" , labelDifficulty, 0 ))
168+ {
169+ for (int n = 0 ; n < difficulties.size (); n++)
170+ {
171+ const bool is_selected = (indexDifficulty == n);
172+ if (ImGui::Selectable (difficulties[n].c_str (), is_selected))
173+ indexDifficulty = n;
174+
175+ if (is_selected)
176+ ImGui::SetItemDefaultFocus ();
177+ }
178+ ImGui::EndCombo ();
179+ }
180+ static int botTeam = 0 ;
181+
182+ if (ImGui::Button (" Add bot##addBot" ))
183+ {
184+ std::string team = botTeam ? R"( ,"teamId":"200"})" : R"( ,"teamId":"100"})" ;
185+ std::string body = R"( {"botDifficulty":")" + difficulties[indexDifficulty] + R"( ","championId":)" + std::to_string (botChamps[indexBots].first ) + team;
186+ result = http->Request (" POST" , " https://127.0.0.1/lol-lobby/v1/lobby/custom/bots" , body, auth->leagueHeader , " " , " " , auth->leaguePort );
187+ }
188+ ImGui::SameLine ();
189+ ImGui::RadioButton (" Blue" , &botTeam, 0 ); ImGui::SameLine ();
190+ ImGui::RadioButton (" Red" , &botTeam, 1 );
191+
124192 ImGui::Columns (1 );
125193
126194 ImGui::Separator ();
@@ -161,25 +229,6 @@ class GameTab
161229
162230 gameID = 0 ;
163231 }
164- // fill practice tool with bots
165- if (fill)
166- {
167- std::this_thread::sleep_for (std::chrono::milliseconds (300 ));
168- std::vector<int >champIDs = { 22 , 18 , 33 ,12 ,10 ,21 ,62 ,89 ,44 ,51 ,96 ,54 ,81 ,98 ,30 ,122 ,11 ,13 ,69 };
169- for (int i = 0 ; i < 4 ; i++)
170- {
171- std::this_thread::sleep_for (std::chrono::milliseconds (50 ));
172- std::string addBlue = R"( {"botDifficulty":"MEDIUM","championId":)" + std::to_string (RandomInt (0 , champIDs.size () - 1 )) + R"( ,"teamId":"100"})" ;
173- result = http->Request (" POST" , " https://127.0.0.1/lol-lobby/v1/lobby/custom/bots" , addBlue, auth->leagueHeader , " " , " " , auth->leaguePort );
174- }
175- for (int i = 0 ; i < 5 ; i++)
176- {
177- std::this_thread::sleep_for (std::chrono::milliseconds (50 ));
178- std::string addRed = R"( {"botDifficulty":"MEDIUM","championId":)" + std::to_string (RandomInt (0 , champIDs.size () - 1 )) + R"( ,"teamId":"200"})" ;
179- result = http->Request (" POST" , " https://127.0.0.1/lol-lobby/v1/lobby/custom/bots" , addRed, auth->leagueHeader , " " , " " , auth->leaguePort );
180- }
181- fill = false ;
182- }
183232
184233 ImGui::Separator ();
185234
0 commit comments