//
// GJShopLayer::didPurchaseItem from 0x4e18a0 to 0x4e1b9a (762 bytes)
//
// 1 xrefs:
// > `non-virtual thunk to'GJShopLayer::didPurchaseItem @ 0x4e1be4
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
void GJShopLayer::didPurchaseItem(GJShopLayer *a1, GJStoreItem *a2)
{
FMODAudioEngine *v4; // r8
int v5; // r2
int v6; // r3
CCCounterLabel *m_currencyLabel; // r8
GameStatsManager *v8; // r10
int Stat; // r0
cocos2d::CCArray *v10; // r0
cocos2d::CCArray *v11; // r10
GJItemIcon *v12; // r8
cocos2d::CCArray *v13; // r10
unsigned int i; // r8
cocos2d::CCArray *v15; // r8
cocos2d::CCObject *v16; // r0
cocos2d::CCObject *v17; // r0
cocos2d::CCObject *v18; // r0
cocos2d::CCObject *v19; // r0
cocos2d::CCObject *v20; // r0
DialogLayer *v21; // r4
int v22; // [sp+4h] [bp-28h]
int v23; // [sp+4h] [bp-28h]
int v24; // [sp+4h] [bp-28h]
int v25; // [sp+4h] [bp-28h]
int v26; // [sp+4h] [bp-28h]
int v27; // [sp+Ch] [bp-20h]
char v28; // [sp+1Ch] [bp-10h] BYREF
char *v29; // [sp+20h] [bp-Ch] BYREF
v4 = FMODAudioEngine::sharedEngine();
sub_776584((int)&v29, "buyItem03.ogg");
FMODAudioEngine::playEffect(v4, (int)&v29, v5, v6);
sub_774008(&v29);
m_currencyLabel = a1->m_currencyLabel;
v8 = GameStatsManager::sharedState();
GJStoreItem::getCurrencyKey((GJStoreItem *)&v29, (int)a2);
Stat = GameStatsManager::getStat(v8, v29);
CCCounterLabel::setTargetCount(m_currencyLabel, Stat);
sub_774008(&v29);
v10 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(a1->m_shopItems, a2->m_index.random - a2->m_index.seed);
v11 = v10;
if ( v10 )
{
v12 = (GJItemIcon *)((int (__fastcall *)(cocos2d::CCArray *))v10->__vftable[13].~CCArray_0)(v10);
v11->__vftable[13].copyWithZone(v11, nullptr);
GJItemIcon::darkenStoreItem(v12, a1->m_type);
v10 = v12->getChildren(v12);
v13 = v10;
if ( v10 )
{
for ( i = 0; ; ++i )
{
v10 = (cocos2d::CCArray *)cocos2d::CCArray::count(v13);
if ( i >= (unsigned int)v10 )
break;
v27 = cocos2d::CCArray::objectAtIndex(v13, i);
if ( (*(int (**)(void))(*(_DWORD *)v27 + 32))() == 1234 )
(*(void (__fastcall **)(int, _DWORD))(*(_DWORD *)v27 + 164))(v27, 0);
}
}
}
if ( a2->m_unlockType.random - a2->m_unlockType.seed == 12 && a2->m_typeID.random - a2->m_typeID.seed == 4 )
{
v15 = (cocos2d::CCArray *)cocos2d::CCArray::create(v10);
sub_776584((int)&v28, "Scratch");
sub_776584((int)&v29, "Ah the shiny thing, excellent choice.");
LOWORD(v22) = -1;
BYTE2(v22) = -1;
v16 = (cocos2d::CCObject *)DialogObject::create(
(DialogObject *)&v28,
(std::string)&v29,
(std::string)10,
1065353216,
0.0,
v22);
cocos2d::CCArray::addObject(v15, v16);
sub_774008(&v29);
sub_774008(&v28);
sub_776584((int)&v28, "Scratch");
sub_776584((int)&v29, "I found it a while ago.\nYea... 'Found' is a good word...");
LOWORD(v23) = -1;
BYTE2(v23) = -1;
v17 = (cocos2d::CCObject *)DialogObject::create(
(DialogObject *)&v28,
(std::string)&v29,
(std::string)13,
1065353216,
0.0,
v23);
cocos2d::CCArray::addObject(v15, v17);
sub_774008(&v29);
sub_774008(&v28);
sub_776584((int)&v28, "Scratch");
sub_776584((int)&v29, "Not sure what it does. If anyone asks you didnt buy it here.");
LOWORD(v24) = -1;
BYTE2(v24) = -1;
v18 = (cocos2d::CCObject *)DialogObject::create(
(DialogObject *)&v28,
(std::string)&v29,
(std::string)11,
1065353216,
0.0,
v24);
cocos2d::CCArray::addObject(v15, v18);
sub_774008(&v29);
sub_774008(&v28);
sub_776584((int)&v28, "Scratch");
sub_776584((int)&v29, "I mean, buy it where?");
LOWORD(v25) = -1;
BYTE2(v25) = -1;
v19 = (cocos2d::CCObject *)DialogObject::create(
(DialogObject *)&v28,
(std::string)&v29,
(std::string)13,
1065353216,
0.0,
v25);
cocos2d::CCArray::addObject(v15, v19);
sub_774008(&v29);
sub_774008(&v28);
sub_776584((int)&v28, "Scratch");
sub_776584((int)&v29, "...");
LOWORD(v26) = -1;
BYTE2(v26) = -1;
v20 = (cocos2d::CCObject *)DialogObject::create(
(DialogObject *)&v28,
(std::string)&v29,
(std::string)8,
1065353216,
0.0,
v26);
cocos2d::CCArray::addObject(v15, v20);
sub_774008(&v29);
sub_774008(&v28);
v21 = DialogLayer::createWithObjects(v15, (int)&dword_0 + 2);
a1->addChild_0(a1, v21, 100);
DialogLayer::updateChatPlacement(v21, Center);
DialogLayer::animateInRandomSide(v21);
}
}