//
// GameStatsManager::unlockSecretChest from 0x8eb248 to 0x8eb3a0 (344 bytes)
//
// 2 xrefs:
// > SecretRewardsLayer::onSelectItem @ 0xb9ee6c
// > ??> @ 0x53cc8
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:56:55 +0000
//
int *__fastcall GameStatsManager::unlockSecretChest(GameStatsManager *this, const char *a2)
{
unsigned int v3; // w23
int *RewardForSecretChest; // x19
int Stat; // w24
int v6; // w0
__int64 v7; // x20
cocos2d::CCString *v8; // x0
size_t v9; // x0
char *CString; // [xsp+48h] [xbp+48h]
__int64 v12[2]; // [xsp+50h] [xbp+50h] BYREF
void *v13; // [xsp+60h] [xbp+60h]
v3 = (unsigned int)a2;
if ( GameStatsManager::isSecretChestUnlocked(this, a2) )
return nullptr;
RewardForSecretChest = (int *)GameStatsManager::getRewardForSecretChest((cocos2d::CCDictionary **)this, v3);
if ( !RewardForSecretChest )
return nullptr;
Stat = GameStatsManager::getStat(this, "21");
v6 = GameStatsManager::keyCostForSecretChest(this, RewardForSecretChest[14]);
if ( Stat < v6 )
return nullptr;
GameStatsManager::setStat(this, "21", (char *)(unsigned int)(Stat - v6));
GameStatsManager::preProcessReward(this, (GJRewardItem *)RewardForSecretChest);
GameStatsManager::registerRewardsFromItem(this, (GJRewardItem *)RewardForSecretChest);
v7 = *((_QWORD *)this + 95);
v8 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", (const char *)v3);
v12[0] = 0;
CString = (char *)cocos2d::CCString::getCString(v8);
v12[1] = 0;
v13 = nullptr;
v9 = strlen(CString);
std::string::__init(v12, CString, v9);
cocos2d::CCDictionary::setObject(v7, (cocos2d::CCObject *)RewardForSecretChest);
if ( (v12[0] & 1) != 0 )
operator delete(v13);
return RewardForSecretChest;
}