// File: XxAdi101xX[P]ChamberCrawler/Character/Character.cc
// Function: Character::defend(Character&, int&, Generator&)
bool Character::defend(Character& attacker,
	int& incomingDamage, Generator& rng) {

	// modifies damage and hit chance if necessary
	if(this->takeDamageFrom(attacker, incomingDamage, rng)) {
		// if is attack hits or is not player
		if (rng.genHitMiss() || !(this->getPlayerState())) {
		// deduct HP
		this->HP -= incomingDamage;
		if (this->HP < 0) {
			this->HP = 0;	
		}
		// reports damage taken
		this->addAction(makeMsg(attacker.getName(), WORD_DEAL_PAST_TENSE + " "
		+ to_string(incomingDamage) + " " + WORD_DAMAGE_NOUN + " "
		+ WORD_TO_PREPOSITION, this->name));

		return true;
		}

	}

	// reports dodge
	this->addAction(makeMsg(this->name, WORD_DODGE_PAST_TENSE + " "
		+ WORD_ATTACK_NOUN + " (" + to_string(incomingDamage) + " "
		+ WORD_DAMAGE_NOUN + ") " + WORD_FROM_PREPOSITION,
		attacker.getName()));

	return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x300, %rsp            # imm = 0x300
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x300(%rbp)
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq (%rdi), %rax
callq *0x40(%rax)
testb $0x1, %al
jne 0x2ec21
jmp 0x2ef48
movq -0x28(%rbp), %rdi
callq 0x34130
testb $0x1, %al
jne 0x2ec42
movq -0x300(%rbp), %rdi
callq 0x2f2f0
testb $0x1, %al
jne 0x2ef46
movq -0x300(%rbp), %rax
movq -0x20(%rbp), %rcx
movl (%rcx), %edx
movl 0x34(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x34(%rax)
cmpl $0x0, 0x34(%rax)
jge 0x2ec6b
movq -0x300(%rbp), %rax
movl $0x0, 0x34(%rax)
movq -0x18(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x2f310
leaq 0x3a639(%rip), %rsi     # 0x692b8
leaq 0x15ef9(%rip), %rdx     # 0x44b7f
leaq -0x128(%rbp), %rdi
callq 0x31710
jmp 0x2ec94
movq -0x20(%rbp), %rax
movl (%rax), %esi
leaq -0x158(%rbp), %rdi
callq 0x31790
jmp 0x2eca8
leaq -0x108(%rbp), %rdi
leaq -0x128(%rbp), %rsi
leaq -0x158(%rbp), %rdx
callq 0x31640
jmp 0x2ecc4
leaq 0x15eb4(%rip), %rdx     # 0x44b7f
leaq -0xe8(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x19360
jmp 0x2ece0
leaq 0x3a5b1(%rip), %rdx     # 0x69298
leaq -0xc8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x315f0
jmp 0x2ecfc
leaq 0x15e7c(%rip), %rdx     # 0x44b7f
leaq -0xa8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x19360
jmp 0x2ed18
leaq 0x3a719(%rip), %rdx     # 0x69438
leaq -0x88(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x315f0
jmp 0x2ed34
movq -0x300(%rbp), %rsi
addq $0x88, %rsi
leaq -0x178(%rbp), %rdi
callq 0x6160
jmp 0x2ed50
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x88(%rbp), %rdx
leaq -0x178(%rbp), %rcx
callq 0x343f0
jmp 0x2ed6d
movq -0x300(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2eb60
jmp 0x2ed7f
leaq -0x48(%rbp), %rdi
callq 0x65e8
leaq -0x178(%rbp), %rdi
callq 0x65e8
leaq -0x88(%rbp), %rdi
callq 0x65e8
leaq -0xa8(%rbp), %rdi
callq 0x65e8
leaq -0xc8(%rbp), %rdi
callq 0x65e8
leaq -0xe8(%rbp), %rdi
callq 0x65e8
leaq -0x108(%rbp), %rdi
callq 0x65e8
leaq -0x158(%rbp), %rdi
callq 0x65e8
leaq -0x128(%rbp), %rdi
callq 0x65e8
leaq -0x68(%rbp), %rdi
callq 0x65e8
movb $0x1, -0x1(%rbp)
jmp 0x2f2ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x2ef38
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x2ef2c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x2ef20
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x2ef14
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x2ef08
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x2eefc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x2eef0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x2eee4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x2eed8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x65e8
leaq -0x178(%rbp), %rdi
callq 0x65e8
leaq -0x88(%rbp), %rdi
callq 0x65e8
leaq -0xa8(%rbp), %rdi
callq 0x65e8
leaq -0xc8(%rbp), %rdi
callq 0x65e8
leaq -0xe8(%rbp), %rdi
callq 0x65e8
leaq -0x108(%rbp), %rdi
callq 0x65e8
leaq -0x158(%rbp), %rdi
callq 0x65e8
leaq -0x128(%rbp), %rdi
callq 0x65e8
leaq -0x68(%rbp), %rdi
callq 0x65e8
jmp 0x2f2dc
jmp 0x2ef48
movq -0x300(%rbp), %rsi
addq $0x88, %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x6160
leaq 0x3a36f(%rip), %rsi     # 0x692d8
leaq 0x15c0f(%rip), %rdx     # 0x44b7f
leaq -0x2b8(%rbp), %rdi
callq 0x31710
jmp 0x2ef7e
leaq 0x3a2d3(%rip), %rdx     # 0x69258
leaq -0x298(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
callq 0x315f0
jmp 0x2ef9a
leaq 0x160f7(%rip), %rdx     # 0x45098
leaq -0x278(%rbp), %rdi
leaq -0x298(%rbp), %rsi
callq 0x19360
jmp 0x2efb6
movq -0x20(%rbp), %rax
movl (%rax), %esi
leaq -0x2d8(%rbp), %rdi
callq 0x31790
jmp 0x2efca
leaq -0x258(%rbp), %rdi
leaq -0x278(%rbp), %rsi
leaq -0x2d8(%rbp), %rdx
callq 0x31640
jmp 0x2efe6
leaq 0x15b92(%rip), %rdx     # 0x44b7f
leaq -0x238(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x19360
jmp 0x2f002
leaq 0x3a28f(%rip), %rdx     # 0x69298
leaq -0x218(%rbp), %rdi
leaq -0x238(%rbp), %rsi
callq 0x315f0
jmp 0x2f01e
leaq 0x16076(%rip), %rdx     # 0x4509b
leaq -0x1f8(%rbp), %rdi
leaq -0x218(%rbp), %rsi
callq 0x19360
jmp 0x2f03a
leaq 0x3a2b7(%rip), %rdx     # 0x692f8
leaq -0x1d8(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x315f0
jmp 0x2f056
movq -0x18(%rbp), %rsi
leaq -0x2f8(%rbp), %rdi
callq 0x2f310
jmp 0x2f068
leaq -0x198(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
leaq -0x1d8(%rbp), %rdx
leaq -0x2f8(%rbp), %rcx
callq 0x343f0
jmp 0x2f08b
movq -0x300(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x2eb60
jmp 0x2f0a0
leaq -0x198(%rbp), %rdi
callq 0x65e8
leaq -0x2f8(%rbp), %rdi
callq 0x65e8
leaq -0x1d8(%rbp), %rdi
callq 0x65e8
leaq -0x1f8(%rbp), %rdi
callq 0x65e8
leaq -0x218(%rbp), %rdi
callq 0x65e8
leaq -0x238(%rbp), %rdi
callq 0x65e8
leaq -0x258(%rbp), %rdi
callq 0x65e8
leaq -0x2d8(%rbp), %rdi
callq 0x65e8
leaq -0x278(%rbp), %rdi
callq 0x65e8
leaq -0x298(%rbp), %rdi
callq 0x65e8
leaq -0x2b8(%rbp), %rdi
callq 0x65e8
leaq -0x1b8(%rbp), %rdi
callq 0x65e8
movb $0x0, -0x1(%rbp)
jmp 0x2f2ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x2f2c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x2f2b4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x2f2a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x2f29c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x2f290
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x2f284
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x2f278
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x2f26c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x2f260
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x2f254
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x2f248
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x65e8
leaq -0x2f8(%rbp), %rdi
callq 0x65e8
leaq -0x1d8(%rbp), %rdi
callq 0x65e8
leaq -0x1f8(%rbp), %rdi
callq 0x65e8
leaq -0x218(%rbp), %rdi
callq 0x65e8
leaq -0x238(%rbp), %rdi
callq 0x65e8
leaq -0x258(%rbp), %rdi
callq 0x65e8
leaq -0x2d8(%rbp), %rdi
callq 0x65e8
leaq -0x278(%rbp), %rdi
callq 0x65e8
leaq -0x298(%rbp), %rdi
callq 0x65e8
leaq -0x2b8(%rbp), %rdi
callq 0x65e8
leaq -0x1b8(%rbp), %rdi
callq 0x65e8
jmp 0x2f2dc
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x300, %rsp            # imm = 0x300
popq %rbp
retq
movq -0x130(%rbp), %rdi
callq 0x6550
nopl (%rax,%rax)