//
// DailyLevelPage::claimLevelReward from 0x1400d1ae0 to 0x1400d1dac (716 bytes)
//
// 2 xrefs:
// > DailyLevelNode::onClaimReward @ 0x1400d2e78
// > ??> @ 0x1406c85bc
//
// 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=3
void DailyLevelPage::claimLevelReward(DailyLevelPage *a1, DailyLevelNode *a2, GJGameLevel *a3, cocos2d::CCPoint a4)
{
GameStatsManager *v8; // rcx
GJRewardItem *v9; // rax
GJRewardItem *v10; // rbp
int v11; // edi
RewardUnlockLayer *v12; // rsi
cocos2d::CCObject *m_rewardItem; // rcx
int v14; // esi
int v15; // esi
cocos2d::CCPoint v16; // rax
CurrencyRewardLayer *v17; // rax
_DWORD *v18; // rdx
GJTimedLevelType m_type; // ecx
__int32 v20; // ecx
cocos2d::CCPoint v21; // [rsp+A0h] [rbp+8h] BYREF
v8 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v21 = (cocos2d::CCPoint)operator new(0x3E0u);
qword_1406C2EE8 = ((__int64 (__fastcall *)(_QWORD))sub_1401D0AE0)(v21);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v8 = (GameStatsManager *)qword_1406C2EE8;
}
v9 = GameStatsManager::completedDailyLevel(v8, a3);
v10 = v9;
v11 = 0;
if ( v9 )
{
v12 = RewardUnlockLayer::create(v9->m_rewardType, nullptr);
a1->addChild_0(a1, v12, 100);
m_rewardItem = v12->m_rewardItem;
if ( m_rewardItem )
cocos2d::CCObject::release(m_rewardItem);
v12->m_rewardItem = v10;
cocos2d::CCObject::retain(v10);
if ( !v10->m_unk || v10->m_rewardType == v12->m_chestType )
{
v12->m_closeBtn->setVisible(v12->m_closeBtn, 0);
v12->m_closeBtn->setEnabled(v12->m_closeBtn, 0);
v12->m_wrongLabel->setVisible(v12->m_wrongLabel, 0);
v12->m_rewardCollected = 1;
if ( v12->m_animationPlayed )
RewardUnlockLayer::playRewardEffect(v12);
}
}
else
{
v14 = a3->m_stars.random - a3->m_stars.seed;
if ( !qword_1406C2EE8 )
{
v21 = (cocos2d::CCPoint)operator new(0x3E0u);
qword_1406C2EE8 = ((__int64 (__fastcall *)(_QWORD))sub_1401D0AE0)(v21);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
}
if ( (unsigned int)(v14 - 2) > 8 )
{
v15 = 0;
}
else if ( v14 == 10 )
{
v15 = 20;
}
else
{
v15 = (int)floorf((float)(v14 + 2) * 0.5);
}
cocos2d::CCPoint::CCPoint(&v21, *(const struct cocos2d::CCPoint **)&a4);
v17 = CurrencyRewardLayer::create(0, 0, 0, v15, Icon, 0, Icon, 0, v16, (CurrencyRewardType)0, 0.0, 1.0);
a1->addChild_0(a1, v17, 14);
}
DailyLevelPage::exitDailyNode(a1, a2, 0.0);
v18 = (_DWORD *)qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v21 = (cocos2d::CCPoint)operator new(0x3D0u);
qword_1406C2EC0 = ((__int64 (__fastcall *)(_QWORD))sub_140141280)(v21);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v18 = (_DWORD *)qword_1406C2EC0;
}
m_type = a1->m_type;
if ( m_type )
{
v20 = m_type - 1;
if ( v20 )
{
if ( v20 == 1 )
v11 = v18[119];
}
else
{
v11 = v18[116];
}
}
else
{
v11 = v18[113];
}
if ( v11 <= a3->m_dailyID.random - a3->m_dailyID.seed )
DailyLevelPage::createDailyNode(a1, nullptr, 0, 0.5, 0);
else
DailyLevelPage::downloadAndCreateNode(a1);
}