//
// GameStatsManager::unlockSecretChest from 0x52ac5c to 0x52ad1a (190 bytes)
//
// 1 xrefs:
// > SecretRewardsLayer::onSelectItem @ 0x6cdea2
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 11:52:00 +0000
//
int *__fastcall GameStatsManager::unlockSecretChest(GameStatsManager *this, const char *a2, int a3, int a4)
{
int *RewardForSecretChest; // r4
int Stat; // r9
int v9; // r0
int v10; // r9
cocos2d::CCString *v11; // r0
const char *CString; // r8
size_t v13; // r0
GameStatsManager *v14; // [sp+0h] [bp-10h] BYREF
const char *v15; // [sp+4h] [bp-Ch]
int v16; // [sp+8h] [bp-8h]
int v17; // [sp+Ch] [bp-4h]
v14 = this;
v15 = a2;
v16 = a3;
v17 = a4;
if ( GameStatsManager::isSecretChestUnlocked(this, a2) )
return nullptr;
RewardForSecretChest = (int *)GameStatsManager::getRewardForSecretChest((cocos2d::CCDictionary **)this, (int)a2);
if ( !RewardForSecretChest )
return nullptr;
Stat = GameStatsManager::getStat(this, "21");
v9 = GameStatsManager::keyCostForSecretChest(this, RewardForSecretChest[13]);
if ( Stat < v9 )
return nullptr;
GameStatsManager::setStat(this, "21", (const char *)(Stat - v9));
GameStatsManager::preProcessReward(this, (GJRewardItem *)RewardForSecretChest);
GameStatsManager::registerRewardsFromItem((unsigned int)this, (GJRewardItem *)RewardForSecretChest);
v10 = *((_DWORD *)this + 122);
v11 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", a2);
v14 = nullptr;
v15 = nullptr;
v16 = 0;
CString = (const char *)cocos2d::CCString::getCString(v11);
v13 = strlen(CString);
std::string::__init((int *)&v14, CString, v13);
cocos2d::CCDictionary::setObject(v10, (cocos2d::CCObject *)RewardForSecretChest);
std::string::~string((int)&v14);
return RewardForSecretChest;
}