| 310 | } |
| 311 | |
| 312 | void RewardUnlockLayer::onHttpRequestCompleted(ax::network::HttpClient* sender, ax::network::HttpResponse* response, int chestID) |
| 313 | { |
| 314 | if (auto str = GameToolbox::getResponse(response)) |
| 315 | { |
| 316 | std::string_view strResp {*str}; |
| 317 | |
| 318 | GetGJRewards* rewards = GetGJRewards::create(); |
| 319 | |
| 320 | auto decodedResponse = GameToolbox::xorCipher(base64_decode(fmt::format("{}", strResp.substr(5))), "59182"); |
| 321 | auto data = GameToolbox::splitByDelim(decodedResponse, ':'); |
| 322 | |
| 323 | GameToolbox::log("{}", (chestID == 1) ? data[6] : data[9]); |
| 324 | auto chestData = GameToolbox::splitByDelim((chestID == 1) ? data[6] : data[9], ','); |
| 325 | int orbs = GameToolbox::stoi(chestData[0]); |
| 326 | int diamonds = GameToolbox::stoi(chestData[1]); |
| 327 | int key = GameToolbox::stoi(chestData[3]); |
| 328 | if (orbs > 0) rewards->orbs = orbs; |
| 329 | if (diamonds > 0) rewards->diamonds = diamonds; |
| 330 | if (key > 0) rewards->key = true; |
| 331 | //add key and shards |
| 332 | |
| 333 | playRewardEffect(rewards); |
| 334 | return; |
| 335 | } |
| 336 | _errorMsg->setVisible(true); |
| 337 | _closeBtn->setVisible(true); |
| 338 | } |
| 339 | |
| 340 | void RewardUnlockLayer::sendHttpRequest(int chestID) |
| 341 | { |
nothing calls this directly
no test coverage detected