// File: /workspace/github_cpp_makefile_star2_O3/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, 0x4(%rsp)
movq 0xa0(%rdi), %rax
cmpq 0x98(%rdi), %rax
je 0x17966
movq %rdi, %r14
movq 0x17b34(%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 0xfac0(%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
xorl %ebp, %ebp
movq 0x98(%r14), %rax
movq 0xa0(%r14), %r12
cmpq %rax, %r12
jne 0x1760c
movl $0x3, %edx
movq %r15, %rdi
leaq 0xd333(%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 0xf9d5(%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 0xd2d9(%rip), %rsi      # 0x248a8
callq 0x31e0
movl $0x3, %edx
movq %r15, %rdi
leaq 0xf1c0(%rip), %rsi      # 0x267a3
callq 0x31e0
movl $0x4, %edx
movq %r15, %rdi
leaq 0xf9c0(%rip), %rsi      # 0x26fb7
callq 0x31e0
movq 0x98(%r14), %rax
movq 0xa0(%r14), %r12
movb $0x62, %bl
subq %rax, %r12
je 0x17848
movq %r12, 0x28(%rsp)
movb %bl, 0x3(%rsp)
movq %rbp, 0x30(%rsp)
movl %ebp, %ebx
negl %ebx
movl $0x1, %ebp
xorl %r12d, %r12d
leal (%rbx,%rbp), %eax
cmpl $0x1, %eax
jne 0x17648
movl $0xb, %edx
movq %r15, %rdi
leaq 0xf4ec(%rip), %rsi      # 0x26b32
jmp 0x17657
movl $0x4, %edx
movq %r15, %rdi
leaq 0xd1af(%rip), %rsi      # 0x24806
callq 0x31e0
movq 0x98(%r14), %rax
movq (%rax,%r12,8), %rsi
movq (%rsi), %rax
leaq 0x8(%rsp), %rdi
callq *(%rax)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r15, %rdi
callq 0x31e0
movq %rax, %r13
movl $0x10, %edx
movq %rax, %rdi
leaq 0xf927(%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 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x176de
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x31b0
movq 0x98(%r14), %rax
movq (%rax,%r12,8), %rdi
callq 0x10674
testl %eax, %eax
je 0x17734
movl $0x13, %edx
movq %r15, %rdi
leaq 0xf8cc(%rip), %rsi      # 0x26fcd
callq 0x31e0
movq 0x98(%r14), %rax
movq (%rax,%r12,8), %rdi
callq 0x10674
movl %eax, %esi
movq %r15, %rdi
callq 0x30f0
movq %rax, %r13
movl $0xc, %edx
movq %rax, %rdi
leaq 0xf8af(%rip), %rsi      # 0x26fe1
jmp 0x177b1
movq 0x98(%r14), %rax
movq (%rax,%r12,8), %rdi
callq 0x10678
movl %eax, %r13d
movl $0x13, %edx
movq %r15, %rdi
leaq 0xf877(%rip), %rsi      # 0x26fcd
callq 0x31e0
movq 0x98(%r14), %rax
movq (%rax,%r12,8), %rdi
testl %r13d, %r13d
je 0x1778e
callq 0x10678
movl %eax, %esi
movq %r15, %rdi
callq 0x30f0
movq %rax, %r13
movl $0xd, %edx
movq %rax, %rdi
leaq 0xf862(%rip), %rsi      # 0x26fee
jmp 0x177b1
callq 0x1067c
cvtss2sd %xmm0, %xmm0
movq %r15, %rdi
callq 0x32a0
movq %rax, %r13
movl $0xb, %edx
movq %rax, %rdi
leaq 0xf84b(%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 0x1762f
cmpq %rax, %rcx
movq 0x30(%rsp), %rbp
movb 0x3(%rsp), %bl
movq 0x28(%rsp), %r12
je 0x17848
callq 0x10684
movl %eax, %ebx
cmpb $0xa, %bl
je 0x17879
shrq $0x3, %r12
leal (%r12,%r12,2), %r13d
movzbl %bl, %eax
cmpl $0x62, %eax
je 0x17a01
cmpb $0x77, %bl
jne 0x178f7
testl %ebp, %ebp
je 0x178f7
decl %ebp
jmp 0x1791a
movl %ebx, %r12d
movq %r14, %rdi
movl %ebp, %esi
callq 0x1159a
movslq %ebp, %rax
movq 0xa0(%r14), %rcx
subq 0x98(%r14), %rcx
sarq $0x3, %rcx
xorl %ebx, %ebx
cmpq %rax, %rcx
sete %r13b
movl $0x4, %edx
movq %r15, %rdi
leaq 0xcade(%rip), %rsi      # 0x24391
callq 0x31e0
movl $0x3, %edx
movq %r15, %rdi
leaq 0xeedc(%rip), %rsi      # 0x267a3
callq 0x31e0
cmpb $0x0, 0x4(%rsp)
jne 0x17a57
movb %r13b, %bl
subl %ebx, %ebp
movq 0xa0(%r14), %rax
subq 0x98(%r14), %rax
shrq $0x3, %rax
leal (%rax,%rax,2), %r13d
movl %r12d, %ebx
jmp 0x1791a
cmpb $0x73, %bl
jne 0x1791a
movslq %ebp, %rax
movq 0xa0(%r14), %rcx
subq 0x98(%r14), %rcx
sarq $0x3, %rcx
decq %rcx
cmpq %rcx, %rax
adcl $0x0, %ebp
movl $0x2, %edx
movq %r15, %rdi
leaq 0xcab2(%rip), %rsi      # 0x243db
callq 0x31e0
movq %r15, %rdi
movl %r13d, %esi
callq 0x32e0
movl $0x1, %edx
movq %rax, %rdi
leaq 0xd2b6(%rip), %rsi      # 0x24bfe
callq 0x31e0
movl $0x3, %edx
movq %r15, %rdi
leaq 0xee47(%rip), %rsi      # 0x267a3
callq 0x31e0
jmp 0x17525
movq 0x1765b(%rip), %rbx     # 0x2efc8
leaq 0xcf0a(%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 0xf5ac(%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 0xceb1(%rip), %rsi      # 0x248a8
movl $0x3, %edx
movq %rbx, %rdi
jmp 0x17a3a
movq 0x175c0(%rip), %rbx     # 0x2efc8
leaq 0xc9cc(%rip), %rsi      # 0x243db
movl $0x2, %edx
movq %rbx, %rdi
callq 0x31e0
addl $0x3, %r13d
movq %rbx, %rdi
movl %r13d, %esi
callq 0x32e0
leaq 0xd1cc(%rip), %rsi      # 0x24bfe
movl $0x1, %edx
movq %rax, %rdi
callq 0x31e0
leaq 0xed5d(%rip), %rsi      # 0x267a3
movl $0x3, %edx
movq %rbx, %rdi
callq 0x31e0
xorl %eax, %eax
jmp 0x17a59
movb $0x1, %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x17a87
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x31b0
movq %rbx, %rdi
callq 0x32f0
nop