// File: /workspace/github_cpp_makefile_star2_O3/XxAdi101xX[P]ChamberCrawler/Character/Dragon.cc
// Function: Dragon::doStartTurnRoutine(Generator&)
void Dragon::doStartTurnRoutine(Generator& rng) {
	// gets all neighbours of the dragonHoard
	vector<shared_ptr<Cell>> neighbourhood = (this->dragonHoardCell)->getNeighbours();

	// check if they have a player on them
	for (auto neighbour: neighbourhood) {
		shared_ptr<Character> occupant = neighbour->getOccupant();

		if (occupant && occupant->getPlayerState()) {
			this->setHostile();

			// attackes player if they are next to dragon hoard
			this->attack(*occupant, rng);

			throw 1;
		}

	}


	// gets all neighbours of dragon
	neighbourhood = (this->getCurrentCell())->getNeighbours();

	// note that I would not like to repeat this code,
	// but there's no operator+ for vectors so I have
	// to check them seperately instead of together

	// check if they have a player on them
	for (auto neighbour: neighbourhood) {
		shared_ptr<Character> occupant = neighbour->getOccupant();

		if (occupant && occupant->getPlayerState()) {
			this->setHostile();
			// don't attack because dragon
			// will get to attack later
		}

	}

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, 0x38(%rsp)
movq %rdi, %rbx
movq 0xa8(%rdi), %rsi
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x1517e
movq (%r14), %r13
movq 0x8(%r14), %rbp
cmpq %rbp, %r13
je 0x197c3
movq %rsp, %r12
movq 0xf846(%rip), %r15      # 0x28fa8
movq (%r13), %rsi
movq 0x8(%r13), %r14
testq %r14, %r14
je 0x19780
cmpb $0x0, (%r15)
je 0x1977b
incl 0x8(%r14)
jmp 0x19780
lock
incl 0x8(%r14)
movq %r12, %rdi
callq 0x15190
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x1979e
callq 0x16972
testb %al, %al
jne 0x198d2
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x197ad
callq 0x1235a
testq %r14, %r14
je 0x197ba
movq %r14, %rdi
callq 0x1235a
addq $0x10, %r13
cmpq %rbp, %r13
jne 0x19762
leaq 0x40(%rsp), %rdi
movq %rbx, %rsi
callq 0x1753c
movq 0x40(%rsp), %rsi
leaq 0x50(%rsp), %rdi
callq 0x1517e
movq 0x30(%rsp), %rax
leaq 0x50(%rsp), %r14
movaps (%r14), %xmm0
movq 0x10(%r14), %rcx
movq %rcx, 0x30(%rsp)
movaps 0x20(%rsp), %xmm1
movaps %xmm0, 0x20(%rsp)
movq %rsp, %rdi
movaps %xmm1, (%rdi)
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
movq $0x0, 0x10(%r14)
callq 0x12220
movq %r14, %rdi
callq 0x12220
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x19835
callq 0x1235a
movq 0x20(%rsp), %r12
movq 0x28(%rsp), %r13
cmpq %r13, %r12
je 0x198b9
movq %rsp, %r15
movq 0xf75a(%rip), %rbp      # 0x28fa8
movq (%r12), %rsi
movq 0x8(%r12), %r14
testq %r14, %r14
je 0x1986d
cmpb $0x0, (%rbp)
je 0x19868
incl 0x8(%r14)
jmp 0x1986d
lock
incl 0x8(%r14)
movq %r15, %rdi
callq 0x15190
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x19894
callq 0x16972
testb %al, %al
je 0x19894
movq %rbx, %rdi
movl $0x1, %esi
callq 0x17710
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x198a3
callq 0x1235a
testq %r14, %r14
je 0x198b0
movq %r14, %rdi
callq 0x1235a
addq $0x10, %r12
cmpq %r13, %r12
jne 0x1984e
leaq 0x20(%rsp), %rdi
callq 0x12220
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movl $0x1, %esi
callq 0x17710
movq (%rsp), %rsi
movq %rbx, %rdi
movq 0x38(%rsp), %rdx
callq 0x17b50
movl $0x4, %edi
callq 0x5160
movl $0x1, (%rax)
movq 0xf679(%rip), %rsi      # 0x28f80
movq %rax, %rdi
xorl %edx, %edx
callq 0x53c0
movq %rax, %rbx
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
jne 0x1994a
jmp 0x1994f
movq %rax, %rbx
jmp 0x1994f
jmp 0x19929
jmp 0x19929
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x19942
callq 0x1235a
jmp 0x19942
jmp 0x1993f
movq %rax, %rbx
testq %r14, %r14
je 0x1994f
movq %r14, %rdi
callq 0x1235a
leaq 0x20(%rsp), %rdi
callq 0x12220
movq %rbx, %rdi
callq 0x53e0
nop