//
// GauntletSelectLayer::onPlay from 0x100572960 to 0x100572e82 (1314 bytes)
//
// 1 xrefs:
// > GauntletSelectLayer::setupGauntlets @ 0x10057228b
//
// 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 __fastcall GauntletSelectLayer::onPlay(GauntletSelectLayer *a1, cocos2d::CCObject *a2)
{
unsigned int v3; // ebx
GameStatsManager *v4; // rdi
GameLevelManager *v5; // rax
GJMapPack *SavedGauntlet; // r14
GameStatsManager *v7; // rax
GameStatsManager *v8; // rax
GameManager *v9; // rbx
cocos2d::CCDirector *v10; // rbx
GauntletType v11; // eax
cocos2d::CCScene *v12; // rax
cocos2d::CCTransitionFade *v13; // rax
cocos2d::CCArray *v14; // rbx
char *v15; // rax
char *v16; // rax
char *v17; // rax
DialogLayer *v18; // rbx
char *v19; // rbx
GauntletSelectLayer *v20; // r12
cocos2d::CCNode *v21; // r14
cocos2d::CCDelayTime *v22; // r15
cocos2d::CCCallFunc *v23; // rax
cocos2d::CCSequence *v24; // rax
GameStatsManager *v25; // rax
GJRewardItem *v26; // rax
GJRewardItem *v27; // r14
RewardUnlockLayer *v28; // r15
__int128 v29; // [rsp+8h] [rbp-C8h] BYREF
void *v30; // [rsp+18h] [rbp-B8h]
__int128 v31; // [rsp+20h] [rbp-B0h] BYREF
void *v32; // [rsp+30h] [rbp-A0h]
__int128 v33; // [rsp+38h] [rbp-98h] BYREF
void *v34; // [rsp+48h] [rbp-88h]
std::string v35; // [rsp+50h] [rbp-80h] BYREF
std::string v36; // [rsp+68h] [rbp-68h] BYREF
std::string v37; // [rsp+80h] [rbp-50h] BYREF
_QWORD v38[2]; // [rsp+98h] [rbp-38h] BYREF
void *v39; // [rsp+A8h] [rbp-28h]
if ( !a1->m_playing && !a1->m_playBlocked && !a1->m_locked )
{
v3 = ((__int64 (__fastcall *)(cocos2d::CCObject *))a2->getTag)(a2);
if ( v3 == 8 && (v4 = GameStatsManager::sharedState(), !GameStatsManager::isItemUnlocked(v4, GJItem, 5)) )
{
v14 = (cocos2d::CCArray *)sub_10071F9E0(v4, 12);
LOBYTE(v29) = 6;
*(_DWORD *)((char *)&v29 + 1) = 3026478;
v35.__r_.__value_.__r.__words[2] = (std::string::size_type)operator new(0x38u);
v35.__r_.__value_.__r.__words[0] = 57;
v35.__r_.__value_.__l.__size_ = 53;
strcpy(v35.__r_.__value_.__l.__data_, "It's no use, that Gauntlet is locked.");
v15 = DialogObject::create(&v29, &v35, 2, 0, 0xFFFFFF, 1.0);
sub_10071FCD0(v14, v15);
if ( (*(_BYTE *)&v35.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v35.__r_.__value_.__l.__data_);
if ( (v29 & 1) != 0 )
operator delete(v30);
LOBYTE(v31) = 6;
*(_DWORD *)((char *)&v31 + 1) = 3026478;
v36.__r_.__value_.__r.__words[2] = (std::string::size_type)operator new(0x40u);
v36.__r_.__value_.__r.__words[0] = 65;
v36.__r_.__value_.__l.__size_ = 62;
strcpy(v36.__r_.__value_.__l.__data_, "The Demon Guardian was the only one who could open it.");
v16 = DialogObject::create(&v31, &v36, 2, 0, 0xFFFFFF, 0.80000001);
sub_10071FCD0(v14, v16);
if ( (*(_BYTE *)&v36.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v36.__r_.__value_.__l.__data_);
if ( (v31 & 1) != 0 )
operator delete(v32);
LOBYTE(v33) = 6;
*(_DWORD *)((char *)&v33 + 1) = 3026478;
v37.__r_.__value_.__r.__words[2] = (std::string::size_type)operator new(0x40u);
v37.__r_.__value_.__r.__words[0] = 65;
v37.__r_.__value_.__l.__size_ = 57;
strcpy(v37.__r_.__value_.__l.__data_, "Not sure what happened to him. He always was a bit crazy.");
v17 = DialogObject::create(&v33, &v37, 2, 0, 0xFFFFFF, 1.0);
sub_10071FCD0(v14, v17);
if ( (*(_BYTE *)&v37.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v37.__r_.__value_.__l.__data_);
if ( (v33 & 1) != 0 )
operator delete(v34);
v18 = DialogLayer::createWithObjects(v14, 2);
((void (__fastcall *)(GauntletSelectLayer *, DialogLayer *, __int64))a1->addChild_0)(a1, v18, 100);
DialogLayer::updateChatPlacement(v18, Center);
DialogLayer::animateInRandomSide(v18);
}
else
{
v5 = GameLevelManager::sharedState();
SavedGauntlet = GameLevelManager::getSavedGauntlet(v5, v3);
v7 = GameStatsManager::sharedState();
if ( GameStatsManager::isGauntletUnlocked(v7, v3) )
{
if ( GJMapPack::hasCompletedMapPack(SavedGauntlet)
&& (v8 = GameStatsManager::sharedState(), !GameStatsManager::isGauntletChestUnlocked(v8, v3)) )
{
v20 = a1;
v21 = (cocos2d::CCNode *)cocos2d::CCDictionary::objectForKey(a1->m_gauntlets, v3);
v22 = cocos2d::CCDelayTime::create(0.5);
v23 = cocos2d::CCCallFunc::create(v21, (cocos2d::SEL_CallFunc)(unsigned __int64)GauntletNode::onClaimReward);
v24 = sub_1003B5760(v22, v23, 0);
cocos2d::CCNode::runAction(v21, v24);
v25 = GameStatsManager::sharedState();
v26 = GameStatsManager::unlockGauntletChest(v25, v3);
if ( v26 )
{
v27 = v26;
v28 = RewardUnlockLayer::create(v26->m_rewardType, nullptr);
((void (__fastcall *)(GauntletSelectLayer *, RewardUnlockLayer *, __int64))v20->addChild_0)(v20, v28, 100);
RewardUnlockLayer::showCollectReward(v28, v27);
}
}
else
{
a1->m_playing = 1;
v9 = GameManager::sharedState();
v9->m_currentGauntlet = ((__int64 (__fastcall *)(cocos2d::CCObject *))a2->getTag)(a2);
v10 = cocos2d::CCDirector::sharedDirector();
v11 = ((unsigned int (__fastcall *)(cocos2d::CCObject *))a2->getTag)(a2);
v12 = GauntletLayer::scene(v11);
v13 = cocos2d::CCTransitionFade::create_1(0.5, v12);
cocos2d::CCDirector::replaceScene(v10, v13);
}
}
else if ( AdToolbox::hasCachedRewardedVideo() )
{
if ( !a1->m_videoPlaying )
{
a1->m_videoPlaying = 1;
GameManager::sharedState()->m_rewardedVideoDelegate = &a1->RewardedVideoDelegate;
GameManager::sharedState()->m_unk664 = v3;
a1->m_gauntletID = v3;
AdToolbox::showRewardedVideo();
}
}
else
{
v39 = operator new(0x50u);
v38[0] = 81;
v38[1] = 74;
strcpy((char *)v39, "The Gauntlet cannot be unlocked right now.\nPlease try again later.");
v19 = FLAlertLayer::create_1(0, (int)"Unlock Gauntlet", (__int64)v38, (int)"OK", 0, COERCE_DOUBLE(1136525312));
if ( (v38[0] & 1) != 0 )
operator delete(v39);
(*(void (__fastcall **)(char *))(*(_QWORD *)v19 + 1288LL))(v19);
}
}
}
}