// File: 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 %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rsi, -0xd0(%rbp)
movq %rdi, %rax
movq -0xd0(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
movq %rax, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc8(%rbp)
callq 0x31520
movq %rax, %rdi
callq 0x33ef0
movq -0xc0(%rbp), %rdi
movl %eax, -0x14(%rbp)
callq 0x31520
movq %rax, %rdi
callq 0x33f10
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x2e969
cmpl $0x1, -0x14(%rbp)
jne 0x2e9a7
movq -0xc8(%rbp), %rdi
callq 0x2eb40
addl -0x18(%rbp), %eax
cmpl $0x0, %eax
jg 0x2e995
movq -0xc8(%rbp), %rdi
callq 0x2eb40
movl %eax, %ecx
subl $0x1, %ecx
xorl %eax, %eax
subl %ecx, %eax
movl %eax, -0x18(%rbp)
movq -0xc8(%rbp), %rdi
movl -0x18(%rbp), %esi
movq (%rdi), %rax
callq *0x48(%rax)
jmp 0x2e9e5
cmpl $0x2, -0x14(%rbp)
je 0x2e9b3
cmpl $0x4, -0x14(%rbp)
jne 0x2e9c5
movq -0xc8(%rbp), %rax
movl -0x18(%rbp), %ecx
addl 0x3c(%rax), %ecx
movl %ecx, 0x3c(%rax)
jmp 0x2e9e3
cmpl $0x3, -0x14(%rbp)
je 0x2e9d1
cmpl $0x5, -0x14(%rbp)
jne 0x2e9e1
movq -0xc8(%rbp), %rax
movl -0x18(%rbp), %ecx
addl 0x44(%rax), %ecx
movl %ecx, 0x44(%rax)
jmp 0x2e9e3
jmp 0x2e9e5
leaq 0x39784(%rip), %rdi     # 0x68170
leaq -0x14(%rbp), %rsi
callq 0x31540
movq -0xc8(%rbp), %rsi
addq $0x88, %rsi
leaq -0x58(%rbp), %rdi
callq 0x6160
leaq 0x3aa45(%rip), %rsi     # 0x69458
leaq -0x78(%rbp), %rdi
callq 0x6160
jmp 0x2ea1e
movq -0xc0(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x315c0
movq -0xd8(%rbp), %rsi
leaq -0xa8(%rbp), %rdi
callq 0x346d0
jmp 0x2ea4d
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq -0x78(%rbp), %rdx
leaq -0xa8(%rbp), %rcx
callq 0x343f0
jmp 0x2ea67
movq -0xc8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x2eb60
jmp 0x2ea79
leaq -0x38(%rbp), %rdi
callq 0x65e8
leaq -0xa8(%rbp), %rdi
callq 0x65e8
leaq -0xb8(%rbp), %rdi
callq 0x19b20
leaq -0x78(%rbp), %rdi
callq 0x65e8
leaq -0x58(%rbp), %rdi
callq 0x65e8
addq $0xe0, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x2eb21
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x2eb0c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x2eb00
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x65e8
leaq -0xa8(%rbp), %rdi
callq 0x65e8
leaq -0xb8(%rbp), %rdi
callq 0x19b20
leaq -0x78(%rbp), %rdi
callq 0x65e8
leaq -0x58(%rbp), %rdi
callq 0x65e8
movq -0x80(%rbp), %rdi
callq 0x6550
nopw %cs:(%rax,%rax)