// File: /workspace/github_cpp_makefile_star2_O1/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 $0x1b8, %rsp            # imm = 0x1B8
movl %esi, %ebp
movq %rdi, %rbx
movq 0x50(%rdi), %rsi
leaq 0x18(%rsp), %r14
movq %r14, %rdi
movl %ebp, %edx
callq 0x14f5c
movq (%r14), %rdi
testq %rdi, %rdi
je 0x171e2
callq 0x14f2c
testl %eax, %eax
je 0x172e3
cmpl $0x5, %eax
je 0x172e3
cmpb $0x0, 0x49(%rbx)
jne 0x16d41
cmpl $0x4, %eax
je 0x16d41
cmpl $0x1, %eax
jne 0x172e3
movq 0x18(%rsp), %rsi
movq %rsp, %rdi
callq 0x14f30
movq (%rsp), %r14
testq %r14, %r14
je 0x16d7f
movq 0x18(%rsp), %rsi
leaq 0xd0(%rsp), %rdi
callq 0x14f30
movq 0xd0(%rsp), %rdi
callq 0x1a366
cmpl $0x1, %eax
sete %r15b
jmp 0x16d82
xorl %r15d, %r15d
testq %r14, %r14
je 0x16d99
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x16d99
callq 0x12250
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x16da8
callq 0x12250
testb %r15b, %r15b
jne 0x172e3
movb 0x49(%rbx), %r14b
testb %r14b, %r14b
je 0x16dbf
xorl %r15d, %r15d
jmp 0x16dde
movq 0x18(%rsp), %rsi
leaq 0x1a8(%rsp), %rdi
callq 0x14f30
cmpq $0x0, 0x1a8(%rsp)
setne %r15b
testb %r14b, %r14b
jne 0x16df5
movq 0x1b0(%rsp), %rdi
testq %rdi, %rdi
je 0x16df5
callq 0x12250
testb %r15b, %r15b
jne 0x172e3
movq 0x18(%rsp), %rsi
movq %rsp, %rdi
callq 0x150a2
movq (%rsp), %r14
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x16e1e
callq 0x12250
testq %r14, %r14
jne 0x172e3
movq 0x50(%rbx), %rdi
movq 0x58(%rbx), %r14
testq %r14, %r14
je 0x16e4b
movq 0x1216d(%rip), %rax     # 0x28fa8
cmpb $0x0, (%rax)
je 0x16e46
incl 0x8(%r14)
jmp 0x16e4b
lock
incl 0x8(%r14)
xorps %xmm0, %xmm0
leaq 0x170(%rsp), %rsi
movaps %xmm0, (%rsi)
callq 0x14f0a
movq 0x178(%rsp), %rdi
testq %rdi, %rdi
je 0x16e70
callq 0x12250
testq %r14, %r14
je 0x16e7d
movq %r14, %rdi
callq 0x12250
movq 0x18(%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x78(%rsp)
movq %rax, 0x80(%rsp)
testq %rax, %rax
je 0x16eae
movq 0x12108(%rip), %rcx     # 0x28fa8
cmpb $0x0, (%rcx)
je 0x16eaa
incl 0x8(%rax)
jmp 0x16eae
lock
incl 0x8(%rax)
leaq 0x78(%rsp), %rsi
movq %rbx, %rdi
callq 0x1755e
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x16ecd
callq 0x12250
leaq 0x130(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x88(%rbx), %rsi
movq 0x90(%rbx), %rdx
addq %rsi, %rdx
leaq 0x120(%rsp), %rdi
callq 0x193f0
leaq 0x110(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x143f6(%rip), %rsi     # 0x2b300
movq 0x143f7(%rip), %rdx     # 0x2b308
addq %rsi, %rdx
leaq 0x100(%rsp), %rdi
callq 0x193f0
leaq 0x188(%rsp), %rdi
movl %ebp, %esi
callq 0x1aa28
leaq 0x140(%rsp), %rdi
leaq 0x120(%rsp), %rsi
leaq 0x100(%rsp), %rdx
leaq 0x188(%rsp), %rcx
callq 0x1a5f0
leaq 0x68(%rbx), %rdi
movq 0x140(%rsp), %rsi
movq 0x148(%rsp), %rdx
movq %rdi, 0xc8(%rsp)
callq 0x5100
leaq 0x150(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x16f97
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x5280
leaq 0x198(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x16fb8
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x5280
movq 0x100(%rsp), %rdi
cmpq %r15, %rdi
je 0x16fd5
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x5280
movq 0x120(%rsp), %rdi
cmpq %r14, %rdi
je 0x16ff2
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x5280
movq 0x50(%rbx), %rsi
movq %rsp, %rdi
callq 0x15090
movq (%rsp), %r15
movq 0x8(%rsp), %r13
cmpq %r13, %r15
je 0x171da
leaq 0x88(%rsp), %rbp
leaq 0xe0(%rsp), %r12
movq (%r15), %rsi
movq 0x8(%r15), %r14
testq %r14, %r14
je 0x17043
movq 0x11f75(%rip), %rax     # 0x28fa8
cmpb $0x0, (%rax)
je 0x1703e
incl 0x8(%r14)
jmp 0x17043
lock
incl 0x8(%r14)
leaq 0x28(%rsp), %rdi
callq 0x14f30
cmpq $0x0, 0x28(%rsp)
je 0x171b1
leaq 0x68(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x88(%rbx), %rsi
movq 0x90(%rbx), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %rdi
callq 0x193f0
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x1428b(%rip), %rsi     # 0x2b320
movq 0x1428c(%rip), %rdx     # 0x2b328
addq %rsi, %rdx
movq %rbp, %rdi
callq 0x193f0
movq 0x28(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x48(%rsp)
movq %rax, 0x50(%rsp)
testq %rax, %rax
je 0x170d5
movq 0x11ee1(%rip), %rcx     # 0x28fa8
cmpb $0x0, (%rcx)
je 0x170d1
incl 0x8(%rax)
jmp 0x170d5
lock
incl 0x8(%rax)
movq %r12, %rdi
leaq 0x48(%rsp), %rsi
callq 0x1ac38
leaq 0xa8(%rsp), %rdi
leaq 0x58(%rsp), %rsi
movq %rbp, %rdx
movq %r12, %rcx
callq 0x1a5f0
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0xc8(%rsp), %rdi
callq 0x5100
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x1713c
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x5280
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0x17161
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x5280
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x17170
callq 0x12250
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x17195
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x5280
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x171b1
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x5280
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x171c0
callq 0x12250
testq %r14, %r14
je 0x171cd
movq %r14, %rdi
callq 0x12250
addq $0x10, %r15
cmpq %r13, %r15
jne 0x17020
movq %rsp, %rdi
callq 0x1212c
movq 0x50(%rbx), %rsi
movq %rsp, %rdi
callq 0x14f30
cmpb $0x1, 0x49(%rbx)
jne 0x172d4
movq (%rsp), %rax
testq %rax, %rax
je 0x172d4
movq %rax, 0x38(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x40(%rsp)
testq %rax, %rax
je 0x1722e
movq 0x11d88(%rip), %rcx     # 0x28fa8
cmpb $0x0, (%rcx)
je 0x1722a
incl 0x8(%rax)
jmp 0x1722e
lock
incl 0x8(%rax)
leaq 0x38(%rsp), %rsi
movq %rbx, %rdi
callq 0x175da
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x1724a
callq 0x12250
movq (%rsp), %rdi
callq 0x1a366
movl %eax, %ebp
testl %eax, %eax
je 0x1725e
movb $0x1, %r15b
jmp 0x1728f
movq (%rsp), %rdi
movq 0x8(%rsp), %r14
testq %r14, %r14
je 0x17283
movq 0x11d35(%rip), %rax     # 0x28fa8
cmpb $0x0, (%rax)
je 0x1727e
incl 0x8(%r14)
jmp 0x17283
lock
incl 0x8(%r14)
callq 0x1a344
movl %eax, %r15d
xorb $0x1, %r15b
testl %ebp, %ebp
setne %al
testq %r14, %r14
sete %cl
orb %al, %cl
jne 0x172a6
movq %r14, %rdi
callq 0x12250
testb %r15b, %r15b
je 0x172d4
movq 0x50(%rbx), %rdi
xorps %xmm0, %xmm0
leaq 0x160(%rsp), %rsi
movaps %xmm0, (%rsi)
callq 0x14ee8
movq 0x168(%rsp), %rdi
testq %rdi, %rdi
je 0x172d4
callq 0x12250
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x172e3
callq 0x12250
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x172f2
callq 0x12250
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x17518
movq %rax, %rbx
leaq 0x150(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x17332
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x5280
jmp 0x17332
movq %rax, %rbx
leaq 0x198(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x17358
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x5280
jmp 0x17358
movq %rax, %rbx
movq 0x100(%rsp), %rdi
cmpq %r15, %rdi
je 0x1737a
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x5280
jmp 0x1737a
movq %rax, %rbx
movq 0x120(%rsp), %rdi
cmpq %r14, %rdi
je 0x1751b
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x5280
jmp 0x1751b
movq %rax, %rbx
movq 0x80(%rsp), %rdi
jmp 0x1741f
movq %rax, %rbx
movq 0x178(%rsp), %rdi
testq %rdi, %rdi
je 0x173c2
callq 0x12250
testq %r14, %r14
je 0x1751b
movq %r14, %rdi
jmp 0x17428
jmp 0x17518
jmp 0x17518
movq %rax, %rbx
testq %r14, %r14
je 0x1741a
movq %r14, %rdi
jmp 0x17415
movq %rax, %rbx
movq 0x168(%rsp), %rdi
jmp 0x17410
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
jmp 0x17410
jmp 0x17403
movq %rax, %rbx
jmp 0x1741a
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x1741a
callq 0x12250
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1751b
callq 0x12250
jmp 0x1751b
jmp 0x17518
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x17476
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x5280
jmp 0x17476
movq %rax, %rbx
jmp 0x174eb
movq %rax, %rbx
jmp 0x174cf
movq %rax, %rbx
jmp 0x1749b
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0x1749b
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x5280
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x174aa
callq 0x12250
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x174cf
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x5280
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x174eb
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x5280
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x174ff
callq 0x12250
jmp 0x174ff
movq %rax, %rbx
testq %r14, %r14
je 0x1750c
movq %r14, %rdi
callq 0x12250
movq %rsp, %rdi
callq 0x1212c
jmp 0x1751b
jmp 0x17518
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1752a
callq 0x12250
movq %rbx, %rdi
callq 0x53e0