//
// GJShopLayer::didPurchaseItem from 0xa7d2f0 to 0xa7d868 (1400 bytes)
//
// 3 xrefs:
// > `non-virtual thunk to'GJShopLayer::didPurchaseItem @ 0xa7d86c
// > ??> @ 0xd4b00
// > ??> @ 0x14963c0
//
// 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 13:00:30 +0000
//
__int64 __fastcall GJShopLayer::didPurchaseItem(GJShopLayer *this, GJStoreItem *a2)
{
__int64 v4; // x19
GameStatsManager *v5; // x0
CCCounterLabel *v6; // x19
GameStatsManager *v7; // x20
char *v8; // x1
int Stat; // w0
__int64 v10; // x0
__int64 v11; // x20
unsigned int v12; // w19
__int64 v13; // x21
cocos2d::CCArray *v14; // x0
cocos2d::CCArray *v15; // x20
__int64 v16; // x21
cocos2d::CCArray *v18; // x0
cocos2d::CCArray *v19; // x20
cocos2d::CCObject *v20; // x0
cocos2d::CCObject *v21; // x0
cocos2d::CCObject *v22; // x0
cocos2d::CCObject *v23; // x0
cocos2d::CCObject *v24; // x0
DialogLayer *v25; // x19
__int64 v26; // [xsp+58h] [xbp+58h] BYREF
__int64 v27; // [xsp+60h] [xbp+60h]
void *v28; // [xsp+68h] [xbp+68h]
GameStatsManager *v29; // [xsp+70h] [xbp+70h] BYREF
__int64 v30; // [xsp+78h] [xbp+78h]
char *v31; // [xsp+80h] [xbp+80h]
v4 = FMODAudioEngine::sharedEngine(_stack_chk_guard);
v29 = nullptr;
v30 = 0;
v31 = nullptr;
std::string::__init((__int64 *)&v29, "buyItem03.ogg", 0xDu);
FMODAudioEngine::playEffect(v4, (char *)&v29);
v5 = (GameStatsManager *)(unsigned __int8)v29;
if ( ((unsigned __int8)v29 & 1) != 0 )
operator delete(v31);
v6 = *((CCCounterLabel **)this + 55);
v7 = (GameStatsManager *)GameStatsManager::sharedState(v5);
GJStoreItem::getCurrencyKey(a2, (__int64)&v29);
v8 = (char *)&v29 + 1;
if ( ((unsigned __int8)v29 & 1) != 0 )
v8 = v31;
Stat = GameStatsManager::getStat(v7, v8);
CCCounterLabel::setTargetCount(v6, Stat);
if ( ((unsigned __int8)v29 & 1) != 0 )
operator delete(v31);
v10 = cocos2d::CCDictionary::objectForKey(
*((cocos2d::CCDictionary **)this + 56),
*((_DWORD *)a2 + 79) - *((_DWORD *)a2 + 80));
v11 = v10;
if ( v10 )
{
v12 = 0;
v13 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v10 + 1072LL))(v10);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v11 + 1056LL))(v11, 0);
GJItemIcon::darkenStoreItem(v13, (GJItemIcon *)*((unsigned int *)this + 114));
v14 = (cocos2d::CCArray *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v13 + 488LL))(v13);
v15 = v14;
if ( v14 )
{
if ( (unsigned int)cocos2d::CCArray::count(v14) )
{
do
{
v16 = cocos2d::CCArray::objectAtIndex(v15, v12++);
if ( (*(unsigned int (__fastcall **)(__int64))(*(_QWORD *)v16 + 64LL))(v16) == 1234 )
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v16 + 344LL))(v16, 0);
}
while ( v12 < (unsigned int)cocos2d::CCArray::count(v15) );
}
}
}
if ( *((_DWORD *)a2 + 85) - *((_DWORD *)a2 + 86) == 12 )
{
v18 = (cocos2d::CCArray *)(unsigned int)(*((_DWORD *)a2 + 82) - *((_DWORD *)a2 + 83));
if ( (_DWORD)v18 == 4 )
{
v19 = (cocos2d::CCArray *)cocos2d::CCArray::create(v18);
v26 = 0;
v27 = 0;
v28 = nullptr;
std::string::__init(&v26, "Scratch", 7u);
v29 = nullptr;
v30 = 0;
v31 = nullptr;
std::string::__init((__int64 *)&v29, "Ah the shiny thing, excellent choice.", 0x2Du);
v20 = (cocos2d::CCObject *)DialogObject::create((char *)&v26, (char *)&v29, 10, 0, 0xFFFFFF, 1.0);
cocos2d::CCArray::addObject(v19, v20);
if ( ((unsigned __int8)v29 & 1) != 0 )
{
operator delete(v31);
if ( (v26 & 1) == 0 )
goto LABEL_18;
}
else if ( (v26 & 1) == 0 )
{
LABEL_18:
v26 = 0;
v27 = 0;
v28 = nullptr;
std::string::__init(&v26, "Scratch", 7u);
v29 = nullptr;
v30 = 0;
v31 = nullptr;
std::string::__init(
(__int64 *)&v29,
"I found it a while ago.\nYea... 'Found' is a good word...",
0x50u);
v21 = (cocos2d::CCObject *)DialogObject::create((char *)&v26, (char *)&v29, 13, 0, 0xFFFFFF, 1.0);
cocos2d::CCArray::addObject(v19, v21);
if ( ((unsigned __int8)v29 & 1) != 0 )
operator delete(v31);
if ( (v26 & 1) != 0 )
operator delete(v28);
v26 = 0;
v27 = 0;
v28 = nullptr;
std::string::__init(&v26, "Scratch", 7u);
v29 = nullptr;
v30 = 0;
v31 = nullptr;
std::string::__init(
(__int64 *)&v29,
"Not sure what it does. If anyone asks you didnt buy it here.",
0x42u);
v22 = (cocos2d::CCObject *)DialogObject::create((char *)&v26, (char *)&v29, 11, 0, 0xFFFFFF, 1.0);
cocos2d::CCArray::addObject(v19, v22);
if ( ((unsigned __int8)v29 & 1) != 0 )
operator delete(v31);
if ( (v26 & 1) != 0 )
operator delete(v28);
v26 = 0;
v27 = 0;
v28 = nullptr;
std::string::__init(&v26, "Scratch", 7u);
v29 = nullptr;
v30 = 0;
v31 = nullptr;
std::string::__init((__int64 *)&v29, "I mean, buy it where?", 0x1Bu);
v23 = (cocos2d::CCObject *)DialogObject::create((char *)&v26, (char *)&v29, 13, 0, 0xFFFFFF, 1.0);
cocos2d::CCArray::addObject(v19, v23);
if ( ((unsigned __int8)v29 & 1) != 0 )
operator delete(v31);
if ( (v26 & 1) != 0 )
operator delete(v28);
v26 = 0;
v27 = 0;
v28 = nullptr;
std::string::__init(&v26, "Scratch", 7u);
v29 = nullptr;
v30 = 0;
v31 = nullptr;
std::string::__init((__int64 *)&v29, "...", 0x15u);
v24 = (cocos2d::CCObject *)DialogObject::create((char *)&v26, (char *)&v29, 8, 0, 0xFFFFFF, 1.0);
cocos2d::CCArray::addObject(v19, v24);
if ( ((unsigned __int8)v29 & 1) != 0 )
operator delete(v31);
if ( (v26 & 1) != 0 )
operator delete(v28);
v25 = (DialogLayer *)DialogLayer::createWithObjects(v19, (cocos2d::CCArray *)((char *)&dword_0 + 2));
(*(void (__fastcall **)(GJShopLayer *, DialogLayer *, __int64))(*(_QWORD *)this + 464LL))(this, v25, 100);
DialogLayer::updateChatPlacement((__int64)v25, 0);
DialogLayer::animateInRandomSide(v25);
return _stack_chk_guard;
}
operator delete(v28);
goto LABEL_18;
}
}
return _stack_chk_guard;
}