//
// GameStatsManager::purchaseItem from 0x8dd904 to 0x8ddab0 (428 bytes)
//
// 2 xrefs:
// > PurchaseItemPopup::onPurchase @ 0xa7c808
// > ??> @ 0x9e410
//
// 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 12:56:48 +0000
//
__int64 __fastcall GameStatsManager::purchaseItem(GameStatsManager *this, const char *a2)
{
unsigned int v2; // w21
bool isStoreItemUnlocked; // w0
unsigned int v5; // w20
GJStoreItem *StoreItem; // x0
GJStoreItem *v8; // x23
char *v9; // x1
int Stat; // w0
int v11; // w1
char *v12; // x2
char *v13; // x1
int v14; // w2
int v15; // w1
__int64 v16; // x23
cocos2d::CCObject *v17; // x22
cocos2d::CCString *v18; // x0
size_t v19; // x0
char *CString; // [xsp+48h] [xbp+48h]
char v21; // [xsp+58h] [xbp+58h] BYREF
_BYTE v22[15]; // [xsp+59h] [xbp+59h] BYREF
char *v23; // [xsp+68h] [xbp+68h]
__int64 v24[2]; // [xsp+70h] [xbp+70h] BYREF
void *v25; // [xsp+80h] [xbp+80h]
v2 = (unsigned int)a2;
if ( (int)a2 <= 0 )
return 0;
isStoreItemUnlocked = GameStatsManager::isStoreItemUnlocked(this, a2);
v5 = isStoreItemUnlocked;
if ( isStoreItemUnlocked )
{
return 0;
}
else
{
StoreItem = (GJStoreItem *)GameStatsManager::getStoreItem((cocos2d::CCDictionary **)this, v2);
v8 = StoreItem;
if ( StoreItem )
{
GJStoreItem::getCurrencyKey(StoreItem, (__int64)&v21);
v9 = v22;
if ( (v21 & 1) != 0 )
v9 = v23;
Stat = GameStatsManager::getStat(this, v9);
v11 = *((_DWORD *)v8 + 88) - *((_DWORD *)v8 + 89);
if ( Stat >= v11 )
{
v12 = (char *)(unsigned int)(Stat - v11);
v13 = v22;
if ( (v21 & 1) != 0 )
v13 = v23;
GameStatsManager::setStat(this, v13, v12);
v14 = *((_DWORD *)v8 + 88);
v15 = *((_DWORD *)v8 + 89);
v16 = *((_QWORD *)this + 79);
v17 = (cocos2d::CCObject *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(unsigned int)(v14 - v15));
v18 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", (const char *)v2);
CString = (char *)cocos2d::CCString::getCString(v18);
v24[0] = 0;
v24[1] = 0;
v25 = nullptr;
v19 = strlen(CString);
std::string::__init(v24, CString, v19);
cocos2d::CCDictionary::setObject(v16, v17);
v5 = 1;
if ( (v24[0] & 1) != 0 )
operator delete(v25);
}
if ( (v21 & 1) != 0 )
operator delete(v23);
}
}
return v5;
}