//
// SecretRewardsLayer::onSpecialItem from 0x6cd9fc to 0x6cdbac (432 bytes)
//
// 1 xrefs:
// > SecretRewardsLayer::onChestType @ 0x6cfee0
//
// 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::onSpecialItem(SecretRewardsLayer *this, cocos2d::CCObject *a2)
{
int v4; // r0
int v5; // r0
int *v6; // r0
int v7; // r5
int v8; // r0
GameStatsManager *v9; // r0
GameStatsManager *v10; // r10
cocos2d::CCArray *v11; // r8
const char *v12; // r5
const char *v13; // r2
cocos2d::CCString *v14; // r0
const char *CString; // r11
size_t v16; // r0
cocos2d::CCObject *v17; // r0
int v18; // r2
cocos2d::CCDirector *v19; // r5
int *v20; // r8
int v21; // r2
int v22; // r3
RewardUnlockLayer **v23; // r8
RewardsPage *v24; // r2
FLAlertLayer *v25; // r5
int v27; // [sp+4h] [bp-40h]
int v28[3]; // [sp+Ch] [bp-38h] BYREF
int v29[3]; // [sp+18h] [bp-2Ch] BYREF
int v30[3]; // [sp+24h] [bp-20h] BYREF
int v31[3]; // [sp+30h] [bp-14h] BYREF
v4 = (*(int (__fastcall **)(cocos2d::CCObject *))(*(_DWORD *)a2 + 32))(a2);
memset(v28, 0, sizeof(v28));
v5 = v4 - 5;
switch ( v5 )
{
case 2:
v6 = std::string::assign(v28, "0005");
v7 = 100;
break;
case 3:
v6 = std::string::assign(v28, "0006");
v7 = 200;
break;
case 1:
v6 = std::string::assign(v28, "0004");
v7 = 50;
break;
default:
return std::string::~string((int)v28);
}
v8 = GameStatsManager::sharedState((GameStatsManager *)v6);
v9 = (GameStatsManager *)cocos2d::CCDictionary::count(*(cocos2d::CCDictionary **)(v8 + 488));
v10 = v9;
if ( (int)v9 >= v7 )
{
v20 = (int *)GameStatsManager::sharedState(v9);
std::string::basic_string(v31, (int)v28);
v23 = (RewardUnlockLayer **)GameStatsManager::unlockSpecialChest(v20, (int)v31, v21, v22);
std::string::~string((int)v31);
if ( v23 )
{
SecretRewardsLayer::switchToOpenedState(this, a2);
v25 = RewardUnlockLayer::create(v23[15], nullptr, v24);
(*(void (__fastcall **)(SecretRewardsLayer *, FLAlertLayer *, int))(*(_DWORD *)this + 232))(this, v25, 100);
RewardUnlockLayer::showCollectReward(v25, (GJRewardItem *)v23);
}
}
else
{
v11 = (cocos2d::CCArray *)cocos2d::CCArray::create(v9);
v12 = (const char *)(v7 - (_DWORD)v10);
memset(v29, 0, sizeof(v29));
std::string::__init(v29, "The Keymaster", 0xDu);
if ( v12 == (_BYTE *)&dword_0 + 1 )
v13 = "Chest";
else
v13 = "Chests";
v14 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Unlock %i more %s, and you can collect this bonus.",
v12,
v13);
CString = (const char *)cocos2d::CCString::getCString(v14);
memset(v30, 0, sizeof(v30));
v16 = strlen(CString);
std::string::__init(v30, CString, v16);
LOWORD(v27) = -1;
BYTE2(v27) = -1;
v17 = (cocos2d::CCObject *)DialogObject::create((int)v29, (int)v30, 2, 1065353216, 0, v27);
cocos2d::CCArray::addObject(v11, v17);
std::string::~string((int)v30);
std::string::~string((int)v29);
v19 = DialogLayer::createWithObjects(v11, (cocos2d::CCArray *)((char *)&dword_0 + 2), v18);
(*(void (__fastcall **)(SecretRewardsLayer *, cocos2d::CCDirector *, int))(*(_DWORD *)this + 232))(this, v19, 100);
DialogLayer::updateChatPlacement(v19, 0);
DialogLayer::animateInRandomSide(v19);
}
return std::string::~string((int)v28);
}