//
// SecretRewardsLayer::onGoldChest from 0x6cdbd0 to 0x6cdd58 (392 bytes)
//
// 0 xrefs:
//
// 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:57:00 +0000
//
GJRewardItem *__fastcall SecretRewardsLayer::onGoldChest(SecretRewardsLayer *this, cocos2d::CCObject *a2)
{
GameStatsManager *v3; // r0
GameStatsManager *Stat; // r5
GameStatsManager *v5; // r0
GameStatsManager *NextGoldChestID; // r0
const char *v7; // r6
int v8; // r5
char *v9; // r1
int v10; // r8
DialogLayer *v11; // r0
int v12; // r2
int v13; // r3
DialogLayer *v14; // r8
GJRewardItem *result; // r0
GameStatsManager *v16; // r0
RewardsPage *v17; // r2
GJRewardItem *v18; // r5
FLAlertLayer *v19; // r6
GameStatsManager *v20; // r0
int v21; // r5
void (__fastcall *v22)(int, int); // r6
GameStatsManager *v23; // r0
const char *v24; // r0
cocos2d::CCString *v25; // r0
int CString; // r0
int v27; // r1
int v28; // r2
int v29; // [sp+4h] [bp-2Ch]
int v30[3]; // [sp+8h] [bp-28h] BYREF
int v31[3]; // [sp+14h] [bp-1Ch] BYREF
int v32[3]; // [sp+20h] [bp-10h] BYREF
v3 = (GameStatsManager *)GameStatsManager::sharedState(this);
Stat = (GameStatsManager *)GameStatsManager::getStat(v3, "43");
v5 = (GameStatsManager *)GameStatsManager::sharedState(Stat);
NextGoldChestID = (GameStatsManager *)GameStatsManager::getNextGoldChestID(v5);
v7 = (const char *)NextGoldChestID;
if ( (int)Stat > 0 && NextGoldChestID )
{
v16 = (GameStatsManager *)GameStatsManager::sharedState(NextGoldChestID);
result = GameStatsManager::unlockGoldChest(v16, v7);
v18 = result;
if ( result )
{
v19 = RewardUnlockLayer::create(*((RewardUnlockLayer **)result + 15), nullptr, v17);
(*(void (__fastcall **)(SecretRewardsLayer *, FLAlertLayer *, int))(*(_DWORD *)this + 232))(this, v19, 100);
v20 = (GameStatsManager *)RewardUnlockLayer::showCollectReward(v19, v18);
v21 = *((_DWORD *)this + 88);
v22 = *(void (__fastcall **)(int, int))(*(_DWORD *)v21 + 464);
v23 = (GameStatsManager *)GameStatsManager::sharedState(v20);
v24 = (const char *)GameStatsManager::getStat(v23, "43");
v25 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", v24);
CString = cocos2d::CCString::getCString(v25);
v22(v21, CString);
SecretRewardsLayer::updateUnlockedGoldLabel((int **)this, v27, v28);
return (GJRewardItem *)SecretRewardsLayer::fadeInOutMusic(this);
}
}
else
{
v8 = 1 - (_DWORD)Stat;
memset(v30, 0, sizeof(v30));
std::string::__init(v30, &unk_B6B226, 0);
if ( v7 )
v9 = "You need a Gold Key to unlock this chest.";
else
v9 = "All out of Gold Chests right now. Come back later.";
std::string::assign(v30, v9);
if ( v8 > 50 )
{
v10 = 18;
}
else if ( v8 > 25 )
{
v10 = 17;
}
else if ( v8 >= 11 )
{
v10 = 4;
}
else
{
v10 = 2;
}
memset(v31, 0, sizeof(v31));
std::string::__init(v31, "The Keymaster", 0xDu);
std::string::basic_string(v32, (int)v30);
LOWORD(v29) = -1;
BYTE2(v29) = -1;
v11 = (DialogLayer *)DialogObject::create((int)v31, (int)v32, v10, 1065353216, 0, v29);
v14 = DialogLayer::create(v11, (DialogObject *)((char *)&dword_0 + 2), v12, v13);
std::string::~string((int)v32);
std::string::~string((int)v31);
DialogLayer::addToMainScene(v14);
DialogLayer::updateChatPlacement(v14, 0);
DialogLayer::animateInRandomSide(v14);
return (GJRewardItem *)std::string::~string((int)v30);
}
return result;
}