// File: /workspace/github_cpp_makefile_star2_O1/arisKoutsou[P]oopproj/./src/livings/Hero.cpp
// Function: Hero::enterMarket(Market*)
void Hero :: enterMarket(Market* market) {
  market->getMenu().clearMenu();
  market->getMenu().displayMenu();
  int selection;
  string sellPrompt = "Please enter the name of the item/spell you want to sell";

  while ((selection = market->getMenu().getSelection())) {   
    market->getMenu().clearMenu();
    switch (selection) {
    case 1: {
      market->printInfo();
      break;
    }
    case 2: {
      string buyPrompt = "Please enter the name of the item/spell you want to buy";
      buyPrompt += "\n(Current Money: ";  
      stringstream ss;
      ss << getMoney();
      buyPrompt += ss.str();
      buyPrompt += ")";
      market->printInfo();
      string input = getUserInput(buyPrompt);
      this->buy(input);
      break;
    }
    case 3: {
      if (!this->inventory.hasSpells() && !this->inventory.hasItems()) {
	cout << "You have no items or spells for sale" << endl;
	break;
      }      
      inventory.printInfo();
      string input = getUserInput(sellPrompt);
      sell(input);
      break;
    }
    case 4: {
      market->getMenu().clearMenu();
      return;
    }
    case 5: {
      handleQuitCase();
      market->getMenu().clearMenu();
      if (quitGame) return;      
      break;
    }
    default: break;
    }
    market->getMenu().displayMenu();
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1e8, %rsp            # imm = 0x1E8
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0xfdf2
movq %rax, %rdi
callq 0x4f74
movq %rbx, %rdi
callq 0xfdf2
movq (%rax), %rcx
movq %rax, %rdi
callq *(%rcx)
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x6420(%rip), %rsi      # 0x1c111
leaq 0x6451(%rip), %rdx      # 0x1c149
leaq 0x40(%rsp), %rdi
callq 0x6520
leaq 0xc0(%r14), %r13
leaq 0x6068(%rip), %rbp      # 0x1bd78
leaq 0x20(%rsp), %r15
movq %rbx, %rdi
callq 0xfdf2
movq %rax, %rdi
callq 0x4ff0
movl %eax, %r12d
testl %eax, %eax
je 0x15f65
movq %rbx, %rdi
callq 0xfdf2
movq %rax, %rdi
callq 0x4f74
decl %r12d
cmpl $0x4, %r12d
ja 0x15ef4
movslq (%rbp,%r12,4), %rax
addq %rbp, %rax
jmpq *%rax
movq %rbx, %rdi
callq 0x11d64
jmp 0x15ef4
movq %r13, %rdi
callq 0xca42
testb %al, %al
jne 0x15d80
movq %r13, %rdi
callq 0xca36
testb %al, %al
je 0x15f09
movq %r13, %rdi
callq 0xea36
leaq 0x60(%rsp), %r12
movq %r12, %rdi
leaq 0x40(%rsp), %rdx
callq 0x14734
movq %r14, %rdi
movq %r12, %rsi
callq 0x15ab4
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x15ef4
movq 0x70(%rsp), %rsi
jmp 0x15eec
callq 0x8c1b
movq %rbx, %rdi
callq 0xfdf2
movq %rax, %rdi
callq 0x4f74
leaq 0xf48b(%rip), %rax      # 0x25269
cmpb $0x0, (%rax)
je 0x15ef4
jmp 0x15f65
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
movq %r15, %rdi
leaq 0x634a(%rip), %rsi      # 0x1c14a
leaq 0x637a(%rip), %rdx      # 0x1c181
callq 0x6520
movq %r15, %rdi
leaq 0x636c(%rip), %rsi      # 0x1c182
callq 0x4470
leaq 0x60(%rsp), %rdi
callq 0x41c0
movl 0xac(%r14), %esi
leaq 0x70(%rsp), %rdi
callq 0x4420
movq %rsp, %rdi
leaq 0x78(%rsp), %rsi
callq 0x43c0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r15, %rdi
callq 0x40e0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x15e6f
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %r15, %rdi
leaq 0x5752(%rip), %rsi      # 0x1b5cb
callq 0x4470
movq %rbx, %rdi
callq 0x11d64
movq %rsp, %r12
movq %r12, %rdi
movq %r15, %rdx
callq 0x14734
movq %r14, %rdi
movq %r12, %rsi
callq 0x15424
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x15eba
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x60(%rsp), %rdi
movq 0xf0d2(%rip), %rsi      # 0x24f98
callq 0x41f0
leaq 0xe0(%rsp), %rdi
callq 0x40f0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x15ef4
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0xfdf2
movq (%rax), %rcx
movq %rax, %rdi
callq *(%rcx)
jmp 0x15d15
movl $0x24, %edx
movq 0xf0ab(%rip), %rdi      # 0x24fc0
leaq 0x6278(%rip), %rsi      # 0x1c194
callq 0x42f0
movq 0xf098(%rip), %rcx      # 0x24fc0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x4270
movsbl %al, %esi
movq 0xf07a(%rip), %rdi      # 0x24fc0
callq 0x4040
movq %rax, %rdi
callq 0x41b0
jmp 0x15ef4
movq %rbx, %rdi
callq 0xfdf2
movq %rax, %rdi
callq 0x4f74
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x15f81
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x42a0
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x16021
movq %rax, %rbx
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x16024
movq 0x70(%rsp), %rsi
jmp 0x16017
jmp 0x16021
jmp 0x15fb7
jmp 0x15fe2
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x15fe5
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x15fe5
jmp 0x15fe2
jmp 0x15fdb
movq %rax, %rbx
jmp 0x16003
jmp 0x16021
movq %rax, %rbx
movq 0xefac(%rip), %rsi      # 0x24f98
leaq 0x60(%rsp), %rdi
callq 0x41f0
leaq 0xe0(%rsp), %rdi
callq 0x40f0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x16024
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x16024
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x16040
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0x4430