// File: /workspace/github_cpp_makefile_star2_O1/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 0x5195
callq 0x534e
leaq -0x68(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0xb43d(%rip), %r14      # 0xffe0
cmpl $0x0, -0x44(%rbp)
jle 0x4d62
xorl %r12d, %r12d
movl $0x1d, %edx
movq 0xb404(%rip), %rdi      # 0xffc0
leaq 0x650f(%rip), %rsi      # 0xb0d2
callq 0x32d0
leal 0x1(%r12), %r13d
movq 0xb3ec(%rip), %rdi      # 0xffc0
movl %r13d, %esi
callq 0x3410
movq %rax, %rbx
movl $0x6, %edx
movq %rax, %rdi
leaq 0x66a8(%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 (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %edx
movq %r14, %rdi
leaq -0x78(%rbp), %rsi
callq 0x3450
movl $0x48, %edi
callq 0x3280
movq %rax, %rbx
movq %r12, -0x30(%rbp)
leaq -0xd0(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
addq %rsi, %rdx
leaq -0xe0(%rbp), %r12
movq %r12, %rdi
callq 0x693a
movb $0x1, %r15b
movq %rbx, %rdi
movq %r12, %rsi
callq 0xa818
movq %rbx, -0x58(%rbp)
xorl %r15d, %r15d
movq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x6d04
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0x4cba
movq -0xd0(%rbp), %rsi
incq %rsi
callq 0x3290
movl %r13d, %r12d
cmpl -0x44(%rbp), %r13d
jl 0x4bb0
jmp 0x4d62
movq %rax, %r13
movb $0x1, %r15b
jmp 0x4d03
jmp 0x4d21
movq %rax, %r13
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0x4d03
movq -0xd0(%rbp), %rsi
incq %rsi
movq %rdx, -0x50(%rbp)
callq 0x3290
movq -0x50(%rbp), %rdx
movq -0x30(%rbp), %r12
testb %r15b, %r15b
je 0x4d24
movl $0x48, %esi
movq %rbx, %rdi
movq %rdx, %rbx
callq 0x3290
movq %rbx, %rdx
jmp 0x4d24
movq %rax, %r13
cmpl $0x1, %edx
jne 0x51fb
movq %r13, %rdi
callq 0x3100
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0xb27b(%rip), %rdi      # 0xffc0
movq %rax, %rsi
callq 0x3270
movq %rax, %rdi
callq 0x3130
callq 0x33c0
movl %r12d, %r13d
jmp 0x4cbd
cmpq $0x1f, -0x70(%rbp)
ja 0x4ba3
cmpl $0x0, -0x40(%rbp)
jle 0x4f40
movq $0x0, -0x30(%rbp)
movl $0x20, %edx
movq 0xb235(%rip), %rdi      # 0xffc0
leaq 0x635e(%rip), %rsi      # 0xb0f0
callq 0x32d0
movq -0x30(%rbp), %rax
leal 0x1(%rax), %r13d
movq 0xb21a(%rip), %rdi      # 0xffc0
movl %r13d, %esi
callq 0x3410
movq %rax, %rbx
movl $0x6, %edx
movq %rax, %rdi
leaq 0x64d6(%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 (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %edx
movq %r14, %rdi
leaq -0x78(%rbp), %rsi
callq 0x3450
movl $0x48, %edi
callq 0x3280
movq %rax, %rbx
movq %r14, %r12
leaq -0xb0(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
addq %rsi, %rdx
leaq -0xc0(%rbp), %r14
movq %r14, %rdi
callq 0x693a
movb $0x1, %r15b
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa654
movq %rbx, -0x58(%rbp)
xorl %r15d, %r15d
movq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x6d04
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
cmpq %rax, %rdi
movq %r12, %r14
je 0x4e8e
movq -0xb0(%rbp), %rsi
incq %rsi
callq 0x3290
movl %r13d, %eax
movq %rax, -0x30(%rbp)
cmpl -0x40(%rbp), %r13d
jl 0x4d7f
jmp 0x4f40
movq %rax, %r13
movb $0x1, %r15b
movq %r12, %r14
jmp 0x4ee1
jmp 0x4efb
movq %rax, %r13
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
cmpq %rax, %rdi
movq %r12, %r14
je 0x4ee1
movq -0xb0(%rbp), %rsi
incq %rsi
movq %rdx, -0x50(%rbp)
callq 0x3290
movq -0x50(%rbp), %rdx
testb %r15b, %r15b
je 0x4efe
movl $0x48, %esi
movq %rbx, %rdi
movq %rdx, %rbx
callq 0x3290
movq %rbx, %rdx
jmp 0x4efe
movq %rax, %r13
cmpl $0x1, %edx
jne 0x51fb
movq %r13, %rdi
callq 0x3100
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0xb0a1(%rip), %rdi      # 0xffc0
movq %rax, %rsi
callq 0x3270
movq %rax, %rdi
callq 0x3130
callq 0x33c0
movq -0x30(%rbp), %rax
movl %eax, %r13d
jmp 0x4e95
cmpq $0x1f, -0x70(%rbp)
ja 0x4d6d
cmpl $0x0, -0x3c(%rbp)
jle 0x510a
xorl %r12d, %r12d
movl $0x21, %edx
movq 0xb05c(%rip), %rdi      # 0xffc0
leaq 0x61a6(%rip), %rsi      # 0xb111
callq 0x32d0
leal 0x1(%r12), %r13d
movq 0xb044(%rip), %rdi      # 0xffc0
movl %r13d, %esi
callq 0x3410
movq %rax, %rbx
movl $0x6, %edx
movq %rax, %rdi
leaq 0x6300(%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 (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %edx
movq %r14, %rdi
leaq -0x78(%rbp), %rsi
callq 0x3450
movl $0x48, %edi
callq 0x3280
movq %rax, %rbx
movq %r12, -0x30(%rbp)
leaq -0x90(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
addq %rsi, %rdx
leaq -0xa0(%rbp), %r12
movq %r12, %rdi
callq 0x693a
movb $0x1, %r15b
movq %rbx, %rdi
movq %r12, %rsi
callq 0xa948
movq %rbx, -0x58(%rbp)
xorl %r15d, %r15d
movq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x6d04
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x5062
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x3290
movl %r13d, %r12d
cmpl -0x3c(%rbp), %r13d
jl 0x4f58
jmp 0x510a
movq %rax, %r13
movb $0x1, %r15b
jmp 0x50ab
jmp 0x50c9
movq %rax, %r13
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x50ab
movq -0x90(%rbp), %rsi
incq %rsi
movq %rdx, -0x50(%rbp)
callq 0x3290
movq -0x50(%rbp), %rdx
movq -0x30(%rbp), %r12
testb %r15b, %r15b
je 0x50cc
movl $0x48, %esi
movq %rbx, %rdi
movq %rdx, %rbx
callq 0x3290
movq %rbx, %rdx
jmp 0x50cc
movq %rax, %r13
cmpl $0x1, %edx
jne 0x51fb
movq %r13, %rdi
callq 0x3100
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0xaed3(%rip), %rdi      # 0xffc0
movq %rax, %rsi
callq 0x3270
movq %rax, %rdi
callq 0x3130
callq 0x33c0
movl %r12d, %r13d
jmp 0x5065
cmpq $0x1f, -0x70(%rbp)
ja 0x4f4b
movl -0x40(%rbp), %eax
addl -0x44(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, 0xb178(%rip)      # 0x1029c
incl 0xb16e(%rip)            # 0x10298
movq -0x80(%rbp), %rdi
movq -0x38(%rbp), %rbx
movq %rbx, %rsi
callq 0x6762
movl $0x0, 0x30(%rbx)
callq 0x5418
movq %rbx, %rdi
callq 0x4246
movq %rbx, %rdi
callq 0x54e6
movslq 0x30(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rsi
movq %rbx, %rdi
callq 0x42c0
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x5183
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 0x5f08(%rip), %rsi      # 0xb0b1
movq %rax, %rdi
callq 0x3460
movq 0xae20(%rip), %rsi      # 0xffd8
movq 0xae09(%rip), %rdx      # 0xffc8
movq %rbx, %rdi
callq 0x3400
jmp 0x51e5
movq %rdx, %rbx
movq %rax, %r13
callq 0x33c0
jmp 0x51f8
jmp 0x51e5
movq %rdx, %rbx
movq %rax, %r13
callq 0x33c0
jmp 0x51f8
movq %rdx, %rbx
movq %rax, %r13
jmp 0x51f8
movq %rdx, %rbx
movq %rax, %r13
callq 0x33c0
movq %rbx, %rdx
cmpl $0x2, %edx
jne 0x5238
movq %r13, %rdi
callq 0x3100
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0xada8(%rip), %rdi      # 0xffc0
movq %rax, %rsi
callq 0x3270
movq %rax, %rdi
callq 0x3130
decl 0xb06e(%rip)            # 0x1029c
callq 0x33c0
jmp 0x5115
cmpl $0x1, %edx
jne 0x52f5
movq %r13, %rdi
callq 0x3100
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0xad67(%rip), %rdi      # 0xffc0
movq %rax, %rsi
callq 0x3270
movq %rax, %rdi
callq 0x3130
callq 0x33c0
jmp 0x5115
jmp 0x52f2
jmp 0x52f2
movq %rax, %r13
callq 0x33c0
jmp 0x52f5
movq %rax, %r13
callq 0x33c0
jmp 0x52f5
movq %rdx, %r14
movq %rax, %r13
jmp 0x52a1
movq %rdx, %r14
movq %rax, %r13
movq %rbx, %rdi
callq 0x31d0
cmpl $0x1, %r14d
jne 0x530e
movq %r13, %rdi
callq 0x3100
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0xad01(%rip), %rdi      # 0xffc0
movq %rax, %rsi
callq 0x3270
movq %rax, %rdi
callq 0x3130
callq 0x33c0
jmp 0x5183
jmp 0x52ed
movq %rax, %r13
callq 0x33c0
jmp 0x530e
movq %rax, %rdi
callq 0x6841
movq %rax, %r13
jmp 0x530e
movq %rax, %r13
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x530e
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x3290
movq -0x80(%rbp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x532a
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rsi
subq %rdi, %rsi
callq 0x3290
movq -0x38(%rbp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x5346
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rsi
subq %rdi, %rsi
callq 0x3290
movq %r13, %rdi
callq 0x3420