//
// GameStatsManager::unlockSecretChest from 0x10033dffc to 0x10033e140 (324 bytes)
//
// 1 xrefs:
// > SecretRewardsLayer::onSelectItem @ 0x1002eb4e8
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
GJRewardItem *__fastcall GameStatsManager::unlockSecretChest(GameStatsManager *a1, int a2)
{
GJRewardItem *v4; // x19
int Stat; // w0
int m_chestID; // w8
int v7; // w8
cocos2d::CCDictionary *m_treasureRoomChests; // x21
cocos2d::CCString *v10; // x0
char *CString; // x0
void *__p[2]; // [xsp+8h] [xbp-38h] BYREF
char v13; // [xsp+1Fh] [xbp-21h]
if ( GameStatsManager::isSecretChestUnlocked(a1, a2) )
return nullptr;
v4 = (GJRewardItem *)cocos2d::CCDictionary::objectForKey(a1->m_allTreasureRoomChests, a2);
if ( v4 )
{
Stat = GameStatsManager::getStat(a1, "21");
m_chestID = v4->m_chestID;
if ( m_chestID <= 6000 )
{
if ( m_chestID <= 5000 )
{
if ( m_chestID <= 4000 )
{
if ( m_chestID <= 3000 )
{
if ( m_chestID <= 2000 )
{
if ( m_chestID <= 1000 )
v7 = 1;
else
v7 = 5;
}
else
{
v7 = 10;
}
}
else
{
v7 = 25;
}
}
else
{
v7 = 50;
}
}
else
{
v7 = 100;
}
}
else
{
v7 = 1;
}
if ( Stat < v7 )
return nullptr;
GameStatsManager::setStat(a1, "21", Stat - v7);
GameStatsManager::preProcessReward(a1, v4);
GameStatsManager::registerRewardsFromItem(a1, v4);
m_treasureRoomChests = a1->m_treasureRoomChests;
v10 = (cocos2d::CCString *)sub_100268F4C("%i", a2);
CString = (char *)cocos2d::CCString::getCString(v10);
sub_100009900(__p, CString);
cocos2d::CCDictionary::setObject_1(m_treasureRoomChests, v4, __p);
if ( v13 < 0 )
operator delete(__p[0]);
}
return v4;
}