// File: Serfati[P]Heroes-of-Might-and-Magic-3/GameUnit.cpp
// Function: GameUnit::GameUnit(int, int, int)
GameUnit::GameUnit(const int w,const int t,const int n) {
    try {
        if ( w < 0 || w > 3 || t < 0 || t > 3 || n < 0 || n > 3 )
            throw (std::invalid_argument("Error: invalid number of heroes!"));
    } catch( std::invalid_argument &exc ) {
        cout << exc.what() << endl;
        return;
    }

    rmdir();
    string _name;
    try {
        /*      warriors     */
        do {
            for (int i = 0; i < w; ++ i) {
                try {
                    std::cout << "Please insert warrior number " << i + 1 << " name:" << endl;
                    getline(cin,_name);
                    realOrder.push_back(new Warrior(_name));
                } catch( std::invalid_argument &exc ) {
                    cout << exc.what() << endl;
                    i --;
                }
            }
        } while ( _name.length() > 31 );
        /*      thieves     */
        do {
            for (int i = 0; i < t; ++ i) {
                try {
                    std::cout << "Please insert thief name number " << i + 1 << " name:" << endl;
                    getline(cin,_name);
                    realOrder.push_back(new Thief(_name));
                } catch( std::invalid_argument &exc ) {
                    cout << exc.what() << endl;
                    i --;
                }
            }
        } while ( _name.length() > 31 );
        /*      necromancers     */
        do {
            for (int i = 0; i < n; ++ i) {
                try {
                    std::cout << "Please insert necromancer number " << i + 1 << " name:" << endl;
                    getline(cin,_name);
                    realOrder.push_back(new Necromancer(_name));
                } catch( std::invalid_argument &exc ) {
                    cout << exc.what() << endl;
                    i --;
                }
            }
        } while ( _name.length() > 31 );

    } catch( std::bad_alloc &exc ) {
        cout << exc.what() << endl;
        ::numberOfPlayers --;
    } catch( std::invalid_argument &exc ) {
        cout << exc.what() << endl;
    }
    ::numberOfPlayers = w + t + n;
    ::roundNumber ++;
    turnOrder = realOrder; /*  just a pointer to a shuffled realOrder    */
    this->currentTurn = 0;
    mkdir();
    shuffle();
    save();
    mainMenu(turnOrder[currentTurn]);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x8290
movq -0x130(%rbp), %rdi
addq $0x18, %rdi
movq %rdi, -0x128(%rbp)
callq 0x8290
cmpl $0x0, -0xc(%rbp)
jl 0x6347
cmpl $0x3, -0xc(%rbp)
jg 0x6347
cmpl $0x0, -0x10(%rbp)
jl 0x6347
cmpl $0x3, -0x10(%rbp)
jg 0x6347
cmpl $0x0, -0x14(%rbp)
jl 0x6347
cmpl $0x3, -0x14(%rbp)
jle 0x640f
movl $0x10, %edi
callq 0x41a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x138(%rbp)
leaq 0xcd4c(%rip), %rsi      # 0x130b1
callq 0x4590
jmp 0x636c
movq -0x138(%rbp), %rdi
movq 0x15c5e(%rip), %rsi     # 0x1bfd8
movq 0x15c47(%rip), %rdx     # 0x1bfc8
callq 0x44f0
jmp 0x6caf
movq -0x138(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
callq 0x4250
jmp 0x63b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x6c86
movq -0x20(%rbp), %rdi
callq 0x4130
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq %rax, %rsi
movq 0x15bdb(%rip), %rdi     # 0x1bfc0
callq 0x4310
movq %rax, -0x140(%rbp)
jmp 0x63f3
movq -0x140(%rbp), %rdi
movq 0x15baf(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x6408
callq 0x44c0
jmp 0x6424
jmp 0x643f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
callq 0x44c0
jmp 0x643a
jmp 0x6bb6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x6c86
jmp 0x6c86
movq -0x130(%rbp), %rdi
callq 0x6cb0
jmp 0x644d
leaq -0x50(%rbp), %rdi
callq 0x4420
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x6653
movq 0x15b50(%rip), %rdi     # 0x1bfc0
leaq 0xcc5b(%rip), %rsi      # 0x130d2
callq 0x4310
movq %rax, -0x148(%rbp)
jmp 0x6485
movq -0x148(%rbp), %rdi
movl -0x54(%rbp), %esi
incl %esi
callq 0x4510
movq %rax, -0x150(%rbp)
jmp 0x649f
movq -0x150(%rbp), %rdi
leaq 0xcde9(%rip), %rsi      # 0x13296
callq 0x4310
movq %rax, -0x158(%rbp)
jmp 0x64bb
movq -0x158(%rbp), %rdi
movq 0x15ae7(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x64d0
movq 0x15b09(%rip), %rdi     # 0x1bfe0
leaq -0x50(%rbp), %rsi
callq 0x4080
jmp 0x64e2
movq -0x130(%rbp), %rax
movq %rax, -0x168(%rbp)
movl $0x48, %edi
callq 0x4320
movq %rax, -0x160(%rbp)
jmp 0x6503
movb $0x1, -0x81(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x4150
jmp 0x6519
movq -0x160(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x12b10
jmp 0x652b
movq -0x168(%rbp), %rdi
movq -0x160(%rbp), %rax
movb $0x0, -0x81(%rbp)
movq %rax, -0x60(%rbp)
leaq -0x60(%rbp), %rsi
callq 0x8760
jmp 0x654f
leaq -0x80(%rbp), %rdi
callq 0x4200
jmp 0x661a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x65ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x658e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x4200
testb $0x1, -0x81(%rbp)
jne 0x6599
jmp 0x65aa
movq -0x160(%rbp), %rdi
movl $0x48, %esi
callq 0x4330
jmp 0x65ac
movl -0x24(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x6aa4
movq -0x20(%rbp), %rdi
callq 0x4130
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq %rax, %rsi
movq 0x159da(%rip), %rdi     # 0x1bfc0
callq 0x4310
movq %rax, -0x170(%rbp)
jmp 0x65f4
movq -0x170(%rbp), %rdi
movq 0x159ae(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x6609
movl -0x54(%rbp), %eax
decl %eax
movl %eax, -0x54(%rbp)
callq 0x44c0
jmp 0x6618
jmp 0x661a
jmp 0x661c
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x645d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
callq 0x44c0
jmp 0x664e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x6aa4
jmp 0x6aa4
jmp 0x6655
leaq -0x50(%rbp), %rdi
callq 0x4460
cmpq $0x1f, %rax
ja 0x6456
jmp 0x666a
movl $0x0, -0x94(%rbp)
movl -0x94(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x687d
movq 0x15936(%rip), %rdi     # 0x1bfc0
leaq 0xca5f(%rip), %rsi      # 0x130f0
callq 0x4310
movq %rax, -0x178(%rbp)
jmp 0x669f
movq -0x178(%rbp), %rdi
movl -0x94(%rbp), %esi
incl %esi
callq 0x4510
movq %rax, -0x180(%rbp)
jmp 0x66bc
movq -0x180(%rbp), %rdi
leaq 0xcbcc(%rip), %rsi      # 0x13296
callq 0x4310
movq %rax, -0x188(%rbp)
jmp 0x66d8
movq -0x188(%rbp), %rdi
movq 0x158ca(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x66ed
movq 0x158ec(%rip), %rdi     # 0x1bfe0
leaq -0x50(%rbp), %rsi
callq 0x4080
jmp 0x66ff
movq -0x130(%rbp), %rax
movq %rax, -0x198(%rbp)
movl $0x48, %edi
callq 0x4320
movq %rax, -0x190(%rbp)
jmp 0x6720
movb $0x1, -0xc1(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x4150
jmp 0x6739
movq -0x190(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x12900
jmp 0x674e
movq -0x198(%rbp), %rdi
movq -0x190(%rbp), %rax
movb $0x0, -0xc1(%rbp)
movq %rax, -0xa0(%rbp)
leaq -0xa0(%rbp), %rsi
callq 0x8760
jmp 0x6778
leaq -0xc0(%rbp), %rdi
callq 0x4200
jmp 0x684f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x67db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x67bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x4200
testb $0x1, -0xc1(%rbp)
jne 0x67c8
jmp 0x67d9
movq -0x190(%rbp), %rdi
movl $0x48, %esi
callq 0x4330
jmp 0x67db
movl -0x24(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x6aa4
movq -0x20(%rbp), %rdi
callq 0x4130
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq %rax, %rsi
movq 0x157ab(%rip), %rdi     # 0x1bfc0
callq 0x4310
movq %rax, -0x1a0(%rbp)
jmp 0x6823
movq -0x1a0(%rbp), %rdi
movq 0x1577f(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x6838
movl -0x94(%rbp), %eax
decl %eax
movl %eax, -0x94(%rbp)
callq 0x44c0
jmp 0x684d
jmp 0x684f
jmp 0x6851
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x6674
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
callq 0x44c0
jmp 0x6878
jmp 0x6aa4
jmp 0x687f
leaq -0x50(%rbp), %rdi
callq 0x4460
cmpq $0x1f, %rax
ja 0x666a
jmp 0x6894
movl $0x0, -0xd4(%rbp)
movl -0xd4(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x6c2b
movq 0x1570c(%rip), %rdi     # 0x1bfc0
leaq 0xc856(%rip), %rsi      # 0x13111
callq 0x4310
movq %rax, -0x1a8(%rbp)
jmp 0x68c9
movq -0x1a8(%rbp), %rdi
movl -0xd4(%rbp), %esi
incl %esi
callq 0x4510
movq %rax, -0x1b0(%rbp)
jmp 0x68e6
movq -0x1b0(%rbp), %rdi
leaq 0xc9a2(%rip), %rsi      # 0x13296
callq 0x4310
movq %rax, -0x1b8(%rbp)
jmp 0x6902
movq -0x1b8(%rbp), %rdi
movq 0x156a0(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x6917
movq 0x156c2(%rip), %rdi     # 0x1bfe0
leaq -0x50(%rbp), %rsi
callq 0x4080
jmp 0x6929
movq -0x130(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movl $0x48, %edi
callq 0x4320
movq %rax, -0x1c0(%rbp)
jmp 0x694a
movb $0x1, -0x101(%rbp)
leaq -0x100(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x4150
jmp 0x6963
movq -0x1c0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x12c60
jmp 0x6978
movq -0x1c8(%rbp), %rdi
movq -0x1c0(%rbp), %rax
movb $0x0, -0x101(%rbp)
movq %rax, -0xe0(%rbp)
leaq -0xe0(%rbp), %rsi
callq 0x8760
jmp 0x69a2
leaq -0x100(%rbp), %rdi
callq 0x4200
jmp 0x6a79
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x6a05
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x69e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x4200
testb $0x1, -0x101(%rbp)
jne 0x69f2
jmp 0x6a03
movq -0x1c0(%rbp), %rdi
movl $0x48, %esi
callq 0x4330
jmp 0x6a05
movl -0x24(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x6aa4
movq -0x20(%rbp), %rdi
callq 0x4130
movq %rax, -0x110(%rbp)
movq -0x110(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq %rax, %rsi
movq 0x15581(%rip), %rdi     # 0x1bfc0
callq 0x4310
movq %rax, -0x1d0(%rbp)
jmp 0x6a4d
movq -0x1d0(%rbp), %rdi
movq 0x15555(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x6a62
movl -0xd4(%rbp), %eax
decl %eax
movl %eax, -0xd4(%rbp)
callq 0x44c0
jmp 0x6a77
jmp 0x6a79
jmp 0x6a7b
movl -0xd4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd4(%rbp)
jmp 0x689e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
callq 0x44c0
jmp 0x6aa2
jmp 0x6aa4
movl -0x24(%rbp), %eax
movl %eax, -0x1d4(%rbp)
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x6bbf
movq -0x20(%rbp), %rdi
callq 0x4130
movq %rax, -0x120(%rbp)
movq -0x120(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq %rax, %rsi
movq 0x154dc(%rip), %rdi     # 0x1bfc0
callq 0x4310
movq %rax, -0x1e0(%rbp)
jmp 0x6af2
movq -0x1e0(%rbp), %rdi
movq 0x154b0(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x6b07
movl 0x15847(%rip), %eax     # 0x1c354
decl %eax
movl %eax, 0x1583f(%rip)     # 0x1c354
callq 0x44c0
jmp 0x6b1c
jmp 0x6b1e
movq -0x130(%rbp), %rsi
movl -0xc(%rbp), %eax
movl -0x10(%rbp), %ecx
addl %ecx, %eax
movl -0x14(%rbp), %ecx
addl %ecx, %eax
movl %eax, 0x1581c(%rip)     # 0x1c354
movl 0x15812(%rip), %eax     # 0x1c350
incl %eax
movl %eax, 0x1580a(%rip)     # 0x1c350
movq %rsi, %rdi
addq $0x18, %rdi
callq 0x8490
jmp 0x6b54
movq -0x130(%rbp), %rdi
movl $0x0, 0x30(%rdi)
callq 0x6db0
jmp 0x6b69
movq -0x130(%rbp), %rdi
callq 0x5970
jmp 0x6b77
movq -0x130(%rbp), %rdi
callq 0x6ec0
jmp 0x6b85
movq -0x130(%rbp), %rax
movq %rax, %rdi
addq $0x18, %rdi
movslq 0x30(%rax), %rsi
callq 0x86e0
movq -0x130(%rbp), %rdi
movq (%rax), %rsi
callq 0x59c0
jmp 0x6bad
leaq -0x50(%rbp), %rdi
callq 0x4200
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
movl -0x1d4(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x6c7d
movq -0x20(%rbp), %rdi
callq 0x4130
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq %rax, %rsi
movq 0x153c4(%rip), %rdi     # 0x1bfc0
callq 0x4310
movq %rax, -0x1e8(%rbp)
jmp 0x6c0a
movq -0x1e8(%rbp), %rdi
movq 0x15398(%rip), %rsi     # 0x1bfb0
callq 0x4340
jmp 0x6c1f
callq 0x44c0
jmp 0x6c26
jmp 0x6b1e
jmp 0x6c2d
leaq -0x50(%rbp), %rdi
callq 0x4460
cmpq $0x1f, %rax
ja 0x6894
jmp 0x6b1e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
callq 0x44c0
jmp 0x6c66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x6c7d
jmp 0x6c7d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
callq 0x44c0
jmp 0x6c7b
jmp 0x6c7d
leaq -0x50(%rbp), %rdi
callq 0x4200
movq -0x128(%rbp), %rdi
callq 0x8700
movq -0x130(%rbp), %rdi
callq 0x8700
movq -0x20(%rbp), %rdi
callq 0x4520
movq %rax, %rdi
callq 0x4f20
nop