// File: MichaelXanth[P]RPG_Game/Market/Market.cpp
// Function: Market::EnterMarket(std::vector<Hero*, std::allocator<Hero*>>&)
bool Market::EnterMarket(vector<Hero *>& heroes)
{
    int action;
    //int buyState;
    string testAction;
    bool infoState = false;

    NewStuff(heroes);

    DisplayMarket();

    while(true){

        bool errFlag = false;

        cout << endl;
        cout << "-------------------------------" << endl << endl;
        cout << "Choose an action: ";

        cout << "\n\n\n\n\n";
        cout << "\033[5A\033[18C";

        cout << "\033[s";

        do {
            if (errFlag)
                usleep(1800000);

            cout << "\033[u";
            cout << "\033[J";
            cout << "\033[s";

            cin >> testAction;

            errFlag = true;
        } while(!isValid(testAction.c_str(),action,1,4));

        switch(action)
        {
            case 1:
                Buy(heroes);
                break;
            case 2:
                Sell(heroes);
                break;
            case 3:
                infoState = !infoState;
                DisplayMarket(infoState);
                break;
            case 4:
                return false;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x4380
movq -0x60(%rbp), %rdi
movb $0x0, -0x39(%rbp)
movq -0x10(%rbp), %rsi
callq 0x31340
jmp 0x39e17
movq -0x60(%rbp), %rdi
movb $0x0, -0x4d(%rbp)
xorl %eax, %eax
movl %eax, %edx
leaq -0x4d(%rbp), %rsi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x32490
jmp 0x39e33
jmp 0x39e35
jmp 0x39e37
movb $0x0, -0x4e(%rbp)
movq 0x14186(%rip), %rdi     # 0x4dfc8
movq 0x1416f(%rip), %rsi     # 0x4dfb8
callq 0x4290
jmp 0x39e50
movq 0x14171(%rip), %rdi     # 0x4dfc8
leaq 0x6434(%rip), %rsi      # 0x40292
callq 0x4260
movq %rax, -0x68(%rbp)
jmp 0x39e69
movq -0x68(%rbp), %rdi
movq 0x14144(%rip), %rsi     # 0x4dfb8
callq 0x4290
movq %rax, -0x70(%rbp)
jmp 0x39e7f
movq -0x70(%rbp), %rdi
movq 0x1412e(%rip), %rsi     # 0x4dfb8
callq 0x4290
jmp 0x39e91
movq 0x14130(%rip), %rdi     # 0x4dfc8
leaq 0x69b4(%rip), %rsi      # 0x40853
callq 0x4260
jmp 0x39ea6
movq 0x1411b(%rip), %rdi     # 0x4dfc8
leaq 0x65b4(%rip), %rsi      # 0x40468
callq 0x4260
jmp 0x39ebb
movq 0x14106(%rip), %rdi     # 0x4dfc8
leaq 0x699d(%rip), %rsi      # 0x40866
callq 0x4260
jmp 0x39ed0
movq 0x140f1(%rip), %rdi     # 0x4dfc8
leaq 0x39a0(%rip), %rsi      # 0x3d87e
callq 0x4260
jmp 0x39ee5
jmp 0x39ee7
testb $0x1, -0x4e(%rbp)
je 0x39f15
movl $0x1b7740, %edi         # imm = 0x1B7740
callq 0x4390
jmp 0x39ef9
jmp 0x39f15
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x4160
jmp 0x3a032
movq 0x140ac(%rip), %rdi     # 0x4dfc8
leaq 0x3985(%rip), %rsi      # 0x3d8a8
callq 0x4260
jmp 0x39f2a
movq 0x14097(%rip), %rdi     # 0x4dfc8
leaq 0x58fb(%rip), %rsi      # 0x3f833
callq 0x4260
jmp 0x39f3f
movq 0x14082(%rip), %rdi     # 0x4dfc8
leaq 0x3931(%rip), %rsi      # 0x3d87e
callq 0x4260
jmp 0x39f54
movq 0x1407d(%rip), %rdi     # 0x4dfd8
leaq -0x38(%rbp), %rsi
callq 0x4340
jmp 0x39f66
movb $0x1, -0x4e(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x4100
movq %rax, %rdi
movl $0x1, -0x54(%rbp)
movl $0x4, -0x58(%rbp)
leaq -0x14(%rbp), %rsi
leaq -0x54(%rbp), %rdx
leaq -0x58(%rbp), %rcx
movl $0x1, %r8d
callq 0x1e340
movb %al, -0x71(%rbp)
jmp 0x39fa0
movb -0x71(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x39ee7
movl -0x14(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x80(%rbp)
subl $0x3, %eax
ja 0x3a02d
movq -0x80(%rbp), %rax
leaq 0x6188(%rip), %rcx      # 0x40150
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x60(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x37980
jmp 0x39fe0
jmp 0x3a02d
movq -0x60(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x394b0
jmp 0x39ff1
jmp 0x3a02d
movq -0x60(%rbp), %rdi
movb -0x39(%rbp), %al
notb %al
andb $0x1, %al
movb %al, -0x39(%rbp)
xorl %eax, %eax
movl %eax, %edx
leaq -0x39(%rbp), %rsi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x32490
jmp 0x3a015
jmp 0x3a02d
leaq -0x38(%rbp), %rdi
callq 0x4160
xorl %eax, %eax
andb $0x1, %al
addq $0x80, %rsp
popq %rbp
retq
jmp 0x39e35
movq -0x48(%rbp), %rdi
callq 0x4440
nopl (%rax,%rax)