// File: 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
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
addq $0xa8, %rdi
callq 0x19df0
movq %rax, %rsi
leaq -0x28(%rbp), %rdi
callq 0x2cf00
leaq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x1a400
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0x1a430
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1a460
testb $0x1, %al
jne 0x328ee
jmp 0x32a07
leaq -0x38(%rbp), %rdi
callq 0x1a4a0
movq %rax, %rsi
leaq -0x50(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x19e60
movq -0xe0(%rbp), %rdi
callq 0x19df0
movq %rax, %rsi
leaq -0x60(%rbp), %rdi
callq 0x2cf30
jmp 0x32924
leaq -0x60(%rbp), %rdi
callq 0x19780
testb $0x1, %al
jne 0x32936
jmp 0x329d9
leaq -0x60(%rbp), %rdi
callq 0x19830
movq %rax, %rdi
callq 0x2f2f0
movb %al, -0xe1(%rbp)
jmp 0x3294f
movb -0xe1(%rbp), %al
testb $0x1, %al
jne 0x3295b
jmp 0x329d9
movq -0xd8(%rbp), %rdi
movl $0x1, %esi
callq 0x301c0
jmp 0x3296e
leaq -0x60(%rbp), %rdi
callq 0x1a210
movq -0xd8(%rbp), %rdi
movq %rax, %rsi
movq -0x10(%rbp), %rdx
callq 0x30500
jmp 0x3298c
movl $0x4, %edi
callq 0x61a0
movq %rax, %rdi
movl $0x1, (%rdi)
movq 0x345ca(%rip), %rsi     # 0x66f70
xorl %eax, %eax
movl %eax, %edx
callq 0x6520
jmp 0x32bed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x329f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x19530
jmp 0x329f9
leaq -0x60(%rbp), %rdi
callq 0x19530
leaq -0x50(%rbp), %rdi
callq 0x199a0
leaq -0x38(%rbp), %rdi
callq 0x1a4e0
jmp 0x328d8
leaq -0x50(%rbp), %rdi
callq 0x199a0
jmp 0x32bdb
movq -0xd8(%rbp), %rsi
leaq -0x98(%rbp), %rdi
callq 0x2ff40
jmp 0x32a1c
leaq -0x98(%rbp), %rdi
callq 0x19df0
movq %rax, %rsi
leaq -0x88(%rbp), %rdi
callq 0x2cf00
jmp 0x32a39
leaq -0x28(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x1a2c0
leaq -0x88(%rbp), %rdi
callq 0x1a2f0
leaq -0x98(%rbp), %rdi
callq 0x199a0
leaq -0x28(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x1a400
movq %rax, -0xa8(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x1a430
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x1a460
testb $0x1, %al
jne 0x32aae
jmp 0x32bc9
leaq -0xa8(%rbp), %rdi
callq 0x1a4a0
movq %rax, %rsi
leaq -0xc0(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x19e60
movq -0xf0(%rbp), %rdi
callq 0x19df0
movq %rax, %rsi
leaq -0xd0(%rbp), %rdi
callq 0x2cf30
jmp 0x32aed
leaq -0xd0(%rbp), %rdi
callq 0x19780
testb $0x1, %al
jne 0x32b02
jmp 0x32b92
leaq -0xd0(%rbp), %rdi
callq 0x19830
movq %rax, %rdi
callq 0x2f2f0
movb %al, -0xf1(%rbp)
jmp 0x32b1e
movb -0xf1(%rbp), %al
testb $0x1, %al
jne 0x32b2a
jmp 0x32b92
movq -0xd8(%rbp), %rdi
movl $0x1, %esi
callq 0x301c0
jmp 0x32b3d
jmp 0x32b92
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x32bdb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x199a0
jmp 0x32bdb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x32bbb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x19530
jmp 0x32bbb
leaq -0xd0(%rbp), %rdi
callq 0x19530
leaq -0xc0(%rbp), %rdi
callq 0x199a0
leaq -0xa8(%rbp), %rdi
callq 0x1a4e0
jmp 0x32a92
leaq -0xc0(%rbp), %rdi
callq 0x199a0
jmp 0x32bdb
leaq -0x28(%rbp), %rdi
callq 0x1a2f0
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0x1a2f0
movq -0x68(%rbp), %rdi
callq 0x6550
nopl (%rax)