// File: /workspace/github_cpp_makefile_star2_O1/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 0x15090
movq (%r14), %r13
movq 0x8(%r14), %rbp
cmpq %rbp, %r13
je 0x19783
movq %rsp, %r12
movq 0xf886(%rip), %r15      # 0x28fa8
movq (%r13), %rsi
movq 0x8(%r13), %r14
testq %r14, %r14
je 0x19740
cmpb $0x0, (%r15)
je 0x1973b
incl 0x8(%r14)
jmp 0x19740
lock
incl 0x8(%r14)
movq %r12, %rdi
callq 0x150a2
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x1975e
callq 0x16922
testb %al, %al
jne 0x19898
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1976d
callq 0x12250
testq %r14, %r14
je 0x1977a
movq %r14, %rdi
callq 0x12250
addq $0x10, %r13
cmpq %rbp, %r13
jne 0x19722
leaq 0x40(%rsp), %rdi
movq %rbx, %rsi
callq 0x17532
movq 0x40(%rsp), %rsi
leaq 0x50(%rsp), %rdi
callq 0x15090
xorps %xmm0, %xmm0
movq %rsp, %rdi
movaps %xmm0, (%rdi)
movups 0x20(%rsp), %xmm0
movq 0x30(%rsp), %rax
leaq 0x50(%rsp), %r14
movups (%r14), %xmm1
movups %xmm1, 0x20(%rsp)
movq 0x10(%r14), %rcx
movq %rcx, 0x30(%rsp)
movaps (%rdi), %xmm1
movaps %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
movups %xmm1, (%r14)
movq $0x0, 0x10(%r14)
callq 0x1212c
movq %r14, %rdi
callq 0x1212c
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x197fb
callq 0x12250
movq 0x20(%rsp), %r12
movq 0x28(%rsp), %r13
cmpq %r13, %r12
je 0x1987f
movq %rsp, %r15
movq 0xf794(%rip), %rbp      # 0x28fa8
movq (%r12), %rsi
movq 0x8(%r12), %r14
testq %r14, %r14
je 0x19833
cmpb $0x0, (%rbp)
je 0x1982e
incl 0x8(%r14)
jmp 0x19833
lock
incl 0x8(%r14)
movq %r15, %rdi
callq 0x150a2
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x1985a
callq 0x16922
testb %al, %al
je 0x1985a
movq %rbx, %rdi
movl $0x1, %esi
callq 0x17706
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x19869
callq 0x12250
testq %r14, %r14
je 0x19876
movq %r14, %rdi
callq 0x12250
addq $0x10, %r12
cmpq %r13, %r12
jne 0x19814
leaq 0x20(%rsp), %rdi
callq 0x1212c
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movl $0x1, %esi
callq 0x17706
movq (%rsp), %rsi
movq %rbx, %rdi
movq 0x38(%rsp), %rdx
callq 0x17b30
movl $0x4, %edi
callq 0x5160
movl $0x1, (%rax)
movq 0xf6b3(%rip), %rsi      # 0x28f80
movq %rax, %rdi
xorl %edx, %edx
callq 0x53c0
movq %rax, %rbx
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
jne 0x19910
jmp 0x19915
movq %rax, %rbx
jmp 0x19915
jmp 0x198ef
jmp 0x198ef
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x19908
callq 0x12250
jmp 0x19908
jmp 0x19905
movq %rax, %rbx
testq %r14, %r14
je 0x19915
movq %r14, %rdi
callq 0x12250
leaq 0x20(%rsp), %rdi
callq 0x1212c
movq %rbx, %rdi
callq 0x53e0
nop