// File: /workspace/github_cpp_makefile_star2_O2/malcolmyeh[P]CC3K/floor.cc
// Function: Floor::usePotion(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
std::string Floor::usePotion(std::string direction){
	Posn p = this->player->getPosition().getNew(direction);
	std::string log;
	for (int i = 0; i < this->potions.size(); ++i){
		if (p == this->potions.at(i)->getPosition()){
			if(this->potions.at(i)->getType() == "RH"){
				this->player->heal(10);
				this->knownPotion[0] = true;
				log = "Restore Health potion restores 10 HP (HP: " + std::to_string(this->player->getHP()) + "). ";
			} else if (this->potions.at(i)->getType() == "BA"){
				this->player = new AtkBuff(this->player, 5);
				this->knownPotion[1] = true;
				log =  "Boost Attack potion grants 5 damage (Atk: " + std::to_string(this->player->getAtk()) + "). ";				
			} else if (this->potions.at(i)->getType() == "BD"){
				this->player = new DefBuff(this->player, 5);
				this->knownPotion[2] = true;
				log =  "Boost Defense potion grants 5 defense (Def: " + std::to_string(this->player->getDef()) + "). ";				
			} else if (this->potions.at(i)->getType() == "PH"){
				this->knownPotion[3] = true;
				if (this->player->getRace() == "Elf"){
					this->player->heal(10);
					log =  "Poison Health potion restores 10 HP (HP: " + std::to_string(this->player->getHP()) + "). ";
				} else {
					this->player->heal(-10);
					log =  "Poison Health potion deals 10 damage (HP: " + std::to_string(this->player->getHP()) + "). ";
				}		
			} else if (this->potions.at(i)->getType() == "WA"){
				this->knownPotion[4] = true;
				if (this->player->getRace() == "Elf"){
					this->player = new AtkBuff(this->player, 5);
					log =  "Wound Attack potion grants 5 damage (Atk: " + std::to_string(this->player->getAtk()) + "). ";
				} else {
					this->player = new AtkBuff(this->player, -5);
					log =  "Wound Attack potion reduces 5 damage (Atk: " + std::to_string(this->player->getAtk()) + "). ";				
				}								
			} else if (this->potions.at(i)->getType() == "WD"){
				this->knownPotion[5] = true;
				if (this->player->getRace() == "Elf"){
					this->player = new DefBuff(this->player, 5);
					log =  "Wound Defense potion grants 5 defense (Def: " + std::to_string(this->player->getDef()) + "). ";
				} else {
					this->player = new DefBuff(this->player, -5);
					log =  "Wound Defense potion reduces 5 defense (Def: " + std::to_string(this->player->getDef()) + "). ";
				}							
			}
			displayGrid[p.y][p.x] = defaultGrid[p.y][p.x];
			Potion * temp = this->potions.at(i);
			this->potions.erase(this->potions.begin() + i);
			delete temp;
			return log;
		}
		
	}
	return "No potion in direction. ";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, -0xb8(%rbp)
movq 0xfe0(%rsi), %rdi
movq (%rdi), %rax
callq *0x38(%rax)
leaq -0xb0(%rbp), %r15
movq %rax, (%r15)
leaq -0xe0(%rbp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x4200
movq %r15, %rdi
movq %r12, %rsi
callq 0x4ad8
leaq -0xc0(%rbp), %rbx
movq %rax, (%rbx)
leaq -0xe0(%rbp), %rdi
callq 0x40e0
leaq -0xa0(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x7f0(%r14), %rax
movq %rax, -0x50(%rbp)
pushq $-0x8
popq %r12
pushq $-0x1
popq %r13
leaq -0x48(%rbp), %r15
incq %r13
movq 0x7f8(%r14), %rax
subq 0x7f0(%r14), %rax
sarq $0x3, %rax
cmpq %r13, %rax
jbe 0x77df
movq -0x50(%rbp), %rdi
movq %r13, %rsi
callq 0x8324
movq (%rax), %rdi
callq 0xcabc
movq %rax, -0x48(%rbp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4bd2
addq $0x8, %r12
testb %al, %al
je 0x76f5
movq -0x50(%rbp), %rdi
movq %r13, %rsi
callq 0x8324
movq (%rax), %rsi
leaq -0x48(%rbp), %rdi
callq 0xd44c
leaq 0x8b2f(%rip), %rsi      # 0x1028c
leaq -0x48(%rbp), %rbx
movq %rbx, %rdi
callq 0x4ac7
movl %eax, %r15d
movq %rbx, %rdi
callq 0x40e0
testb %r15b, %r15b
je 0x7802
movq 0xfe0(%r14), %rdi
pushq $0xa
popq %rsi
callq 0x9152
movb $0x1, 0xff0(%r14)
movq 0xfe0(%r14), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
leaq -0x70(%rbp), %rdi
movl %eax, %esi
callq 0x851e
leaq 0x8e04(%rip), %rsi      # 0x105b7
leaq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0x84f0
leaq 0x93fb(%rip), %rdx      # 0x10bc5
leaq -0x48(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x84c7
jmp 0x7955
leaq 0x8f5f(%rip), %rsi      # 0x10745
leaq -0x48(%rbp), %rdx
movq -0xb8(%rbp), %rdi
callq 0x40b0
movq -0xb8(%rbp), %rbx
jmp 0x7a35
movq -0x50(%rbp), %rdi
movq %r13, %rsi
callq 0x8324
movq (%rax), %rsi
leaq -0x48(%rbp), %rdi
callq 0xd44c
leaq 0x8a6e(%rip), %rsi      # 0x1028f
movq %rbx, %rdi
callq 0x4ac7
movl %eax, %r15d
movq %rbx, %rdi
callq 0x40e0
testb %r15b, %r15b
je 0x78ac
pushq $0x60
popq %rdi
callq 0x4190
movq %rax, %r15
movq 0xfe0(%r14), %rsi
pushq $0x5
popq %rdx
movq %rax, %rdi
callq 0xf874
movq %r15, 0xfe0(%r14)
movb $0x1, 0xff1(%r14)
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
leaq -0x70(%rbp), %rdi
movl %eax, %esi
callq 0x851e
leaq 0x8d62(%rip), %rsi      # 0x105e2
leaq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0x84f0
leaq 0x932e(%rip), %rdx      # 0x10bc5
leaq -0x48(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x84c7
jmp 0x7955
movq -0x50(%rbp), %rdi
movq %r13, %rsi
callq 0x8324
movq (%rax), %rsi
leaq -0x48(%rbp), %rdi
callq 0xd44c
leaq 0x89c7(%rip), %rsi      # 0x10292
movq %rbx, %rdi
callq 0x4ac7
movl %eax, %r15d
movq %rbx, %rdi
callq 0x40e0
testb %r15b, %r15b
je 0x7a56
pushq $0x60
popq %rdi
callq 0x4190
movq %rax, %r15
movq 0xfe0(%r14), %rsi
pushq $0x5
popq %rdx
movq %rax, %rdi
callq 0xf908
movq %r15, 0xfe0(%r14)
movb $0x1, 0xff2(%r14)
movq (%r15), %rax
movq %r15, %rdi
callq *0x10(%rax)
leaq -0x70(%rbp), %rdi
movl %eax, %esi
callq 0x851e
leaq 0x8cdf(%rip), %rsi      # 0x1060d
leaq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0x84f0
leaq 0x9280(%rip), %rdx      # 0x10bc5
leaq -0x48(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x84c7
leaq -0xb0(%rbp), %rdi
movq %rbx, %rsi
callq 0x41d0
movq %rbx, %rdi
callq 0x40e0
leaq -0x90(%rbp), %rdi
callq 0x40e0
leaq -0x70(%rbp), %rdi
callq 0x40e0
movslq -0xbc(%rbp), %rax
movslq -0xc0(%rbp), %rcx
imulq $0x4f, %rax, %rax
addq %rax, %r14
movb 0x6(%rcx,%r14), %al
movb %al, 0x820(%rcx,%r14)
movq -0x50(%rbp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x8324
movq (%rax), %rbx
addq (%r14), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x8346
testq %rbx, %rbx
leaq -0xa0(%rbp), %r14
je 0x79d8
leaq 0x10(%rbx), %rdi
callq 0x40e0
pushq $0x30
popq %rsi
movq %rbx, %rdi
callq 0x41a0
movq -0xb8(%rbp), %rbx
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq -0xb0(%rbp), %rcx
cmpq %r14, %rcx
je 0x7a0d
movq %rcx, (%rbx)
movq -0xa0(%rbp), %rax
movq %rax, 0x10(%rbx)
jmp 0x7a14
movups (%r14), %xmm0
movups %xmm0, (%rax)
movq -0xa8(%rbp), %rax
movq %rax, 0x8(%rbx)
movq %r14, -0xb0(%rbp)
andq $0x0, -0xa8(%rbp)
movb $0x0, -0xa0(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x40e0
movq %rbx, %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x50(%rbp), %rdi
movq %r13, %rsi
callq 0x8324
movq (%rax), %rsi
leaq -0x48(%rbp), %rdi
callq 0xd44c
leaq 0x8820(%rip), %rsi      # 0x10295
movq %rbx, %rdi
callq 0x4ac7
movl %eax, %r15d
movq %rbx, %rdi
callq 0x40e0
testb %r15b, %r15b
je 0x7b27
movb $0x1, 0xff3(%r14)
movq 0xfe0(%r14), %rsi
movq (%rsi), %rax
leaq -0x48(%rbp), %rdi
callq *0x28(%rax)
leaq 0x8b89(%rip), %rsi      # 0x1063a
movq %rbx, %rdi
callq 0x4ac7
movl %eax, %r15d
movq %rbx, %rdi
callq 0x40e0
movq 0xfe0(%r14), %rdi
testb %r15b, %r15b
je 0x7c09
pushq $0xa
popq %rsi
callq 0x9152
movq 0xfe0(%r14), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
leaq -0x70(%rbp), %rdi
movl %eax, %esi
callq 0x851e
leaq 0x8b43(%rip), %rsi      # 0x1063e
leaq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0x84f0
leaq 0x90b3(%rip), %rdx      # 0x10bc5
leaq -0x48(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x84c7
jmp 0x7955
movq -0x50(%rbp), %rdi
movq %r13, %rsi
callq 0x8324
movq (%rax), %rsi
leaq -0x48(%rbp), %rdi
callq 0xd44c
leaq 0x8752(%rip), %rsi      # 0x10298
movq %rbx, %rdi
callq 0x4ac7
movl %eax, %r15d
movq %rbx, %rdi
callq 0x40e0
testb %r15b, %r15b
je 0x7c5c
movb $0x1, 0xff4(%r14)
movq 0xfe0(%r14), %rsi
movq (%rsi), %rax
leaq -0x48(%rbp), %rdi
callq *0x28(%rax)
leaq 0x8ab8(%rip), %rsi      # 0x1063a
movq %rbx, %rdi
callq 0x4ac7
movl %eax, %r15d
movq %rbx, %rdi
callq 0x40e0
testb %r15b, %r15b
je 0x7d3e
pushq $0x60
popq %rdi
callq 0x4190
movq %rax, %r15
movq 0xfe0(%r14), %rsi
pushq $0x5
popq %rdx
movq %rax, %rdi
callq 0xf874
movq %r15, 0xfe0(%r14)
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
leaq -0x70(%rbp), %rdi
movl %eax, %esi
callq 0x851e
leaq 0x8ab6(%rip), %rsi      # 0x10693
leaq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0x84f0
leaq 0x8fd1(%rip), %rdx      # 0x10bc5
leaq -0x48(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x84c7
jmp 0x7955
pushq $-0xa
popq %rsi
callq 0x9152
movq 0xfe0(%r14), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
leaq -0x70(%rbp), %rdi
movl %eax, %esi
callq 0x851e
leaq 0x8a38(%rip), %rsi      # 0x10668
leaq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0x84f0
leaq 0x8f7e(%rip), %rdx      # 0x10bc5
leaq -0x48(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x84c7
jmp 0x7955
movq -0x50(%rbp), %rdi
movq %r13, %rsi
callq 0x8324
movq (%rax), %rsi
leaq -0x48(%rbp), %rdi
callq 0xd44c
leaq 0x8620(%rip), %rsi      # 0x1029b
movq %rbx, %rdi
callq 0x4ac7
movl %eax, %r15d
movq %rbx, %rdi
callq 0x40e0
testb %r15b, %r15b
je 0x7981
movb $0x1, 0xff5(%r14)
movq 0xfe0(%r14), %rsi
movq (%rsi), %rax
leaq -0x48(%rbp), %rdi
callq *0x28(%rax)
leaq 0x8983(%rip), %rsi      # 0x1063a
movq %rbx, %rdi
callq 0x4ac7
movl %eax, %r15d
movq %rbx, %rdi
callq 0x40e0
testb %r15b, %r15b
je 0x7da9
pushq $0x60
popq %rdi
callq 0x4190
movq %rax, %r15
movq 0xfe0(%r14), %rsi
pushq $0x5
popq %rdx
movq %rax, %rdi
callq 0xf908
movq %r15, 0xfe0(%r14)
movq (%r15), %rax
movq %r15, %rdi
callq *0x10(%rax)
leaq -0x70(%rbp), %rdi
movl %eax, %esi
callq 0x851e
leaq 0x89d8(%rip), %rsi      # 0x106ea
leaq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0x84f0
leaq 0x8e9c(%rip), %rdx      # 0x10bc5
leaq -0x48(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x84c7
jmp 0x7955
pushq $0x60
popq %rdi
callq 0x4190
movq %rax, %r15
movq 0xfe0(%r14), %rsi
pushq $-0x5
popq %rdx
movq %rax, %rdi
callq 0xf874
movq %r15, 0xfe0(%r14)
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
leaq -0x70(%rbp), %rdi
movl %eax, %esi
callq 0x851e
leaq 0x8941(%rip), %rsi      # 0x106be
leaq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0x84f0
leaq 0x8e31(%rip), %rdx      # 0x10bc5
leaq -0x48(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x84c7
jmp 0x7955
pushq $0x60
popq %rdi
callq 0x4190
movq %rax, %r15
movq 0xfe0(%r14), %rsi
pushq $-0x5
popq %rdx
movq %rax, %rdi
callq 0xf908
movq %r15, 0xfe0(%r14)
movq (%r15), %rax
movq %r15, %rdi
callq *0x10(%rax)
leaq -0x70(%rbp), %rdi
movl %eax, %esi
callq 0x851e
leaq 0x892f(%rip), %rsi      # 0x10717
leaq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0x84f0
leaq 0x8dc6(%rip), %rdx      # 0x10bc5
leaq -0x48(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x84c7
jmp 0x7955
jmp 0x7e6a
jmp 0x7e6a
jmp 0x7e7b
jmp 0x7e7b
jmp 0x7e58
jmp 0x7e58
jmp 0x7e6a
jmp 0x7e6a
jmp 0x7ea5
jmp 0x7ea5
jmp 0x7e7b
jmp 0x7e7b
jmp 0x7e58
jmp 0x7ea5
jmp 0x7e58
jmp 0x7ea5
jmp 0x7ea5
jmp 0x7e6a
jmp 0x7e6a
jmp 0x7e7b
jmp 0x7e7b
jmp 0x7ea5
jmp 0x7ea5
jmp 0x7ea5
jmp 0x7ea5
jmp 0x7ea5
jmp 0x7e6a
jmp 0x7e7b
jmp 0x7ea5
jmp 0x7e58
jmp 0x7e6a
jmp 0x7ea5
jmp 0x7e7b
jmp 0x7ea5
movq %rax, %rbx
pushq $0x60
popq %rsi
movq %r15, %rdi
callq 0x41a0
jmp 0x7ea8
jmp 0x7ea5
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x40e0
jmp 0x7e7e
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x40e0
jmp 0x7ea8
jmp 0x7ea5
jmp 0x7ea5
jmp 0x7ea5
jmp 0x7ea5
jmp 0x7ea5
jmp 0x7ea5
jmp 0x7ea5
jmp 0x7ea5
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
jmp 0x7eaf
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x40e0
movq %rbx, %rdi
callq 0x4280