//
// GameStatsManager::awardDiamondsForLevel from 0x41c2c8 to 0x41c4b8 (496 bytes)
//
// 2 xrefs:
// > PlayLayer::levelComplete @ 0x3139da
// > PlayLayer::destroyPlayer @ 0x3140ee
//
// 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::awardDiamondsForLevel(GameStatsManager *a1, GJGameLevel *a2)
{
const char *v4; // r8
int BaseDiamonds; // r0
int random; // r3
int seed; // r2
int v8; // s17
int v9; // r9
const char *v10; // r9
cocos2d::CCDictionary *m_timelyDiamondScores; // r10
cocos2d::CCString *v12; // r0
int v13; // s16
float v14; // s17
int v15; // r5
int v16; // r5
cocos2d::CCDictionary *m_timelyStars; // r9
cocos2d::CCString *v18; // r0
int v19; // r10
cocos2d::CCObject *v20; // r8
cocos2d::CCObject *v21; // [sp+0h] [bp-24h]
char *v22; // [sp+8h] [bp-1Ch] BYREF
std::string v23; // [sp+Ch] [bp-18h] BYREF
_BYTE v24[4]; // [sp+10h] [bp-14h] BYREF
std::string v25; // [sp+14h] [bp-10h] BYREF
_BYTE v26[4]; // [sp+18h] [bp-Ch] BYREF
if ( a2->m_dailyID.random - a2->m_dailyID.seed > 0 || a2->m_gauntletLevel )
{
v4 = (const char *)(a2->m_stars.random - a2->m_stars.seed);
BaseDiamonds = GameStatsManager::getBaseDiamonds(a1, (int)v4);
random = a2->m_orbCompletion.random;
seed = a2->m_orbCompletion.seed;
v8 = BaseDiamonds;
if ( BaseDiamonds > 0 )
{
v9 = random - seed;
if ( random - seed > 0 )
{
if ( v9 > 99 )
v10 = (const char *)&dword_64;
else
v10 = (const char *)(v9 & ~(v9 >> 31));
GameStatsManager::getCurrencyKey((GameStatsManager *)&v22, (GJGameLevel *)a1, a2);
m_timelyDiamondScores = a1->m_timelyDiamondScores;
if ( a2->m_dailyID.random - a2->m_dailyID.seed <= 0 )
m_timelyDiamondScores = a1->m_gauntletDiamondScores;
sub_776584((int)&v23, v22);
v12 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(m_timelyDiamondScores, &v23);
v13 = cocos2d::CCString::intValue(v12);
sub_774008(&v23);
if ( v13 < (int)v10 )
{
v14 = (float)v8;
v15 = (int)floorf(v14 * (float)((float)v13 / 100.0));
v16 = (int)floorf(v14 * (float)((float)(int)v10 / 100.0)) - v15;
if ( v16 > 0 )
{
v21 = (cocos2d::CCObject *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", v10);
sub_776584((int)v24, v22);
cocos2d::CCDictionary::setObject((int)m_timelyDiamondScores, v21);
sub_774008(v24);
m_timelyStars = a1->m_timelyStars;
if ( a2->m_dailyID.random - a2->m_dailyID.seed <= 0 )
m_timelyStars = a1->m_onlineStars;
sub_776584((int)&v25, v22);
v18 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(m_timelyStars, &v25);
v19 = cocos2d::CCString::intValue(v18);
sub_774008(&v25);
if ( v19 < (int)v4 )
{
v20 = (cocos2d::CCObject *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", v4);
sub_776584((int)v26, v22);
cocos2d::CCDictionary::setObject((int)m_timelyStars, v20);
sub_774008(v26);
}
GameStatsManager::incrementStat(a1, "13", v16);
}
}
sub_774008(&v22);
}
}
}
}