//methode heeft nog aardig wat c++ errors
void DungeonGenerator::GenerateDoorways(Array2D* rooms, int width, int height)
{
	deque<Room*> queue;
	vector<Room*> visitedRooms;

	int randomX = RandomInt::generateInt(0, width - 1);
	int randomY = RandomInt::generateInt(0, height - 1);

	//begin bij willekeurige kamer
	Room* start = rooms->get(randomX, randomY);
	queue.push_back(start);

	while (!queue.empty()) {
		Room* room = queue.front();
		queue.pop_front(); // haal room uit queue

		bool found = find(visitedRooms.begin(), visitedRooms.end(), room) != visitedRooms.end();
		if (!found) {
			visitedRooms.push_back(room);
		}

		for (Room* adjecent : GetAdjecentRooms(rooms, room, width, height)) {
			bool found1 = find(queue.begin(), queue.end(), adjecent) != queue.end();
			bool found2 = find(visitedRooms.begin(), visitedRooms.end(), adjecent) != visitedRooms.end();

			//Als kamer nog niet bezocht is of in queue staat
			if (!found1 /*&& !found2*/ && (visitedRooms.size() < (width*height))) {
				//als kamer rechts van huidige kamer is
				int makeDoorway = 1;
				if (found2) {
					//als kamer al bezocht is moet er toch een kans zijn dat er toch een doorway komt
					int maxRoll = (width + height) / 2 - 3; //De kans is lager des te groter de dungeon
					makeDoorway = RandomInt::generateInt(0, maxRoll);
				}
				if (makeDoorway == 1) {
					if (adjecent->GetXPosition() > room->GetXPosition()) {
						room->SetDoorway(Room::Direction::East, adjecent);
						adjecent->SetDoorway(Room::Direction::West, room);
					}
					//als kamer links van huidige kamer is
					if (adjecent->GetXPosition() < room->GetXPosition()) {
						room->SetDoorway(Room::Direction::West, adjecent);
						adjecent->SetDoorway(Room::Direction::East, room);
					}
					//als kamer onder de huidige kamer is
					if (adjecent->GetYPosition() > room->GetYPosition()) {
						room->SetDoorway(Room::Direction::South, adjecent);
						adjecent->SetDoorway(Room::Direction::North, room);
					}
					//als kamer boven de huidige kamer is
					if (adjecent->GetYPosition() < room->GetYPosition()) {
						room->SetDoorway(Room::Direction::North, adjecent);
						adjecent->SetDoorway(Room::Direction::South, room);
					}
				}

				//zet kamer op queue
				queue.push_back(adjecent);
			}
		}
	}

	queue.clear();
	visitedRooms.clear();
}
void CompasCommand::getPath(Room * stairRoom)
{
	vector<Room*> path;
	vector<std::string> directions;
	Room* step = stairRoom;
	vector<int> enemiesHp;

	// check of stairRoom wel in predecessors zit
	if (predecessors.find(stairRoom) != predecessors.end()) {
		path.push_back(stairRoom);

		//werk hashmap terug vanuit stairRoom
		while (predecessors.find(step) != predecessors.end()) {
			step = predecessors[step];
			path.push_back(step);
		}

		for (int i = path.size() - 1; i >= 0; i--) {
			if (i > 0) {
				Room* to = path[i];
				Room* from = path[i - 1];

				if (to->hasEnemy()) {
					enemiesHp.push_back(to->getEnemy()->getHealth());
				}

				if (from->GetXPosition() == to->GetXPosition()) {
					if (from->GetYPosition() > to->GetYPosition()) {
						directions.push_back("South");
					}
					else {
						directions.push_back("North");
					}
				}
				else if (from->GetYPosition() == to->GetYPosition()) {
					if (from->GetXPosition() > to->GetXPosition()) {
						directions.push_back("East");
					}
					else {
						directions.push_back("West");
					}
				}

				/*if (from->GetXPosition() < to->GetXPosition()) {
					directions.push_back("West");
				}
				else if (from->GetXPosition() > to->GetXPosition()) {
					directions.push_back("East");
				}
				else if (from->GetYPosition() > to->GetYPosition()) {
					directions.push_back("North");
				}
				else if (from->GetYPosition() < to->GetYPosition()) {
					directions.push_back("South");
				}*/
			}
		}

		//print de instructies
		for (int i = 0; i < directions.size(); i++) {
			if (i > 0) {
				std::cout << " - ";
			}
			std::cout << directions[i];
		}
		std::cout << endl;

		//print enemies info
		if (enemiesHp.size() > 0) {
			std::cout << enemiesHp.size() << " enemies (";
			for (int i = 0; i < enemiesHp.size(); i++) {
				if (i > 0) {
					std::cout << ", ";
				}
				std::cout << enemiesHp[i] << " hp";
			}
			std::cout << ")" << endl;
		}
		else {
			std::cout << "No enemies" << endl;
		}
		
	}

}