//
// GameStatsManager::awardCurrencyForLevel from 0x41bfc8 to 0x41c1f6 (558 bytes)
//
// 4 xrefs:
// > PlayLayer::levelComplete @ 0x3137ba
// > PlayLayer::destroyPlayer @ 0x3140c4
// > GameLevelManager::updateLevelRewards @ 0x3c6442
// > GameStatsManager::awardOldSpecialStats @ 0x41c28e
//
// 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 GameStatsManager::awardCurrencyForLevel(GameStatsManager *a1, GJGameLevel *a2)
{
float v2; // s14
int v5; // r7
const char *v6; // r9
cocos2d::CCDictionary *m_mainCurrencyScores; // r10
const char *v8; // r7
cocos2d::CCString *v9; // r0
int v10; // s16
float BaseCurrencyForLevel; // s17
int v12; // r4
float v13; // r0
int v14; // s15
int v15; // r4
cocos2d::CCDictionary *m_timelyStars; // r10
cocos2d::CCString *v17; // r0
cocos2d::CCObject *v18; // r9
_BOOL4 v19; // [sp+0h] [bp-2Ch]
int v20; // [sp+0h] [bp-2Ch]
_BOOL4 v21; // [sp+4h] [bp-28h]
cocos2d::CCObject *v22; // [sp+8h] [bp-24h]
char *v23; // [sp+10h] [bp-1Ch] BYREF
std::string v24; // [sp+14h] [bp-18h] BYREF
char *v25; // [sp+18h] [bp-14h] BYREF
std::string v26; // [sp+1Ch] [bp-10h] BYREF
_BYTE v27[4]; // [sp+20h] [bp-Ch] BYREF
v5 = a2->m_orbCompletion.random - a2->m_orbCompletion.seed;
v6 = (const char *)(a2->m_stars.random - a2->m_stars.seed);
v19 = a2->m_levelType == Main;
v21 = a2->m_dailyID.random - a2->m_dailyID.seed > 0;
if ( a2->m_dailyID.random - a2->m_dailyID.seed <= 0 )
{
if ( a2->m_levelType == Main )
{
m_mainCurrencyScores = a1->m_mainCurrencyScores;
}
else if ( a2->m_gauntletLevel )
{
m_mainCurrencyScores = a1->m_gauntletCurrencyScores;
}
else
{
m_mainCurrencyScores = a1->m_onlineCurrencyScores;
}
}
else
{
m_mainCurrencyScores = a1->m_timelyCurrencyScores;
}
if ( (int)v6 > 0 && v5 > 0 )
{
if ( v5 > 99 )
v8 = (const char *)&dword_64;
else
v8 = (const char *)(v5 & ~(v5 >> 31));
GameStatsManager::getCurrencyKey((GameStatsManager *)&v23, (GJGameLevel *)a1, a2);
sub_776584((int)&v24, v23);
v9 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(m_mainCurrencyScores, &v24);
v10 = cocos2d::CCString::intValue(v9);
sub_774008(&v24);
if ( v10 < (int)v8 )
{
BaseCurrencyForLevel = (float)GameStatsManager::getBaseCurrencyForLevel(a1, a2);
v12 = (int)floorf(BaseCurrencyForLevel * (float)((float)v10 / 100.0));
v13 = floorf(BaseCurrencyForLevel * (float)((float)(int)v8 / 100.0));
if ( v8 == (const char *)&dword_64 )
v2 = 0.25;
v14 = (int)v13;
if ( v8 == (const char *)&dword_64 )
v14 = (int)(float)((float)v14 + (float)(BaseCurrencyForLevel * v2));
v15 = v14 - v12;
if ( v15 > 0 )
{
v22 = (cocos2d::CCObject *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", v8);
sub_776584((int)&v25, v23);
cocos2d::CCDictionary::setObject((int)m_mainCurrencyScores, v22);
sub_774008(&v25);
if ( !v19 )
{
m_timelyStars = a1->m_timelyStars;
if ( !v21 )
m_timelyStars = a1->m_onlineStars;
GameStatsManager::getCurrencyKey((GameStatsManager *)&v25, (GJGameLevel *)a1, a2);
sub_776584((int)&v26, v25);
v17 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(m_timelyStars, &v26);
v20 = cocos2d::CCString::intValue(v17);
sub_774008(&v26);
if ( v20 < (int)v6 )
{
v18 = (cocos2d::CCObject *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", v6);
sub_776584((int)v27, v25);
cocos2d::CCDictionary::setObject((int)m_timelyStars, v18);
sub_774008(v27);
}
sub_774008(&v25);
}
GameStatsManager::incrementStat(a1, "14", v15);
}
}
sub_774008(&v23);
}
}