| 506 | } |
| 507 | |
| 508 | static std::string GetPlayerPreferences() |
| 509 | { |
| 510 | std::string challengesData = LCU::Request("GET", "/lol-challenges/v1/summary-player-data/local-player"); |
| 511 | Json::CharReaderBuilder builder; |
| 512 | const std::unique_ptr<Json::CharReader> reader(builder.newCharReader()); |
| 513 | JSONCPP_STRING err; |
| 514 | Json::Value root; |
| 515 | if (reader->parse(challengesData.c_str(), challengesData.c_str() + static_cast<int>(challengesData.length()), &root, &err)) |
| 516 | { |
| 517 | std::string titleId = root["title"]["itemId"].asString(); |
| 518 | std::string bannerId = root["bannerId"].asString(); |
| 519 | |
| 520 | std::string result = "{"; |
| 521 | for (Json::Value::ArrayIndex i = 0; i < root["topChallenges"].size(); i++) |
| 522 | { |
| 523 | if (i == 0) |
| 524 | result += "\"challengeIds\":["; |
| 525 | |
| 526 | result += root["topChallenges"][i]["id"].asString(); |
| 527 | |
| 528 | if (i != root["topChallenges"].size() - 1) |
| 529 | result += ","; |
| 530 | else |
| 531 | result += "]"; |
| 532 | } |
| 533 | |
| 534 | if (titleId != "-1") |
| 535 | { |
| 536 | if (result.size() != 1) |
| 537 | result += ","; |
| 538 | result += R"("title":")" + titleId + "\""; |
| 539 | } |
| 540 | |
| 541 | if (!bannerId.empty()) |
| 542 | { |
| 543 | if (result.size() != 1) |
| 544 | result += ","; |
| 545 | result += R"("bannerAccent":")" + bannerId + "\""; |
| 546 | } |
| 547 | result += "}"; |
| 548 | |
| 549 | return result; |
| 550 | } |
| 551 | return ""; |
| 552 | } |
| 553 | }; |