//
// GauntletSelectLayer::onPlay from 0x1401fa770 to 0x1401fafbf (2127 bytes)
//
// 2 xrefs:
// > GauntletSelectLayer::setupGauntlets @ 0x1401fa111
// > ??> @ 0x1406cc9e4
//
// 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=15
void GauntletSelectLayer::onPlay(GauntletSelectLayer *a1, cocos2d::CCObject *a2)
{
float v2; // xmm3_4
int v5; // eax
GameStatsManager *v6; // rcx
__int64 v7; // r15
__int64 v8; // rcx
cocos2d::CCArray *v9; // rbx
char *v10; // rax
char *v11; // rax
char *v12; // rax
DialogLayer *DialogLayer; // rdi
__int64 v14; // rcx
cocos2d::CCDirector *v15; // rax
cocos2d::CCLayer_vtbl *v16; // rbx
const cocos2d::CCPoint *v17; // rax
__int64 v18; // rbx
cocos2d::CCString *v19; // rax
const char *CString; // rax
int v21; // r14d
size_t v22; // r8
GJMapPack *v23; // rbx
void *v24; // rcx
cocos2d::CCArray *m_levels; // rcx
cocos2d::CCArray *v26; // rcx
__int64 v27; // rcx
__int64 v28; // rbx
_QWORD *v29; // rax
bool isSpecialChestUnlocked; // bl
CCLightFlash *v31; // rdi
__int64 v32; // rbx
struct cocos2d::CCDelayTime *v33; // rax
struct cocos2d::CCSequence *v34; // rax
cocos2d::ccColor3B *v35; // r8
__int64 v36; // rcx
GameStatsManager *v37; // rbx
__int64 v38; // rax
GJRewardItem *v39; // rdi
GameStatsManager *v40; // rcx
RewardUnlockLayer *v41; // rbx
cocos2d::CCObject *m_rewardItem; // rcx
__int64 v43; // rbx
GauntletType v44; // eax
struct cocos2d::CCScene *v45; // rax
struct cocos2d::CCTransitionFade *v46; // rbx
__int64 v47; // rcx
cocos2d::CCDirector *v48; // rax
float v49; // [rsp+20h] [rbp-69h]
__int16 v50; // [rsp+30h] [rbp-59h] BYREF
char v51; // [rsp+32h] [rbp-57h]
void **v52; // [rsp+40h] [rbp-49h]
void *v53; // [rsp+48h] [rbp-41h]
_BYTE v54[32]; // [rsp+50h] [rbp-39h] BYREF
void *Block[2]; // [rsp+70h] [rbp-19h] BYREF
__int64 v56; // [rsp+80h] [rbp-9h]
unsigned __int64 v57; // [rsp+88h] [rbp-1h]
__int128 v58; // [rsp+90h] [rbp+7h] BYREF
__int64 v59; // [rsp+A0h] [rbp+17h]
__int64 v60; // [rsp+A8h] [rbp+1Fh]
if ( !a1->m_playing && !a1->m_playBlocked && !a1->m_locked )
{
v5 = a2->getTag(a2);
v7 = v5;
if ( v5 != 8 )
goto LABEL_9;
if ( !qword_1406C2EE8 )
{
v52 = (void **)operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v52);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
}
if ( GameStatsManager::isItemUnlocked(v6, GJItem, 5) )
{
LABEL_9:
v18 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v53 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v53);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v18 = qword_1406C2EC0;
}
v19 = cocos2d::CCString::createWithFormat("%i", v7);
CString = cocos2d::CCString::getCString(v19);
*(_OWORD *)Block = 0;
v21 = 0;
v56 = 0;
v57 = 0;
v22 = -1;
do
++v22;
while ( CString[v22] );
sub_14003A930(Block, CString, v22);
v23 = (GJMapPack *)cocos2d::CCDictionary::objectForKey(*(_QWORD *)(v18 + 576), Block);
if ( v57 > 0xF )
{
v24 = Block[0];
if ( v57 + 1 >= 0x1000 )
{
v24 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v24 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v24);
}
v56 = 0;
v57 = 15;
LOBYTE(Block[0]) = 0;
if ( !qword_1406C2EE8 )
{
v53 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v53);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
}
m_levels = v23->m_levels;
if ( !m_levels || !cocos2d::CCArray::count(m_levels) )
goto LABEL_41;
v26 = v23->m_levels;
if ( v26 )
v21 = cocos2d::CCArray::count(v26);
if ( GJMapPack::completedMaps(v23) < v21 )
goto LABEL_41;
v28 = qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v53 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v53);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v28 = qword_1406C2EE8;
}
GameStatsManager::getGauntletRewardKey(v27, &v58, v7);
v29 = (_QWORD *)sub_14003BDB0((__int64)v54, (__int64)&v58);
isSpecialChestUnlocked = GameStatsManager::isSpecialChestUnlocked(v28, v29);
sub_14003A830((__int64)&v58);
if ( !isSpecialChestUnlocked )
{
v31 = (CCLightFlash *)cocos2d::CCDictionary::objectForKey(a1->m_gauntlets, v7);
v32 = cocos2d::CCCallFunc::create(v31, GauntletNode::onClaimReward);
v33 = cocos2d::CCDelayTime::create(0.5);
v34 = cocos2d::CCSequence::create(v33, v32, 0);
cocos2d::CCNode::runAction(v31, (cocos2d::CCPoint)v34, v35, v2, v49);
v37 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v53 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v53);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v37 = (GameStatsManager *)qword_1406C2EE8;
}
GameStatsManager::getGauntletRewardKey(v36, &v58, v7);
v38 = sub_14003BDB0((__int64)v54, (__int64)&v58);
v39 = GameStatsManager::unlockSpecialChest(v37, v38);
if ( v39 )
{
v40 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v53 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v53);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v40 = (GameStatsManager *)qword_1406C2EE8;
}
GameStatsManager::incrementStat(v40, "40", 1);
}
sub_14003A830((__int64)&v58);
if ( v39 )
{
v41 = RewardUnlockLayer::create(v39->m_rewardType, nullptr);
a1->addChild_0(a1, v41, 100);
m_rewardItem = v41->m_rewardItem;
if ( m_rewardItem )
cocos2d::CCObject::release(m_rewardItem);
v41->m_rewardItem = v39;
cocos2d::CCObject::retain(v39);
if ( !v39->m_unk || v39->m_rewardType == v41->m_chestType )
{
v41->m_closeBtn->setVisible(v41->m_closeBtn, 0);
v41->m_closeBtn->setEnabled(v41->m_closeBtn, 0);
v41->m_wrongLabel->setVisible(v41->m_wrongLabel, 0);
v41->m_rewardCollected = 1;
if ( v41->m_animationPlayed )
RewardUnlockLayer::playRewardEffect(v41);
}
}
}
else
{
LABEL_41:
a1->m_playing = 1;
v43 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v53 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v53);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v43 = qword_1406C2ED8;
}
*(_DWORD *)(v43 + 1052) = a2->getTag(a2);
v44 = a2->getTag(a2);
v45 = GauntletLayer::scene(v44);
v46 = cocos2d::CCTransitionFade::create(0.5, v45);
v48 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v47);
cocos2d::CCDirector::replaceScene(v48, v46);
}
}
else
{
v9 = (cocos2d::CCArray *)cocos2d::CCArray::create(v8);
v52 = Block;
v50 = -1;
v51 = -1;
*(_OWORD *)Block = 0;
v56 = 0;
v57 = 15;
Block[0] = sub_14003AA10(0x40u);
v56 = 53;
v57 = 63;
strcpy((char *)Block[0], "It's no use, that Gauntlet is locked.");
v58 = 0;
v59 = 3;
v60 = 15;
LOWORD(v58) = *(_WORD *)"...";
WORD1(v58) = (unsigned __int8)asc_14053DBB0[2];
v10 = DialogObject::create((__int64)&v58, (__int64)Block, 2, 1.0, 0, (__int64)&v50);
cocos2d::CCArray::addObject(v9, (struct cocos2d::CCObject *)v10);
v52 = (void **)&v58;
v50 = -1;
v51 = -1;
v58 = 0;
v59 = 0;
v60 = 15;
*(_QWORD *)&v58 = sub_14003AA10(0x40u);
v59 = 62;
v60 = 63;
strcpy((char *)v58, "The Demon Guardian was the only one who could open it.");
*(_OWORD *)Block = 0;
v56 = 3;
v57 = 15;
LOWORD(Block[0]) = *(_WORD *)"...";
WORD1(Block[0]) = (unsigned __int8)asc_14053DBB0[2];
v11 = DialogObject::create((__int64)Block, (__int64)&v58, 2, 0.80000001, 0, (__int64)&v50);
cocos2d::CCArray::addObject(v9, (struct cocos2d::CCObject *)v11);
v52 = (void **)&v58;
v50 = -1;
v51 = -1;
v58 = 0;
v59 = 0;
v60 = 15;
*(_QWORD *)&v58 = sub_14003AA10(0x40u);
v59 = 57;
v60 = 63;
strcpy((char *)v58, "Not sure what happened to him. He always was a bit crazy.");
*(_OWORD *)Block = 0;
v56 = 3;
v57 = 15;
LOWORD(Block[0]) = *(_WORD *)"...";
WORD1(Block[0]) = (unsigned __int8)asc_14053DBB0[2];
v12 = DialogObject::create((__int64)Block, (__int64)&v58, 2, 1.0, 0, (__int64)&v50);
cocos2d::CCArray::addObject(v9, (struct cocos2d::CCObject *)v12);
DialogLayer = DialogLayer::createDialogLayer(nullptr, v9, 2);
a1->addChild_0(a1, DialogLayer, 100);
v15 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v14);
cocos2d::CCDirector::getWinSize(v15);
v16 = DialogLayer->m_mainLayer->__vftable;
cocos2d::CCPoint::CCPoint(0.0, *(float *)&v52 * 0.5);
v16->setPosition_0(DialogLayer->m_mainLayer, v17);
DialogLayer::animateInRandomSide(DialogLayer);
}
}
}