MCPcopy Create free account
hub / github.com/Open-GD/OpenGD / onHttpRequestCompleted

Method onHttpRequestCompleted

Source/RewardUnlockLayer.cpp:312–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

310}
311
312void 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
340void RewardUnlockLayer::sendHttpRequest(int chestID)
341{

Callers

nothing calls this directly

Calls 3

createFunction · 0.85
base64_decodeFunction · 0.85
logFunction · 0.85

Tested by

no test coverage detected