// File: /workspace/github_cpp_makefile_star2_O2/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 $0x38, %rsp
movl %esi, 0x10(%rsp)
movq 0xa0(%rdi), %rax
cmpq 0x98(%rdi), %rax
je 0x112f8
movq %rdi, %r14
movq 0x16002(%rip), %r15     # 0x26fc8
movq %r15, %rdi
callq 0x30d0
leaq 0xcfb0(%rip), %rsi      # 0x1df85
movq %rax, %rdi
callq 0x31d0
movq %rax, %rdi
callq 0x30d0
movq %rax, %rdi
callq 0x30d0
xorl %r13d, %r13d
leaq 0xcb3b(%rip), %rbp      # 0x1db32
movq 0x98(%r14), %rax
movq 0xa0(%r14), %rcx
cmpq %rax, %rcx
jne 0x11082
movq %r15, %rdi
leaq 0xa86a(%rip), %rsi      # 0x1b87e
callq 0x31d0
movq %r15, %rdi
callq 0x30d0
movq %rax, %rdi
leaq 0xcf33(%rip), %rsi      # 0x1df5e
callq 0x31d0
movq %rax, %rdi
callq 0x30d0
movl $0x16e360, %edi         # imm = 0x16E360
callq 0x32a0
movq %r15, %rdi
leaq 0xa85c(%rip), %rsi      # 0x1b8a8
callq 0x31d0
movq %r15, %rdi
leaq 0xc748(%rip), %rsi      # 0x1d7a3
callq 0x31d0
movq %r15, %rdi
leaq 0xcf4d(%rip), %rsi      # 0x1dfb7
callq 0x31d0
movq 0x98(%r14), %rax
movq 0xa0(%r14), %rcx
movb $0x62, 0xf(%rsp)
movq %rcx, %rdx
subq %rax, %rdx
shrq $0x3, %rdx
leal (%rdx,%rdx,2), %edx
movl %edx, 0x14(%rsp)
xorl %ebx, %ebx
movl %ebx, %ebx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rbx, %rdx
jbe 0x111f6
cmpl %ebx, %r13d
leaq 0xa752(%rip), %rsi      # 0x1b806
cmoveq %rbp, %rsi
movq %r15, %rdi
callq 0x31d0
movq 0x98(%r14), %rax
movq (%rax,%rbx,8), %rsi
movq (%rsi), %rax
leaq 0x18(%rsp), %r12
movq %r12, %rdi
callq *(%rax)
movq %r15, %rdi
movq %r12, %rsi
callq 0x3190
movq %rax, %rdi
leaq 0xcecf(%rip), %rsi      # 0x1dfbc
callq 0x31d0
movq %rax, %rdi
callq 0x30d0
leaq 0x18(%rsp), %rdi
callq 0x30c0
movq 0x98(%r14), %rax
movq (%rax,%rbx,8), %rdi
callq 0xcd66
testl %eax, %eax
je 0x11158
movq %r15, %rdi
leaq 0xceab(%rip), %rsi      # 0x1dfcd
callq 0x31d0
movq %rax, %r12
movq 0x98(%r14), %rax
movq (%rax,%rbx,8), %rdi
callq 0xcd66
movl %eax, %esi
movq %r12, %rdi
callq 0x3120
movq %rax, %rdi
leaq 0xce93(%rip), %rsi      # 0x1dfe1
callq 0x31d0
movq %rax, %rdi
jmp 0x111d4
movl %r13d, %ebp
movq 0x98(%r14), %rax
movq (%rax,%rbx,8), %rdi
callq 0xcd6a
movl %eax, %r13d
movq %r15, %rdi
leaq 0xce55(%rip), %rsi      # 0x1dfcd
callq 0x31d0
movq %rax, %r12
movq 0x98(%r14), %rax
movq (%rax,%rbx,8), %rdi
testl %r13d, %r13d
je 0x111ab
callq 0xcd6a
movl %eax, %esi
movq %r12, %rdi
callq 0x3120
movq %rax, %rdi
leaq 0xce45(%rip), %rsi      # 0x1dfee
jmp 0x111c2
callq 0xcd6e
movq %r12, %rdi
callq 0x3140
movq %rax, %rdi
leaq 0xce3a(%rip), %rsi      # 0x1dffc
callq 0x31d0
movq %rax, %rdi
movl %ebp, %r13d
leaq 0xc95e(%rip), %rbp      # 0x1db32
callq 0x30d0
movq %rax, %rdi
callq 0x30d0
incl %ebx
movq 0x98(%r14), %rax
movq 0xa0(%r14), %rcx
jmp 0x11095
cmpq %rax, %rcx
movb 0xf(%rsp), %al
je 0x11204
callq 0xcd74
movslq %r13d, %r12
cmpb $0xa, %al
movl 0x14(%rsp), %ebx
movb %al, 0xf(%rsp)
je 0x11230
movzbl %al, %ecx
cmpl $0x62, %ecx
je 0x11343
cmpb $0x77, %al
jne 0x1129c
testl %r13d, %r13d
je 0x1129c
decl %r13d
jmp 0x112bc
movq %r14, %rdi
movl %r12d, %esi
callq 0xd90e
movq 0xa0(%r14), %rax
subq 0x98(%r14), %rax
sarq $0x3, %rax
xorl %ebx, %ebx
cmpq %r12, %rax
sete %r12b
movq %r15, %rdi
leaq 0xa131(%rip), %rsi      # 0x1b391
callq 0x31d0
movq %r15, %rdi
leaq 0xc534(%rip), %rsi      # 0x1d7a3
callq 0x31d0
cmpb $0x0, 0x10(%rsp)
jne 0x1138a
movb %r12b, %bl
subl %ebx, %r13d
movq 0xa0(%r14), %rax
subq 0x98(%r14), %rax
shrq $0x3, %rax
leal (%rax,%rax,2), %ebx
jmp 0x112bc
cmpb $0x73, %al
jne 0x112bc
movq 0xa0(%r14), %rax
subq 0x98(%r14), %rax
sarq $0x3, %rax
decq %rax
cmpq %rax, %r12
adcl $0x0, %r13d
movq %r15, %rdi
leaq 0xa115(%rip), %rsi      # 0x1b3db
callq 0x31d0
movq %rax, %rdi
movl %ebx, %esi
callq 0x3320
movq %rax, %rdi
leaq 0xa91f(%rip), %rsi      # 0x1bbfe
callq 0x31d0
movq %r15, %rdi
leaq 0xc4b5(%rip), %rsi      # 0x1d7a3
callq 0x31d0
jmp 0x10ff7
movq 0x15cc9(%rip), %rbx     # 0x26fc8
leaq 0xa578(%rip), %rsi      # 0x1b87e
movq %rbx, %rdi
callq 0x31d0
movq %rbx, %rdi
callq 0x30d0
leaq 0xcc41(%rip), %rsi      # 0x1df5e
movq %rax, %rdi
callq 0x31d0
movq %rax, %rdi
callq 0x30d0
movl $0x16e360, %edi         # imm = 0x16E360
callq 0x32a0
leaq 0xa56a(%rip), %rsi      # 0x1b8a8
movq %rbx, %rdi
jmp 0x11372
movl %ebx, %ebp
movq 0x15c7c(%rip), %rbx     # 0x26fc8
leaq 0xa088(%rip), %rsi      # 0x1b3db
movq %rbx, %rdi
callq 0x31d0
addl $0x3, %ebp
movq %rax, %rdi
movl %ebp, %esi
callq 0x3320
leaq 0xa88f(%rip), %rsi      # 0x1bbfe
movq %rax, %rdi
callq 0x31d0
leaq 0xc425(%rip), %rsi      # 0x1d7a3
movq %rbx, %rdi
callq 0x31d0
xorl %eax, %eax
jmp 0x1138c
movb $0x1, %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x30c0
movq %rbx, %rdi
callq 0x3330