// File: /workspace/github_cpp_makefile_star2_O1/XxAdi101xX[P]ChamberCrawler/Character/Character.cc
// Function: Character::applyPotion(std::shared_ptr<Potion>)
void Character::applyPotion(const shared_ptr<Potion> potion) {
	PotionType type = potion->getPotionType();
	int potency = potion->getPotency();

	// health based potions
	if (type == PotionType::RestoreHealth
		|| type == PotionType::PoisonHealth) {

		if (this->getHP() + potency <= 0) {
			potency = -(this->getHP() - 1);
		}

		this->addHPViaPotion(potency);
	}

	// attack based potions
	else if (type == PotionType::BoostAttack
		|| type == PotionType::WoundAttack) {

		this->attackBuff += potency;
	}

	// defence based potions
	else if (type == PotionType::BoostDefence
		|| type == PotionType::WoundDefence) {

		this->defenceBuff += potency;
	}

	usedPotions.emplace_back(type);

	// reports what potion was used
	this->addAction(makeMsg(this->name, WORD_USE_PAST_TENSE , potionToText(potion)));
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rdi
callq 0x1a3e4
movl %eax, 0x4(%rsp)
movq (%r14), %rdi
callq 0x1a3e8
movl 0x4(%rsp), %ecx
cmpl $0x1, %ecx
ja 0x158a7
movl 0x34(%rbx), %ecx
movl $0x1, %esi
subl %ecx, %esi
addl %eax, %ecx
cmovgl %eax, %esi
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x48(%rax)
jmp 0x158c7
addl $-0x2, %ecx
cmpl $0x3, %ecx
ja 0x158c7
leaq 0xa7de(%rip), %rdx      # 0x20094
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
addl %eax, 0x3c(%rbx)
jmp 0x158c7
addl %eax, 0x44(%rbx)
leaq 0x147ca(%rip), %rax     # 0x2a098
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x158e8
movl 0x4(%rsp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0x158f9
leaq 0x147a9(%rip), %rdi     # 0x2a098
leaq 0x4(%rsp), %rdx
callq 0x19480
leaq 0x48(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x88(%rbx), %rsi
movq 0x90(%rbx), %rdx
addq %rsi, %rdx
leaq 0x38(%rsp), %rdi
callq 0x193f0
leaq 0x28(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x15a52(%rip), %rsi     # 0x2b380
movq 0x15a53(%rip), %rdx     # 0x2b388
addq %rsi, %rdx
leaq 0x18(%rsp), %rdi
callq 0x193f0
movq (%r14), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x1596d
movq 0x13649(%rip), %rcx     # 0x28fa8
cmpb $0x0, (%rcx)
je 0x15969
incl 0x8(%rax)
jmp 0x1596d
lock
incl 0x8(%rax)
leaq 0x78(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1aaad
leaq 0x58(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0x18(%rsp), %rdx
leaq 0x78(%rsp), %rcx
callq 0x1a5f0
addq $0x68, %rbx
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq %rbx, %rdi
callq 0x5100
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x159c6
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x5280
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x159e7
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5280
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x159f6
callq 0x12250
movq 0x18(%rsp), %rdi
cmpq %r12, %rdi
je 0x15a0d
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5280
movq 0x38(%rsp), %rdi
cmpq %r15, %rdi
je 0x15a24
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5280
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x15a56
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x5280
jmp 0x15a56
movq %rax, %rbx
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x15a7c
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5280
jmp 0x15a7c
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x15a8b
callq 0x12250
movq 0x18(%rsp), %rdi
cmpq %r12, %rdi
je 0x15aa7
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5280
jmp 0x15aa7
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r15, %rdi
je 0x15abe
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5280
movq %rbx, %rdi
callq 0x53e0