// File: /workspace/github_cpp_makefile_star2_O1/MichaelXanth[P]RPG_Game/Living/Heroes/Hero.cpp
// Function: Hero::DisplayPotions(bool)
bool Hero::DisplayPotions(bool isInBattle)
{
    int arrow = 0;

    if(!potionsArray.size())
    {
        cout << "\033[s";
        cout << endl << "Sorry, there are no available potions." << endl;

        usleep(1500000);

        cout << "\033[u";
        cout << "\033[J";

        return false;
    }

    cout << endl << "Press 'b' to go back, 'enter' to drink the potion" << endl << endl;

    while(true)
    {
        int lines;
        char selection;

        if(!potionsArray.size())
        {
            cout << "\033[s";
            cout << endl << "Sorry, there are no available potions." << endl;

            usleep(1500000);

            cout << "\033[u";
            cout << "\033[J";
            cout << "\033[1B";

            selection = 'b';
        }

        lines = 3 * potionsArray.size();

        for(unsigned int i = 0; i < potionsArray.size(); i++)
        {
            if(arrow == i)
                cout << " \033[1;33m~> ";
            else
                cout << "    ";

            cout << potionsArray[i]->GetName() << "\033[0m            " << endl;
            if(potionsArray[i]->PotionIncreaseStrength())
                cout << "    \u2022 Power-Up: +" << potionsArray[i]->PotionIncreaseStrength() << " in strength" << endl << endl;
            else if(potionsArray[i]->PotionIncreaseDexterity())
                cout << "    \u2022 Power-Up: +" << potionsArray[i]->PotionIncreaseDexterity() << " in dexterity" << endl << endl;
            else
                cout << "    \u2022 Power-Up: +" << potionsArray[i]->PotionIncreaseAgility() << " in agility" << endl << endl;
        }

        if(potionsArray.size())
            selection = getch();

        if(selection == 'b')
        {
            cout << "\033[" << lines + 3 << "A";
            cout << "\033[J";

            /*for(int i = 0; i < lines + 6; i++)
                cout << "\033[1A\033[K";
            cout << "\033[5B";*/

            return false;
        }/**
        else if(selection == 'c')
        {
            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')
        {
            DrinkPotion(arrow);

            if(arrow == potionsArray.size())
                arrow--;

            cout << "\033[3A";
            cout << "\033[J";

            lines = 3 * potionsArray.size();

            if(isInBattle)
                return true;
        }
        else if(selection == 'w' && arrow)
            arrow--;
        else if(selection == 's' && arrow < potionsArray.size() - 1)
            arrow++;

        cout << "\033[" << lines << "A";
        cout << "\033[J";
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %esi, 0x1c(%rsp)
movq 0xa0(%rdi), %rax
cmpq 0x98(%rdi), %rax
je 0x179b1
movq %rdi, %r14
movq 0x17b3a(%rip), %r15     # 0x2efc8
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3190
movsbl %al, %esi
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
movq %rax, %rbx
leaq 0xfac6(%rip), %rsi      # 0x26f85
movl $0x31, %edx
movq %rax, %rdi
callq 0x31e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3190
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3190
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
movq $0x0, 0x10(%rsp)
movl %eax, 0xc(%rsp)
movq 0xa0(%r14), %rax
cmpq 0x98(%r14), %rax
jne 0x17601
movl $0x3, %edx
movq %r15, %rdi
leaq 0xd331(%rip), %rsi      # 0x2487e
callq 0x31e0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3190
movsbl %al, %esi
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
movq %rax, %r13
movl $0x26, %edx
movq %rax, %rdi
leaq 0xf9d3(%rip), %rsi      # 0x26f5e
callq 0x31e0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3190
movsbl %al, %esi
movq %r13, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
movl $0x16e360, %edi         # imm = 0x16E360
callq 0x3260
movl $0x3, %edx
movq %r15, %rdi
leaq 0xd2d7(%rip), %rsi      # 0x248a8
callq 0x31e0
movl $0x3, %edx
movq %r15, %rdi
leaq 0xf1be(%rip), %rsi      # 0x267a3
callq 0x31e0
movl $0x4, %edx
movq %r15, %rdi
leaq 0xf9be(%rip), %rsi      # 0x26fb7
callq 0x31e0
movb $0x62, %bpl
movb %bpl, 0xb(%rsp)
movq 0x98(%r14), %rax
movq 0xa0(%r14), %rcx
movq %rcx, %rdx
subq %rax, %rdx
movq %rdx, 0x40(%rsp)
je 0x17833
movq 0x10(%rsp), %rbx
negl %ebx
movl $0x1, %ebp
xorl %r12d, %r12d
leal (%rbx,%rbp), %eax
cmpl $0x1, %eax
jne 0x1764d
movl $0xb, %edx
movq %r15, %rdi
leaq 0xf4e7(%rip), %rsi      # 0x26b32
jmp 0x1765c
movl $0x4, %edx
movq %r15, %rdi
leaq 0xd1aa(%rip), %rsi      # 0x24806
callq 0x31e0
movq 0x98(%r14), %rax
movq (%rax,%r12,8), %rsi
movq (%rsi), %rax
leaq 0x20(%rsp), %rdi
callq *(%rax)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq %r15, %rdi
callq 0x31e0
movq %rax, %r13
movl $0x10, %edx
movq %rax, %rdi
leaq 0xf922(%rip), %rsi      # 0x26fbc
callq 0x31e0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3190
movsbl %al, %esi
movq %r13, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x176e3
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x31b0
movq 0x98(%r14), %rax
movq (%rax,%r12,8), %rdi
callq 0x10718
testl %eax, %eax
je 0x17739
movl $0x13, %edx
movq %r15, %rdi
leaq 0xf8c7(%rip), %rsi      # 0x26fcd
callq 0x31e0
movq 0x98(%r14), %rax
movq (%rax,%r12,8), %rdi
callq 0x10718
movl %eax, %esi
movq %r15, %rdi
callq 0x30f0
movq %rax, %r13
movl $0xc, %edx
movq %rax, %rdi
leaq 0xf8aa(%rip), %rsi      # 0x26fe1
jmp 0x177b6
movq 0x98(%r14), %rax
movq (%rax,%r12,8), %rdi
callq 0x1071c
movl %eax, %r13d
movl $0x13, %edx
movq %r15, %rdi
leaq 0xf872(%rip), %rsi      # 0x26fcd
callq 0x31e0
movq 0x98(%r14), %rax
movq (%rax,%r12,8), %rdi
testl %r13d, %r13d
je 0x17793
callq 0x1071c
movl %eax, %esi
movq %r15, %rdi
callq 0x30f0
movq %rax, %r13
movl $0xd, %edx
movq %rax, %rdi
leaq 0xf85d(%rip), %rsi      # 0x26fee
jmp 0x177b6
callq 0x10720
cvtss2sd %xmm0, %xmm0
movq %r15, %rdi
callq 0x32a0
movq %rax, %r13
movl $0xb, %edx
movq %rax, %rdi
leaq 0xf846(%rip), %rsi      # 0x26ffc
callq 0x31e0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3190
movsbl %al, %esi
movq %r13, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3190
movsbl %al, %esi
movq %r13, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
movl %ebp, %r12d
movq 0x98(%r14), %rax
movq 0xa0(%r14), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
incl %ebp
cmpq %r12, %rdx
ja 0x17634
cmpq %rax, %rcx
movb 0xb(%rsp), %bpl
je 0x17844
callq 0x10728
movl %eax, %ebp
cmpb $0xa, %bpl
je 0x1788b
movq 0x40(%rsp), %rax
shrq $0x3, %rax
leal (%rax,%rax,2), %r13d
movzbl %bpl, %eax
cmpl $0x62, %eax
jne 0x178fa
movl $0x2, %edx
movq %r15, %rdi
leaq 0xcb68(%rip), %rsi      # 0x243db
callq 0x31e0
addl $0x3, %r13d
xorl %ebx, %ebx
movl $0x0, 0xc(%rsp)
jmp 0x17971
movq %r14, %rdi
movq 0x10(%rsp), %rbx
movl %ebx, %esi
callq 0x115ee
movslq %ebx, %rax
movq 0xa0(%r14), %rcx
subq 0x98(%r14), %rcx
sarq $0x3, %rcx
xorl %edx, %edx
cmpq %rax, %rcx
sete %dl
subl %edx, %ebx
movq %rbx, 0x10(%rsp)
movl $0x4, %edx
movq %r15, %rdi
leaq 0xcac4(%rip), %rsi      # 0x24391
callq 0x31e0
movl $0x3, %edx
movq %r15, %rdi
leaq 0xeec2(%rip), %rsi      # 0x267a3
callq 0x31e0
cmpb $0x0, 0x1c(%rsp)
je 0x17915
movb $0x1, %al
movl %eax, 0xc(%rsp)
xorl %ebx, %ebx
jmp 0x179a4
cmpb $0x77, %bpl
jne 0x1792d
cmpl $0x0, 0x10(%rsp)
je 0x1792d
movq 0x10(%rsp), %rax
decl %eax
movq %rax, 0x10(%rsp)
jmp 0x1795b
movq 0xa0(%r14), %rax
subq 0x98(%r14), %rax
shrq $0x3, %rax
leal (%rax,%rax,2), %r13d
jmp 0x1795b
cmpb $0x73, %bpl
jne 0x1795b
movq 0x10(%rsp), %rdx
movslq %edx, %rax
movq 0xa0(%r14), %rcx
subq 0x98(%r14), %rcx
sarq $0x3, %rcx
decq %rcx
cmpq %rcx, %rax
adcl $0x0, %edx
movq %rdx, 0x10(%rsp)
movl $0x2, %edx
movq %r15, %rdi
leaq 0xca71(%rip), %rsi      # 0x243db
callq 0x31e0
movb $0x1, %bl
movq %r15, %rdi
movl %r13d, %esi
callq 0x32e0
movl $0x1, %edx
movq %rax, %rdi
leaq 0xd273(%rip), %rsi      # 0x24bfe
callq 0x31e0
movl $0x3, %edx
movq %r15, %rdi
leaq 0xee04(%rip), %rsi      # 0x267a3
callq 0x31e0
testb %bl, %bl
jne 0x1752a
jmp 0x17a6b
movq 0x17610(%rip), %rbx     # 0x2efc8
leaq 0xcebf(%rip), %rsi      # 0x2487e
movl $0x3, %edx
movq %rbx, %rdi
callq 0x31e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3190
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
movq %rax, %r14
leaq 0xf561(%rip), %rsi      # 0x26f5e
movl $0x26, %edx
movq %rax, %rdi
callq 0x31e0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3190
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3100
movl $0x16e360, %edi         # imm = 0x16E360
callq 0x3260
leaq 0xce66(%rip), %rsi      # 0x248a8
movl $0x3, %edx
movq %rbx, %rdi
callq 0x31e0
leaq 0xed4d(%rip), %rsi      # 0x267a3
movl $0x3, %edx
movq %rbx, %rdi
callq 0x31e0
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
andb $0x1, %al
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x17a9f
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x31b0
movq %rbx, %rdi
callq 0x32f0
nop