//
// GauntletSelectLayer::onPlay from 0x1402ff670 to 0x1402ffeef (2175 bytes)
//
// 2 xrefs:
// > GauntletSelectLayer::setupGauntlets @ 0x1402ff00e
// > ??> @ 0x14091e458
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:30:07 +0000
//
// Hidden C++ exception states: #wind=15
void __fastcall GauntletSelectLayer::onPlay(__int64 a1, __int64 a2)
{
int v4; // eax
__int64 v5; // rcx
__int64 v6; // r15
__int64 v7; // rcx
cocos2d::CCArray *v8; // rbx
void **v9; // rax
void **v10; // rax
void **v11; // rax
cocos2d::CCLayerColor *DialogLayer; // rsi
__int64 v13; // rcx
__int64 v14; // rax
__int64 v15; // rdi
__int64 v16; // rbx
__int64 v17; // rax
__int64 v18; // rbx
cocos2d::CCString *v19; // rax
const char *CString; // rax
signed int v21; // edi
size_t v22; // r8
__int64 v23; // rbx
void *v24; // rcx
cocos2d::CCArray *v25; // rcx
signed int v26; // r12d
cocos2d::CCArray *v27; // rcx
__int64 v28; // rbx
_QWORD *v29; // rax
bool isSpecialChestUnlocked; // bl
cocos2d::CCNode *v31; // rdi
__int64 v32; // rbx
struct cocos2d::CCFiniteTimeAction *v33; // rax
struct cocos2d::CCAction *v34; // rax
__int64 v35; // rcx
__int64 v36; // rbx
__int64 v37; // rax
__int64 v38; // rdi
__int64 v39; // rcx
__int64 v40; // rbx
cocos2d::CCObject *v41; // rcx
__int64 v42; // rbx
unsigned int v43; // eax
__int64 v44; // rdx
__int64 v45; // r8
__int64 v46; // r9
struct cocos2d::CCScene *v47; // rax
struct cocos2d::CCScene *v48; // rbx
__int64 v49; // rcx
cocos2d::CCDirector *v50; // rax
__int16 v51; // [rsp+30h] [rbp-59h] BYREF
char v52; // [rsp+32h] [rbp-57h]
void **v53; // [rsp+40h] [rbp-49h] BYREF
void *v54; // [rsp+48h] [rbp-41h] BYREF
_BYTE v55[32]; // [rsp+50h] [rbp-39h] BYREF
void *Block[2]; // [rsp+70h] [rbp-19h] BYREF
__int64 v57; // [rsp+80h] [rbp-9h]
unsigned __int64 v58; // [rsp+88h] [rbp-1h]
__int128 v59; // [rsp+90h] [rbp+7h] BYREF
__int64 v60; // [rsp+A0h] [rbp+17h]
__int64 v61; // [rsp+A8h] [rbp+1Fh]
if ( !*(_BYTE *)(a1 + 473) && !*(_BYTE *)(a1 + 504) && !*(_BYTE *)(a1 + 513) )
{
v4 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a2 + 56LL))(a2);
v6 = v4;
if ( v4 != 8 )
goto LABEL_9;
if ( !qword_14090BFE0 )
{
v53 = (void **)operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480((__int64)v53);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
}
if ( (unsigned __int8)GameStatsManager::isItemUnlocked(v5, 0xCu, 5u) )
{
LABEL_9:
v18 = *(_QWORD *)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v54 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v54);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v18 = *(_QWORD *)&qword_14090BFB0;
}
v19 = cocos2d::CCString::createWithFormat((const char *)&word_1406ED6F8, (unsigned int)v6);
CString = cocos2d::CCString::getCString(v19);
*(_OWORD *)Block = 0;
v21 = 0;
v57 = 0;
v58 = 0;
v22 = -1;
do
++v22;
while ( CString[v22] );
sub_14003D230(Block, CString, v22);
v23 = cocos2d::CCDictionary::objectForKey(*(_QWORD *)(v18 + 1184), Block);
if ( v58 > 0xF )
{
v24 = Block[0];
if ( v58 + 1 >= 0x1000 )
{
v24 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v24 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v24);
}
v57 = 0;
v58 = 15;
LOBYTE(Block[0]) = 0;
if ( !qword_14090BFE0 )
{
v54 = operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480((__int64)v54);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
}
v25 = *(cocos2d::CCArray **)(v23 + 320);
if ( !v25 || !cocos2d::CCArray::count(v25) )
goto LABEL_41;
v26 = GJMapPack::completedMaps(v23);
v27 = *(cocos2d::CCArray **)(v23 + 320);
if ( v27 )
v21 = cocos2d::CCArray::count(v27);
if ( v26 < v21 )
goto LABEL_41;
v28 = qword_14090BFE0;
if ( !qword_14090BFE0 )
{
v54 = operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480((__int64)v54);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v28 = qword_14090BFE0;
}
GameStatsManager::getGauntletRewardKey((__int64)v27, &v59, v6);
v29 = (_QWORD *)sub_14003F4F0((__int64)v55, (__int64)&v59);
isSpecialChestUnlocked = GameStatsManager::isSpecialChestUnlocked(v28, v29);
sub_14003D310((__int64)&v59);
if ( !isSpecialChestUnlocked )
{
v31 = cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(a1 + 496), v6);
v32 = cocos2d::CCCallFunc::create(v31, GauntletNode::onClaimReward);
v33 = cocos2d::CCDelayTime::create(0.5);
v34 = cocos2d::CCSequence::create(v33, v32, 0);
cocos2d::CCNode::runAction(v31, v34);
v36 = qword_14090BFE0;
if ( !qword_14090BFE0 )
{
v54 = operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480((__int64)v54);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v36 = qword_14090BFE0;
}
GameStatsManager::getGauntletRewardKey(v35, &v59, v6);
v37 = sub_14003F4F0((__int64)v55, (__int64)&v59);
v38 = GameStatsManager::unlockSpecialChest(v36, v37);
if ( v38 )
{
v39 = qword_14090BFE0;
if ( !qword_14090BFE0 )
{
v54 = operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480((__int64)v54);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v39 = qword_14090BFE0;
}
GameStatsManager::incrementStat(v39, "40", 1u);
}
sub_14003D310((__int64)&v59);
if ( v38 )
{
v40 = RewardUnlockLayer::create(*(unsigned int *)(v38 + 64), 0);
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)a1 + 456LL))(a1, v40, 100);
v41 = *(cocos2d::CCObject **)(v40 + 704);
if ( v41 )
cocos2d::CCObject::release(v41);
*(_QWORD *)(v40 + 704) = v38;
cocos2d::CCObject::retain((cocos2d::CCObject *)v38);
if ( !*(_BYTE *)(v38 + 80) || *(_DWORD *)(v38 + 64) == *(_DWORD *)(v40 + 696) )
{
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(v40 + 720) + 336LL))(*(_QWORD *)(v40 + 720), 0);
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(v40 + 720) + 936LL))(*(_QWORD *)(v40 + 720), 0);
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(v40 + 712) + 336LL))(*(_QWORD *)(v40 + 712), 0);
*(_BYTE *)(v40 + 700) = 1;
if ( *(_BYTE *)(v40 + 701) )
RewardUnlockLayer::playRewardEffect(v40);
}
}
}
else
{
LABEL_41:
*(_BYTE *)(a1 + 473) = 1;
v42 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v54 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v54);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v42 = qword_14090BFD0;
}
*(_DWORD *)(v42 + 1116) = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a2 + 56LL))(a2);
v43 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a2 + 56LL))(a2);
v47 = (struct cocos2d::CCScene *)GauntletLayer::scene(v43, v44, v45, v46);
v48 = cocos2d::CCTransitionFade::create(0.5, v47);
v50 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v49);
cocos2d::CCDirector::replaceScene(v50, v48);
}
}
else
{
v8 = (cocos2d::CCArray *)cocos2d::CCArray::create(v7);
v53 = Block;
v51 = -1;
v52 = -1;
*(_OWORD *)Block = 0;
v57 = 0;
v58 = 0;
Block[0] = sub_14003D460(0x40u);
v57 = 53;
v58 = 63;
strcpy((char *)Block[0], "It's no use, that Gauntlet is locked.");
v59 = 0;
v60 = 3;
v61 = 15;
LOWORD(v59) = *(_WORD *)"...";
WORD1(v59) = (unsigned __int8)asc_14070EB14[2];
v9 = DialogObject::create((__int64)&v59, (__int64)Block, 2, 1.0, 0, (__int64)&v51);
cocos2d::CCArray::addObject(v8, (struct cocos2d::CCObject *)v9);
v53 = (void **)&v59;
v51 = -1;
v52 = -1;
v59 = 0;
v60 = 0;
v61 = 0;
*(_QWORD *)&v59 = sub_14003D460(0x40u);
v60 = 62;
v61 = 63;
strcpy((char *)v59, "The Demon Guardian was the only one who could open it.");
*(_OWORD *)Block = 0;
v57 = 3;
v58 = 15;
LOWORD(Block[0]) = *(_WORD *)"...";
WORD1(Block[0]) = (unsigned __int8)asc_14070EB14[2];
v10 = DialogObject::create((__int64)Block, (__int64)&v59, 2, 0.80000001, 0, (__int64)&v51);
cocos2d::CCArray::addObject(v8, (struct cocos2d::CCObject *)v10);
v53 = (void **)&v59;
v51 = -1;
v52 = -1;
v59 = 0;
v60 = 0;
v61 = 0;
*(_QWORD *)&v59 = sub_14003D460(0x40u);
v60 = 57;
v61 = 63;
strcpy((char *)v59, "Not sure what happened to him. He always was a bit crazy.");
*(_OWORD *)Block = 0;
v57 = 3;
v58 = 15;
LOWORD(Block[0]) = *(_WORD *)"...";
WORD1(Block[0]) = (unsigned __int8)asc_14070EB14[2];
v11 = DialogObject::create((__int64)Block, (__int64)&v59, 2, 1.0, 0, (__int64)&v51);
cocos2d::CCArray::addObject(v8, (struct cocos2d::CCObject *)v11);
DialogLayer = DialogLayer::createDialogLayer(0, (__int64)v8, 2u);
(*(void (__fastcall **)(__int64, cocos2d::CCLayerColor *, __int64))(*(_QWORD *)a1 + 456LL))(a1, DialogLayer, 100);
v14 = cocos2d::CCDirector::sharedDirector(v13);
cocos2d::CCDirector::getWinSize(v14, &v53);
v15 = **((_QWORD **)DialogLayer + 70);
v16 = *((_QWORD *)DialogLayer + 70);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v54, *(float *)&v53 * 0.5, *((float *)&v53 + 1) * 0.5);
(*(void (__fastcall **)(__int64, __int64))(v15 + 184))(v16, v17);
DialogLayer::animateInRandomSide(DialogLayer);
}
}
}