// File: /workspace/github_cpp_makefile_star2_O2/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 $0x1f8, %rsp            # imm = 0x1F8
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0xcacc
movq %rax, %rdi
callq 0x4bf4
movq %rbx, %rdi
callq 0xcacc
movq (%rax), %rcx
movq %rax, %rdi
callq *(%rcx)
leaq 0x53e7(%rip), %rsi      # 0x16111
leaq 0x10(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x578c
leaq 0xc0(%r14), %rax
movq %rax, 0x8(%rsp)
leaq 0x502c(%rip), %r12      # 0x15d78
leaq 0x50(%rsp), %r15
leaq 0x30(%rsp), %rbp
movq %rbx, %rdi
callq 0xcacc
movq %rax, %rdi
callq 0x4c44
movl %eax, %r13d
testl %eax, %eax
je 0x10f0a
movq %rbx, %rdi
callq 0xcacc
movq %rax, %rdi
callq 0x4bf4
decl %r13d
cmpl $0x4, %r13d
ja 0x10ec8
movslq (%r12,%r13,4), %rax
addq %r12, %rax
jmpq *%rax
movq %rbx, %rdi
callq 0xde0a
jmp 0x10ec8
movq 0x8(%rsp), %rdi
callq 0xa390
testb %al, %al
jne 0x10dc4
movq 0x8(%rsp), %rdi
callq 0xa384
testb %al, %al
je 0x10edd
movq 0x8(%rsp), %rdi
callq 0xb738
leaq 0x70(%rsp), %r13
movq %r13, %rdi
leaq 0x10(%rsp), %rdx
callq 0xffce
movq %r14, %rdi
movq %r13, %rsi
callq 0x10b7e
movq %r13, %rdi
jmp 0x10ec3
callq 0x7833
movq %rbx, %rdi
callq 0xcacc
movq %rax, %rdi
callq 0x4bf4
leaq 0x1044a(%rip), %rax     # 0x21259
cmpb $0x0, (%rax)
je 0x10ec8
jmp 0x10f0a
movq %r15, %rdi
leaq 0x5323(%rip), %rsi      # 0x1614a
leaq 0x70(%rsp), %rdx
callq 0x578c
movq %r15, %rdi
leaq 0x5347(%rip), %rsi      # 0x16182
callq 0x4440
leaq 0x70(%rsp), %rdi
callq 0x41b0
movl 0xac(%r14), %esi
leaq 0x80(%rsp), %rdi
callq 0x4400
movq %rbp, %rdi
leaq 0x88(%rsp), %rsi
callq 0x43a0
movq %r15, %rdi
movq %rbp, %rsi
callq 0x4450
movq %rbp, %rdi
callq 0x4470
movq %r15, %rdi
leaq 0x4730(%rip), %rsi      # 0x155bb
callq 0x4440
movq %rbx, %rdi
callq 0xde0a
movq %rbp, %rdi
movq %r15, %rdx
callq 0xffce
movq %r14, %rdi
movq %rbp, %rsi
callq 0x10814
movq %rbp, %rdi
callq 0x4470
leaq 0x70(%rsp), %rdi
callq 0x41e0
movq %r15, %rdi
callq 0x4470
movq %rbx, %rdi
callq 0xcacc
movq (%rax), %rcx
movq %rax, %rdi
callq *(%rcx)
jmp 0x10d56
movq 0x100dc(%rip), %rdi     # 0x20fc0
leaq 0x52a9(%rip), %rsi      # 0x16194
callq 0x4250
movq %rax, %rdi
callq 0x4120
jmp 0x10ec8
movq %rbx, %rdi
callq 0xcacc
movq %rax, %rdi
callq 0x4bf4
leaq 0x10(%rsp), %rdi
callq 0x4470
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x10f6b
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
jmp 0x10f64
jmp 0x10f6b
jmp 0x10f38
jmp 0x10f52
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x4470
jmp 0x10f55
jmp 0x10f52
jmp 0x10f4b
movq %rax, %rbx
jmp 0x10f5f
jmp 0x10f6b
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x41e0
leaq 0x50(%rsp), %rdi
callq 0x4470
jmp 0x10f6e
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4470
movq %rbx, %rdi
callq 0x4410