| 177 | } |
| 178 | |
| 179 | static void GetAllChampionSkins() |
| 180 | { |
| 181 | std::string getSkins = cpr::Get(cpr::Url{ "https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/v1/skins.json" }).text; |
| 182 | Json::CharReaderBuilder builder; |
| 183 | const std::unique_ptr<Json::CharReader> reader(builder.newCharReader()); |
| 184 | JSONCPP_STRING err; |
| 185 | Json::Value root; |
| 186 | if (!reader->parse(getSkins.c_str(), getSkins.c_str() + static_cast<int>(getSkins.length()), &root, &err)) |
| 187 | return; |
| 188 | |
| 189 | std::map<std::string, Champ> champs; |
| 190 | for (const std::string& id : root.getMemberNames()) |
| 191 | { |
| 192 | const Json::Value currentSkin = root[id]; |
| 193 | |
| 194 | std::string loadScreenPath = currentSkin["loadScreenPath"].asString(); |
| 195 | size_t nameStart = loadScreenPath.find("ASSETS/Characters/") + strlen("ASSETS/Characters/"); |
| 196 | std::string champName = loadScreenPath.substr(nameStart, loadScreenPath.find('/', nameStart) - nameStart); |
| 197 | |
| 198 | std::string name = currentSkin["name"].asString(); |
| 199 | |
| 200 | std::pair<std::string, std::string> skin; |
| 201 | if (currentSkin["isBase"].asBool() == true) |
| 202 | { |
| 203 | champs[champName].name = champName; |
| 204 | std::string champKey = id; |
| 205 | if (champKey.size() >= 3 && champKey.substr(champKey.size() - 3) == "000") { |
| 206 | champKey.erase(champKey.size() - 3); |
| 207 | } |
| 208 | |
| 209 | champs[champName].key = std::stoi(champKey); |
| 210 | skin.first = id; |
| 211 | skin.second = "default"; |
| 212 | champs[champName].skins.insert(champs[champName].skins.begin(), skin); |
| 213 | } |
| 214 | else |
| 215 | { |
| 216 | if (currentSkin["questSkinInfo"]) // K/DA ALL OUT Seraphine |
| 217 | { |
| 218 | for (const Json::Value skinTiers = currentSkin["questSkinInfo"]["tiers"]; const auto & skinTier : skinTiers) |
| 219 | { |
| 220 | skin.first = skinTier["id"].asString(); |
| 221 | skin.second = skinTier["name"].asString(); |
| 222 | champs[champName].skins.emplace_back(skin); |
| 223 | } |
| 224 | } |
| 225 | else |
| 226 | { |
| 227 | skin.first = id; |
| 228 | skin.second = name; |
| 229 | champs[champName].skins.emplace_back(skin); |
| 230 | } |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | std::vector<Champ> temp; |
| 235 | for (const auto& c : champs) |
| 236 | { |