// File: 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
subq $0x200, %rsp            # imm = 0x200
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x18(%rbp), %rdi
callq 0x8900
testb $0x1, %al
jne 0x59f0
jmp 0x62b3
movb $0x1, -0x19(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x4420
leaq -0x60(%rbp), %rdi
callq 0x4420
leaq -0x78(%rbp), %rdi
callq 0x11b00
jmp 0x5a11
movq $0x0, -0x90(%rbp)
movq 0x1659d(%rip), %rdi     # 0x1bfc0
leaq 0xd709(%rip), %rsi      # 0x13133
callq 0x4310
movq %rax, -0x140(%rbp)
jmp 0x5a38
movq -0x18(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0xf0c0
jmp 0x5a4a
movq -0x140(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x42f0
movq %rax, -0x148(%rbp)
jmp 0x5a66
movq -0x148(%rbp), %rdi
movq 0x1653c(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x5a7b
leaq -0xb0(%rbp), %rdi
callq 0x4200
testb $0x1, -0x19(%rbp)
je 0x6261
movq 0x16528(%rip), %rdi     # 0x1bfc0
leaq 0xd69d(%rip), %rsi      # 0x1313c
callq 0x4310
movq %rax, -0x150(%rbp)
jmp 0x5aad
movq -0x150(%rbp), %rdi
movq 0x164f5(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x5ac2
movq 0x164f7(%rip), %rdi     # 0x1bfc0
leaq 0xd69b(%rip), %rsi      # 0x1316b
callq 0x4310
movq %rax, -0x158(%rbp)
jmp 0x5ade
movq -0x158(%rbp), %rdi
movq 0x164c4(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x5af3
movq 0x164c6(%rip), %rdi     # 0x1bfc0
leaq 0xd680(%rip), %rsi      # 0x13181
callq 0x4310
movq %rax, -0x160(%rbp)
jmp 0x5b0f
movq -0x160(%rbp), %rdi
movq 0x16493(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x5b24
movq 0x16495(%rip), %rdi     # 0x1bfc0
leaq 0xd661(%rip), %rsi      # 0x13193
callq 0x4310
movq %rax, -0x168(%rbp)
jmp 0x5b40
movq -0x168(%rbp), %rdi
movq 0x16462(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x5b55
movq 0x16464(%rip), %rdi     # 0x1bfc0
leaq 0xd653(%rip), %rsi      # 0x131b6
callq 0x4310
movq %rax, -0x170(%rbp)
jmp 0x5b71
movq -0x170(%rbp), %rdi
movq 0x16431(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x5b86
movq 0x16433(%rip), %rdi     # 0x1bfc0
leaq 0xd632(%rip), %rsi      # 0x131c6
callq 0x4310
movq %rax, -0x178(%rbp)
jmp 0x5ba2
movq -0x178(%rbp), %rdi
movq 0x16400(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x5bb7
movq 0x16402(%rip), %rdi     # 0x1bfc0
leaq 0xd630(%rip), %rsi      # 0x131f5
callq 0x4310
movq %rax, -0x180(%rbp)
jmp 0x5bd3
movq -0x180(%rbp), %rdi
movq 0x163cf(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x5be8
movq 0x163d1(%rip), %rdi     # 0x1bfc0
leaq 0xd611(%rip), %rsi      # 0x13207
callq 0x4310
movq %rax, -0x188(%rbp)
jmp 0x5c04
movq -0x188(%rbp), %rdi
movq 0x1639e(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x5c19
movq 0x163c0(%rip), %rdi     # 0x1bfe0
leaq -0x40(%rbp), %rsi
callq 0x43e0
jmp 0x5c2b
leaq -0x40(%rbp), %rdi
callq 0x4140
movq %rax, %rdi
callq 0x4480
movl %eax, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x190(%rbp)
subl $0x6, %eax
ja 0x6229
movq -0x190(%rbp), %rax
leaq 0xd3c6(%rip), %rcx      # 0x13030
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x629f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x6296
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x4200
jmp 0x6296
cmpl $-0x1, 0x1668e(%rip)    # 0x1c350
jle 0x5cd8
movq -0x138(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x7340
jmp 0x5cd6
jmp 0x5d26
movq 0x162e1(%rip), %rdi     # 0x1bfc0
leaq 0xd538(%rip), %rsi      # 0x1321e
callq 0x4310
movq %rax, -0x198(%rbp)
jmp 0x5cf4
movq -0x198(%rbp), %rdi
movl 0x1664f(%rip), %esi     # 0x1c350
callq 0x4510
movq %rax, -0x1a0(%rbp)
jmp 0x5d0f
movq -0x1a0(%rbp), %rdi
movq 0x16293(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x5d24
jmp 0x5d26
movq -0x138(%rbp), %rdi
callq 0x6ec0
jmp 0x5d34
cmpl $0x1, 0x16619(%rip)     # 0x1c354
jg 0x5e25
movq -0x138(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x86e0
movq (%rax), %rsi
leaq -0xf8(%rbp), %rdi
callq 0xf0c0
jmp 0x5d62
leaq 0xd4ea(%rip), %rdx      # 0x13253
leaq -0xd8(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x8920
jmp 0x5d7e
movq 0x1623b(%rip), %rdi     # 0x1bfc0
leaq -0xd8(%rbp), %rsi
callq 0x42f0
movq %rax, -0x1a8(%rbp)
jmp 0x5d9a
movq -0x1a8(%rbp), %rdi
movq 0x16208(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x5daf
leaq -0xd8(%rbp), %rdi
callq 0x4200
leaq -0xf8(%rbp), %rdi
callq 0x4200
movq -0x138(%rbp), %rdi
callq 0x6cb0
jmp 0x5dd5
movb $0x0, -0x1(%rbp)
movl $0x1, -0xfc(%rbp)
jmp 0x626b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x5e14
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x4200
leaq -0xf8(%rbp), %rdi
callq 0x4200
jmp 0x6296
jmp 0x625c
movq -0x18(%rbp), %rdi
callq 0x8970
movb %al, -0x1a9(%rbp)
jmp 0x5e3b
movb -0x1a9(%rbp), %al
testb $0x1, %al
jne 0x5e64
jmp 0x5e47
movq -0x18(%rbp), %rdi
callq 0x8990
jmp 0x5e52
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x89c0
jmp 0x5e62
jmp 0x5e97
movq 0x16155(%rip), %rdi     # 0x1bfc0
leaq 0xd3f1(%rip), %rsi      # 0x13263
callq 0x4310
movq %rax, -0x1b8(%rbp)
jmp 0x5e80
movq -0x1b8(%rbp), %rdi
movq 0x16122(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x5e95
jmp 0x5e97
jmp 0x625c
movq -0x138(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x7730
jmp 0x5eae
jmp 0x5f28
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x6296
movq -0x80(%rbp), %rdi
callq 0x4130
movq %rax, -0x108(%rbp)
movq -0x108(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq %rax, %rsi
movq 0x160c4(%rip), %rdi     # 0x1bfc0
callq 0x4310
movq %rax, -0x1c0(%rbp)
jmp 0x5f0a
movq -0x1c0(%rbp), %rdi
movq 0x16098(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x5f1f
callq 0x44c0
jmp 0x5f26
jmp 0x5f28
jmp 0x625c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
callq 0x44c0
jmp 0x5f43
jmp 0x6296
movq -0x18(%rbp), %rdi
callq 0xfb70
jmp 0x5f53
jmp 0x625c
movq -0x18(%rbp), %rdi
callq 0x89e0
movb %al, -0x1c1(%rbp)
jmp 0x5f69
movb -0x1c1(%rbp), %al
testb $0x1, %al
jne 0x6197
jmp 0x5f79
movq -0x18(%rbp), %rdi
callq 0xf0f0
movl %eax, -0x1c8(%rbp)
jmp 0x5f8a
movl -0x1c8(%rbp), %eax
cmpl $0x1, %eax
jne 0x617a
movq 0x16020(%rip), %rdi     # 0x1bfc0
leaq 0xd2dd(%rip), %rsi      # 0x13284
callq 0x4310
movq %rax, -0x1d0(%rbp)
jmp 0x5fb5
movq -0x1d0(%rbp), %rdi
movq 0x15fed(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x5fca
movq 0x1600f(%rip), %rdi     # 0x1bfe0
leaq -0x60(%rbp), %rsi
callq 0x43e0
jmp 0x5fdc
leaq -0x128(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x4150
jmp 0x5fee
movq -0x138(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x7c30
movq %rax, -0x1d8(%rbp)
jmp 0x600a
movq -0x1d8(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x4200
xorl %eax, %eax
cmpq -0x90(%rbp), %rax
jne 0x6150
movl $0x10, %edi
callq 0x41a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x1e0(%rbp)
leaq 0xd24c(%rip), %rsi      # 0x1329d
callq 0x4590
jmp 0x6058
movq -0x1e0(%rbp), %rdi
movq 0x15f72(%rip), %rsi     # 0x1bfd8
movq 0x15f5b(%rip), %rdx     # 0x1bfc8
callq 0x44f0
jmp 0x62d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x60c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x4200
jmp 0x60c0
movq -0x1e0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
callq 0x4250
movl -0x84(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x6296
movq -0x80(%rbp), %rdi
callq 0x4130
movq %rax, -0x130(%rbp)
movq -0x130(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq %rax, %rsi
movq 0x15ec3(%rip), %rdi     # 0x1bfc0
callq 0x4310
movq %rax, -0x1e8(%rbp)
jmp 0x610b
movq -0x1e8(%rbp), %rdi
movq 0x15e97(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x6120
callq 0x44c0
jmp 0x6127
jmp 0x6129
movq -0x18(%rbp), %rdi
movq -0x90(%rbp), %rsi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
jmp 0x613e
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x8a00
jmp 0x614e
jmp 0x61ca
movq -0x18(%rbp), %rdi
movq -0x90(%rbp), %rsi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
jmp 0x6165
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x8a00
jmp 0x6175
jmp 0x625c
jmp 0x6129
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
callq 0x44c0
jmp 0x6192
jmp 0x6296
movq 0x15e22(%rip), %rdi     # 0x1bfc0
leaq 0xd10f(%rip), %rsi      # 0x132b4
callq 0x4310
movq %rax, -0x1f0(%rbp)
jmp 0x61b3
movq -0x1f0(%rbp), %rdi
movq 0x15def(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x61c8
jmp 0x61ca
jmp 0x625c
movq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x8a00
jmp 0x61dc
movq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x89c0
jmp 0x61e9
movq -0x138(%rbp), %rdi
callq 0x6ec0
jmp 0x61f7
movq -0x138(%rbp), %rdi
movb $0x0, -0x19(%rbp)
callq 0x7cd0
jmp 0x6209
jmp 0x625c
movq -0x138(%rbp), %rdi
callq 0x6ec0
jmp 0x6219
movb $0x1, -0x1(%rbp)
movl $0x1, -0xfc(%rbp)
jmp 0x626b
movq 0x15d90(%rip), %rdi     # 0x1bfc0
leaq 0xd0b9(%rip), %rsi      # 0x132f0
callq 0x4310
movq %rax, -0x1f8(%rbp)
jmp 0x6245
movq -0x1f8(%rbp), %rdi
movq 0x15d5d(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x625a
jmp 0x625c
jmp 0x5a87
movl $0x0, -0xfc(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x8a20
leaq -0x60(%rbp), %rdi
callq 0x4200
leaq -0x40(%rbp), %rdi
callq 0x4200
movl -0xfc(%rbp), %eax
testl %eax, %eax
je 0x6294
jmp 0x6292
jmp 0x62b7
jmp 0x62b3
leaq -0x78(%rbp), %rdi
callq 0x8a20
leaq -0x60(%rbp), %rdi
callq 0x4200
leaq -0x40(%rbp), %rdi
callq 0x4200
jmp 0x62c5
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq
movq -0x80(%rbp), %rdi
callq 0x4520
movq %rax, %rdi
callq 0x4f20
nopw %cs:(%rax,%rax)