// File: 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
movq %rsp, %rbp
subq $0x2d0, %rsp            # imm = 0x2D0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x278(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1dc90
movq %rax, %rdi
callq 0x61a0
movq -0x10(%rbp), %rdi
callq 0x1dc90
movq %rax, %rdi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
leaq -0x39(%rbp), %rdi
movq %rdi, -0x270(%rbp)
callq 0x5560
movq -0x270(%rbp), %rdx
leaq 0x97d8(%rip), %rsi      # 0x2f0e9
leaq -0x38(%rbp), %rdi
callq 0x7d20
jmp 0x2591c
leaq -0x39(%rbp), %rdi
callq 0x5350
movq -0x10(%rbp), %rdi
callq 0x1dc90
movq %rax, -0x280(%rbp)
jmp 0x25937
movq -0x280(%rbp), %rdi
callq 0x6240
movl %eax, -0x284(%rbp)
jmp 0x2594b
movl -0x284(%rbp), %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, %eax
je 0x25d14
movq -0x10(%rbp), %rdi
callq 0x1dc90
movq %rax, -0x290(%rbp)
jmp 0x2596f
movq -0x290(%rbp), %rdi
callq 0x61a0
jmp 0x2597d
movl -0x14(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x298(%rbp)
subl $0x4, %eax
ja 0x25cea
movq -0x298(%rbp), %rax
leaq 0x93ae(%rip), %rcx      # 0x2ed50
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x39(%rbp), %rdi
callq 0x5350
jmp 0x25d39
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x25d30
movq -0x10(%rbp), %rdi
callq 0x1ff20
jmp 0x259e1
jmp 0x25cec
leaq -0x71(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x5560
movq -0x2a0(%rbp), %rdx
leaq 0x971e(%rip), %rsi      # 0x2f122
leaq -0x70(%rbp), %rdi
callq 0x7d20
jmp 0x25a0f
leaq -0x71(%rbp), %rdi
callq 0x5350
leaq 0x973b(%rip), %rsi      # 0x2f15a
leaq -0x70(%rbp), %rdi
callq 0x52c0
jmp 0x25a2a
leaq -0x200(%rbp), %rdi
callq 0x5200
jmp 0x25a38
movq -0x278(%rbp), %rdi
leaq -0x1f0(%rbp), %rax
movq %rax, -0x2a8(%rbp)
callq 0x21f80
movq -0x2a8(%rbp), %rdi
movl %eax, %esi
callq 0x5540
jmp 0x25a62
leaq -0x220(%rbp), %rdi
leaq -0x200(%rbp), %rsi
callq 0x52e0
jmp 0x25a77
leaq -0x70(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x5420
jmp 0x25a89
leaq -0x220(%rbp), %rdi
callq 0x55d0
leaq 0x8b0f(%rip), %rsi      # 0x2e5ab
leaq -0x70(%rbp), %rdi
callq 0x52c0
jmp 0x25aa7
movq -0x10(%rbp), %rdi
callq 0x1ff20
jmp 0x25ab2
movq -0x278(%rbp), %rsi
leaq -0x240(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0x23ec0
jmp 0x25acb
movq -0x278(%rbp), %rdi
leaq -0x240(%rbp), %rsi
callq 0x24e20
jmp 0x25ae0
leaq -0x240(%rbp), %rdi
callq 0x55d0
leaq -0x200(%rbp), %rdi
callq 0x5230
leaq -0x70(%rbp), %rdi
callq 0x55d0
jmp 0x25cec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x71(%rbp), %rdi
callq 0x5350
jmp 0x25d30
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x25b7a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x25b6e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x55d0
jmp 0x25b6e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x55d0
leaq -0x200(%rbp), %rdi
callq 0x5230
leaq -0x70(%rbp), %rdi
callq 0x55d0
jmp 0x25d30
movq -0x278(%rbp), %rdi
addq $0xc0, %rdi
callq 0x14ca0
movb %al, -0x2a9(%rbp)
jmp 0x25ba3
movb -0x2a9(%rbp), %al
testb $0x1, %al
jne 0x25c0c
jmp 0x25baf
movq -0x278(%rbp), %rdi
addq $0xc0, %rdi
callq 0x14c70
movb %al, -0x2aa(%rbp)
jmp 0x25bca
movb -0x2aa(%rbp), %al
testb $0x1, %al
jne 0x25c0c
jmp 0x25bd6
movq 0x1a3e3(%rip), %rdi     # 0x3ffc0
leaq 0x9588(%rip), %rsi      # 0x2f16c
callq 0x52f0
movq %rax, -0x2b8(%rbp)
jmp 0x25bf2
movq -0x2b8(%rbp), %rdi
movq 0x1a3a0(%rip), %rsi     # 0x3ffa0
callq 0x5330
jmp 0x25c07
jmp 0x25cec
movq -0x278(%rbp), %rdi
addq $0xc0, %rdi
callq 0x17020
jmp 0x25c21
movq -0x278(%rbp), %rsi
leaq -0x260(%rbp), %rdi
leaq -0x38(%rbp), %rdx
callq 0x23ec0
jmp 0x25c3a
movq -0x278(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x255b0
jmp 0x25c4f
leaq -0x260(%rbp), %rdi
callq 0x55d0
jmp 0x25cec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x55d0
jmp 0x25d30
movq -0x10(%rbp), %rdi
callq 0x1dc90
movq %rax, -0x2c0(%rbp)
jmp 0x25c8f
movq -0x2c0(%rbp), %rdi
callq 0x61a0
jmp 0x25c9d
movl $0x1, -0x264(%rbp)
jmp 0x25d1e
callq 0xe390
jmp 0x25cb0
movq -0x10(%rbp), %rdi
callq 0x1dc90
movq %rax, -0x2c8(%rbp)
jmp 0x25cc2
movq -0x2c8(%rbp), %rdi
callq 0x61a0
jmp 0x25cd0
leaq 0x1a632(%rip), %rax     # 0x40309
testb $0x1, (%rax)
je 0x25ce8
movl $0x1, -0x264(%rbp)
jmp 0x25d1e
jmp 0x25cec
jmp 0x25cec
movq -0x10(%rbp), %rdi
callq 0x1dc90
movq %rax, -0x2d0(%rbp)
jmp 0x25cfe
movq -0x2d0(%rbp), %rdi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
jmp 0x25d0f
jmp 0x25925
movl $0x0, -0x264(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x55d0
addq $0x2d0, %rsp            # imm = 0x2D0
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x55d0
movq -0x48(%rbp), %rdi
callq 0x5550
nopw %cs:(%rax,%rax)