//
// SecretRewardsLayer::onSelectItem from 0x1003865bc to 0x100386824 (616 bytes)
//
// 1 xrefs:
// > SecretRewardsLayer::generateChestItems @ 0x1003862dc
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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:03:33 +0000
//
void __fastcall SecretRewardsLayer::onSelectItem(_QWORD *a1, __int64 a2)
{
int v4; // w0
int Stat; // w24
__int64 v6; // x21
__int64 v7; // x0
__int64 v8; // x0
int v9; // w22
__int64 v10; // x0
__int64 v11; // x0
bool v12; // vf
int v13; // w24
int v14; // w23
__int64 v15; // x0
__int64 v16; // x0
__int64 v17; // x21
_QWORD *v18; // x20
__int64 v19; // x0
__int64 v20; // x20
int v21; // w0
int v22; // w0
void *v23; // x0
__int64 CString; // x0
void *v25; // x0
const std::string::value_type *v26; // x0
int v27; // w19
int v28; // w9
char *v29; // x0
__int64 v30; // x19
std::string __p; // [xsp+10h] [xbp-80h] BYREF
void *v32[2]; // [xsp+30h] [xbp-60h] BYREF
char v33; // [xsp+47h] [xbp-49h]
std::string v34; // [xsp+48h] [xbp-48h] BYREF
v4 = GameStatsManager::sharedState(a1);
Stat = GameStatsManager::getStat(v4, "21");
v6 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a2 + 64LL))(a2);
v7 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a2 + 1072LL))(a2);
v8 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v7 + 64LL))(v7);
v9 = v8;
v10 = GameStatsManager::sharedState(v8);
v11 = GameStatsManager::keyCostForSecretChest(v10, v6);
v12 = __OFSUB__((_DWORD)v11, Stat);
v13 = v11 - Stat;
if ( (v13 < 0) ^ v12 | (v13 == 0) )
{
v15 = GameStatsManager::sharedState(v11);
v16 = GameStatsManager::unlockSecretChest(v15, v6);
if ( v16 )
{
v17 = v16;
*(_DWORD *)(v16 + 56) = v9;
SecretRewardsLayer::switchToOpenedState(v16, a2);
v18 = RewardUnlockLayer::create(*(unsigned int *)(v17 + 64), 0);
(*(void (__fastcall **)(_QWORD *, _QWORD *, __int64))(*a1 + 464LL))(a1, v18, 100);
v19 = RewardUnlockLayer::showCollectReward((__int64)v18, v17);
v20 = a1[59];
v21 = GameStatsManager::sharedState(v19);
v22 = GameStatsManager::getStat(v21, "21");
v23 = sub_1003065B0("%i", v22);
CString = cocos2d::CCString::getCString((__int64)v23);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v20 + 928LL))(v20, CString);
SecretRewardsLayer::updateUnlockedLabel((__int64)a1);
}
}
else
{
v14 = v11;
sub_100009900(&v34, "");
if ( v14 == 1 )
{
std::string::assign(&v34, "You need a key to unlock this chest.");
}
else
{
v25 = sub_1003065B0("You need %i more keys to unlock this chest", v13);
v26 = (const std::string::value_type *)cocos2d::CCString::getCString((__int64)v25);
std::string::assign(&v34, v26);
}
if ( v13 <= 50 )
{
if ( v13 <= 10 )
v28 = 2;
else
v28 = 4;
if ( v13 <= 25 )
v27 = v28;
else
v27 = 17;
}
else
{
v27 = 18;
}
sub_100009900(v32, "The Keymaster");
if ( SHIBYTE(v34.__r_.__value_.__r.__words[2]) < 0 )
sub_1000097D0(&__p, v34.__r_.__value_.__l.__data_, v34.__r_.__value_.__l.__size_);
else
__p = v34;
v29 = DialogObject::create((__int64)v32, (__int64)&__p, v27, 0, 0xFFFFFF, 1.0);
v30 = DialogLayer::create((__int64)v29, 2);
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__p.__r_.__value_.__l.__data_);
if ( v33 < 0 )
operator delete(v32[0]);
DialogLayer::addToMainScene(v30);
DialogLayer::updateChatPlacement(v30, 0);
DialogLayer::animateInRandomSide(v30);
if ( SHIBYTE(v34.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v34.__r_.__value_.__l.__data_);
}
}