#pragma once #include "json.hpp" #include #include #include #include namespace utils { nlohmann::json loadJson(const std::string& path); void saveJson(const nlohmann::json& data, const std::string& path); template std::string join(Container parts, std::string joiner) { std::stringstream out; bool isFirst = true; for(std::string p : parts) { if(! isFirst) { out << joiner; } isFirst = false; out << p; } return out.str(); } const std::map cpValue { {"cp", 1}, {"sp", 10}, {"ep", 50}, {"gp", 100}, {"pp", 1000} }; // Accepts coins formatted "X Yp" where X is an integer and Y is any of c, s, e, g, p. int coins2copper(const std::string& coins); // Greedily selects highest coin values to minimize total number of coins // Returns a vector of pairs mapping coin type to coint std::vector> copper2coins(int coppers); std::string getCostString(int coppers); // Recursively loads all .json files under directory /*std::vector loadAll(std::string directory) { std::vector items; for(auto path : std::filesystem::recursive_directory_iterator(directory)) { if(path.path().extension() == ".json") { items.push_back(Item::instance(loadJson(path.path()))); } } return items; }*/ }