// File: /workspace/github_cpp_makefile_star2_O2/arisKoutsou[P]oopproj/./src/livings/Hero.cpp
// Function: Hero::handleCastSpellCase(std::__cxx11::list<Monster*, std::allocator<Monster*>>&)
bool Hero :: handleCastSpellCase(list<Monster*>& monsters) {
  if (spells.empty()) {
    cout << endl << "You have no spells equiped";
    return false;
  }
  Monster* monsterToAttack;
  if (monsters.size() == 1) {
    monsterToAttack = *monsters.begin();

    this->castSpell(monsterToAttack);

    cout << endl
	 << "Attacking the only monster here: "
 	 << monsterToAttack->getName() << endl;

    if (monsterToAttack->getHealthPower() == 0) {
      monsters.remove(monsterToAttack);
      delete monsterToAttack;
    }
    return true;

  } else {

    monsterToAttack = NULL;
    cout << endl
	 << "Please enter the name of the monster you want to attack"
	 << endl << endl << "> ";
    list<Monster*> :: const_iterator it = monsters.begin();
       
    string name;
    getline(cin, name);       
    for (it = monsters.begin(); it != monsters.end(); ++it) {
      if ((*it)->getName() == name) {
	monsterToAttack = (*it);
	break;
      }
    }

    if (monsterToAttack != NULL) {
      this->castSpell(monsterToAttack);
      cout << endl << "Casting Spell on " << monsterToAttack->getName() << endl;
      
      if (monsterToAttack->getHealthPower() == 0) {
	monsters.remove(monsterToAttack);
	delete monsterToAttack;
      }
      return true;
    } else {

      cout << endl << "There is no such Monster here..." << endl;
    }

  }

  return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
leaq 0x60(%rdi), %rax
cmpq %rax, 0x60(%rdi)
je 0x11a2b
movq %rsi, %rbx
movq %rdi, %r14
cmpq $0x1, 0x10(%rsi)
jne 0x11a4d
movq (%rbx), %rax
movq 0x10(%rax), %r15
movq %r15, 0x8(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x10ff0
movq 0xf601(%rip), %rdi      # 0x20fc0
callq 0x4120
leaq 0x488b(%rip), %rsi      # 0x16256
movq %rax, %rdi
callq 0x4250
movq %rax, %r14
movq %r15, %rdi
callq 0x12a64
movq %r14, %rdi
movq %rax, %rsi
callq 0x4220
movq %rax, %rdi
callq 0x4120
movq %r15, %rdi
callq 0x12a58
movb $0x1, %bpl
testl %eax, %eax
jne 0x11b91
leaq 0x8(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x127e0
movq (%r14), %rdi
testq %rdi, %rdi
je 0x11b91
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x11b91
movq 0xf58e(%rip), %rdi      # 0x20fc0
callq 0x4120
leaq 0x48a6(%rip), %rsi      # 0x162e4
movq %rax, %rdi
callq 0x4250
xorl %ebp, %ebp
jmp 0x11b91
andq $0x0, 0x8(%rsp)
movq 0xf566(%rip), %rdi      # 0x20fc0
callq 0x4120
leaq 0x4812(%rip), %rsi      # 0x16278
movq %rax, %rdi
callq 0x4250
movq %rax, %rdi
callq 0x4120
movq %rax, %rdi
callq 0x4120
leaq 0x35b7(%rip), %rsi      # 0x1503c
movq %rax, %rdi
callq 0x4250
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0xf52b(%rip), %rdi      # 0x20fd0
leaq 0x10(%rsp), %rsi
callq 0x4060
leaq 0x10(%rsp), %r15
movq %rbx, %r12
movq (%r12), %r12
cmpq %rbx, %r12
je 0x11ae5
movq 0x10(%r12), %rdi
callq 0x12a64
movq %rax, %rdi
movq %r15, %rsi
callq 0x57df
testb %al, %al
je 0x11ab7
movq 0x10(%r12), %rsi
movq %rsi, 0x8(%rsp)
jmp 0x11aea
movq 0x8(%rsp), %rsi
testq %rsi, %rsi
setne %bpl
je 0x11b64
movq %r14, %rdi
callq 0x10ff0
movq 0xf4be(%rip), %rdi      # 0x20fc0
callq 0x4120
leaq 0x47f1(%rip), %rsi      # 0x162ff
movq %rax, %rdi
callq 0x4250
movq %rax, %r14
movq 0x8(%rsp), %rdi
callq 0x12a64
movq %r14, %rdi
movq %rax, %rsi
callq 0x4220
movq %rax, %rdi
callq 0x4120
movq 0x8(%rsp), %rdi
callq 0x12a58
testl %eax, %eax
jne 0x11b87
leaq 0x8(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x127e0
movq (%r14), %rdi
testq %rdi, %rdi
je 0x11b87
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x11b87
movq 0xf455(%rip), %rdi      # 0x20fc0
callq 0x4120
leaq 0x474c(%rip), %rsi      # 0x162c3
movq %rax, %rdi
callq 0x4250
movq %rax, %rdi
callq 0x4120
leaq 0x10(%rsp), %rdi
callq 0x4470
movl %ebp, %eax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x11ba2
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4470
movq %rbx, %rdi
callq 0x4410
nop