//
// GameStatsManager::purchaseItem from 0x5231cc to 0x5232c0 (244 bytes)
//
// 1 xrefs:
// > PurchaseItemPopup::onPurchase @ 0x61104c
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:51:53 +0000
//
int __fastcall GameStatsManager::purchaseItem(GameStatsManager *this, const char *a2)
{
int isStoreItemUnlocked; // r6
int StoreItem; // r0
int v7; // r5
char *v8; // r1
int Stat; // r0
int v10; // r2
const char *v11; // r2
char *v12; // r1
int v13; // r7
cocos2d::CCObject *v14; // r6
cocos2d::CCString *v15; // r0
const char *CString; // r9
size_t v17; // r0
char v18; // [sp+4h] [bp-20h] BYREF
_BYTE v19[7]; // [sp+5h] [bp-1Fh] BYREF
char *v20; // [sp+Ch] [bp-18h]
int v21[3]; // [sp+10h] [bp-14h] BYREF
if ( (int)a2 <= 0 )
return 0;
isStoreItemUnlocked = GameStatsManager::isStoreItemUnlocked(this, a2);
if ( isStoreItemUnlocked )
return 0;
StoreItem = GameStatsManager::getStoreItem((cocos2d::CCDictionary **)this, (int)a2);
v7 = StoreItem;
if ( StoreItem )
{
GJStoreItem::getCurrencyKey((GJStoreItem *)&v18, StoreItem);
if ( (v18 & 1) != 0 )
v8 = v20;
else
v8 = v19;
Stat = GameStatsManager::getStat(this, v8);
v10 = *(_DWORD *)(v7 + 300) - *(_DWORD *)(v7 + 304);
if ( Stat >= v10 )
{
v11 = (const char *)(Stat - v10);
if ( (v18 & 1) != 0 )
v12 = v20;
else
v12 = v19;
GameStatsManager::setStat(this, v12, v11);
v13 = *((_DWORD *)this + 106);
v14 = (cocos2d::CCObject *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(*(_DWORD *)(v7 + 300) - *(_DWORD *)(v7 + 304)));
v15 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", a2);
CString = (const char *)cocos2d::CCString::getCString(v15);
memset(v21, 0, sizeof(v21));
v17 = strlen(CString);
std::string::__init(v21, CString, v17);
cocos2d::CCDictionary::setObject(v13, v14);
isStoreItemUnlocked = 1;
std::string::~string((int)v21);
}
std::string::~string((int)&v18);
}
return isStoreItemUnlocked;
}