<commit_before>/* <NAME>
Mar 19 2015 */

#include "room.h"

// room information
bool Room::has_wall() const // used to determine if a ceiling can be placed
{
	// first do an easy check to see if there are any surfaces
	if (room_sides.size() == 0)
	{
		return false;
	}

	// for each surface
	for (std::map<std::string, Room_Side>::const_iterator it = room_sides.begin();
		it != room_sides.cend(); ++it)
	{
		// if the surface is a wall
		if (it->first == C::NORTH || it->first == C::EAST ||
			it->first == C::SOUTH || it->first == C::WEST)
		{
			return true;
		}
	}

	// the room does not have a wall
	return false;
}
bool Room::has_standing_wall() const
{
	// first do an easy check to see if there are any surfaces
	if (room_sides.size() == 0)
	{
		return false;
	}

	// for each surface
	for (std::map<std::string, Room_Side>::const_iterator it = room_sides.begin();
		it != room_sides.cend(); ++it)
	{
		// if the surface is an intact wall
		if (it->second.is_intact() && (
			it->first == C::NORTH || it->first == C::EAST ||
			it->first == C::SOUTH || it->first == C::WEST))
		{
			return true;
		}
	}

	// the room does not have a wall
	return false;
}
bool Room::is_standing_wall(const std::string & surface_ID) const
{
	// check if there are no sides OR surface_ID is not a room side
	if (room_sides.size() == 0 ||
		!(surface_ID == C::NORTH || surface_ID == C::SOUTH || surface_ID == C::WEST || surface_ID == C::EAST))
	{
		return false;
	}

	// check if the surface exists
	if (!this->has_surface(surface_ID))
	{
		return false;
	}

	// return "is the surface intact?"
	return (room_sides.find(surface_ID)->second.is_intact());
}
bool Room::has_surface(const std::string & direction_id) const
{
	return room_sides.find(direction_id) != room_sides.cend();
}
std::string Room::can_move_in_direction(const std::string & direction_ID, const std::string & faction_ID)
{
	// if a surface is present
	if (has_surface(direction_ID))
	{
		// a player can move through the surface if it is rubble

		if (room_sides.find(direction_ID)->second.is_rubble())
		{
			return C::GOOD_SIGNAL;
		}

		return room_sides.find(direction_ID)->second.can_move_through_wall(faction_ID);
	}
	else // a surface does not exist...
	{
		// ...so the player is free to move
		return C::GOOD_SIGNAL;
	}
}
bool Room::contains_no_items() const
{
	return contents.size() == 0;
}
bool Room::is_unloadable() const
{
	return actor_ids.size() == 0 && viewing_actor_ids.size() == 0;
}
bool Room::is_observed_by(const std::string & actor_id) const
{
	return U::contains(viewing_actor_ids, actor_id);
}
bool Room::is_water() const
{
	return water;
}
bool Room::is_forest() const
{
	return this->contains(C::TREE_ID);
}
bool Room::has_non_mineral_deposit_item() const
{
	// for each item in the room
	for (std::multimap<std::string, std::shared_ptr<Item>>::const_iterator it = contents.cbegin(); it != contents.cend(); ++it)
	{
		// if the item is not a mineral deposit
		if (it->first != C::IRON_DEPOSIT_ID && it->first != C::LIMESTONE_DEPOSIT_ID) // find a better way to do this
		{
			// an item is not a mineral deposit
			return true;
		}
	}

	// any item found was a mineral deposit
	return false;
}
bool Room::has_mineral_deposit() const
{
	// determine if a room contains an iron or limestone deposit
	return contents.find(C::IRON_DEPOSIT_ID) != contents.cend() ||
		contents.find(C::LIMESTONE_DEPOSIT_ID) != contents.cend();
}

