@@ -225,14 +225,15 @@ class GameTab
225225
226226 ImGui::Separator ();
227227
228- // todo invite everyone from friendlist to lobby button
229-
230228 ImGui::Columns (3 , 0 , false );
231229 if (ImGui::Button (" Start queue" ))
232230 {
233231 result = http->Request (" POST" , " https://127.0.0.1/lol-lobby/v2/lobby/matchmaking/search" , " " , auth->leagueHeader , " " , " " , auth->leaguePort );
234232 }
235233 ImGui::NextColumn ();
234+
235+ // if you press this during queue search you wont be able to start the queue again
236+ // unless you reenter the lobby :)
236237 if (ImGui::Button (" Dodge" ))
237238 {
238239 result = http->Request (" POST" , R"( https://127.0.0.1/lol-login/v1/session/invoke?destination=lcdsServiceProxy&method=call&args=["","teambuilder-draft","quitV2",""])" , " " , auth->leagueHeader , " " , " " , auth->leaguePort );
@@ -290,8 +291,35 @@ class GameTab
290291
291292 ImGui::Separator ();
292293
294+ ImGui::Columns (3 , 0 , false );
293295 ImGui::Checkbox (" Auto accept" , &S.gameTab .autoAcceptEnabled );
294296
297+ ImGui::NextColumn ();
298+ if (ImGui::Button (" Invite everyone to lobby" ))
299+ {
300+ std::string getFriends = http->Request (" GET" , " https://127.0.0.1/lol-chat/v1/friends" , " " , auth->leagueHeader , " " , " " , auth->leaguePort );
301+
302+ Json::CharReaderBuilder builder;
303+ const std::unique_ptr<Json::CharReader> reader (builder.newCharReader ());
304+ JSONCPP_STRING err;
305+ Json::Value root;
306+ if (reader->parse (getFriends.c_str (), getFriends.c_str () + static_cast <int >(getFriends.length ()), &root, &err))
307+ {
308+ if (root.isArray ())
309+ {
310+ for (Json::Value::ArrayIndex i = 0 ; i < root.size (); ++i)
311+ {
312+ std::string friendSummId = root[i][" summonerId" ].asString ();
313+ std::string inviteBody = " [{\" toSummonerId\" :" + friendSummId + " }]" ;
314+ http->Request (" POST" , " https://127.0.0.1/lol-lobby/v2/lobby/invitations" , inviteBody,
315+ auth->leagueHeader , " " , " " , auth->leaguePort );
316+ }
317+ result = " Invited friends to lobby" ;
318+ }
319+ }
320+ }
321+ ImGui::Columns (1 );
322+
295323 ImGui::Columns (2 , 0 , false );
296324
297325 ImGui::Text (" Instant message: " );
@@ -315,13 +343,16 @@ class GameTab
315343 ImGui::SliderInt (" Delay##sliderInstalockDelay" , &S.gameTab .instalockDelay , 0 , 10000 , " %d ms" );
316344
317345 ImGui::NextColumn ();
318- // todo
319- bool test11;
320- ImGui::Checkbox (" Dodge on champion ban" , &test11);
346+
347+ ImGui::Checkbox (" Dodge on champion ban" , &S.gameTab .dodgeOnBan );
348+
349+ ImGui::SameLine ();
350+ Misc::HelpMarker (" Ignores backup pick" );
321351
322352 ImGui::Columns (1 );
323353
324- if (ImGui::CollapsingHeader (" Instalock champ" ))
354+ std::string chosenInstalock = " Instalock champ \t\t Chosen: " + Misc::ChampIdToName (S.gameTab .instalockId ) + " ###AnimatedInstalock" ;
355+ if (ImGui::CollapsingHeader (chosenInstalock.c_str ()))
325356 {
326357 std::vector<std::pair<int , std::string>>instalockChamps = GetInstalockChamps ();
327358 for (auto champ : instalockChamps)
@@ -334,26 +365,25 @@ class GameTab
334365 }
335366 }
336367
337- // todo
338- if (ImGui::CollapsingHeader (" Backup pick " ))
368+ std::string chosenBackup = " Backup pick \t\t\t Chosen: " + Misc::ChampIdToName (S. gameTab . backupId ) + " ###AnimatedBackup " ;
369+ if (ImGui::CollapsingHeader (chosenBackup. c_str () ))
339370 {
340371 ImGui::Text (" None" );
341372 ImGui::SameLine ();
342- // ImGui::RadioButton("##noneBackupPick", &S.gameTab.backupId, 0);
373+ ImGui::RadioButton (" ##noneBackupPick" , &S.gameTab .backupId , 0 );
343374 std::vector<std::pair<int , std::string>>instalockChamps = GetInstalockChamps ();
344375 for (auto champ : instalockChamps)
345376 {
346377 char bufchamp[128 ];
347378 sprintf_s (bufchamp, " ##Select %s" , champ.second .c_str ());
348379 ImGui::Text (" %s" , champ.second .c_str ());
349380 ImGui::SameLine ();
350- // ImGui::RadioButton(bufchamp, &S.gameTab.backupId, champ.first);
381+ ImGui::RadioButton (bufchamp, &S.gameTab .backupId , champ.first );
351382 }
352383 }
353384
354- // todo: backup pick or dodge
355-
356- if (ImGui::CollapsingHeader (" Auto ban" ))
385+ std::string chosenAutoban = " Auto ban\t\t\t\t Chosen: " + Misc::ChampIdToName (S.gameTab .autoBanId ) + " ###AnimatedAutoban" ;
386+ if (ImGui::CollapsingHeader (chosenAutoban.c_str ()))
357387 {
358388 if (champSkins.empty ())
359389 {
@@ -470,13 +500,22 @@ class GameTab
470500 std::string getChat = http->Request (" GET" , " https://127.0.0.1/lol-chat/v1/conversations" , " " , auth->leagueHeader , " " , " " , auth->leaguePort );
471501 if (reader->parse (getChat.c_str (), getChat.c_str () + static_cast <int >(getChat.length ()), &root, &err))
472502 {
473- std::string lobbyID = root[0 ][" id" ].asString ();
474- std::string request = " https://127.0.0.1/lol-chat/v1/conversations/" + lobbyID + " /messages" ;
475- std::string error = " errorCode" ;
476- while (error.find (" errorCode" ) != std::string::npos)
503+ if (root.isArray ())
477504 {
478- error = http->Request (" POST" , request, R"( {"type":"chat", "body":")" + std::string (S.gameTab .instantMessage ) + R"( "})" , auth->leagueHeader , " " , " " , auth->leaguePort );
479- std::this_thread::sleep_for (std::chrono::milliseconds (1 ));
505+ for (Json::Value::ArrayIndex i = 0 ; i < root.size (); i++)
506+ {
507+ if (root[i][" type" ].asString () != " championSelect" )
508+ continue ;
509+ std::string lobbyID = root[i][" id" ].asString ();
510+ std::string request = " https://127.0.0.1/lol-chat/v1/conversations/" + lobbyID + " /messages" ;
511+ std::string error = " errorCode" ;
512+ while (error.find (" errorCode" ) != std::string::npos)
513+ {
514+ error = http->Request (" POST" , request, R"( {"type":"chat", "body":")" + std::string (S.gameTab .instantMessage ) + R"( "})" , auth->leagueHeader , " " , " " , auth->leaguePort );
515+ std::this_thread::sleep_for (std::chrono::milliseconds (1 ));
516+ }
517+ break ;
518+ }
480519 }
481520 }
482521 }
@@ -489,7 +528,7 @@ class GameTab
489528 {
490529 if (::FindWindowA (" RCLIENT" , " League of Legends" ))
491530 {
492- if (S.gameTab .autoAcceptEnabled || S.gameTab .autoBanId || (S.gameTab .instalockEnabled && S.gameTab .instalockId ))
531+ if (S.gameTab .autoAcceptEnabled || S.gameTab .autoBanId || (S.gameTab .dodgeOnBan && S. gameTab . instalockEnabled ) || (S. gameTab . instalockEnabled && S.gameTab .instalockId ))
493532 {
494533 Json::Value rootSearch;
495534 Json::Value rootChampSelect;
@@ -502,6 +541,7 @@ class GameTab
502541 {
503542 static bool foundCell = false ;
504543 static bool sendMessage = true ;
544+ static int useBackupId = 0 ;
505545 std::string searchState = rootSearch[" searchState" ].asString ();
506546 if (searchState == " Found" )
507547 {
@@ -510,15 +550,43 @@ class GameTab
510550 {
511551 foundCell = false ;
512552 sendMessage = true ;
553+ useBackupId = 0 ;
513554 if (S.gameTab .autoAcceptEnabled )
514555 {
515556 http->Request (" POST" , " https://127.0.0.1/lol-matchmaking/v1/ready-check/accept" , " " , auth->leagueHeader , " " , " " , auth->leaguePort );
516557 }
558+ std::this_thread::sleep_for (std::chrono::milliseconds (100 ));
517559 }
518560 else
519561 {
520562 if (reader->parse (getChampSelect.c_str (), getChampSelect.c_str () + static_cast <int >(getChampSelect.length ()), &rootChampSelect, &err))
521563 {
564+ // if (S.gameTab.dodgeOnBan && S.gameTab.instalockId && S.gameTab.instalockEnabled)
565+ // {
566+ // // empty on draft? look within actions
567+ // auto myTeamBans = rootChampSelect["bans"]["myTeamBans"];
568+ // if (myTeamBans.isArray())
569+ // {
570+ // for (Json::Value::ArrayIndex i = 0; i < myTeamBans.size(); i++)
571+ // {
572+ // if (myTeamBans[i].asInt() == S.gameTab.instalockId)
573+ // {
574+ // http->Request("POST", R"(https://127.0.0.1/lol-login/v1/session/invoke?destination=lcdsServiceProxy&method=call&args=["","teambuilder-draft","quitV2",""])", "", auth->leagueHeader, "", "", auth->leaguePort);
575+ // }
576+ // }
577+ // }
578+ // auto theirTeamBans = rootChampSelect["bans"]["theirTeamBans"];
579+ // if (theirTeamBans.isArray())
580+ // {
581+ // for (Json::Value::ArrayIndex i = 0; i < theirTeamBans.size(); i++)
582+ // {
583+ // if (theirTeamBans[i].asInt() == S.gameTab.instalockId)
584+ // {
585+ // http->Request("POST", R"(https://127.0.0.1/lol-login/v1/session/invoke?destination=lcdsServiceProxy&method=call&args=["","teambuilder-draft","quitV2",""])", "", auth->leagueHeader, "", "", auth->leaguePort);
586+ // }
587+ // }
588+ // }
589+ // }
522590 if (sendMessage && !S.gameTab .instantMessage .empty ())
523591 {
524592 sendMessage = false ;
@@ -564,21 +632,26 @@ class GameTab
564632 if (actions[i][" actorCellId" ].asInt () == cellId)
565633 {
566634 std::string actionType = actions[i][" type" ].asString ();
567- if (actionType == " pick" && S.gameTab .instalockId )
635+ if (actionType == " pick" && S.gameTab .instalockId && S. gameTab . instalockEnabled )
568636 {
569637 // if havent picked yet
570638 if (actions[i][" completed" ].asBool () == false )
571639 {
572640 std::this_thread::sleep_for (std::chrono::milliseconds (S.gameTab .instalockDelay ));
641+
642+ int currentPick = S.gameTab .instalockId ;
643+ if (useBackupId)
644+ currentPick = useBackupId;
645+
573646 http->Request (" PATCH" , " https://127.0.0.1/lol-champ-select/v1/session/actions/" + actions[i][" id" ].asString (),
574- R"( {"completed":true,"championId":)" + std::to_string (S.gameTab .instalockId ) + " }" , auth->leagueHeader , " " , " " , auth->leaguePort );
575- }
576- else
577- {
578- // we picked already, theres nothing to do so sleep
579- std::this_thread::sleep_for (std::chrono::milliseconds (1000 ));
580- break ;
647+ R"( {"completed":true,"championId":)" + std::to_string (currentPick) + " }" , auth->leagueHeader , " " , " " , auth->leaguePort );
581648 }
649+ // else
650+ // {
651+ // // we picked already, theres nothing to do so sleep
652+ // std::this_thread::sleep_for(std::chrono::milliseconds(1000));
653+ // break;
654+ // }
582655 }
583656 else if (actionType == " ban" && S.gameTab .autoBanId )
584657 {
@@ -588,9 +661,26 @@ class GameTab
588661 R"( {"completed":true,"championId":)" + std::to_string (S.gameTab .autoBanId ) + " }" , auth->leagueHeader , " " , " " , auth->leaguePort );
589662 }
590663 }
591- else break ;
664+ // else break;
665+ }
666+ // if dodge on ban enabled or backup pick
667+ if ((S.gameTab .dodgeOnBan || S.gameTab .backupId ) && S.gameTab .instalockEnabled && S.gameTab .instalockId )
668+ {
669+ if (actions[i][" type" ].asString () == " ban" && actions[i][" completed" ].asBool () == true )
670+ {
671+ if (actions[i][" championId" ].asInt () == S.gameTab .instalockId )
672+ {
673+ if (S.gameTab .dodgeOnBan )
674+ {
675+ http->Request (" POST" , R"( https://127.0.0.1/lol-login/v1/session/invoke?destination=lcdsServiceProxy&method=call&args=["","teambuilder-draft","quitV2",""])" , " " , auth->leagueHeader , " " , " " , auth->leaguePort );
676+ }
677+ else if (S.gameTab .backupId )
678+ {
679+ useBackupId = S.gameTab .backupId ;
680+ }
681+ }
682+ }
592683 }
593- else continue ;
594684 }
595685 }
596686 }
@@ -607,12 +697,18 @@ class GameTab
607697 else
608698 {
609699 foundCell = false ;
700+ sendMessage = true ;
701+ useBackupId = 0 ;
610702 std::this_thread::sleep_for (std::chrono::milliseconds (1000 ));
611703 }
612704 }
613705 }
614706 }
615707 }
708+ else
709+ {
710+ std::this_thread::sleep_for (std::chrono::milliseconds (1000 ));
711+ }
616712
617713 std::this_thread::sleep_for (std::chrono::milliseconds (1 ));
618714 }
0 commit comments