// File: MichaelXanth[P]RPG_Game/Living/Heroes/Hero.cpp
// Function: Hero::DisplayArmors(bool)
bool Hero::DisplayArmors(bool isInBattle)
{
    int arrow = 0;
    int lines;

    Armor* prevArmor = equippedArmor;

    lines = 3 * armorsArray.size();

    if(!armorsArray.size())
    {
        cout << "\033[s";
        cout << endl << "Sorry, there are no available armors." << endl;

        usleep(1500000);

        cout << "\033[u";
        cout << "\033[J";

        return false;
    }

    if(isInBattle)
        cout << endl << "Press 'b' to cancel, 'c' to confirm, 'enter' to equip or unequip an armor" << endl << endl;
    else
        cout << endl << "Press 'b' to go back and confirm, 'c' to cancel, 'enter' to equip or unequip an armor" << endl << endl;

    while(true)
    {
        char selection;

        for(unsigned int i = 0; i < armorsArray.size(); i++)
        {
            if(arrow == i)
                cout << " \033[1;33m~> ";
            else
                cout << "    ";

            cout << armorsArray[i]->GetName() << "\033[0m";

            if(equippedArmor == armorsArray[i])
                cout << " \033[38;5;10m(equiped)\033[0m";
            else
                cout << "          ";

            cout << endl;

            cout << "    \u2022 Damage Reduction: " << armorsArray[i]->GetDamageReduction() << endl << endl;
        }

        selection = getch();

        if((isInBattle && selection == 'b') || (!isInBattle && selection == 'c'))
        {
            equippedArmor = prevArmor;
            if(equippedArmor != NULL)
                armorDefence = equippedArmor->GetDamageReduction();
            else
                armorDefence = 0;
        }

        if(selection == 'b')
        {
            /*if(isInBattle)
            {*/
                cout << "\033[" << lines + 3 << "A";
                cout << "\033[J";
            /*}
            else
            {
                cout << "\033[" << lines + 6 << "A";
                cout << "\033[5B";
                cout << "\033[J";
            }*/
            //for(int i = 0; i < lines + 6; i++)
            //    cout << "\033[1A\033[K";

            return false;
        }
        else if(selection == 'c')
        {
            if(isInBattle)
            {
                cout << "\033[" << lines + 11 << "A";
                cout << "\033[J";
            }
            else
            {
                cout << "\033[" << lines + 3 << "A";
                cout << "\033[J";
            }
            //for(int i = 0; i < lines + 11; i++)
            //    cout << "\033[1A\033[K";

            return true;
        }
        else if(selection == '\n')
        {
            if(armorsArray[arrow] == equippedArmor)
            {
                equippedArmor = NULL;
                armorDefence = 0;
            }
            else
                WearArmor(arrow);
        }
        else if(selection == 'w' && arrow)
            arrow--;
        else if(selection == 's' && arrow < armorsArray.size() - 1)
            arrow++;

        cout << "\033[" << lines << "A";
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x68(%rbp)
movl $0x0, -0x18(%rbp)
movq 0xe0(%rdi), %rax
movq %rax, -0x28(%rbp)
addq $0xb0, %rdi
callq 0x26ec0
movq -0x68(%rbp), %rdi
imulq $0x3, %rax, %rax
movl %eax, -0x1c(%rbp)
addq $0xb0, %rdi
callq 0x26ec0
cmpq $0x0, %rax
jne 0x26057
movq 0x27fe7(%rip), %rdi     # 0x4dfc8
leaq 0x17896(%rip), %rsi     # 0x3d87e
callq 0x4260
movq 0x27fd4(%rip), %rdi     # 0x4dfc8
movq 0x27fbd(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
leaq 0x19f05(%rip), %rsi     # 0x3ff0f
callq 0x4260
movq %rax, %rdi
movq 0x27f9f(%rip), %rsi     # 0x4dfb8
callq 0x4290
movl $0x16e360, %edi         # imm = 0x16E360
callq 0x4390
movq 0x27f99(%rip), %rdi     # 0x4dfc8
leaq 0x17872(%rip), %rsi     # 0x3d8a8
callq 0x4260
movq 0x27f86(%rip), %rdi     # 0x4dfc8
leaq 0x197ea(%rip), %rsi     # 0x3f833
callq 0x4260
movb $0x0, -0x1(%rbp)
jmp 0x264e0
testb $0x1, -0x11(%rbp)
je 0x2609f
movq 0x27f64(%rip), %rdi     # 0x4dfc8
movq 0x27f4d(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
leaq 0x19ebb(%rip), %rsi     # 0x3ff35
callq 0x4260
movq %rax, %rdi
movq 0x27f2f(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
movq 0x27f20(%rip), %rsi     # 0x4dfb8
callq 0x4290
jmp 0x260df
movq 0x27f22(%rip), %rdi     # 0x4dfc8
movq 0x27f0b(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
leaq 0x19ec3(%rip), %rsi     # 0x3ff7f
callq 0x4260
movq %rax, %rdi
movq 0x27eed(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
movq 0x27ede(%rip), %rsi     # 0x4dfb8
callq 0x4290
jmp 0x260e1
movl $0x0, -0x30(%rbp)
movq -0x68(%rbp), %rdi
movl -0x30(%rbp), %eax
movq %rax, -0x70(%rbp)
addq $0xb0, %rdi
callq 0x26ec0
movq %rax, %rcx
movq -0x70(%rbp), %rax
cmpq %rcx, %rax
jae 0x26290
movl -0x18(%rbp), %eax
cmpl -0x30(%rbp), %eax
jne 0x2612c
movq 0x27eaa(%rip), %rdi     # 0x4dfc8
leaq 0x19a9d(%rip), %rsi     # 0x3fbc2
callq 0x4260
jmp 0x2613f
movq 0x27e95(%rip), %rdi     # 0x4dfc8
leaq 0x176cc(%rip), %rsi     # 0x3d806
callq 0x4260
movq -0x68(%rbp), %rdi
addq $0xb0, %rdi
movl -0x30(%rbp), %eax
movl %eax, %esi
callq 0x27680
movq (%rax), %rsi
movq (%rsi), %rax
movq (%rax), %rax
leaq -0x50(%rbp), %rdi
movq %rdi, -0x80(%rbp)
callq *%rax
movq -0x80(%rbp), %rsi
movq 0x27e56(%rip), %rdi     # 0x4dfc8
callq 0x4210
movq %rax, -0x78(%rbp)
jmp 0x2617d
movq -0x78(%rbp), %rdi
leaq 0x19cec(%rip), %rsi     # 0x3fe74
callq 0x4260
jmp 0x2618f
leaq -0x50(%rbp), %rdi
callq 0x4160
movq -0x68(%rbp), %rdi
movq 0xe0(%rdi), %rax
movq %rax, -0x88(%rbp)
addq $0xb0, %rdi
movl -0x30(%rbp), %eax
movl %eax, %esi
callq 0x27680
movq %rax, %rcx
movq -0x88(%rbp), %rax
cmpq (%rcx), %rax
jne 0x261f9
movq 0x27df7(%rip), %rdi     # 0x4dfc8
leaq 0x19dfd(%rip), %rsi     # 0x3ffd5
callq 0x4260
jmp 0x2620c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x4160
jmp 0x264ee
movq 0x27dc8(%rip), %rdi     # 0x4dfc8
leaq 0x175f9(%rip), %rsi     # 0x3d800
callq 0x4260
movq 0x27db5(%rip), %rdi     # 0x4dfc8
movq 0x27d9e(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq 0x27da2(%rip), %rdi     # 0x4dfc8
leaq 0x1993b(%rip), %rsi     # 0x3fb68
callq 0x4260
movq -0x68(%rbp), %rdi
movq %rax, -0x90(%rbp)
addq $0xb0, %rdi
movl -0x30(%rbp), %eax
movl %eax, %esi
callq 0x27680
movq (%rax), %rdi
callq 0x1e6d0
movq -0x90(%rbp), %rdi
movl %eax, %esi
callq 0x4370
movq %rax, %rdi
movq 0x27d4a(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
movq 0x27d3b(%rip), %rsi     # 0x4dfb8
callq 0x4290
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x260e8
callq 0x1e820
movb %al, -0x29(%rbp)
testb $0x1, -0x11(%rbp)
je 0x262a7
movsbl -0x29(%rbp), %eax
cmpl $0x62, %eax
je 0x262b6
testb $0x1, -0x11(%rbp)
jne 0x262fd
movsbl -0x29(%rbp), %eax
cmpl $0x63, %eax
jne 0x262fd
movq -0x68(%rbp), %rax
movq -0x28(%rbp), %rcx
movq %rcx, 0xe0(%rax)
cmpq $0x0, 0xe0(%rax)
je 0x262ed
movq -0x68(%rbp), %rax
movq 0xe0(%rax), %rdi
callq 0x1e6d0
movl %eax, %ecx
movq -0x68(%rbp), %rax
movl %ecx, 0x100(%rax)
jmp 0x262fb
movq -0x68(%rbp), %rax
movl $0x0, 0x100(%rax)
jmp 0x262fd
movsbl -0x29(%rbp), %eax
cmpl $0x62, %eax
jne 0x26352
movq 0x27cbb(%rip), %rdi     # 0x4dfc8
leaq 0x170c7(%rip), %rsi     # 0x3d3db
callq 0x4260
movq %rax, %rdi
movl -0x1c(%rbp), %esi
addl $0x3, %esi
callq 0x4430
movq %rax, %rdi
leaq 0x179a1(%rip), %rsi     # 0x3dcd2
callq 0x4260
movq 0x27c8b(%rip), %rdi     # 0x4dfc8
leaq 0x194ef(%rip), %rsi     # 0x3f833
callq 0x4260
movb $0x0, -0x1(%rbp)
jmp 0x264e0
movsbl -0x29(%rbp), %eax
cmpl $0x63, %eax
jne 0x263f6
testb $0x1, -0x11(%rbp)
je 0x263aa
movq 0x27c5c(%rip), %rdi     # 0x4dfc8
leaq 0x17068(%rip), %rsi     # 0x3d3db
callq 0x4260
movq %rax, %rdi
movl -0x1c(%rbp), %esi
addl $0xb, %esi
callq 0x4430
movq %rax, %rdi
leaq 0x17942(%rip), %rsi     # 0x3dcd2
callq 0x4260
movq 0x27c2c(%rip), %rdi     # 0x4dfc8
leaq 0x19490(%rip), %rsi     # 0x3f833
callq 0x4260
jmp 0x263ed
movq 0x27c17(%rip), %rdi     # 0x4dfc8
leaq 0x17023(%rip), %rsi     # 0x3d3db
callq 0x4260
movq %rax, %rdi
movl -0x1c(%rbp), %esi
addl $0x3, %esi
callq 0x4430
movq %rax, %rdi
leaq 0x178fd(%rip), %rsi     # 0x3dcd2
callq 0x4260
movq 0x27be7(%rip), %rdi     # 0x4dfc8
leaq 0x1944b(%rip), %rsi     # 0x3f833
callq 0x4260
movb $0x1, -0x1(%rbp)
jmp 0x264e0
movsbl -0x29(%rbp), %eax
cmpl $0xa, %eax
jne 0x2644c
movq -0x68(%rbp), %rdi
addq $0xb0, %rdi
movslq -0x18(%rbp), %rsi
callq 0x27680
movq -0x68(%rbp), %rcx
movq (%rax), %rax
cmpq 0xe0(%rcx), %rax
jne 0x2643e
movq -0x68(%rbp), %rax
movq $0x0, 0xe0(%rax)
movl $0x0, 0x100(%rax)
jmp 0x2644a
movq -0x68(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x20770
jmp 0x264aa
movsbl -0x29(%rbp), %eax
cmpl $0x77, %eax
jne 0x26466
cmpl $0x0, -0x18(%rbp)
je 0x26466
movl -0x18(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x264a8
movsbl -0x29(%rbp), %eax
cmpl $0x73, %eax
jne 0x264a6
movq -0x68(%rbp), %rdi
movslq -0x18(%rbp), %rax
movq %rax, -0x98(%rbp)
addq $0xb0, %rdi
callq 0x26ec0
movq %rax, %rcx
movq -0x98(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0x264a6
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x264a8
jmp 0x264aa
jmp 0x264ac
jmp 0x264ae
movq 0x27b13(%rip), %rdi     # 0x4dfc8
leaq 0x16f1f(%rip), %rsi     # 0x3d3db
callq 0x4260
movq %rax, %rdi
movl -0x1c(%rbp), %esi
callq 0x4430
movq %rax, %rdi
leaq 0x177fc(%rip), %rsi     # 0x3dcd2
callq 0x4260
jmp 0x260e1
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xa0, %rsp
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x4440
nopw (%rax,%rax)