// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, -0x38(%rbp)
leaq 0x18(%rdi), %rax
movq %rax, -0x80(%rbp)
movl %edx, -0x40(%rbp)
movl %edx, %eax
movl %esi, -0x44(%rbp)
orl %esi, %eax
movl %ecx, -0x3c(%rbp)
orl %ecx, %eax
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
cmpl $0x4, %eax
jae 0x516d
callq 0x5326
leaq -0x68(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0xd0(%rbp), %r14
xorl %eax, %eax
movq 0xb47c(%rip), %r15      # 0xffe0
cmpl $0x0, -0x44(%rbp)
jle 0x4d2b
movq $0x0, -0x30(%rbp)
movl $0x1d, %edx
movq 0xb43e(%rip), %rdi      # 0xffc0
leaq 0x6549(%rip), %rsi      # 0xb0d2
callq 0x32d0
movq -0x30(%rbp), %rax
leal 0x1(%rax), %r13d
movq 0xb423(%rip), %rdi      # 0xffc0
movl %r13d, %esi
callq 0x3410
movq %rax, %rbx
movl $0x6, %edx
movq %rax, %rdi
leaq 0x66df(%rip), %rsi      # 0xb296
callq 0x32d0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31b0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %edx
movq %r15, %rdi
leaq -0x78(%rbp), %rsi
callq 0x3450
movl $0x48, %edi
callq 0x3280
movq %rax, %rbx
movq %r14, -0xe0(%rbp)
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
addq %rsi, %rdx
leaq -0xe0(%rbp), %r12
movq %r12, %rdi
callq 0x6930
movb $0x1, %r15b
movq %rbx, %rdi
movq %r12, %rsi
callq 0xa7e0
movq %rbx, -0x58(%rbp)
xorl %r15d, %r15d
movq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x6cd8
movq -0xe0(%rbp), %rdi
movq %r14, %rbx
cmpq %r14, %rdi
je 0x4c74
movq -0xd0(%rbp), %rsi
incq %rsi
callq 0x3290
movl %r13d, %eax
movq %rax, -0x30(%rbp)
movq 0xb35e(%rip), %r15      # 0xffe0
movq %rbx, %r14
cmpl -0x44(%rbp), %r13d
jl 0x4b76
jmp 0x4d27
movq %rax, %r13
jmp 0x4ccd
jmp 0x4ce2
movq %rax, %r13
movq -0xe0(%rbp), %rdi
cmpq %r14, %rdi
je 0x4cc1
movq -0xd0(%rbp), %rsi
incq %rsi
movq %rdx, -0x50(%rbp)
callq 0x3290
movq -0x50(%rbp), %rdx
testb %r15b, %r15b
movq 0xb315(%rip), %r15      # 0xffe0
je 0x4ce5
movl $0x48, %esi
movq %rbx, %rdi
movq %rdx, %rbx
callq 0x3290
movq %rbx, %rdx
jmp 0x4ce5
movq %rax, %r13
cmpl $0x1, %edx
jne 0x51d3
movq %r13, %rdi
callq 0x3100
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0xb2ba(%rip), %rdi      # 0xffc0
movq %rax, %rsi
callq 0x3270
movq %rax, %rdi
callq 0x3130
callq 0x33c0
movq -0x30(%rbp), %rax
movl %eax, %r13d
jmp 0x4c85
movq -0x70(%rbp), %rax
cmpq $0x1f, %rax
ja 0x4b64
leaq -0xb0(%rbp), %r12
cmpl $0x0, -0x40(%rbp)
jle 0x4f03
movq $0x0, -0x30(%rbp)
movl $0x20, %edx
movq 0xb266(%rip), %rdi      # 0xffc0
leaq 0x638f(%rip), %rsi      # 0xb0f0
callq 0x32d0
movq -0x30(%rbp), %rax
leal 0x1(%rax), %r13d
movq 0xb24b(%rip), %rdi      # 0xffc0
movl %r13d, %esi
callq 0x3410
movq %rax, %rbx
movl $0x6, %edx
movq %rax, %rdi
leaq 0x6507(%rip), %rsi      # 0xb296
callq 0x32d0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31b0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %edx
movq %r15, %rdi
leaq -0x78(%rbp), %rsi
callq 0x3450
movl $0x48, %edi
callq 0x3280
movq %rax, %rbx
movq %r12, -0xc0(%rbp)
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
addq %rsi, %rdx
leaq -0xc0(%rbp), %r14
movq %r14, %rdi
callq 0x6930
movb $0x1, %r15b
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa61c
movq %rbx, -0x58(%rbp)
xorl %r15d, %r15d
movq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x6cd8
movq -0xc0(%rbp), %rdi
movq %r12, %rbx
cmpq %r12, %rdi
je 0x4e4c
movq -0xb0(%rbp), %rsi
incq %rsi
callq 0x3290
movl %r13d, %eax
movq %rax, -0x30(%rbp)
movq 0xb186(%rip), %r15      # 0xffe0
movq %rbx, %r12
cmpl -0x40(%rbp), %r13d
jl 0x4d4e
jmp 0x4eff
movq %rax, %r13
jmp 0x4ea5
jmp 0x4eba
movq %rax, %r13
movq -0xc0(%rbp), %rdi
cmpq %r12, %rdi
je 0x4e99
movq -0xb0(%rbp), %rsi
incq %rsi
movq %rdx, -0x50(%rbp)
callq 0x3290
movq -0x50(%rbp), %rdx
testb %r15b, %r15b
movq 0xb13d(%rip), %r15      # 0xffe0
je 0x4ebd
movl $0x48, %esi
movq %rbx, %rdi
movq %rdx, %rbx
callq 0x3290
movq %rbx, %rdx
jmp 0x4ebd
movq %rax, %r13
cmpl $0x1, %edx
jne 0x51d3
movq %r13, %rdi
callq 0x3100
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0xb0e2(%rip), %rdi      # 0xffc0
movq %rax, %rsi
callq 0x3270
movq %rax, %rdi
callq 0x3130
callq 0x33c0
movq -0x30(%rbp), %rax
movl %eax, %r13d
jmp 0x4e5d
movq -0x70(%rbp), %rax
cmpq $0x1f, %rax
ja 0x4d3c
movq 0xb0ac(%rip), %r12      # 0xffc0
cmpl $0x0, -0x3c(%rbp)
jle 0x50e3
movq $0x0, -0x30(%rbp)
movl $0x21, %edx
movq %r12, %rdi
leaq 0x61dc(%rip), %rsi      # 0xb111
callq 0x32d0
movq -0x30(%rbp), %rax
leal 0x1(%rax), %r13d
movq %r12, %rdi
movl %r13d, %esi
callq 0x3410
movq %rax, %rbx
movl $0x6, %edx
movq %rax, %rdi
leaq 0x6337(%rip), %rsi      # 0xb296
callq 0x32d0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31b0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %edx
movq %r15, %rdi
leaq -0x78(%rbp), %rsi
callq 0x3450
movl $0x48, %edi
callq 0x3280
movq %rax, %rbx
movq %r12, %r14
leaq -0x90(%rbp), %r12
movq %r12, -0xa0(%rbp)
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
addq %rsi, %rdx
leaq -0xa0(%rbp), %r15
movq %r15, %rdi
callq 0x6930
movq %r15, %rsi
movb $0x1, %r15b
movq %rbx, %rdi
callq 0xa910
movq %rbx, -0x58(%rbp)
xorl %r15d, %r15d
movq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x6cd8
movq -0xa0(%rbp), %rdi
cmpq %r12, %rdi
je 0x5023
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x3290
movl %r13d, %eax
movq %rax, -0x30(%rbp)
movq %r14, %r12
movq 0xafac(%rip), %r15      # 0xffe0
cmpl -0x3c(%rbp), %r13d
jl 0x4f26
jmp 0x50df
movq %rax, %r13
movq %r14, %r12
movq 0xaf90(%rip), %r15      # 0xffe0
jmp 0x5089
jmp 0x509e
movq %rax, %r13
movq -0xa0(%rbp), %rdi
cmpq %r12, %rdi
je 0x507a
movq -0x90(%rbp), %rsi
incq %rsi
movq %rdx, -0x50(%rbp)
callq 0x3290
movq -0x50(%rbp), %rdx
testb %r15b, %r15b
movq %r14, %r12
movq 0xaf59(%rip), %r15      # 0xffe0
je 0x50a1
movl $0x48, %esi
movq %rbx, %rdi
movq %rdx, %rbx
callq 0x3290
movq %rbx, %rdx
jmp 0x50a1
movq %rax, %r13
cmpl $0x1, %edx
jne 0x51d3
movq %r13, %rdi
callq 0x3100
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq %r12, %rdi
movq %rax, %rsi
callq 0x3270
movq %rax, %rdi
callq 0x3130
callq 0x33c0
movq -0x30(%rbp), %rax
movl %eax, %r13d
jmp 0x5034
movq -0x70(%rbp), %rax
cmpq $0x1f, %rax
ja 0x4f14
movl -0x40(%rbp), %eax
addl -0x44(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, 0xb1a0(%rip)      # 0x1029c
incl 0xb196(%rip)            # 0x10298
movq -0x80(%rbp), %rdi
movq -0x38(%rbp), %rbx
movq %rbx, %rsi
callq 0x674a
movl $0x0, 0x30(%rbx)
callq 0x53f0
movq %rbx, %rdi
callq 0x4234
movq %rbx, %rdi
callq 0x54be
movslq 0x30(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rsi
movq %rbx, %rdi
callq 0x42ae
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x515b
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x3290
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x3140
movq %rax, %rbx
leaq 0x5f30(%rip), %rsi      # 0xb0b1
movq %rax, %rdi
callq 0x3460
movq 0xae48(%rip), %rsi      # 0xffd8
movq 0xae31(%rip), %rdx      # 0xffc8
movq %rbx, %rdi
callq 0x3400
jmp 0x51bd
movq %rdx, %rbx
movq %rax, %r13
callq 0x33c0
jmp 0x51d0
jmp 0x51bd
movq %rdx, %rbx
movq %rax, %r13
callq 0x33c0
jmp 0x51d0
movq %rdx, %rbx
movq %rax, %r13
jmp 0x51d0
movq %rdx, %rbx
movq %rax, %r13
callq 0x33c0
movq %rbx, %rdx
cmpl $0x2, %edx
jne 0x5210
movq %r13, %rdi
callq 0x3100
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0xadd0(%rip), %rdi      # 0xffc0
movq %rax, %rsi
callq 0x3270
movq %rax, %rdi
callq 0x3130
decl 0xb096(%rip)            # 0x1029c
callq 0x33c0
jmp 0x50ed
cmpl $0x1, %edx
jne 0x52cd
movq %r13, %rdi
callq 0x3100
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0xad8f(%rip), %rdi      # 0xffc0
movq %rax, %rsi
callq 0x3270
movq %rax, %rdi
callq 0x3130
callq 0x33c0
jmp 0x50ed
jmp 0x52ca
jmp 0x52ca
movq %rax, %r13
callq 0x33c0
jmp 0x52cd
movq %rax, %r13
callq 0x33c0
jmp 0x52cd
movq %rdx, %r14
movq %rax, %r13
jmp 0x5279
movq %rdx, %r14
movq %rax, %r13
movq %rbx, %rdi
callq 0x31d0
cmpl $0x1, %r14d
jne 0x52e6
movq %r13, %rdi
callq 0x3100
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0xad29(%rip), %rdi      # 0xffc0
movq %rax, %rsi
callq 0x3270
movq %rax, %rdi
callq 0x3130
callq 0x33c0
jmp 0x515b
jmp 0x52c5
movq %rax, %r13
callq 0x33c0
jmp 0x52e6
movq %rax, %rdi
callq 0x6837
movq %rax, %r13
jmp 0x52e6
movq %rax, %r13
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x52e6
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x3290
movq -0x80(%rbp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x5302
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rsi
subq %rdi, %rsi
callq 0x3290
movq -0x38(%rbp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x531e
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rsi
subq %rdi, %rsi
callq 0x3290
movq %r13, %rdi
callq 0x3420