// File: /workspace/github_cpp_makefile_star2_O2/Serfati[P]Heroes-of-Might-and-Magic-3/GameUnit.cpp
// Function: GameUnit::mainMenu(Hero*)
bool GameUnit::mainMenu(Hero *turn) {
    if ( turn->inLife()) {
        bool isTurnRun = 1;
        string index;
        string toRob;
        Creature c;
        Hero *ptr = nullptr;
        cout << "Welcome " << turn->getName() << endl;
        while ( isTurnRun ) {
            cout << "What is your next step in the path to victory?" << endl;
            cout << "‫‪1. Attack‬‬" << endl;
            cout << "2. Get daily gold" << endl;
            cout << "‫‪3.‬‬ Buy creatures‬‬" << endl;
            cout << "4. Show details" << endl;
            cout << "‫‪5‬‬.‬‬ Special skill‬‬‬‬" << endl;
            cout << "6. End of my turn" << endl;
            cout << "7.‬ Exit‬‬‬‬" << endl;
            cin >> index;

            int choice = atoi(index.c_str());
            switch ( choice ) {
                case 1:    /*	Attack‬‬	*/
                    if ( ::roundNumber > - 1 )
                        attackMenu(turn);
                    else cout << "Can'nt attack before round 4, You're still on round " << ::roundNumber << endl;
                    save();
                    if ( ::numberOfPlayers <= 1 ) { // last player
                        cout << realOrder[0]->getName() + " is the winner!" << endl;
                        rmdir();
                        return (EXIT_SUCCESS);
                    }
                    break;

                case 2:    /*	Get daily gold	*/
                    if ( ! turn->isGotDG()) {
                        turn->getDailyGold();
                        turn->setGotDG(true);
                    } else cout << "You already got your daily gold!" << endl;
                    break;

                case 3: /*	Buy creatures	*/
                    try {
                        storeMenu(turn);
                    } catch( std::invalid_argument &e ) { cout << e.what() << endl; }
                    break;

                case 4:    /*	Show details	*/
                    turn->showHero();
                    break;

                case 5:    /*	Special skill‬‬‬‬	*/
                    if ( ! turn->isUsedSA()) {
                        try {
                            if ( turn->getType() == thief ) {
                                std::cout << "Please insert hero name:" << endl;
                                cin >> toRob;
                                ptr = getHeroByName(toRob);
                                if ( NULL == ptr )
                                    throw std::invalid_argument("Hero to rob not found!");
                                turn->specialAbility(*ptr);
                                turn->setUsedSA(true);
                                break;
                            }
                        } catch( std::invalid_argument &e ) { cout << e.what() << endl; }
                        turn->specialAbility(*ptr);
                        turn->setUsedSA(true);
                    } else cout << "You already used your special ability! wait for next round." << endl;
                    break;

                case 6:    /*	End of my turn	*/
                    turn->setUsedSA(false);
                    turn->setGotDG(false);
                    save();
                    isTurnRun = false;
                    nextTurn();
                    break;

                case 7: /* 	‫‪Exit‬‬‬‬  */
                    save();
                    return 1;

                default:
                    cout << "please choose a valid number" << endl;
                    break;
            }
        }
    }
    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdi, -0x30(%rbp)
cmpb $0x1, 0x3a(%rsi)
jne 0x43f0
movq %rsi, %r14
leaq -0x90(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq -0x70(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq -0xf8(%rbp), %rdi
callq 0x82b4
movq 0xa01b(%rip), %rdi      # 0xdfc0
leaq 0x5187(%rip), %rsi      # 0x9133
callq 0x3270
movq %rax, %r15
leaq -0x60(%rbp), %rdi
movq %r14, %rsi
callq 0x6c44
leaq -0x60(%rbp), %rsi
movq %r15, %rdi
callq 0x3260
movq %rax, %rdi
callq 0x3150
leaq -0x60(%rbp), %rdi
callq 0x3130
movb $0x1, %r13b
movq $0x0, -0x38(%rbp)
movq 0x9fd1(%rip), %r15      # 0xdfc0
leaq 0x503a(%rip), %r12      # 0x9030
movl %r13d, %ebx
testb $0x1, %bl
je 0x43d6
movq %r15, %rdi
leaq 0x5130(%rip), %rsi      # 0x913c
callq 0x3270
movq %rax, %rdi
callq 0x3150
movq %r15, %rdi
leaq 0x5148(%rip), %rsi      # 0x916b
callq 0x3270
movq %rax, %rdi
callq 0x3150
movq %r15, %rdi
leaq 0x5147(%rip), %rsi      # 0x9181
callq 0x3270
movq %rax, %rdi
callq 0x3150
movq %r15, %rdi
leaq 0x5142(%rip), %rsi      # 0x9193
callq 0x3270
movq %rax, %rdi
callq 0x3150
movq %r15, %rdi
leaq 0x514e(%rip), %rsi      # 0x91b6
callq 0x3270
movq %rax, %rdi
callq 0x3150
movq %r15, %rdi
leaq 0x5147(%rip), %rsi      # 0x91c6
callq 0x3270
movq %rax, %rdi
callq 0x3150
movq %r15, %rdi
leaq 0x515f(%rip), %rsi      # 0x91f5
callq 0x3270
movq %rax, %rdi
callq 0x3150
movq %r15, %rdi
leaq 0x515a(%rip), %rsi      # 0x9207
callq 0x3270
movq %rax, %rdi
callq 0x3150
movq 0x9f1f(%rip), %rdi      # 0xdfe0
leaq -0xa0(%rbp), %rsi
callq 0x32d0
movq -0xa0(%rbp), %rdi
callq 0x3340
decl %eax
leaq 0x520e(%rip), %rsi      # 0x92f0
cmpl $0x6, %eax
ja 0x41e1
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
cmpl $0x0, 0xa195(%rip)      # 0xe290
js 0x422e
movq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0x4e72
jmp 0x4253
cmpb $0x0, 0x39(%r14)
leaq 0x5196(%rip), %rsi      # 0x92b4
jne 0x41e1
movq %r14, %rdi
callq 0x6c60
cmpl $0x1, %eax
jne 0x434d
movq %r15, %rdi
leaq 0x5145(%rip), %rsi      # 0x9284
callq 0x3270
movq %rax, %rdi
callq 0x3150
movq 0x9e8d(%rip), %rdi      # 0xdfe0
leaq -0x80(%rbp), %rsi
callq 0x32d0
leaq -0xe0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x32f0
movq -0x30(%rbp), %rdi
leaq -0xe0(%rbp), %rbx
movq %rbx, %rsi
callq 0x53a4
movq %rax, %r13
movq %rbx, %rdi
callq 0x3130
testq %r13, %r13
je 0x4271
movq (%r14), %rax
movq %r13, -0x38(%rbp)
movq %r14, %rdi
movq %r13, %rsi
callq *(%rax)
movb $0x1, 0x39(%r14)
movq %r13, -0x38(%rbp)
movb $0x1, %r13b
jmp 0x3ff6
movq %r14, %rsi
callq 0x50bc
movb $0x1, %r13b
jmp 0x3ff6
movq %r14, %rdi
callq 0x7232
movb $0x1, %r13b
jmp 0x3ff6
cmpb $0x0, 0x38(%r14)
leaq 0x5084(%rip), %rsi      # 0x9263
je 0x4219
movq %r15, %rdi
callq 0x3270
movq %rax, %rdi
callq 0x3150
movb $0x1, %r13b
jmp 0x3ff6
andw $0x0, 0x38(%r14)
movq -0x30(%rbp), %rdi
callq 0x4b9c
xorl %r13d, %r13d
movq -0x30(%rbp), %rdi
callq 0x5416
jmp 0x3ff6
movq %r14, %rdi
callq 0x58dc
movb $0x1, 0x38(%r14)
movb $0x1, %r13b
jmp 0x3ff6
movq %r15, %rdi
leaq 0x4fe6(%rip), %rsi      # 0x921e
callq 0x3270
movl 0xa04d(%rip), %esi      # 0xe290
movq %rax, %rdi
callq 0x33e0
movq %rax, %rdi
callq 0x3150
movq -0x30(%rbp), %rdi
callq 0x4b9c
cmpl $0x1, 0xa031(%rip)      # 0xe294
movb $0x1, %r13b
jg 0x3ff6
jmp 0x4374
pushq $0x10
popq %rdi
callq 0x3160
movq %rax, %rbx
movq %rax, %rdi
leaq 0x5017(%rip), %rsi      # 0x929d
callq 0x3440
movq $0x0, -0x38(%rbp)
movq %rbx, %rdi
movq 0x9d3b(%rip), %rsi      # 0xdfd8
movq 0x9d24(%rip), %rdx      # 0xdfc8
callq 0x33d0
jmp 0x440c
movq %rdx, %r13
movq %rax, -0x40(%rbp)
movq %rbx, %rdi
callq 0x31e0
movq $0x0, -0x38(%rbp)
jmp 0x4319
movq %rdx, %r13
movq %rax, -0x40(%rbp)
movq %rbx, %rdi
callq 0x3130
jmp 0x4319
cmpl $0x1, %edx
jne 0x4466
movq %rax, %rdi
callq 0x3100
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq %r15, %rdi
movq %rax, %rsi
callq 0x3270
movq %rax, %rdi
callq 0x3150
callq 0x3390
movb $0x1, %r13b
jmp 0x3ff6
movq %rdx, %r13
movq %rax, -0x40(%rbp)
cmpl $0x1, %r13d
jne 0x440c
movq -0x40(%rbp), %rdi
callq 0x3100
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq %r15, %rdi
movq %rax, %rsi
callq 0x3270
movq %rax, %rdi
callq 0x3150
callq 0x3390
movq (%r14), %rax
movq %r14, %rdi
movq -0x38(%rbp), %rsi
callq *(%rax)
movb $0x1, 0x39(%r14)
movb $0x1, %r13b
jmp 0x3ff6
movb $0x1, %r13b
movq -0x30(%rbp), %rdi
callq 0x4b9c
jmp 0x43d6
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rsi
leaq -0xc0(%rbp), %rdi
callq 0x6c44
leaq 0x4ec2(%rip), %rdx      # 0x9253
leaq -0x60(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x58b3
movq 0x9c18(%rip), %rdi      # 0xdfc0
leaq -0x60(%rbp), %rsi
callq 0x3260
movq %rax, %rdi
callq 0x3150
leaq -0x60(%rbp), %rdi
callq 0x3130
leaq -0xc0(%rbp), %rdi
callq 0x3130
callq 0x4a64
xorl %r13d, %r13d
leaq -0x80(%rbp), %rdi
callq 0x3130
leaq -0xa0(%rbp), %rdi
callq 0x3130
testb $0x1, %bl
jne 0x43f3
xorl %r13d, %r13d
andb $0x1, %r13b
movl %r13d, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x40(%rbp), %rbx
jmp 0x4469
jmp 0x4466
movq %rax, %rbx
callq 0x3390
jmp 0x4469
jmp 0x4466
movq %rax, %rbx
callq 0x3390
jmp 0x4469
movq %rax, %rdi
callq 0x5858
movq %rax, %rbx
jmp 0x4445
jmp 0x4466
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x3130
leaq -0xc0(%rbp), %rdi
jmp 0x445d
jmp 0x4466
jmp 0x4466
jmp 0x4466
jmp 0x4466
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x3130
jmp 0x4469
jmp 0x4466
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x3130
leaq -0xa0(%rbp), %rdi
callq 0x3130
movq %rbx, %rdi
callq 0x33f0