//
// GauntletSelectLayer::onPlay from 0x917ab0 to 0x918000 (1360 bytes)
//
// 3 xrefs:
// > ??> @ 0x348c0
// > GauntletSelectLayer::setupGauntlets @ 0x91c24c
// > ??> @ 0x1229970
//
// 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 GauntletSelectLayer::onPlay(GauntletSelectLayer *a1, cocos2d::CCObject *a2)
{
unsigned int v4; // w22
GameLevelManager *v5; // x0
GJMapPack *SavedGauntlet; // x23
GameStatsManager *v7; // x0
GameManager *v8; // x20
cocos2d::CCDirector *v9; // x20
GauntletType v10; // w0
cocos2d::CCScene *v11; // x0
cocos2d::CCTransitionFade *v12; // x0
GameStatsManager *v13; // x0
cocos2d::CCNode *v14; // x21
cocos2d::CCSequence *v15; // x23
cocos2d::CCFiniteTimeAction *v16; // x0
cocos2d::CCAction *v17; // x0
GameStatsManager *v18; // x0
GJRewardItem *v19; // x0
GJRewardItem *v20; // x21
RewardUnlockLayer *v21; // x22
FLAlertLayer *v22; // x20
GameStatsManager *v23; // x0
_BOOL8 isItemUnlocked; // x0
cocos2d::CCArray *v25; // x24
cocos2d::CCObject *v26; // x0
cocos2d::CCObject *v27; // x0
cocos2d::CCObject *v28; // x0
DialogLayer *v29; // x21
_QWORD v30[2]; // [xsp+0h] [xbp+0h] BYREF
__int64 v31; // [xsp+78h] [xbp+78h] BYREF
__int64 v32; // [xsp+80h] [xbp+80h] BYREF
if ( !a1->m_playing && !a1->m_playBlocked && !a1->m_locked )
{
v4 = a2->getTag(a2);
if ( v4 != 8
|| (v23 = GameStatsManager::sharedState(), isItemUnlocked = GameStatsManager::isItemUnlocked(v23, GJItem, 5)) )
{
v5 = GameLevelManager::sharedState();
SavedGauntlet = GameLevelManager::getSavedGauntlet(v5, v4);
v7 = GameStatsManager::sharedState();
if ( GameStatsManager::isGauntletUnlocked(v7, v4) )
{
if ( !GJMapPack::hasCompletedMapPack(SavedGauntlet)
|| (v13 = GameStatsManager::sharedState(), GameStatsManager::isGauntletChestUnlocked(v13, v4)) )
{
a1->m_playing = (unsigned __int8)&dword_0 + 1;
v8 = GameManager::sharedState();
v8->m_currentGauntlet = a2->getTag(a2);
v9 = cocos2d::CCDirector::sharedDirector();
v10 = a2->getTag(a2);
v11 = GauntletLayer::scene(v10);
v12 = cocos2d::CCTransitionFade::create(0.5, v11);
cocos2d::CCDirector::replaceScene(v9, v12);
}
else
{
v14 = (cocos2d::CCNode *)cocos2d::CCDictionary::objectForKey(a1->m_gauntlets, v4);
v15 = (cocos2d::CCSequence *)cocos2d::CCDelayTime::create(0.5);
v16 = (cocos2d::CCFiniteTimeAction *)cocos2d::CCCallFunc::create(v14, GauntletNode::onClaimReward, 0);
v17 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v15, v16, 0);
cocos2d::CCNode::runAction(v14, v17);
v18 = GameStatsManager::sharedState();
v19 = GameStatsManager::unlockGauntletChest(v18, v4);
v20 = v19;
if ( v19 )
{
v21 = RewardUnlockLayer::create(v19->m_rewardType, nullptr);
a1->addChild_0(a1, v21, 100);
RewardUnlockLayer::showCollectReward(v21, v20);
}
}
}
else if ( AdToolbox::hasCachedRewardedVideo() )
{
if ( !a1->m_videoPlaying )
{
a1->m_videoPlaying = (unsigned __int8)&dword_0 + 1;
GameManager::sharedState()->m_rewardedVideoDelegate = &a1->RewardedVideoDelegate;
GameManager::sharedState()->m_unk664 = v4;
a1->m_gauntletID = v4;
AdToolbox::showRewardedVideo();
}
}
else
{
sub_D153B8((int)&v32, "The Gauntlet cannot be unlocked right now.\nPlease try again later.");
v22 = FLAlertLayer::create(0, (__int64)"Unlock Gauntlet", (__int64)&v32);
if ( (__int64 *)(v32 - 24) != &qword_124B6B0 )
sub_917A6C((void *)(v32 - 24));
v22->show(v22);
}
}
else
{
v25 = (cocos2d::CCArray *)cocos2d::CCArray::create((cocos2d::CCArray *)isItemUnlocked);
sub_D153B8((int)&v31, "...");
sub_D153B8((unsigned int)v30 + 128, "It's no use, that Gauntlet is locked.");
v26 = (cocos2d::CCObject *)DialogObject::create(1.0, (__int64)&v31, (__int64)&v32, 2, 0, (int)&unk_FFFFFF);
cocos2d::CCArray::addObject(v25, v26);
if ( (__int64 *)(v32 - 24) != &qword_124B6B0 )
sub_917A6C((void *)(v32 - 24));
if ( (__int64 *)(v31 - 24) != &qword_124B6B0 )
sub_917A6C((void *)(v31 - 24));
sub_D153B8((unsigned int)v30 + 120, "...");
sub_D153B8((unsigned int)v30 + 128, "The Demon Guardian was the only one who could open it.");
v27 = (cocos2d::CCObject *)DialogObject::create(0.8, (__int64)&v31, (__int64)&v32, 2, 0, (int)&unk_FFFFFF);
cocos2d::CCArray::addObject(v25, v27);
if ( (__int64 *)(v32 - 24) != &qword_124B6B0 )
sub_917A6C((void *)(v32 - 24));
if ( (__int64 *)(v31 - 24) != &qword_124B6B0 )
sub_917A6C((void *)(v31 - 24));
sub_D153B8((unsigned int)v30 + 120, "...");
sub_D153B8((unsigned int)v30 + 128, "Not sure what happened to him. He always was a bit crazy.");
v28 = (cocos2d::CCObject *)DialogObject::create(1.0, (__int64)&v31, (__int64)&v32, 2, 0, (int)&unk_FFFFFF);
cocos2d::CCArray::addObject(v25, v28);
if ( (__int64 *)(v32 - 24) != &qword_124B6B0 )
sub_917A6C((void *)(v32 - 24));
if ( (__int64 *)(v31 - 24) != &qword_124B6B0 )
sub_917A6C((void *)(v31 - 24));
v29 = DialogLayer::createWithObjects(v25, (int)&dword_0 + 2);
a1->addChild_0(a1, v29, 100);
DialogLayer::updateChatPlacement(v29, Center);
DialogLayer::animateInRandomSide(v29);
}
}
}