// File: /workspace/github_cpp_makefile_star2_O2/XxAdi101xX[P]ChamberCrawler/Character/Character.cc
// Function: Character::doMove(Direction)
void Character::doMove(Direction direction) {
	shared_ptr<Cell> cell = (this->currentCell)->getNeighbour(direction);
	if (cell != nullptr) {
		// type of cell attempting to move to
		CellType cellType = cell->getCellType();

		// seperating cases of non movement for clarity

		// nobody can enter a Wall or Null
		if ((cellType == CellType::Wall)
			|| (cellType == CellType::Null)) {

			return;
		}

		// NPCs cannot leave their chamber
		if (!(this->isPlayer) && (cellType != CellType::FloorTile)
			&& (cellType != CellType::Stairs)) {

			return;
		}

		// nobody can walk over a potion
		if (cell->getItem() && (cell->getItem())->getItemType()
			== ItemType::Potion) {

			return;
		}

		// NPCs cannot occupy a tile if it has an item
		if (!(this->isPlayer) && cell->getItem()) {

			return;
		}

		// two characters cannot be on the same cell
		if (cell->getOccupant()) {
			return;
		}

		// otherwise move as normal

		// removes character from currentCell
		(this->getCurrentCell())->setOccupant(nullptr);

		// changes currentCell to the new one
		// setOccupant is done in setCell
		this->setCell(cell);

		// reports movement
		this->addAction(makeMsg(this->name, WORD_MOVE_PAST_TENSE,
			directionToText(direction)));

		// gets the neighbourhood
		vector<shared_ptr<Cell>> neighbourhood 
			= (this->currentCell)->getNeighbours();

		// reports all item sightings
		for (auto neighbour: neighbourhood) {
			shared_ptr<Item> item = neighbour->getItem();

			if (item != nullptr) {
				this->addAction(makeMsg(this->name, WORD_SEE_PAST_TENSE,
					itemToText(item)));
			}

		}

	}

	// if is player, and there's an item on the new cell (not potion);
	shared_ptr<Item> tempItem = currentCell->getItem();

	if (this->isPlayer && tempItem) {
		// uses the item
		// wont do anything if its a dragon hoard
		this->applyItem(tempItem);

		// remove the item from the cell (only if it isnt a dragon hoard)
		if (tempItem->getItemType() != ItemType::GoldPile 
			|| !(static_pointer_cast<GoldPile>(tempItem)->getBoundState())) {
			
			currentCell->setItem(nullptr);
		}

	}

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
movl %esi, %ebp
movq %rdi, %r14
leaq 0x50(%rdi), %r15
movq 0x50(%rdi), %rsi
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
movl %ebp, %edx
callq 0x10906
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x11bf3
callq 0x108f0
testl %eax, %eax
je 0x11c97
cmpl $0x5, %eax
je 0x11c97
cmpb $0x0, 0x49(%r14)
jne 0x118fe
cmpl $0x4, %eax
je 0x118fe
cmpl $0x1, %eax
jne 0x11c97
movq 0x28(%rsp), %rsi
movq %rsp, %rdi
callq 0x108f4
cmpq $0x0, (%rsp)
je 0x1194b
movq 0x28(%rsp), %rsi
leaq 0x18(%rsp), %rdi
callq 0x108f4
movq 0x18(%rsp), %rdi
callq 0x13abc
movl %eax, %ebx
leaq 0x20(%rsp), %rdi
callq 0xd24a
leaq 0x8(%rsp), %rdi
callq 0xd24a
cmpl $0x1, %ebx
jne 0x11955
jmp 0x11c97
leaq 0x8(%rsp), %rdi
callq 0xd24a
cmpb $0x0, 0x49(%r14)
jne 0x11980
movq 0x28(%rsp), %rsi
movq %rsp, %rdi
callq 0x108f4
leaq 0x8(%rsp), %rdi
movq -0x8(%rdi), %rbx
callq 0xd24a
testq %rbx, %rbx
jne 0x11c97
movq 0x28(%rsp), %rsi
movq %rsp, %rdi
callq 0x109f6
leaq 0x8(%rsp), %rdi
movq -0x8(%rdi), %rbx
callq 0xd24a
testq %rbx, %rbx
jne 0x11c97
movq %rsp, %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xd360
movq (%rbx), %rdi
xorps %xmm0, %xmm0
leaq 0x80(%rsp), %rsi
movaps %xmm0, (%rsi)
callq 0x108da
leaq 0x88(%rsp), %rdi
callq 0xd24a
leaq 0x8(%rsp), %rdi
callq 0xd24a
leaq 0xb8(%rsp), %rbx
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0xd360
movq %r14, %rdi
movq %rbx, %rsi
callq 0x11e0c
leaq 0xc0(%rsp), %rdi
callq 0xd24a
leaq 0x88(%r14), %rsi
leaq 0x128(%rsp), %rdi
movq %rsi, 0x60(%rsp)
callq 0x52e0
leaq 0x148cc(%rip), %rsi     # 0x262f8
leaq 0x108(%rsp), %rdi
callq 0x52e0
leaq 0xe8(%rsp), %rdi
movl %ebp, %esi
callq 0x13e80
leaq 0x148(%rsp), %rdi
leaq 0x128(%rsp), %rsi
leaq 0x108(%rsp), %rdx
leaq 0xe8(%rsp), %rcx
callq 0x13ce8
leaq 0x68(%r14), %rdi
leaq 0x148(%rsp), %rsi
movq %rdi, 0x58(%rsp)
callq 0x5410
movq %r14, 0x48(%rsp)
leaq 0x148(%rsp), %rdi
callq 0x5428
leaq 0xe8(%rsp), %rdi
callq 0x5428
leaq 0x108(%rsp), %rdi
callq 0x5428
leaq 0x128(%rsp), %rdi
callq 0x5428
movq %r15, 0x50(%rsp)
movq (%r15), %rsi
movq %rsp, %rdi
callq 0x109e4
movq (%rsp), %r12
movq 0x8(%rsp), %rax
movq %rax, 0x68(%rsp)
leaq 0x188(%rsp), %r13
leaq 0x168(%rsp), %r14
leaq 0x1a8(%rsp), %r15
cmpq 0x68(%rsp), %r12
je 0x11be1
leaq 0x18(%rsp), %rdi
movq %r12, %rsi
callq 0xd360
movq 0x18(%rsp), %rsi
leaq 0x38(%rsp), %rdi
callq 0x108f4
cmpq $0x0, 0x38(%rsp)
je 0x11bc4
leaq 0xc8(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x52e0
movq %r13, %rbp
movq %r13, %rdi
leaq 0x147d4(%rip), %rsi     # 0x26318
callq 0x52e0
leaq 0xa8(%rsp), %r13
movq %r13, %rdi
leaq 0x38(%rsp), %rsi
callq 0xd32c
movq %r14, %rbx
movq %r14, %rdi
movq %r13, %rsi
callq 0x13fb2
movq %r15, %rdi
leaq 0xc8(%rsp), %rsi
movq %rbp, %r13
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x13ce8
movq 0x58(%rsp), %rdi
movq %r15, %rsi
callq 0x5410
movq %r15, %rdi
callq 0x5428
movq %r14, %rdi
callq 0x5428
leaq 0xb0(%rsp), %rdi
callq 0xd24a
movq %r13, %rdi
callq 0x5428
leaq 0xc8(%rsp), %rdi
callq 0x5428
leaq 0x40(%rsp), %rdi
callq 0xd24a
leaq 0x20(%rsp), %rdi
callq 0xd24a
addq $0x10, %r12
jmp 0x11af2
movq %rsp, %rdi
callq 0xd100
movq 0x50(%rsp), %r15
movq 0x48(%rsp), %r14
movq (%r15), %rsi
movq %rsp, %rdi
callq 0x108f4
cmpb $0x1, 0x49(%r14)
jne 0x11c8d
cmpq $0x0, (%rsp)
je 0x11c8d
leaq 0x98(%rsp), %rbx
movq %rsp, %rsi
movq %rbx, %rdi
callq 0xd32c
movq %r14, %rdi
movq %rbx, %rsi
callq 0x11e72
leaq 0xa0(%rsp), %rdi
callq 0xd24a
movq (%rsp), %rdi
callq 0x13abc
testl %eax, %eax
jne 0x11c70
leaq 0x18(%rsp), %rbx
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x12c99
movq (%rbx), %rdi
callq 0x13a9a
movl %eax, %ebx
leaq 0x20(%rsp), %rdi
callq 0xd24a
testb %bl, %bl
jne 0x11c8d
movq (%r15), %rdi
xorps %xmm0, %xmm0
leaq 0x70(%rsp), %rsi
movaps %xmm0, (%rsi)
callq 0x108c4
leaq 0x78(%rsp), %rdi
callq 0xd24a
leaq 0x8(%rsp), %rdi
callq 0xd24a
leaq 0x30(%rsp), %rdi
callq 0xd24a
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x11dce
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0x5428
jmp 0x11ccd
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x5428
jmp 0x11cdf
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x5428
jmp 0x11cf1
movq %rax, %rbx
leaq 0x128(%rsp), %rdi
callq 0x5428
jmp 0x11de8
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
jmp 0x11d5e
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
jmp 0x11d54
jmp 0x11dce
jmp 0x11d29
jmp 0x11dce
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
jmp 0x11d54
jmp 0x11d44
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
jmp 0x11d54
jmp 0x11dce
movq %rax, %rbx
jmp 0x11d59
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0xd24a
leaq 0x8(%rsp), %rdi
callq 0xd24a
jmp 0x11de8
jmp 0x11dce
movq %rax, %rbx
jmp 0x11dc2
movq %rax, %rbx
leaq 0x1a8(%rsp), %rdi
callq 0x5428
jmp 0x11d8e
movq %rax, %rbx
jmp 0x11db5
movq %rax, %rbx
jmp 0x11d9b
movq %rax, %rbx
leaq 0x168(%rsp), %rdi
callq 0x5428
leaq 0xb0(%rsp), %rdi
callq 0xd24a
leaq 0x188(%rsp), %rdi
callq 0x5428
leaq 0xc8(%rsp), %rdi
callq 0x5428
leaq 0x40(%rsp), %rdi
callq 0xd24a
jmp 0x11dd6
movq %rax, %rbx
jmp 0x11de8
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xd24a
movq %rsp, %rdi
callq 0xd100
leaq 0x30(%rsp), %rdi
callq 0xd24a
movq %rbx, %rdi
callq 0x53c0