| 1630 | } |
| 1631 | |
| 1632 | static std::string ChangeRunesOpgg() |
| 1633 | { |
| 1634 | //std::string champSelect = LCU::Request("GET", "/lol-champ-select/v1/session"); |
| 1635 | //if (champSelect.empty() || champSelect.find("RPC_ERROR") != std::string::npos) |
| 1636 | //{ |
| 1637 | // return "Champion select not found"; |
| 1638 | //} |
| 1639 | |
| 1640 | Json::CharReaderBuilder builder; |
| 1641 | const std::unique_ptr<Json::CharReader> reader(builder.newCharReader()); |
| 1642 | JSONCPP_STRING err; |
| 1643 | Json::Value rootCurrentPage; |
| 1644 | //Json::Value rootCSelect; |
| 1645 | |
| 1646 | //if (!reader->parse(champSelect.c_str(), champSelect.c_str() + static_cast<int>(champSelect.length()), &rootCSelect, &err)) |
| 1647 | //{ |
| 1648 | // return "Failed to get champion select"; |
| 1649 | //} |
| 1650 | |
| 1651 | std::string currentChampion = LCU::Request("GET", "/lol-champ-select/v1/current-champion"); |
| 1652 | if (currentChampion == "0" || currentChampion.empty() || currentChampion.find("RPC_ERROR") != std::string::npos) |
| 1653 | { |
| 1654 | return "Champion not picked"; |
| 1655 | } |
| 1656 | |
| 1657 | std::string currentChampionName; |
| 1658 | for (const auto& [key, name, skins] : champSkins) |
| 1659 | { |
| 1660 | if (std::stoi(currentChampion) == key) |
| 1661 | { |
| 1662 | currentChampionName = name; |
| 1663 | break; |
| 1664 | } |
| 1665 | } |
| 1666 | |
| 1667 | std::string getCurrentPage = LCU::Request("GET", "/lol-perks/v1/currentpage"); |
| 1668 | if (!reader->parse(getCurrentPage.c_str(), getCurrentPage.c_str() + static_cast<int>(getCurrentPage.length()), &rootCurrentPage, &err)) |
| 1669 | { |
| 1670 | return "Failed to get current rune page"; |
| 1671 | } |
| 1672 | std::string currentPageId = rootCurrentPage["id"].asString(); |
| 1673 | |
| 1674 | std::stringstream ssOpgg(cpr::Get(cpr::Url{ "https://www.op.gg/champions/" + Utils::ToLower(currentChampionName) }).text); |
| 1675 | std::vector<std::string> runes; |
| 1676 | std::string primaryPerk, secondaryPerk; |
| 1677 | |
| 1678 | std::string buf; |
| 1679 | while (ssOpgg >> buf) |
| 1680 | { |
| 1681 | if (runes.size() == 9) |
| 1682 | break; |
| 1683 | |
| 1684 | if (buf.find("src=\"https://opgg-static.akamaized.net/images/lol/perk") != std::string::npos |
| 1685 | || buf.find("src=\"https://opgg-static.akamaized.net/meta/images/lol/perk") != std::string::npos) |
| 1686 | { |
| 1687 | if (buf.find("grayscale") != std::string::npos) |
| 1688 | continue; |
| 1689 | |