// File: /workspace/github_cpp_makefile_star2_O2/Matteo-Grellier[P]RPG/main.cpp
// Function: main
int main(int argc, char const *argv[])
{
    srand(time(NULL));

    try {

        Menu::start();

        //characters
        Mage mage("Mage");
        Barbarian barbarian("Barbarian");
        Priest priest("Priest");
        Monster monster1("monster1");
        Monster monster2("monster2");
        Monster monster3("monster3");

        Potion bigPotion(1, 300);
        Potion mediumPotion(3, 100);
        Potion littlePotion(6, 50);
        Character::potionsList.push_back(&bigPotion);
        Character::potionsList.push_back(&mediumPotion);
        Character::potionsList.push_back(&littlePotion);

        string characterName;
        string charactersType[3] = {"Mage", "Barbarian", "Priest"};

        //create characters and select names
        for (int i = 0; i < 3; i++) {
            Menu::devToScreen(
                "",
                "Select a name for your " + charactersType[i] + " character",
                ""
            );

            cout << Menu::endLine;
            cin >> characterName;

            if (i == 0) {
                mage.name = characterName;

            } else if (i == 1) {
                barbarian.name = characterName;

            } else {
                priest.name = characterName;
            }
        }

        
        //faire des tours tant que tt le monde n'est pas mort
        while(!Menu::isEndOfCombat()) {
            Menu::turn();
        }
    }
    catch(IllegalFury& illegalF){
        cout << "An illegal barbarian fury operation occured : " << illegalF.what() << endl;
    }
    catch(EmptyPotion& ep){
        cout << "An illegal drink operation occured : " << ep.what() << endl;
    }
    catch(std::exception& e){
        cout << "An exception occured : " << e.what() << endl;
    }

    Menu::devToScreen("","End of combat","");

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
xorl %edi, %edi
callq 0x2160
movl %eax, %edi
callq 0x2170
callq 0x4b2e
leaq 0x4b26(%rip), %rsi      # 0x7020
leaq -0x200(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
callq 0x2c78
leaq -0x308(%rbp), %rdi
leaq -0x200(%rbp), %rsi
callq 0x2cb4
leaq -0x200(%rbp), %rdi
callq 0x22a8
leaq 0x4af2(%rip), %rsi      # 0x7025
leaq -0x1e0(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
callq 0x2c78
leaq -0x2b8(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x40c8
leaq -0x1e0(%rbp), %rdi
callq 0x22a8
leaq 0x4ac3(%rip), %rsi      # 0x702f
leaq -0x1c0(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
callq 0x2c78
leaq -0x358(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x4698
leaq -0x1c0(%rbp), %rdi
callq 0x22a8
leaq 0x4a91(%rip), %rsi      # 0x7036
leaq -0x1a0(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
callq 0x2c78
leaq -0x430(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
callq 0x2d3c
leaq -0x1a0(%rbp), %rdi
callq 0x22a8
leaq 0x4a61(%rip), %rsi      # 0x703f
leaq -0x180(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
callq 0x2c78
leaq -0x3e8(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x2d3c
leaq -0x180(%rbp), %rdi
callq 0x22a8
leaq 0x4a31(%rip), %rsi      # 0x7048
leaq -0x160(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
callq 0x2c78
leaq -0x3a0(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x2d3c
leaq -0x160(%rbp), %rdi
callq 0x22a8
movabsq $0x12c00000001, %rax    # imm = 0x12C00000001
leaq -0x208(%rbp), %rcx
movq %rax, (%rcx)
movabsq $0x6400000003, %rax     # imm = 0x6400000003
movq %rax, -0x3c(%rbp)
movabsq $0x3200000006, %rax     # imm = 0x3200000006
movq %rax, -0x34(%rbp)
leaq -0xa0(%rbp), %rsi
movq %rcx, (%rsi)
leaq 0x8b1e(%rip), %rdi      # 0xb1a8
callq 0x2fa0
leaq -0x3c(%rbp), %rax
leaq -0xa0(%rbp), %rsi
movq %rax, (%rsi)
leaq 0x8b04(%rip), %rdi      # 0xb1a8
callq 0x2fa0
leaq -0x34(%rbp), %rax
leaq -0xa0(%rbp), %rsi
movq %rax, (%rsi)
leaq 0x8aea(%rip), %rdi      # 0xb1a8
callq 0x2fa0
leaq -0xb0(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x4943(%rip), %rsi      # 0x7020
leaq -0xa0(%rbp), %r15
leaq -0x140(%rbp), %rdx
movq %r15, %rdi
callq 0x2c78
leaq -0x80(%rbp), %r12
leaq 0x4927(%rip), %rsi      # 0x7025
leaq -0x2a(%rbp), %rdx
movq %r12, %rdi
callq 0x2c78
leaq -0x60(%rbp), %r12
leaq 0x491a(%rip), %rsi      # 0x702f
leaq -0x29(%rbp), %rdx
movq %r12, %rdi
callq 0x2c78
xorl %r14d, %r14d
leaq -0x268(%rbp), %r13
leaq -0x248(%rbp), %rbx
cmpq $0x3, %r14
je 0x282d
leaq -0x228(%rbp), %rdi
leaq 0x4de8(%rip), %rsi      # 0x7532
leaq -0x2a(%rbp), %rdx
callq 0x2c78
leaq -0x140(%rbp), %r12
movq %r12, %rdi
leaq 0x48ed(%rip), %rsi      # 0x7051
movq %r15, %rdx
callq 0x2de5
movq %r13, %rdi
movq %r12, %rsi
leaq 0x48f0(%rip), %rdx      # 0x7069
callq 0x2dbc
movq %rbx, %rdi
leaq 0x4daa(%rip), %rsi      # 0x7532
leaq -0x29(%rbp), %rdx
callq 0x2c78
leaq -0x228(%rbp), %r12
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x4f26
movq %rbx, %rdi
callq 0x22a8
movq %r13, %rdi
callq 0x22a8
leaq -0x140(%rbp), %rdi
callq 0x22a8
movq %r12, %rdi
callq 0x22a8
movq 0x87f7(%rip), %rdi      # 0xafc8
leaq 0x89f8(%rip), %rsi      # 0xb1d0
callq 0x2150
movq 0x87f4(%rip), %rdi      # 0xafd8
leaq -0xc0(%rbp), %rsi
callq 0x21c0
leaq -0x2b0(%rbp), %rdi
cmpl $0x1, %r14d
je 0x2810
leaq -0x300(%rbp), %rdi
testl %r14d, %r14d
je 0x2810
leaq -0x350(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x20e0
incq %r14
addq $0x20, %r15
jmp 0x2732
callq 0x5052
callq 0x51aa
testb %al, %al
je 0x2828
pushq $0x40
popq %rbx
leaq (%rbx,%rbp), %rdi
addq $-0xa0, %rdi
callq 0x22a8
addq $-0x20, %rbx
cmpq $-0x20, %rbx
jne 0x2839
leaq -0xc0(%rbp), %rdi
callq 0x22a8
leaq -0x3a0(%rbp), %rdi
callq 0x2e5c
leaq -0x3e8(%rbp), %rdi
callq 0x2e5c
leaq -0x430(%rbp), %rdi
callq 0x2e5c
leaq -0x358(%rbp), %rdi
callq 0x2e5c
leaq -0x2b8(%rbp), %rdi
callq 0x2e5c
leaq -0x308(%rbp), %rdi
callq 0x2e5c
leaq 0x4c84(%rip), %rsi      # 0x7532
leaq -0x120(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
callq 0x2c78
leaq 0x4819(%rip), %rsi      # 0x70e1
leaq -0x100(%rbp), %rdi
leaq -0x308(%rbp), %rdx
callq 0x2c78
leaq 0x4c50(%rip), %rsi      # 0x7532
leaq -0xe0(%rbp), %rdi
leaq -0x2b8(%rbp), %rdx
callq 0x2c78
leaq -0x120(%rbp), %rdi
leaq -0x100(%rbp), %rsi
leaq -0xe0(%rbp), %rdx
callq 0x4f26
leaq -0xe0(%rbp), %rdi
callq 0x22a8
leaq -0x100(%rbp), %rdi
callq 0x22a8
leaq -0x120(%rbp), %rdi
callq 0x22a8
xorl %eax, %eax
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2949
movq %rdx, %r14
movq %rax, %rbx
addq $-0x20, %r12
movq %r12, %rdi
callq 0x22a8
cmpq %r15, %r12
jne 0x294f
jmp 0x2b03
movq %rdx, %r14
movq %rax, %rbx
jmp 0x2b03
jmp 0x2974
jmp 0x2974
movq %rdx, %r14
movq %rax, %rbx
jmp 0x2b0f
movq %rdx, %r14
movq %rax, %rbx
leaq -0x160(%rbp), %rdi
callq 0x22a8
jmp 0x2b1b
movq %rdx, %r14
movq %rax, %rbx
jmp 0x2b1b
movq %rdx, %r14
movq %rax, %rbx
leaq -0x180(%rbp), %rdi
callq 0x22a8
jmp 0x2b27
movq %rdx, %r14
movq %rax, %rbx
jmp 0x2b27
movq %rdx, %r14
movq %rax, %rbx
leaq -0x1a0(%rbp), %rdi
callq 0x22a8
jmp 0x2b33
movq %rdx, %r14
movq %rax, %rbx
jmp 0x2b33
movq %rdx, %r14
movq %rax, %rbx
leaq -0x1c0(%rbp), %rdi
callq 0x22a8
jmp 0x2b3f
movq %rdx, %r14
movq %rax, %rbx
jmp 0x2b3f
movq %rdx, %r14
movq %rax, %rbx
leaq -0x1e0(%rbp), %rdi
callq 0x22a8
jmp 0x2b4b
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
callq 0x22a8
jmp 0x2a3d
movq %rdx, %r14
movq %rax, %rbx
jmp 0x2b4b
movq %rax, %rbx
leaq -0x100(%rbp), %rdi
callq 0x22a8
jmp 0x2a65
movq %rdx, %r14
movq %rax, %rbx
leaq -0x200(%rbp), %rdi
callq 0x22a8
jmp 0x2b57
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
callq 0x22a8
jmp 0x2a78
jmp 0x2a80
movq %rax, %rbx
movq %rbx, %rdi
callq 0x2260
movq %rdx, %r14
movq %rax, %rbx
jmp 0x2b57
movq %rdx, %r14
movq %rax, %rbx
leaq -0x248(%rbp), %rdi
callq 0x22a8
jmp 0x2ab7
jmp 0x2adf
movq %rdx, %r14
movq %rax, %rbx
jmp 0x2acf
movq %rdx, %r14
movq %rax, %rbx
jmp 0x2ac3
movq %rdx, %r14
movq %rax, %rbx
leaq -0x268(%rbp), %rdi
callq 0x22a8
leaq -0x140(%rbp), %rdi
callq 0x22a8
leaq -0x228(%rbp), %rdi
callq 0x22a8
jmp 0x2ae5
jmp 0x2adf
movq %rdx, %r14
movq %rax, %rbx
pushq $0x40
popq %r15
leaq (%r15,%rbp), %rdi
addq $-0xa0, %rdi
callq 0x22a8
addq $-0x20, %r15
cmpq $-0x20, %r15
jne 0x2ae9
leaq -0xc0(%rbp), %rdi
callq 0x22a8
leaq -0x3a0(%rbp), %rdi
callq 0x2e5c
leaq -0x3e8(%rbp), %rdi
callq 0x2e5c
leaq -0x430(%rbp), %rdi
callq 0x2e5c
leaq -0x358(%rbp), %rdi
callq 0x2e5c
leaq -0x2b8(%rbp), %rdi
callq 0x2e5c
leaq -0x308(%rbp), %rdi
callq 0x2e5c
cmpl $0x3, %r14d
jne 0x2b9f
movq %rbx, %rdi
callq 0x2090
movq %rax, %rbx
movq 0x8459(%rip), %rdi      # 0xafc8
leaq 0x453c(%rip), %rsi      # 0x70b2
callq 0x2180
movq %rax, %r14
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movq %r14, %rdi
movq %rax, %rsi
callq 0x2180
movq %rax, %rdi
callq 0x20b0
jmp 0x2c2b
cmpl $0x2, %r14d
jne 0x2be4
movq %rbx, %rdi
callq 0x2090
movq %rax, %rbx
movq 0x8411(%rip), %rdi      # 0xafc8
leaq 0x44ce(%rip), %rsi      # 0x708c
callq 0x2180
movq %rax, %r14
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movq %r14, %rdi
movq %rax, %rsi
callq 0x2180
movq %rax, %rdi
callq 0x20b0
jmp 0x2c2b
cmpl $0x1, %r14d
jne 0x2a78
movq %rbx, %rdi
callq 0x2090
movq %rax, %rbx
movq 0x83c8(%rip), %rdi      # 0xafc8
leaq 0x446d(%rip), %rsi      # 0x7074
callq 0x2180
movq %rax, %r14
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movq %r14, %rdi
movq %rax, %rsi
callq 0x2180
movq %rax, %rdi
callq 0x20b0
callq 0x2240
jmp 0x28a7
movq %rax, %rbx
callq 0x2240
jmp 0x2a78
movq %rax, %rbx
callq 0x2240
jmp 0x2a78
movq %rax, %rbx
callq 0x2240
jmp 0x2a78
movq %rax, %rdi
callq 0x2e78