//
// SecretRewardsLayer::onSelectItem from 0x6cdd78 to 0x6cdf34 (444 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
//
int *__fastcall SecretRewardsLayer::onSelectItem(SecretRewardsLayer *this, cocos2d::CCObject *a2)
{
GameStatsManager *v4; // r0
int Stat; // r4
const char *v6; // r11
int v7; // r0
GameStatsManager *v8; // r10
GameStatsManager *v9; // r0
GameStatsManager *v10; // r0
GameStatsManager *v11; // r8
const char *v12; // r4
char *v13; // r1
cocos2d::CCString *v14; // r0
int v15; // r8
DialogLayer *v16; // r0
int v17; // r2
int v18; // r3
DialogLayer *v19; // r8
int *result; // r0
GameStatsManager *v21; // r0
int v22; // r2
int v23; // r3
RewardUnlockLayer **v24; // r4
RewardsPage *v25; // r2
FLAlertLayer *v26; // r7
GameStatsManager *v27; // r0
int v28; // r4
void (__fastcall *v29)(int, int); // r7
GameStatsManager *v30; // r0
const char *v31; // r0
cocos2d::CCString *v32; // r0
int CString; // r0
int v34; // [sp+4h] [bp-30h]
int v35[3]; // [sp+8h] [bp-2Ch] BYREF
int v36[3]; // [sp+14h] [bp-20h] BYREF
int v37[3]; // [sp+20h] [bp-14h] BYREF
v4 = (GameStatsManager *)GameStatsManager::sharedState(this);
Stat = GameStatsManager::getStat(v4, "21");
v6 = (const char *)(*(int (__fastcall **)(cocos2d::CCObject *))(*(_DWORD *)a2 + 32))(a2);
v7 = (*(int (__fastcall **)(cocos2d::CCObject *))(*(_DWORD *)a2 + 536))(a2);
v8 = (GameStatsManager *)(*(int (__fastcall **)(int))(*(_DWORD *)v7 + 32))(v7);
v9 = (GameStatsManager *)GameStatsManager::sharedState(v8);
v10 = (GameStatsManager *)GameStatsManager::keyCostForSecretChest(v9, (int)v6);
v11 = v10;
if ( Stat >= (int)v10 )
{
v21 = (GameStatsManager *)GameStatsManager::sharedState(v10);
result = GameStatsManager::unlockSecretChest(v21, v6, v22, v23);
v24 = (RewardUnlockLayer **)result;
if ( result )
{
result[13] = (int)v8;
SecretRewardsLayer::switchToOpenedState(this, a2);
v26 = RewardUnlockLayer::create(v24[15], nullptr, v25);
(*(void (__fastcall **)(SecretRewardsLayer *, FLAlertLayer *, int))(*(_DWORD *)this + 232))(this, v26, 100);
v27 = (GameStatsManager *)RewardUnlockLayer::showCollectReward(v26, (GJRewardItem *)v24);
v28 = *((_DWORD *)this + 87);
v29 = *(void (__fastcall **)(int, int))(*(_DWORD *)v28 + 464);
v30 = (GameStatsManager *)GameStatsManager::sharedState(v27);
v31 = (const char *)GameStatsManager::getStat(v30, "21");
v32 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", v31);
CString = cocos2d::CCString::getCString(v32);
v29(v28, CString);
return (int *)SecretRewardsLayer::updateUnlockedLabel(this);
}
}
else
{
v12 = (char *)v10 - Stat;
memset(v35, 0, sizeof(v35));
std::string::__init(v35, &unk_B6B226, 0);
if ( v11 == (GameStatsManager *)((char *)&dword_0 + 1) )
{
v13 = "You need a key to unlock this chest.";
}
else
{
v14 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"You need %i more keys to unlock this chest",
v12);
v13 = (char *)cocos2d::CCString::getCString(v14);
}
std::string::assign(v35, v13);
if ( (int)v12 > 50 )
{
v15 = 18;
}
else if ( (int)v12 > 25 )
{
v15 = 17;
}
else if ( (int)v12 >= 11 )
{
v15 = 4;
}
else
{
v15 = 2;
}
memset(v36, 0, sizeof(v36));
std::string::__init(v36, "The Keymaster", 0xDu);
std::string::basic_string(v37, (int)v35);
LOWORD(v34) = -1;
BYTE2(v34) = -1;
v16 = (DialogLayer *)DialogObject::create((int)v36, (int)v37, v15, 1065353216, 0, v34);
v19 = DialogLayer::create(v16, (DialogObject *)((char *)&dword_0 + 2), v17, v18);
std::string::~string((int)v37);
std::string::~string((int)v36);
DialogLayer::addToMainScene(v19);
DialogLayer::updateChatPlacement(v19, 0);
DialogLayer::animateInRandomSide(v19);
return (int *)std::string::~string((int)v35);
}
return result;
}