39 lines
951 B
C++
39 lines
951 B
C++
#include "difficulty.h"
|
|
|
|
#include <vector> // Para vector
|
|
|
|
namespace Difficulty {
|
|
|
|
static std::vector<Info> difficulties_list;
|
|
|
|
void init() {
|
|
difficulties_list = {
|
|
{Code::EASY, "Easy"},
|
|
{Code::NORMAL, "Normal"},
|
|
{Code::HARD, "Hard"}
|
|
};
|
|
}
|
|
|
|
auto getDifficulties() -> std::vector<Info>& {
|
|
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
|