// File: 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
movq %rsp, %rbp
subq $0xb0, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x60(%rbp)
movl $0x0, -0x18(%rbp)
addq $0x98, %rdi
callq 0x26ea0
cmpq $0x0, %rax
jne 0x265b5
movq 0x27a89(%rip), %rdi     # 0x4dfc8
leaq 0x17338(%rip), %rsi     # 0x3d87e
callq 0x4260
movq 0x27a76(%rip), %rdi     # 0x4dfc8
movq 0x27a5f(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
leaq 0x19a86(%rip), %rsi     # 0x3ffee
callq 0x4260
movq %rax, %rdi
movq 0x27a41(%rip), %rsi     # 0x4dfb8
callq 0x4290
movl $0x16e360, %edi         # imm = 0x16E360
callq 0x4390
movq 0x27a3b(%rip), %rdi     # 0x4dfc8
leaq 0x17314(%rip), %rsi     # 0x3d8a8
callq 0x4260
movq 0x27a28(%rip), %rdi     # 0x4dfc8
leaq 0x1928c(%rip), %rsi     # 0x3f833
callq 0x4260
movb $0x0, -0x1(%rbp)
jmp 0x26aff
movq 0x27a0c(%rip), %rdi     # 0x4dfc8
movq 0x279f5(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
leaq 0x19a43(%rip), %rsi     # 0x40015
callq 0x4260
movq %rax, %rdi
movq 0x279d7(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
movq 0x279c8(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq -0x60(%rbp), %rdi
addq $0x98, %rdi
callq 0x26ea0
cmpq $0x0, %rax
jne 0x2669a
movq 0x279b2(%rip), %rdi     # 0x4dfc8
leaq 0x17261(%rip), %rsi     # 0x3d87e
callq 0x4260
movq 0x2799f(%rip), %rdi     # 0x4dfc8
movq 0x27988(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
leaq 0x199af(%rip), %rsi     # 0x3ffee
callq 0x4260
movq %rax, %rdi
movq 0x2796a(%rip), %rsi     # 0x4dfb8
callq 0x4290
movl $0x16e360, %edi         # imm = 0x16E360
callq 0x4390
movq 0x27964(%rip), %rdi     # 0x4dfc8
leaq 0x1723d(%rip), %rsi     # 0x3d8a8
callq 0x4260
movq 0x27951(%rip), %rdi     # 0x4dfc8
leaq 0x191b5(%rip), %rsi     # 0x3f833
callq 0x4260
movq 0x2793e(%rip), %rdi     # 0x4dfc8
leaq 0x199b6(%rip), %rsi     # 0x40047
callq 0x4260
movb $0x62, -0x1d(%rbp)
movq -0x60(%rbp), %rdi
addq $0x98, %rdi
callq 0x26ea0
imulq $0x3, %rax, %rax
movl %eax, -0x1c(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x60(%rbp), %rdi
movl -0x24(%rbp), %eax
movq %rax, -0x68(%rbp)
addq $0x98, %rdi
callq 0x26ea0
movq %rax, %rcx
movq -0x68(%rbp), %rax
cmpq %rcx, %rax
jae 0x2694d
movl -0x18(%rbp), %eax
cmpl -0x24(%rbp), %eax
jne 0x266fc
movq 0x278da(%rip), %rdi     # 0x4dfc8
leaq 0x194cd(%rip), %rsi     # 0x3fbc2
callq 0x4260
jmp 0x2670f
movq 0x278c5(%rip), %rdi     # 0x4dfc8
leaq 0x170fc(%rip), %rsi     # 0x3d806
callq 0x4260
movq -0x60(%rbp), %rdi
addq $0x98, %rdi
movl -0x24(%rbp), %eax
movl %eax, %esi
callq 0x277c0
movq (%rax), %rsi
movq (%rsi), %rax
movq (%rax), %rax
leaq -0x48(%rbp), %rdi
movq %rdi, -0x78(%rbp)
callq *%rax
movq -0x78(%rbp), %rsi
movq 0x27886(%rip), %rdi     # 0x4dfc8
callq 0x4210
movq %rax, -0x70(%rbp)
jmp 0x2674d
movq -0x70(%rbp), %rdi
leaq 0x198f4(%rip), %rsi     # 0x4004c
callq 0x4260
movq %rax, -0x80(%rbp)
jmp 0x26763
movq -0x80(%rbp), %rdi
movq 0x2784a(%rip), %rsi     # 0x4dfb8
callq 0x4290
jmp 0x26775
leaq -0x48(%rbp), %rdi
callq 0x4160
movq -0x60(%rbp), %rdi
addq $0x98, %rdi
movl -0x24(%rbp), %eax
movl %eax, %esi
callq 0x277c0
movq (%rax), %rdi
callq 0x1e7c0
cmpl $0x0, %eax
je 0x26835
movq 0x2781d(%rip), %rdi     # 0x4dfc8
leaq 0x198ab(%rip), %rsi     # 0x4005d
callq 0x4260
movq -0x60(%rbp), %rdi
movq %rax, -0x88(%rbp)
addq $0x98, %rdi
movl -0x24(%rbp), %eax
movl %eax, %esi
callq 0x277c0
movq (%rax), %rdi
callq 0x1e7c0
movq -0x88(%rbp), %rdi
movl %eax, %esi
callq 0x4370
movq %rax, %rdi
leaq 0x1987e(%rip), %rsi     # 0x40071
callq 0x4260
movq %rax, %rdi
movq 0x277b6(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
movq 0x277a7(%rip), %rsi     # 0x4dfb8
callq 0x4290
jmp 0x2693d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x4160
jmp 0x26b0d
movq -0x60(%rbp), %rdi
addq $0x98, %rdi
movl -0x24(%rbp), %eax
movl %eax, %esi
callq 0x277c0
movq (%rax), %rdi
callq 0x1e7e0
cmpl $0x0, %eax
je 0x268cb
movq 0x2776a(%rip), %rdi     # 0x4dfc8
leaq 0x197f8(%rip), %rsi     # 0x4005d
callq 0x4260
movq -0x60(%rbp), %rdi
movq %rax, -0x90(%rbp)
addq $0x98, %rdi
movl -0x24(%rbp), %eax
movl %eax, %esi
callq 0x277c0
movq (%rax), %rdi
callq 0x1e7e0
movq -0x90(%rbp), %rdi
movl %eax, %esi
callq 0x4370
movq %rax, %rdi
leaq 0x197d8(%rip), %rsi     # 0x4007e
callq 0x4260
movq %rax, %rdi
movq 0x27703(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
movq 0x276f4(%rip), %rsi     # 0x4dfb8
callq 0x4290
jmp 0x2693b
movq 0x276f6(%rip), %rdi     # 0x4dfc8
leaq 0x19784(%rip), %rsi     # 0x4005d
callq 0x4260
movq -0x60(%rbp), %rdi
movq %rax, -0x98(%rbp)
addq $0x98, %rdi
movl -0x24(%rbp), %eax
movl %eax, %esi
callq 0x277c0
movq (%rax), %rdi
callq 0x1e800
movq -0x98(%rbp), %rdi
callq 0x41b0
movq %rax, %rdi
leaq 0x19774(%rip), %rsi     # 0x4008c
callq 0x4260
movq %rax, %rdi
movq 0x27691(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, %rdi
movq 0x27682(%rip), %rsi     # 0x4dfb8
callq 0x4290
jmp 0x2693d
jmp 0x2693f
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x266b8
movq -0x60(%rbp), %rdi
addq $0x98, %rdi
callq 0x26ea0
cmpq $0x0, %rax
je 0x2696b
callq 0x1e820
movb %al, -0x1d(%rbp)
movsbl -0x1d(%rbp), %eax
cmpl $0x62, %eax
jne 0x269c0
movq 0x2764d(%rip), %rdi     # 0x4dfc8
leaq 0x16a59(%rip), %rsi     # 0x3d3db
callq 0x4260
movq %rax, %rdi
movl -0x1c(%rbp), %esi
addl $0x3, %esi
callq 0x4430
movq %rax, %rdi
leaq 0x17333(%rip), %rsi     # 0x3dcd2
callq 0x4260
movq 0x2761d(%rip), %rdi     # 0x4dfc8
leaq 0x18e81(%rip), %rsi     # 0x3f833
callq 0x4260
movb $0x0, -0x1(%rbp)
jmp 0x26aff
movsbl -0x1d(%rbp), %eax
cmpl $0xa, %eax
jne 0x26a5a
movq -0x60(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x20610
movq -0x60(%rbp), %rdi
movslq -0x18(%rbp), %rax
movq %rax, -0xa0(%rbp)
addq $0x98, %rdi
callq 0x26ea0
movq %rax, %rcx
movq -0xa0(%rbp), %rax
cmpq %rcx, %rax
jne 0x26a0c
movl -0x18(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x18(%rbp)
movq 0x275b5(%rip), %rdi     # 0x4dfc8
leaq 0x16977(%rip), %rsi     # 0x3d391
callq 0x4260
movq 0x275a2(%rip), %rdi     # 0x4dfc8
leaq 0x18e06(%rip), %rsi     # 0x3f833
callq 0x4260
movq -0x60(%rbp), %rdi
addq $0x98, %rdi
callq 0x26ea0
imulq $0x3, %rax, %rax
movl %eax, -0x1c(%rbp)
testb $0x1, -0x11(%rbp)
je 0x26a58
movb $0x1, -0x1(%rbp)
jmp 0x26aff
jmp 0x26ab8
movsbl -0x1d(%rbp), %eax
cmpl $0x77, %eax
jne 0x26a74
cmpl $0x0, -0x18(%rbp)
je 0x26a74
movl -0x18(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x26ab6
movsbl -0x1d(%rbp), %eax
cmpl $0x73, %eax
jne 0x26ab4
movq -0x60(%rbp), %rdi
movslq -0x18(%rbp), %rax
movq %rax, -0xa8(%rbp)
addq $0x98, %rdi
callq 0x26ea0
movq %rax, %rcx
movq -0xa8(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0x26ab4
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x26ab6
jmp 0x26ab8
jmp 0x26aba
movq 0x27507(%rip), %rdi     # 0x4dfc8
leaq 0x16913(%rip), %rsi     # 0x3d3db
callq 0x4260
movq %rax, %rdi
movl -0x1c(%rbp), %esi
callq 0x4430
movq %rax, %rdi
leaq 0x171f0(%rip), %rsi     # 0x3dcd2
callq 0x4260
movq 0x274da(%rip), %rdi     # 0x4dfc8
leaq 0x18d3e(%rip), %rsi     # 0x3f833
callq 0x4260
jmp 0x265f5
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xb0, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x4440
nopw %cs:(%rax,%rax)