// File: /workspace/github_cpp_makefile_star2_O2/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, -0x40(%rbp)
leaq 0x18(%rdi), %rax
movq %rax, -0x60(%rbp)
movl %edx, -0x50(%rbp)
movl %edx, %eax
movl %esi, -0x54(%rbp)
orl %esi, %eax
movl %ecx, -0x4c(%rbp)
orl %ecx, %eax
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
cmpl $0x4, %eax
jae 0x48de
callq 0x4a64
leaq -0x70(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorl %ebx, %ebx
leaq -0xe0(%rbp), %r12
leal 0x1(%rbx), %r15d
cmpl -0x54(%rbp), %ebx
jge 0x4601
movq 0x9ac2(%rip), %rdi      # 0xdfc0
leaq 0x4bcd(%rip), %rsi      # 0x90d2
callq 0x3270
movq %rax, %rdi
movl %r15d, %esi
callq 0x33e0
movq %rax, %rdi
leaq 0x4d77(%rip), %rsi      # 0x9296
callq 0x3270
movq %rax, %rdi
callq 0x3150
movq 0x9aad(%rip), %rdi      # 0xdfe0
leaq -0x80(%rbp), %rsi
callq 0x3060
pushq $0x48
popq %rdi
callq 0x3280
movq %rax, %r13
movq %r12, %rdi
leaq -0x80(%rbp), %rsi
callq 0x32f0
movb $0x1, %r14b
movq %r13, %rdi
movq %r12, %rsi
callq 0x8ac8
movq %r13, -0x48(%rbp)
xorl %r14d, %r14d
movq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x5dfa
jmp 0x45f1
movq %rdx, -0x30(%rbp)
movq %rax, %r14
jmp 0x45a7
movq %rdx, -0x30(%rbp)
movq %rax, %r14
jmp 0x45b2
movq %rax, %r14
jmp 0x45b6
movq %rdx, -0x30(%rbp)
movq %rax, -0x38(%rbp)
movq %r12, %rdi
callq 0x3130
testb %r14b, %r14b
movq -0x38(%rbp), %r14
je 0x45b2
movq %r13, %rdi
pushq $0x48
popq %rsi
callq 0x3290
movq -0x30(%rbp), %rdx
cmpl $0x1, %edx
jne 0x4942
movq %r14, %rdi
callq 0x3100
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x99e9(%rip), %rdi      # 0xdfc0
movq %rax, %rsi
callq 0x3270
movq %rax, %rdi
callq 0x3150
callq 0x3390
jmp 0x44ee
movq %r12, %rdi
callq 0x3130
movl %r15d, %ebx
jmp 0x44ea
cmpq $0x1f, -0x78(%rbp)
movl $0x0, %ebx
ja 0x44ea
xorl %ebx, %ebx
leaq -0xc0(%rbp), %r12
leal 0x1(%rbx), %r15d
cmpl -0x50(%rbp), %ebx
jge 0x4731
movq 0x9992(%rip), %rdi      # 0xdfc0
leaq 0x4abb(%rip), %rsi      # 0x90f0
callq 0x3270
movq %rax, %rdi
movl %r15d, %esi
callq 0x33e0
movq %rax, %rdi
leaq 0x4c47(%rip), %rsi      # 0x9296
callq 0x3270
movq %rax, %rdi
callq 0x3150
movq 0x997d(%rip), %rdi      # 0xdfe0
leaq -0x80(%rbp), %rsi
callq 0x3060
pushq $0x48
popq %rdi
callq 0x3280
movq %rax, %r13
movq %r12, %rdi
leaq -0x80(%rbp), %rsi
callq 0x32f0
movb $0x1, %r14b
movq %r13, %rdi
movq %r12, %rsi
callq 0x8968
movq %r13, -0x48(%rbp)
xorl %r14d, %r14d
movq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x5dfa
jmp 0x4721
movq %rdx, -0x30(%rbp)
movq %rax, %r14
jmp 0x46d7
movq %rdx, -0x30(%rbp)
movq %rax, %r14
jmp 0x46e2
movq %rax, %r14
jmp 0x46e6
movq %rdx, -0x30(%rbp)
movq %rax, -0x38(%rbp)
movq %r12, %rdi
callq 0x3130
testb %r14b, %r14b
movq -0x38(%rbp), %r14
je 0x46e2
movq %r13, %rdi
pushq $0x48
popq %rsi
callq 0x3290
movq -0x30(%rbp), %rdx
cmpl $0x1, %edx
jne 0x4942
movq %r14, %rdi
callq 0x3100
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x98b9(%rip), %rdi      # 0xdfc0
movq %rax, %rsi
callq 0x3270
movq %rax, %rdi
callq 0x3150
callq 0x3390
jmp 0x461e
movq %r12, %rdi
callq 0x3130
movl %r15d, %ebx
jmp 0x461a
cmpq $0x1f, -0x78(%rbp)
movl $0x0, %ebx
ja 0x461a
xorl %ebx, %ebx
leaq -0xa0(%rbp), %r15
leal 0x1(%rbx), %r12d
cmpl -0x4c(%rbp), %ebx
jge 0x4861
movq 0x9862(%rip), %rdi      # 0xdfc0
leaq 0x49ac(%rip), %rsi      # 0x9111
callq 0x3270
movq %rax, %rdi
movl %r12d, %esi
callq 0x33e0
movq %rax, %rdi
leaq 0x4b17(%rip), %rsi      # 0x9296
callq 0x3270
movq %rax, %rdi
callq 0x3150
movq 0x984d(%rip), %rdi      # 0xdfe0
leaq -0x80(%rbp), %rsi
callq 0x3060
pushq $0x48
popq %rdi
callq 0x3280
movq %rax, %r13
movq %r15, %rdi
leaq -0x80(%rbp), %rsi
callq 0x32f0
movb $0x1, %r14b
movq %r13, %rdi
movq %r15, %rsi
callq 0x8b9c
movq %r13, -0x48(%rbp)
xorl %r14d, %r14d
movq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x5dfa
jmp 0x4851
movq %rdx, -0x30(%rbp)
movq %rax, %r14
jmp 0x4807
movq %rdx, -0x30(%rbp)
movq %rax, %r14
jmp 0x4812
movq %rax, %r14
jmp 0x4816
movq %rdx, -0x30(%rbp)
movq %rax, -0x38(%rbp)
movq %r15, %rdi
callq 0x3130
testb %r14b, %r14b
movq -0x38(%rbp), %r14
je 0x4812
movq %r13, %rdi
pushq $0x48
popq %rsi
callq 0x3290
movq -0x30(%rbp), %rdx
cmpl $0x1, %edx
jne 0x4942
movq %r14, %rdi
callq 0x3100
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x9789(%rip), %rdi      # 0xdfc0
movq %rax, %rsi
callq 0x3270
movq %rax, %rdi
callq 0x3150
callq 0x3390
jmp 0x474e
movq %r15, %rdi
callq 0x3130
movl %r12d, %ebx
jmp 0x474a
cmpq $0x20, -0x78(%rbp)
movl $0x0, %ebx
jae 0x474a
movl -0x50(%rbp), %eax
addl -0x54(%rbp), %eax
addl -0x4c(%rbp), %eax
movl %eax, 0x9a14(%rip)      # 0xe294
incl 0x9a0a(%rip)            # 0xe290
movq -0x60(%rbp), %rdi
movq -0x40(%rbp), %rbx
movq %rbx, %rsi
callq 0x5784
andl $0x0, 0x30(%rbx)
callq 0x4afe
movq %rbx, %rdi
callq 0x3f34
movq %rbx, %rdi
callq 0x4b9c
movslq 0x30(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rsi
movq %rbx, %rdi
callq 0x3f4a
leaq -0x80(%rbp), %rdi
callq 0x3130
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x3160
movq %rax, %r14
leaq 0x47c1(%rip), %rsi      # 0x90b1
movq %rax, %rdi
callq 0x3440
movq 0x96d9(%rip), %rsi      # 0xdfd8
movq 0x96c2(%rip), %rdx      # 0xdfc8
movq %r14, %rdi
callq 0x33d0
jmp 0x492c
movq %rdx, %rbx
movq %rax, %r14
callq 0x3390
jmp 0x493f
jmp 0x492c
movq %rdx, %rbx
movq %rax, %r14
callq 0x3390
jmp 0x493f
movq %rdx, %rbx
movq %rax, %r14
jmp 0x493f
movq %rdx, %rbx
movq %rax, %r14
callq 0x3390
movq %rbx, %rdx
cmpl $0x2, %edx
jne 0x497f
movq %r14, %rdi
callq 0x3100
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x9661(%rip), %rdi      # 0xdfc0
movq %rax, %rsi
callq 0x3270
movq %rax, %rdi
callq 0x3150
decl 0x991f(%rip)            # 0xe294
callq 0x3390
jmp 0x4871
cmpl $0x1, %edx
jne 0x49b6
movq %r14, %rdi
callq 0x3100
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x9624(%rip), %rdi      # 0xdfc0
movq %rax, %rsi
callq 0x3270
movq %rax, %rdi
callq 0x3150
callq 0x3390
jmp 0x4871
movq %r14, %rbx
jmp 0x4a40
jmp 0x4a3d
jmp 0x4a3d
movq %rax, %rbx
callq 0x3390
jmp 0x4a40
movq %rax, %rbx
callq 0x3390
jmp 0x4a40
movq %rdx, %r15
movq %rax, %rbx
jmp 0x49ec
movq %rdx, %r15
movq %rax, %rbx
movq %r14, %rdi
callq 0x31e0
cmpl $0x1, %r15d
jne 0x4a49
movq %rbx, %rdi
callq 0x3100
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x95b6(%rip), %rdi      # 0xdfc0
movq %rax, %rsi
callq 0x3270
movq %rax, %rdi
callq 0x3150
callq 0x3390
jmp 0x48cc
jmp 0x4a38
movq %rax, %rbx
callq 0x3390
jmp 0x4a49
movq %rax, %rdi
callq 0x5858
movq %rax, %rbx
jmp 0x4a49
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x3130
movq -0x60(%rbp), %rdi
callq 0x5a50
movq -0x40(%rbp), %rdi
callq 0x5a50
movq %rbx, %rdi
callq 0x33f0
nop