Skip to content

Commit

Permalink
added none to autoban and random to instalock
Browse files Browse the repository at this point in the history
  • Loading branch information
KebsCS committed Nov 26, 2023
1 parent 792ea6b commit 354d27f
Showing 1 changed file with 55 additions and 18 deletions.
73 changes: 55 additions & 18 deletions KBotExt/GameTab.h
Original file line number Diff line number Diff line change
Expand Up @@ -558,17 +558,25 @@ class GameTab
if (!instalockChamps.empty())
{
std::vector<std::string> instalockChampsNames;
instalockChampsNames.reserve(instalockChamps.size());
instalockChampsNames.reserve(instalockChamps.size() + 1);
instalockChampsNames.emplace_back("Random");

std::string selectedChamp = ChampIdToName(S.gameTab.instalockId);
std::ranges::copy(selectedChamp, instalockComboData.input);
if (S.gameTab.instalockId == -1)
{
std::ranges::copy("Random", instalockComboData.input);
}
else
{
std::string selectedChamp = ChampIdToName(S.gameTab.instalockId);
std::ranges::copy(selectedChamp, instalockComboData.input);
}

for (size_t i = 0; i < instalockChamps.size(); i++)
{
instalockChampsNames.emplace_back(instalockChamps[i].second);
if (instalockComboData.input == instalockChamps[i].second)
{
instalockComboData.index = i;
instalockComboData.index = i + 1;
}
}
instalockComboData.items = instalockChampsNames;
Expand All @@ -582,11 +590,18 @@ class GameTab
{
if (instalockComboData.index != -1)
{
for (const auto& [key, name, skins] : champSkins)
if (std::string(instalockComboData.input) == "Random")
{
if (instalockComboData.input == name)
S.gameTab.instalockId = -1;
}
else
{
for (const auto& [key, name, skins] : champSkins)
{
S.gameTab.instalockId = key;
if (instalockComboData.input == name)
{
S.gameTab.instalockId = key;
}
}
}
}
Expand Down Expand Up @@ -635,18 +650,26 @@ class GameTab
std::vector<std::string> autobanChampsNames;
if (!champSkins.empty())
{
autobanChampsNames.reserve(champSkins.size());
autobanChampsNames.reserve(champSkins.size() + 1);
autobanChampsNames.emplace_back("None");

std::string selectedChamp = ChampIdToName(S.gameTab.autoBanId);
std::ranges::copy(selectedChamp, autobanComboData.input);
if (S.gameTab.autoBanId == -1)
{
std::ranges::copy("None", autobanComboData.input);
}
else
{
std::string selectedChamp = ChampIdToName(S.gameTab.autoBanId);
std::ranges::copy(selectedChamp, autobanComboData.input);
}

for (size_t i = 0; i < champSkins.size(); i++)
{
autobanChampsNames.emplace_back(champSkins[i].name);

if (autobanComboData.input == champSkins[i].name)
{
autobanComboData.index = i;
autobanComboData.index = i + 1;
}
}
autobanComboData.items = autobanChampsNames;
Expand All @@ -659,11 +682,18 @@ class GameTab
{
if (autobanComboData.index != -1)
{
for (const auto& [key, name, skins] : champSkins)
if (std::string(autobanComboData.input) == "None")
{
S.gameTab.autoBanId = -1;
}
else
{
if (autobanComboData.input == name)
for (const auto& [key, name, skins] : champSkins)
{
S.gameTab.autoBanId = key;
if (autobanComboData.input == name)
{
S.gameTab.autoBanId = key;
}
}
}
}
Expand Down Expand Up @@ -1384,8 +1414,8 @@ class GameTab
// search for own actions
if (action["actorCellId"].asInt() == cellId)
{
if (std::string actionType = action["type"].asString(); actionType == "pick" && S.gameTab.instalockId && S.gameTab
.instalockEnabled)
if (std::string actionType = action["type"].asString(); actionType == "pick"
&& S.gameTab.instalockId && S.gameTab.instalockEnabled)
{
// if haven't picked yet
if (action["completed"].asBool() == false)
Expand All @@ -1398,6 +1428,12 @@ class GameTab
if (useBackupId)
currentPick = useBackupId;

if (S.gameTab.instalockId == -1)
{
std::vector<std::pair<int, std::string>> instalockChamps = GetInstalockChamps();
currentPick = instalockChamps[Utils::RandomInt(0, instalockChamps.size() - 1)].first;
}

session.SetUrl(std::format("https://127.0.0.1:{}/lol-champ-select/v1/session/actions/{}",
LCU::league.port,
action["id"].asString()));
Expand Down Expand Up @@ -1425,7 +1461,8 @@ class GameTab
}
}
// action that isn't our player, if dodge on ban enabled or backup pick
else if ((S.gameTab.dodgeOnBan || S.gameTab.backupId) && S.gameTab.instalockEnabled && S.gameTab.instalockId)
else if ((S.gameTab.dodgeOnBan || S.gameTab.backupId) && S.gameTab.instalockEnabled
&& S.gameTab.instalockId && (S.gameTab.instalockId != -1))
{
if (isPicked)
break;
Expand Down Expand Up @@ -1453,7 +1490,7 @@ class GameTab
}
else if (action["type"].asString() == "pick" && action["completed"].asBool() == true)
{
if (S.gameTab.backupId && action["championId"].asInt() == S.gameTab.instalockId)
if (S.gameTab.backupId && (action["championId"].asInt() == S.gameTab.instalockId))
{
useBackupId = S.gameTab.backupId;
}
Expand Down

3 comments on commit 354d27f

@Dorlander
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty for random

@AhmedEzzi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kebs i wanna email to reach to you

@KebsCS
Copy link
Owner Author

@KebsCS KebsCS commented on 354d27f Dec 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kebs i wanna email to reach to you

reach out to me on discord @KebsCS

Please sign in to comment.