//
// PurchaseItemPopup::onPurchase from 0x1402afb30 to 0x1402afbd6 (166 bytes)
//
// 3 xrefs:
// > PurchaseItemPopup::init @ 0x1402af53c
// > ??> @ 0x1406d22a0
// > ??> @ 0x1406d22ac
//
// 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
//
// Hidden C++ exception states: #wind=1
void PurchaseItemPopup::onPurchase(PurchaseItemPopup *a1, cocos2d::CCObject *a2)
{
int v3; // edi
GameStatsManager *v4; // rcx
GJPurchaseDelegate *m_delegate; // rcx
_BOOL8 v6; // rdx
void *v7; // [rsp+30h] [rbp+8h]
v3 = a1->m_storeItem->m_index.random - a1->m_storeItem->m_index.seed;
v4 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v7 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v7);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v4 = (GameStatsManager *)qword_1406C2EE8;
}
if ( GameStatsManager::purchaseItem(v4, v3) )
{
m_delegate = a1->m_delegate;
if ( m_delegate )
m_delegate->didPurchaseItem(m_delegate, a1->m_storeItem);
}
a1->setKeypadEnabled(a1, 0);
LOBYTE(v6) = 1;
a1->removeFromParentAndCleanup(a1, v6);
}