// chests
void Room::add_chest(const std::string & set_faction_id)
{
	chest = std::make_shared<Chest>(set_faction_id);
}
bool Room::has_chest() const
{
	return chest != nullptr;
}
std::string Room::get_chest_faction_id() const
{
	// return the chest's faction, or "" if there is no chest (indicating a validation failure in the calling function)
	return (has_chest()) ? chest->get_faction_id() : "";
}
int Room::chest_health() const
{
	// return the chest's health, or 0 if there is no chest (indicating a validation failure in the calling function)
	return (has_chest()) ? chest->get_health() : 0;
}
void Room::add_item_to_chest(const std::shared_ptr<Item> & item)
{
	chest->insert(item);
}
Update_Messages Room::chest_contents(const std::string & faction_ID, const std::string & username) const
{
	// if no chest exists in this room
	if (!has_chest())
	{
		return Update_Messages("There is no chest here.");
	}

	// if the chest was crafted by another faction
	if (chest->get_faction_id() != faction_ID)
	{
		return Update_Messages("This chest has an unfamiliar lock.",
			username + " tries the chest's lock.");
	}

	// return the contents of the chest
	return Update_Messages(chest->contents_to_string(), username + " looks into the chest.");
}
void Room::damage_chest()
{
	// use equipped weapon and damage tables


}
bool Room::chest_has(const std::string & item_id) const
{
	// if there is no hchest here
	if (!has_chest())
	{
		return false;
	}

	return chest->contains(item_id);
}
std::shared_ptr<Item> Room::remove_from_chest(const std::string & item_id)
{
	// manifest a stone if a chest does not exist
	// (this would indicate an validation failure in the calling function)<commit_msg>add correct message for empty chests<commit_after>/* <NAME>
Mar 19 2015 */

#include "room.h"

// room information
bool Room::has_wall() const // used to determine if a ceiling can be placed
{
	// first do an easy check to see if there are any surfaces
	if (room_sides.size() == 0)
	{
		return false;
	}

	// for each surface
	for (std::map<std::string, Room_Side>::const_iterator it = room_sides.begin();
		it != room_sides.cend(); ++it)
	{
		// if the surface is a wall
		if (it->first == C::NORTH || it->first == C::EAST ||
			it->first == C::SOUTH || it->first == C::WEST)
		{
			return true;
		}
	}

	// the room does not have a wall
	return false;
}
bool Room::has_standing_wall() const
{
	// first do an easy check to see if there are any surfaces
	if (room_sides.size() == 0)
	{
		return false;
	}

	// for each surface
	for (std::map<std::string, Room_Side>::const_iterator it = room_sides.begin();
		it != room_sides.cend(); ++it)
	{
		// if the surface is an intact wall
		if (it->second.is_intact() && (
			it->first == C::NORTH || it->first == C::EAST ||
			it->first == C::SOUTH || it->first == C::WEST))
		{
			return true;
		}
	}

	// the room does not have a wall
	return false;
}
bool Room::is_standing_wall(const std::string & surface_ID) const
{
	// check if there are no sides OR surface_ID is not a room side
	if (room_sides.size() == 0 ||
		!(surface_ID == C::NORTH || surface_ID == C::SOUTH || surface_ID == C::WEST || surface_ID == C::EAST))
	{
		return false;
	}

	// check if the surface exists
	if (!this->has_surface(surface_ID))
	{
		return false;
	}

	// return "is the surface intact?"
	return (room_sides.find(surface_ID)->second.is_intact());
}
bool Room::has_surface(const std::string & direction_id) const
{
	return room_sides.find(direction_id) != room_sides.cend();
}
std::string Room::can_move_in_direction(const std::string & direction_ID, const std::string & faction_ID)
{
	// if a surface is present
	if (has_surface(direction_ID))
	{
		// a player can move through the surface if it is rubble

		if (room_sides.find(direction_ID)->second.is_rubble())
		{
			return C::GOOD_SIGNAL;
		}

		return room_sides.find(direction_ID)->second.can_move_through_wall(faction_ID);
	}
	else // a surface does not exist...
	{
		// ...so the player is free to move
		return C::GOOD_SIGNAL;
	}
}
bool Room::contains_no_items() const
{
	return contents.size() == 0;
}
bool Room::is_unloadable() const
{
	return actor_ids.size() == 0 && viewing_actor_ids.size() == 0;
}
bool Room::is_observed_by(const std::string & actor_id) const
{
	return U::contains(viewing_actor_ids, actor_id);
}
bool Room::is_water() const
{
	return water;
}
bool Room::is_forest() const
{
	return this->contains(C::TREE_ID);
}
bool Room::has_non_mineral_deposit_item() const
{
	// for each item in the room
	for (std::multimap<std::string, std::shared_ptr<Item>>::const_iterator it = contents.cbegin(); it != contents.cend(); ++it)
	{
		// if the item is not a mineral deposit
		if (it->first != C::IRON_DEPOSIT_ID && it->first != C::LIMESTONE_DEPOSIT_ID) // find a better way to do this
		{
			// an item is not a mineral deposit
			return true;
		}
	}

	// any item found was a mineral deposit
	return false;
}
bool Room::has_mineral_deposit() const
{
	// determine if a room contains an iron or limestone deposit
	return contents.find(C::IRON_DEPOSIT_ID) != contents.cend() ||
		contents.find(C::LIMESTONE_DEPOSIT_ID) != contents.cend();
}

// chests
void Room::add_chest(const std::string & set_faction_id)
{
	chest = std::make_shared<Chest>(set_faction_id);
}
bool Room::has_chest() const
{
	return chest != nullptr;
}
std::string Room::get_chest_faction_id() const
{
	// return the chest's faction, or "" if there is no chest (indicating a validation failure in the calling function)
	return (has_chest()) ? chest->get_faction_id() : "";
}
int Room::chest_health() const
{
	// return the chest's health, or 0 if there is no chest (indicating a validation failure in the calling function)
	return (has_chest()) ? chest->get_health() : 0;
}
void Room::add_item_to_chest(const std::shared_ptr<Item> & item)
{
	chest->insert(item);
}
Update_Messages Room::chest_contents(const std::string & faction_ID, const std::string & username) const
{
	// if no chest exists in this room
	if (!has_chest())
	{
		return Update_Messages("There is no chest here.");
	}

	// if the chest was crafted by another faction
	if (chest->get_faction_id() != faction_ID)
	{
		return Update_Messages("This chest has an unfamiliar lock.",
			username + " tries the chest's lock.");
	}
	
	// if the chest is empty
	if (chest->size() == 0) return Update_Messages("There is nothing in the chest.",
		username + " looks into the chest.");

	// return the contents of the chest
	return Update_Messages(chest->contents_to_string(), username + " looks into the chest.");
}
void Room::damage_chest()
{
	// use equipped weapon and damage tables


}
bool Room::chest_has(const std::string & item_id) const
{
	// if there is no hchest here
	if (!has_chest())
	{
		return false;
	}

	return chest->contains(item_id);
}
std::shared_ptr<Item> Room::remove_from_chest(const std::string & item_id)
{
	// manifest a stone if a chest does not exist
	// (this would indicate an validation failure in the calling function)
{'fraction_non_alphanumeric': 0.14282962534912838, 'fraction_numerical': 0.0027930270634691323, 'mean_word_length': 4.1127523387493845, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 64, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2083594', 'n_tokens_mistral': 3791, 'n_tokens_neox': 3601, 'n_words': 1054}