Source

zorkish / Location.hpp

Full commit
/*
 * Location.hpp
 *
 *  Created on: 04/09/2012
 *      Author: rhys
 */

#ifndef LOCATION_HPP_
#define LOCATION_HPP_

#include <map>

class Location {
private:
    std::string list_exits() const {
        if (this->exits.empty()) {
            return "\nThere are no exits leading from this location.";
        } else {
            std::stringstream ss;
            for (const auto& pair : this->exits) {
                ss << "\n *  " << pair.first;
            }
            return "\nExits:" + ss.str();
        }
    }

public:
    std::string name;
    std::string description;
    std::map<std::string, int> exits;
    Inventory inv;

    Location(std::string name, std::string description)
            : name(name), description(description) {}

    std::string long_desc() const {
        return name + "\n\n" + description +
                this->inv.list("\nItems:", "\n  * ", "") +
                this->list_exits();
    }
};


#endif /* LOCATION_HPP_ */