// File: /workspace/github_cpp_makefile_star2_O2/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 $0x58, %rsp
movq %rsi, 0x38(%rsp)
movq %rdi, 0x18(%rsp)
movq 0xa8(%rdi), %rsi
leaq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0x109e4
movq (%r14), %rbx
movq 0x8(%r14), %r12
leaq 0x10(%rsp), %r15
leaq 0x28(%rsp), %r14
leaq 0x20(%rsp), %r13
leaq 0x8(%rsp), %rbp
cmpq %r12, %rbx
je 0x130b3
movq %r13, %rdi
movq %rbx, %rsi
callq 0xd360
movq 0x20(%rsp), %rsi
movq %rbp, %rdi
callq 0x109f6
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1309d
callq 0x11700
testb %al, %al
jne 0x1317a
movq %r15, %rdi
callq 0xd24a
movq %r14, %rdi
callq 0xd24a
addq $0x10, %rbx
jmp 0x13069
leaq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x11dfa
movq 0x8(%rsp), %rsi
leaq 0x20(%rsp), %rdi
callq 0x109e4
leaq 0x40(%rsp), %rbx
leaq 0x20(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0xdf8a
movq %r15, %rdi
callq 0xd100
leaq 0x10(%rsp), %rdi
callq 0xd24a
movq (%rbx), %r13
movq 0x8(%rbx), %rbx
leaq 0x10(%rsp), %r12
leaq 0x28(%rsp), %r14
leaq 0x8(%rsp), %rbp
cmpq %rbx, %r13
je 0x13161
movq %r15, %rdi
movq %r13, %rsi
callq 0xd360
movq 0x20(%rsp), %rsi
movq %rbp, %rdi
callq 0x109f6
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1314b
callq 0x11700
testb %al, %al
je 0x1314b
movq 0x18(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x11f50
movq %r12, %rdi
callq 0xd24a
movq %r14, %rdi
callq 0xd24a
addq $0x10, %r13
jmp 0x1310e
leaq 0x40(%rsp), %rdi
callq 0xd100
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %rsi
movq 0x18(%rsp), %rdi
callq 0x11f50
movq 0x8(%rsp), %rsi
movq 0x18(%rsp), %rdi
movq 0x38(%rsp), %rdx
callq 0x12174
pushq $0x4
popq %rdi
callq 0x5150
movl $0x1, (%rax)
movq 0x10dd0(%rip), %rsi     # 0x23f80
movq %rax, %rdi
xorl %edx, %edx
callq 0x53a0
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
jmp 0x131e8
movq %rax, %rbx
jmp 0x131ed
jmp 0x131cb
movq %rax, %rbx
movq %r15, %rdi
jmp 0x131d9
movq %rax, %rbx
movq %r12, %rdi
callq 0xd24a
jmp 0x131e5
jmp 0x131e2
movq %rax, %rbx
movq %r14, %rdi
callq 0xd24a
leaq 0x40(%rsp), %rdi
callq 0xd100
movq %rbx, %rdi
callq 0x53c0
nop