#include "difficulty.hpp" #include // Para vector namespace Difficulty { static std::vector difficulties_list; void init() { difficulties_list = { {.code = Code::EASY, .name = "Easy"}, {.code = Code::NORMAL, .name = "Normal"}, {.code = Code::HARD, .name = "Hard"}}; } auto getDifficulties() -> std::vector& { return difficulties_list; } auto getNameFromCode(Code code) -> std::string { for (const auto& difficulty : difficulties_list) { if (difficulty.code == code) { return difficulty.name; } } return !difficulties_list.empty() ? difficulties_list.front().name : "Unknown"; } auto getCodeFromName(const std::string& name) -> Code { for (const auto& difficulty : difficulties_list) { if (difficulty.name == name) { return difficulty.code; } } return !difficulties_list.empty() ? difficulties_list.front().code : Code::NORMAL; } } // namespace Difficulty